# HG changeset patch # User Christian Urban # Date 1582325756 -3600 # Node ID 8a50ccea59e836e9e5410379b5294a111fa7a17a # Parent 0ea14d84efe383ecae1a48d297b19b05bdbf3720 updated diff -r 0ea14d84efe3 -r 8a50ccea59e8 handouts/ho07.pdf Binary file handouts/ho07.pdf has changed diff -r 0ea14d84efe3 -r 8a50ccea59e8 handouts/ho07.tex --- a/handouts/ho07.tex Fri Feb 07 12:44:27 2020 +0000 +++ b/handouts/ho07.tex Fri Feb 21 23:55:56 2020 +0100 @@ -4,6 +4,7 @@ \usepackage{../langs} \usepackage{../grammar} \usepackage{../graphics} +\usetikzlibrary{calc,shapes,arrows} \usepackage{framed} \usepackage[belowskip=7pt,aboveskip=0pt]{caption} @@ -1074,6 +1075,58 @@ L2: \end{lstlisting} +\begin{figure}[p] +\begin{center} +\begin{tikzpicture}[every text node part/.style={align=left}, + stack/.style={rectangle split,rectangle split parts = 5, + fill=black!20,draw,text width=1.6cm,line width=0.5mm}] +\node (A) {}; +\node[stack,right = 80pt] (0) at (A.east) {$\textit{index}$\nodepart{two} \ldots\phantom{l}}; +\node[stack,right = 60pt] (1) at (0.east) + {array\nodepart{two} + $\textit{index}$\nodepart{three} \ldots\phantom{l}}; +\node[stack,below = 40pt] (2) at (1.south) + {array\nodepart{two} + $\textit{index}$ \nodepart{three} + array \nodepart{four} + $\textit{index}$\nodepart{five} \ldots\phantom{l}}; +\node[stack,left = 90pt] (3) at (2.west) + {array\_len\nodepart{two} + $\textit{index}$ \nodepart{three} + array \nodepart{four} + $\textit{index}$\nodepart{five} \ldots\phantom{l}}; +\node[stack,below right of = 3,node distance = 130pt,rectangle split parts = 3] (4b) at (3.south) + {array\nodepart{two} + $\textit{index}$\nodepart{three} \ldots\phantom{l}}; +\node[stack,below left of = 3,node distance = 130pt,rectangle split parts = 3] (4a) at (3.south) + {array\nodepart{two} + $\textit{index}$\nodepart{three} \ldots\phantom{l}}; +\node[stack,below of = 4a,node distance = 70pt,rectangle split parts = 3] (5a) at (4a.south) + {$\textit{index}$\nodepart{two} + array\nodepart{three} \ldots\phantom{l}}; +\node[stack,below of = 5a,node distance = 60pt,rectangle split parts = 2] (6a) at (5a.south) + {$\textit{array\_elem}$\nodepart{two} \ldots\phantom{l}}; +\node[stack,below of = 4b,node distance = 65pt,rectangle split parts = 2] (5b) at (4b.south) + {\ldots\phantom{l}}; +\node[stack,below of = 5b,node distance = 60pt,rectangle split parts = 2] (6b) at (5b.south) + {0\nodepart{two} \ldots\phantom{l}}; + +\draw [|->,line width=2.5mm] (A) -- node [above,pos=0.45] {$\textit{index\_aexp}$} (0); +\draw [->,line width=2.5mm] (0) -- node [above,pos=0.35] {\instr{aload}} (1); +\draw [->,line width=2.5mm] (1) -- node [right,pos=0.35] {\instr{dup2}} (2); +\draw [->,line width=2.5mm] (2) -- node [above,pos=0.40] {\instr{arraylength}} (3); +\path[->,draw,line width=2.5mm] + let \p1=(3.south), \p2=(4a.north) in (3.south) -- +(0,0.5*\y2-0.5*\y1) node [right,pos=0.50] {\instr{if_icmple}} -| (4a.north); +\path[->,draw,line width=2.5mm] + let \p1=(3.south), \p2=(4b.north) in (3.south) -- +(0,0.5*\y2-0.5*\y1) -| (4b.north); +\draw [->,line width=2.5mm] (4a) -- node [right,pos=0.35] {\instr{swap}} (5a); +\draw [->,line width=2.5mm] (4b) -- node [right,pos=0.35] {\instr{pop2}} (5b); +\draw [->,line width=2.5mm] (5a) -- node [right,pos=0.35] {\instr{iaload}} (6a); +\draw [->,line width=2.5mm] (5b) -- node [right,pos=0.35] {\instr{iconst_0}} (6b); +\end{tikzpicture} +\end{center} +\end{figure} + goto\_w problem solved for too large jumps \end{document}