handouts/ho07.tex
changeset 714 8a50ccea59e8
parent 713 0ea14d84efe3
child 941 66adcae6c762
equal deleted inserted replaced
713:0ea14d84efe3 714:8a50ccea59e8
     2 \documentclass{article}
     2 \documentclass{article}
     3 \usepackage{../style}
     3 \usepackage{../style}
     4 \usepackage{../langs}
     4 \usepackage{../langs}
     5 \usepackage{../grammar}
     5 \usepackage{../grammar}
     6 \usepackage{../graphics}
     6 \usepackage{../graphics}
       
     7 \usetikzlibrary{calc,shapes,arrows}
     7 \usepackage{framed}
     8 \usepackage{framed}
     8 \usepackage[belowskip=7pt,aboveskip=0pt]{caption}
     9 \usepackage[belowskip=7pt,aboveskip=0pt]{caption}
     9 
    10 
    10 
    11 
    11 
    12 
  1072   $\textit{value\_aexp}$
  1073   $\textit{value\_aexp}$
  1073   iastore
  1074   iastore
  1074 L2:
  1075 L2:
  1075 \end{lstlisting}
  1076 \end{lstlisting}
  1076 
  1077 
       
  1078 \begin{figure}[p]
       
  1079 \begin{center}
       
  1080 \begin{tikzpicture}[every text node part/.style={align=left},
       
  1081                     stack/.style={rectangle split,rectangle split parts = 5,
       
  1082                                   fill=black!20,draw,text width=1.6cm,line width=0.5mm}]
       
  1083 \node (A)  {};
       
  1084 \node[stack,right = 80pt] (0) at (A.east) {$\textit{index}$\nodepart{two} \ldots\phantom{l}};
       
  1085 \node[stack,right = 60pt] (1) at (0.east)  
       
  1086    {array\nodepart{two}
       
  1087     $\textit{index}$\nodepart{three} \ldots\phantom{l}};
       
  1088 \node[stack,below = 40pt] (2) at (1.south)  
       
  1089    {array\nodepart{two}
       
  1090     $\textit{index}$ \nodepart{three}
       
  1091     array \nodepart{four}
       
  1092     $\textit{index}$\nodepart{five} \ldots\phantom{l}}; 
       
  1093 \node[stack,left = 90pt] (3) at (2.west)  
       
  1094    {array\_len\nodepart{two}
       
  1095     $\textit{index}$ \nodepart{three}
       
  1096     array \nodepart{four}
       
  1097     $\textit{index}$\nodepart{five} \ldots\phantom{l}};    
       
  1098 \node[stack,below right of = 3,node distance = 130pt,rectangle split parts = 3] (4b) at (3.south)
       
  1099    {array\nodepart{two}
       
  1100     $\textit{index}$\nodepart{three} \ldots\phantom{l}};
       
  1101 \node[stack,below left of = 3,node distance = 130pt,rectangle split parts = 3] (4a) at (3.south)
       
  1102    {array\nodepart{two}
       
  1103     $\textit{index}$\nodepart{three} \ldots\phantom{l}};  
       
  1104 \node[stack,below of = 4a,node distance = 70pt,rectangle split parts = 3] (5a) at (4a.south)
       
  1105    {$\textit{index}$\nodepart{two}
       
  1106     array\nodepart{three} \ldots\phantom{l}};                
       
  1107 \node[stack,below of = 5a,node distance = 60pt,rectangle split parts = 2] (6a) at (5a.south)
       
  1108    {$\textit{array\_elem}$\nodepart{two} \ldots\phantom{l}};
       
  1109 \node[stack,below of = 4b,node distance = 65pt,rectangle split parts = 2] (5b) at (4b.south)
       
  1110    {\ldots\phantom{l}};       
       
  1111 \node[stack,below of = 5b,node distance = 60pt,rectangle split parts = 2] (6b) at (5b.south)
       
  1112    {0\nodepart{two} \ldots\phantom{l}}; 
       
  1113 
       
  1114 \draw [|->,line width=2.5mm] (A) -- node [above,pos=0.45] {$\textit{index\_aexp}$} (0); 
       
  1115 \draw [->,line width=2.5mm] (0) -- node [above,pos=0.35] {\instr{aload}} (1);
       
  1116 \draw [->,line width=2.5mm] (1) -- node [right,pos=0.35] {\instr{dup2}} (2);  
       
  1117 \draw [->,line width=2.5mm] (2) -- node [above,pos=0.40] {\instr{arraylength}} (3);
       
  1118 \path[->,draw,line width=2.5mm] 
       
  1119   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);  
       
  1120 \path[->,draw,line width=2.5mm] 
       
  1121   let \p1=(3.south), \p2=(4b.north) in (3.south) -- +(0,0.5*\y2-0.5*\y1) -| (4b.north);
       
  1122 \draw [->,line width=2.5mm] (4a) -- node [right,pos=0.35] {\instr{swap}} (5a);
       
  1123 \draw [->,line width=2.5mm] (4b) -- node [right,pos=0.35] {\instr{pop2}} (5b);  
       
  1124 \draw [->,line width=2.5mm] (5a) -- node [right,pos=0.35] {\instr{iaload}} (6a);
       
  1125 \draw [->,line width=2.5mm] (5b) -- node [right,pos=0.35] {\instr{iconst_0}} (6b);
       
  1126 \end{tikzpicture}                      
       
  1127 \end{center}
       
  1128 \end{figure}
       
  1129 
  1077 goto\_w problem solved for too large jumps
  1130 goto\_w problem solved for too large jumps
  1078 \end{document}
  1131 \end{document}
  1079 
  1132 
  1080 %%% Local Variables: 
  1133 %%% Local Variables: 
  1081 %%% mode: latex  
  1134 %%% mode: latex