summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-12-20 00:32:06 +0000
committerKarl Berry <karl@freefriends.org>2012-12-20 00:32:06 +0000
commit739063891a32d329e0abff276ba180a8a8bdfa2e (patch)
treee3bff961df1607cd27c58185eb9262201dced449 /Master
parentde59445736f108b31987dcfa77e83c6872454b04 (diff)
drawstack (19dec12)
git-svn-id: svn://tug.org/texlive/trunk@28582 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/drawstack/Makefile9
-rw-r--r--Master/texmf-dist/doc/latex/drawstack/README2
-rw-r--r--Master/texmf-dist/doc/latex/drawstack/stack-example.pdfbin55599 -> 110321 bytes
-rw-r--r--Master/texmf-dist/doc/latex/drawstack/stack-example.tex83
-rw-r--r--Master/texmf-dist/tex/latex/drawstack/drawstack.sty48
5 files changed, 140 insertions, 2 deletions
diff --git a/Master/texmf-dist/doc/latex/drawstack/Makefile b/Master/texmf-dist/doc/latex/drawstack/Makefile
new file mode 100644
index 00000000000..8df48452151
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/drawstack/Makefile
@@ -0,0 +1,9 @@
+all: stack-example.pdf drawstack.zip
+
+stack-example.pdf: stack-example.tex drawstack.sty
+ pdflatex stack-example.tex
+
+FILES=stack-example.pdf stack-example.tex drawstack.sty README Makefile
+
+drawstack.zip: $(FILES)
+ cd .. && zip -r $@ $(FILES:%=drawstack/%) && mv drawstack.zip drawstack/
diff --git a/Master/texmf-dist/doc/latex/drawstack/README b/Master/texmf-dist/doc/latex/drawstack/README
index 388191c406c..64173b882c5 100644
--- a/Master/texmf-dist/doc/latex/drawstack/README
+++ b/Master/texmf-dist/doc/latex/drawstack/README
@@ -3,4 +3,4 @@ This is a simple LaTeX package to easily draw execution stack
on top of TikZ.
Author's name: Matthieu Moy
-License type: lppl \ No newline at end of file
+License type: lppl
diff --git a/Master/texmf-dist/doc/latex/drawstack/stack-example.pdf b/Master/texmf-dist/doc/latex/drawstack/stack-example.pdf
index b74d38cba73..4cf88fea574 100644
--- a/Master/texmf-dist/doc/latex/drawstack/stack-example.pdf
+++ b/Master/texmf-dist/doc/latex/drawstack/stack-example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/drawstack/stack-example.tex b/Master/texmf-dist/doc/latex/drawstack/stack-example.tex
index 863b0981bed..3f87460897a 100644
--- a/Master/texmf-dist/doc/latex/drawstack/stack-example.tex
+++ b/Master/texmf-dist/doc/latex/drawstack/stack-example.tex
@@ -102,6 +102,89 @@ comments to see how to use it.
\cell{Interesting cell} \cellround{Yes, this one!}
\end{drawstack}
+\section{Structures without a stack structure}
+
+\begin{tikzpicture}
+ \draw (3, -1) node (Otm) {
+ \begin{tabular}{c}
+ Object\\vtable
+ \end{tabular}
+ };
+
+ \drawstruct{(0,0)}
+ \structcell[freecell]{~} \coordinate (Atm) at (currentcell.east);
+ \structcell[freecell]{\texttt{@Object.equals()}}
+ \structcell[freecell]{\texttt{@code A.m()}}
+ \structcell[freecell]{\texttt{@code A.p()}} \coordinate (A) at (currentcell.west);
+ \structname{
+ \begin{tabular}{c}
+ A's vtable
+ \end{tabular}
+ }
+
+ \drawstruct{(-4,-3)}
+ \structcell[freecell]{} \coordinate (Btm) at (currentcell.east);
+ \structcell[freecell]{\texttt{@Object.equals()}}
+ \structcell[freecell]{\texttt{@code A.m()}}
+ \structcell[freecell]{\texttt{@code B.p()}}
+ \structcell[freecell]{\texttt{@code B.q()}}
+ \structname{B's vtable}
+
+ \draw[->] (Btm) -- (A);
+ \draw[->] (Atm) -- (Otm);
+\end{tikzpicture}
+
+\section{Structures and stack together}
+
+\begin{tikzpicture}[scale=.8]
+
+ \stacktop{}
+ \separator
+ \cell{\texttt{p3}} \cellcomL{11(GB)} \coordinate (p3) at (currentcell.east);
+ \separator
+ \cell{\texttt{p2}} \cellcomL{10(GB)} \coordinate (p2) at (currentcell.east);
+ \separator
+ \cell{\texttt{p1}} \cellcomL{ 9(GB)} \coordinate (p1) at (currentcell.east);
+ \separator
+ \cell{\texttt{@P3D.diag}} \cellcomL{ 8(GB)}
+ \cell{\texttt{\footnotesize @Object.equals}} \cellcomL{ 7(GB)}
+ \cell{\texttt{3(GB)}} \cellcomL{ 6(GB)} \coordinate (T1) at (currentcell.east);
+ \separator
+ \cell{\texttt{@P2D.diag}} \cellcomL{ 5(GB)}
+ \cell{\texttt{\footnotesize @Object.equals}} \cellcomL{ 4(GB)}
+ \cell{\texttt{1(GB)}} \cellcomL{ 3(GB)} \coordinate (T2) at (currentcell.east);
+ \separator
+ \cell{\texttt{\footnotesize @Object.equals}} \cellcomL{ 2(GB)}
+ \cell{\texttt{null}} \cellcomL{ 1(GB)}
+ \cell[draw=none]{Stack}
+
+
+ \drawstruct{(5,1)})
+ \structcell{z=2,5}
+ \structcell{y=2,5}
+ \structcell{x=2,5}
+ \structcell{.} \coordinate (O1) at (currentcell.west);
+ \coordinate (O1l) at (currentcell.south);
+
+ \drawstruct{(9,-3)}
+ \structcell{y=1}
+ \structcell{x=1}
+ \structcell{.} \coordinate (O2) at (currentcell.west);
+ \coordinate (O2l) at (currentcell.south);
+
+ \draw[->] (p3) -- (O1);
+ \draw[->] (p2) -- (O1);
+ \draw[->] (p1) -- (O2);
+
+ \draw[->] (O1l) .. controls (O1 |- T1) .. (T1);
+ \draw[->] (O2l) .. controls (O2 |- T2) .. (T2);
+
+ \draw (10,-10) node{Heap};
+
+\end{tikzpicture}
+
+
+
\section{Using tikzpicture instead of drawstack}
% The environment drawstack is basically a syntactic sugar for
diff --git a/Master/texmf-dist/tex/latex/drawstack/drawstack.sty b/Master/texmf-dist/tex/latex/drawstack/drawstack.sty
index 14ae776841b..b05e81ebb27 100644
--- a/Master/texmf-dist/tex/latex/drawstack/drawstack.sty
+++ b/Master/texmf-dist/tex/latex/drawstack/drawstack.sty
@@ -25,12 +25,14 @@
% Default styles definition.
\tikzstyle{freecell}=[fill=green!10,draw=green!30!black]
+\tikzstyle{freestruct}=[fill=blue!10,draw=blue!30!black]
\tikzstyle{occupiedcell}=[fill=green!10!red!10,draw=green!30!black]
\tikzstyle{padding}=[fill=green!10!black!10,draw=green!30!black]
\tikzstyle{highlight}=[draw=red!50!black,text=red!50!black]
\DeclareOption{nocolor}{
\tikzstyle{freecell}=[fill=white!95!black,draw=black]
+ \tikzstyle{freestruct}=[fill=white!93!black,draw=black]
\tikzstyle{occupiedcell}=[fill=white!60!black,draw=black]
\tikzstyle{padding}=[fill=white!90!black!10,draw=black]
\tikzstyle{highlight}=[draw=black,text=black]
@@ -44,13 +46,14 @@
\usetikzlibrary{snakes} % braces
\newcounter{cellnb}
+\newcounter{structnb}
\setcounter{cellnb}{0}
\newcommand{\llcell}[3]{
\addtocounter{cellnb}{-#1}
\setcounter{ptrnb}{0}
\draw[#2] (0,\value{cellnb}) +(-2,-.5) rectangle +(2,-.5+#1);
- \draw (0,\value{cellnb}+#1/2-0.5) node{#3};
+ \draw (0,\value{cellnb}+#1/2-0.5) node(currentcell) {#3};
}
\newcommand{\bigcell}[2]{
\llcell{#1}{freecell}{#2}
@@ -64,6 +67,16 @@
\newcommand{\cell}[2][freecell]{%
\llcell{1}{#1}{#2}}
+\newcommand{\separator}[1][freecell,very thick]{
+ \draw[#1] (0,\value{cellnb}) +(-2,-.5) -- +(2,-.5);
+}
+
+% Pointer to the next cell, useful if the next cell has size != 0.
+\newcommand{\cellptrnext}[1]{
+ \draw[<-,line width=0.7pt] (0,\value{cellnb}-1) +(2,\value{ptrnb}*0.1) -- +(2.5,\value{ptrnb}*0.45);
+ \draw (2.5,\value{ptrnb}*0.5+\value{cellnb}-1) node[anchor=west] {#1};
+ \addtocounter{ptrnb}{1}
+}
\newcounter{ptrnb}
\newcommand{\cellptr}[1]{
\draw[<-,line width=0.7pt] (0,\value{cellnb}) +(2,\value{ptrnb}*0.1) -- +(2.5,\value{ptrnb}*0.45);
@@ -73,10 +86,17 @@
\newcommand{\esp}{\cellptr{\%esp}}
\newcommand{\ebp}{\cellptr{\%ebp}}
+% like cellptr, but without the arrow
\newcommand{\cellcom}[1]{
\draw (2.4,\value{ptrnb}*0.5+\value{cellnb}) node[anchor=west] {#1};
\addtocounter{ptrnb}{1}
}
+% like cellcom, but on the left hand side
+\newcommand{\cellcomL}[1]{
+ \draw (-2,\value{ptrnb}*0.5+\value{cellnb}) node[anchor=east] {#1};
+ \addtocounter{ptrnb}{1}
+}
+
\newcommand{\cellround}[1]{
\begin{pgfonlayer}{foreground layer}
\draw[highlight] (0,\value{cellnb})
@@ -130,4 +150,30 @@
\draw[snake=brace] (-2,-#1-0.5) -- (-2,-#2-0.5);
\draw (0, #1) node {#3};
}
+
+\newcommand{\drawstruct}[1]{
+ \setcounter{structnb}{0}
+ \path #1 coordinate (structpos);
+ \path (structpos) ++ (0,\value{structnb}) +(-1.6,-.5) coordinate (structtopleft);
+}
+
+\newcommand{\llstructcell}[3]{
+ \addtocounter{structnb}{-#1}
+ \path (structpos) ++ (0,\value{structnb}) +(-1.6,-.5) coordinate (topleft);
+ \path (structpos) ++ (0,\value{structnb}) +(-1.6,-.5+#1) coordinate (bottomleft);
+ \path (structpos) ++ (0,\value{structnb}) +( 1.6,-.5+#1) coordinate (bottomright);
+ \draw[#2] (topleft) rectangle (bottomright);
+ \draw (structpos) ++ (0,\value{structnb}+#1/2-0.5) node (currentcell){#3};
+}
+
+\newcommand{\structcell}[2][freestruct]{%
+ \llstructcell{1}{#1}{#2}
+}
+
+\newcommand{\structname}[1]{
+ \path (structpos) ++ (0,\value{structnb}) +(-1.6,-.5) coordinate (structbottomleft);
+ \draw (barycentric cs:structtopleft=.5,structbottomleft=.5)
+ node[rotate=90,anchor=south] {#1};
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%