--- a/progs/fun/fun.sc Fri Nov 27 13:53:06 2020 +0000
+++ b/progs/fun/fun.sc Tue Dec 01 05:41:12 2020 +0000
@@ -1,17 +1,25 @@
// A Small Compiler for a Simple Functional Language
-// (it does not include a parser and lexer)
+// (includes a parser and lexer)
//
// call with
//
+// amm fun.sc test
+//
+// or
+//
// amm fun.sc main defs.fun
-//
// amm fun.sc main fact.fun
//
-// or
-// amm fun.sc test
+// or
+//
+// amm fun.sc run defs.fun
+// amm fun.sc run fact.fun
//
-// the latter will print out the JVM instructions for two
+// the first prints out the JVM instructions for two
// factorial functions
+//
+// the next compile/run fun files
+//
import $file.fun_tokens, fun_tokens._
import $file.fun_parser, fun_parser._
@@ -76,15 +84,21 @@
// variable / index environments
type Env = Map[String, Int]
+def compile_op(op: String) = op match {
+ case "+" => i"iadd"
+ case "-" => i"isub"
+ case "*" => i"imul"
+ case "/" => i"idiv"
+ case "%" => i"irem"
+}
+
+
// compile expressions
-def compile_exp(a: Exp, env : Env) : String = a match {
+def compile_exp(a: Exp, env: Env) : String = a match {
case Num(i) => i"ldc $i"
case Var(s) => i"iload ${env(s)}"
- case Aop("+", a1, a2) => compile_exp(a1, env) ++ compile_exp(a2, env) ++ i"iadd"
- case Aop("-", a1, a2) => compile_exp(a1, env) ++ compile_exp(a2, env) ++ i"isub"
- case Aop("*", a1, a2) => compile_exp(a1, env) ++ compile_exp(a2, env) ++ i"imul"
- case Aop("/", a1, a2) => compile_exp(a1, env) ++ compile_exp(a2, env) ++ i"idiv"
- case Aop("%", a1, a2) => compile_exp(a1, env) ++ compile_exp(a2, env) ++ i"irem"
+ case Aop(op, a1, a2) =>
+ compile_exp(a1, env) ++ compile_exp(a2, env) ++ compile_op(op)
case If(b, a1, a2) => {
val if_else = Fresh("If_else")
val if_end = Fresh("If_end")
@@ -137,8 +151,8 @@
}
case Main(a) => {
m".method public static main([Ljava/lang/String;)V" ++
- m".limit locals 200" ++
- m".limit stack 200" ++
+ m".limit locals 1" ++
+ m".limit stack ${1 + max_stack_exp(a)}" ++
compile_exp(a, Map()) ++
i"invokestatic XXX/XXX/write(I)V" ++
i"return" ++
@@ -153,6 +167,21 @@
}
+import ammonite.ops._
+
+def compile_to_file(prog: List[Decl], class_name: String) : Unit =
+ write.over(pwd / s"$class_name.j", compile(prog, class_name))
+
+def compile_and_run(prog: List[Decl], class_name: String) : Unit = {
+ println(s"Start of compilation")
+ compile_to_file(prog, class_name)
+ println(s"generated $class_name.j file")
+ os.proc("java", "-jar", "jasmin.jar", s"$class_name.j").call()
+ println(s"generated $class_name.class file")
+ println(s"Run program")
+ os.proc("java", s"${class_name}/${class_name}").call(stdout = os.Inherit)
+ println(s"done.")
+}
// An example program (two versions of factorial)
@@ -181,9 +210,9 @@
Aop("*",Var("n"),Var("acc")))))),
Main(Sequence(Write(Call("fact",List(Num(10)))),
- Write(Call("facT",List(Num(10), Num(1)))))))
+ Write(Call("facT",List(Num(10), Num(1)))))))
-// prints out the JVM instructions
+// prints out the JVM instructions for the factorial example
@main
def test() =
println(compile(test_prog, "fact"))
@@ -197,3 +226,12 @@
val ast = parse_tks(tks)
println(compile(ast, class_name))
}
+
+@main
+def run(fname: String) = {
+ val path = os.pwd / fname
+ val class_name = fname.stripSuffix("." ++ path.ext)
+ val tks = tokenise(os.read(path))
+ val ast = parse_tks(tks)
+ compile_and_run(ast, class_name)
+}
--- a/progs/fun/fun_llvm.sc Fri Nov 27 13:53:06 2020 +0000
+++ b/progs/fun/fun_llvm.sc Tue Dec 01 05:41:12 2020 +0000
@@ -1,22 +1,35 @@
// A Small LLVM Compiler for a Simple Functional Language
// (includes an external lexer and parser)
//
+//
// call with
//
+// amm fun_llvm.sc main fact.fun
+// amm fun_llvm.sc main defs.fun
+//
+// or
+//
// amm fun_llvm.sc write fact.fun
-//
// amm fun_llvm.sc write defs.fun
//
-// this will generate a .ll file. Other options are compile and run.
+// this will generate an .ll file.
+//
+// or
//
-// You can interpret an .ll file using lli.
+// amm fun_llvm.sc run fact.fun
+// amm fun_llvm.sc run defs.fun
+//
+//
+// You can interpret an .ll file using lli, for example
+//
+// lli fact.ll
//
// The optimiser can be invoked as
//
// opt -O1 -S in_file.ll > out_file.ll
// opt -O3 -S in_file.ll > out_file.ll
//
-// The code produced for the various architectures can be obtains with
+// The code produced for the various architectures can be obtain with
//
// llc -march=x86 -filetype=asm in_file.ll -o -
// llc -march=arm -filetype=asm in_file.ll -o -
@@ -30,7 +43,6 @@
import $file.fun_tokens, fun_tokens._
import $file.fun_parser, fun_parser._
-import scala.util._
// for generating new labels
@@ -150,10 +162,11 @@
case "/" => "sdiv i32 "
case "%" => "srem i32 "
case "==" => "icmp eq i32 "
- case "<=" => "icmp sle i32 " // signed less or equal
- case "<" => "icmp slt i32 " // signed less than
+ case "<=" => "icmp sle i32 " // signed less or equal
+ case "<" => "icmp slt i32 " // signed less than
}
+// compile K values
def compile_val(v: KVal) : String = v match {
case KNum(i) => s"$i"
case KVar(s) => s"%$s"
@@ -211,19 +224,22 @@
}
}
+
// main compiler functions
-
-def compile_prog(prog: List[Decl]) : String =
+def compile(prog: List[Decl]) : String =
prelude ++ (prog.map(compile_decl).mkString)
+import ammonite.ops._
+
+
@main
-def compile(fname: String) = {
+def main(fname: String) = {
val path = os.pwd / fname
val file = fname.stripSuffix("." ++ path.ext)
val tks = tokenise(os.read(path))
val ast = parse_tks(tks)
- println(compile_prog(ast))
+ println(compile(ast))
}
@main
@@ -232,7 +248,7 @@
val file = fname.stripSuffix("." ++ path.ext)
val tks = tokenise(os.read(path))
val ast = parse_tks(tks)
- val code = compile_prog(ast)
+ val code = compile(ast)
os.write.over(os.pwd / (file ++ ".ll"), code)
}
@@ -240,13 +256,11 @@
def run(fname: String) = {
val path = os.pwd / fname
val file = fname.stripSuffix("." ++ path.ext)
- val tks = tokenise(os.read(path))
- val ast = parse_tks(tks)
- val code = compile_prog(ast)
- os.write.over(os.pwd / (file ++ ".ll"), code)
+ write(fname)
os.proc("llc", "-filetype=obj", file ++ ".ll").call()
- os.proc("gcc", file ++ ".o", "-o", file).call()
- print(os.proc(os.pwd / file).call().out.string)
+ os.proc("gcc", file ++ ".o", "-o", file ++ ".bin").call()
+ os.proc(os.pwd / (file ++ ".bin")).call(stdout = os.Inherit)
+ println(s"done.")
}
--- a/progs/fun/funt.sc Fri Nov 27 13:53:06 2020 +0000
+++ b/progs/fun/funt.sc Tue Dec 01 05:41:12 2020 +0000
@@ -1,5 +1,20 @@
// A Small Compiler for a Simple Functional Language
-// (includes a lexer and a parser)
+// - includes a lexer and a parser
+// - performs tail-call optimisations
+//
+// call with
+//
+// amm fun.sc main defs.fun
+// amm fun.sc main fact.fun
+//
+// or
+//
+// amm fun.sc run defs.fun
+// amm fun.sc run fact.fun
+//
+// the first prints out the JVM instructions
+// the second runs the generated class files
+
import $file.fun_tokens, fun_tokens._
import $file.fun_parser, fun_parser._
@@ -26,7 +41,8 @@
// calculating the maximal needed stack size
def max_stack_exp(e: Exp): Int = e match {
case Call(_, args) => args.map(max_stack_exp).sum
- case If(a, e1, e2) => max_stack_bexp(a) + (List(max_stack_exp(e1), max_stack_exp(e2)).max)
+ case If(a, e1, e2) =>
+ max_stack_bexp(a) + (List(max_stack_exp(e1), max_stack_exp(e2)).max)
case Write(e) => max_stack_exp(e) + 1
case Var(_) => 1
case Num(_) => 1
@@ -61,15 +77,19 @@
type Env = Map[String, Int]
+def compile_op(op: String) = op match {
+ case "+" => i"iadd"
+ case "-" => i"isub"
+ case "*" => i"imul"
+ case "/" => i"idiv"
+ case "%" => i"irem"
+}
def compile_expT(a: Exp, env : Env, name: String) : String = a match {
case Num(i) => i"ldc $i"
case Var(s) => i"iload ${env(s)}"
- case Aop("+", a1, a2) => compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ i"iadd"
- case Aop("-", a1, a2) => compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ i"isub"
- case Aop("*", a1, a2) => compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ i"imul"
- case Aop("/", a1, a2) => compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ i"idiv"
- case Aop("%", a1, a2) => compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ i"irem"
+ case Aop(op, a1, a2) =>
+ compile_expT(a1, env, "") ++ compile_expT(a2, env, "") ++ compile_op(op)
case If(b, a1, a2) => {
val if_else = Fresh("If_else")
val if_end = Fresh("If_end")
@@ -141,6 +161,22 @@
(library + instructions).replaceAllLiterally("XXX", class_name)
}
+import ammonite.ops._
+
+def compile_to_file(prog: List[Decl], class_name: String) : Unit =
+ write.over(pwd / s"$class_name.j", compile(prog, class_name))
+
+def compile_and_run(prog: List[Decl], class_name: String) : Unit = {
+ println(s"Start of compilation")
+ compile_to_file(prog, class_name)
+ println(s"generated $class_name.j file")
+ os.proc("java", "-jar", "jasmin.jar", s"$class_name.j").call()
+ println(s"generated $class_name.class file")
+ println(s"Run program")
+ os.proc("java", s"${class_name}/${class_name}").call(stdout = os.Inherit)
+ println(s"done.")
+}
+
@main
def main(fname: String) = {
@@ -151,18 +187,11 @@
println(compile(ast, class_name))
}
-/*
-
-import scala.sys.process._
-
-def compile_run(class_name: String) : Unit = {
- compile_file(class_name)
- (s"java -jar jvm/jasmin-2.4/jasmin.jar ${class_name}.j").!!
- println("Time: " + time_needed(2, (s"java ${class_name}/${class_name}").!))
+@main
+def run(fname: String) = {
+ val path = os.pwd / fname
+ val class_name = fname.stripSuffix("." ++ path.ext)
+ val tks = tokenise(os.read(path))
+ val ast = parse_tks(tks)
+ compile_and_run(ast, class_name)
}
-
-
-//examples
-compile_run("defs")
-compile_run("fact")
-*/
Binary file progs/fun/jasmin.jar has changed
Binary file slides/slides08.pdf has changed
--- a/slides/slides08.tex Fri Nov 27 13:53:06 2020 +0000
+++ b/slides/slides08.tex Tue Dec 01 05:41:12 2020 +0000
@@ -62,216 +62,216 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
-\begin{center}
-\bl{\begin{tabular}{@{}lcl@{}}
-\meta{Stmt} & $::=$ & $\texttt{skip}$\\
- & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
- & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
- & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
- & $|$ & \texttt{read}\;\textit{Id}\\
- & $|$ & \texttt{write}\;\textit{Id}\\
- & $|$ & \texttt{write}\;\textit{String}\medskip\\
-\meta{Stmts} & $::=$ & \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
- & $|$ & \meta{Stmt}\medskip\\
-\meta{Block} & $::=$ & \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
- & $|$ & \meta{Stmt}\medskip\\
-\meta{AExp} & $::=$ & \ldots\\
-\meta{BExp} & $::=$ & \ldots\\
-\end{tabular}}
-\end{center}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{center}
+% \bl{\begin{tabular}{@{}lcl@{}}
+% \meta{Stmt} & $::=$ & $\texttt{skip}$\\
+% & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
+% & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
+% & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
+% & $|$ & \texttt{read}\;\textit{Id}\\
+% & $|$ & \texttt{write}\;\textit{Id}\\
+% & $|$ & \texttt{write}\;\textit{String}\medskip\\
+% \meta{Stmts} & $::=$ & \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
+% & $|$ & \meta{Stmt}\medskip\\
+% \meta{Block} & $::=$ & \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
+% & $|$ & \meta{Stmt}\medskip\\
+% \meta{AExp} & $::=$ & \ldots\\
+% \meta{BExp} & $::=$ & \ldots\\
+% \end{tabular}}
+% \end{center}
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t,fragile]
-\frametitle{Compiling AExps}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[t,fragile]
+% \frametitle{Compiling AExps}
-For example \bl{$1 + ((2 * 3) + (4 - 3))$}:\medskip
+% For example \bl{$1 + ((2 * 3) + (4 - 3))$}:\medskip
-\begin{columns}[T]
-\begin{column}{.3\textwidth}
-\begin{center}
-\bl{\begin{tikzpicture}
-\tikzset{level distance=12mm,sibling distance=4mm}
-\tikzset{edge from parent/.style={draw,very thick}}
-\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
-\end{tikzpicture}}
-\end{center}
-\end{column}
-\begin{column}{.3\textwidth}
-\begin{lstlisting}[language=JVMIS,numbers=none]
-ldc 1
-ldc 2
-ldc 3
-imul
-ldc 4
-ldc 3
-isub
-iadd
-iadd
-\end{lstlisting}
-\end{column}
-\end{columns}\bigskip
+% \begin{columns}[T]
+% \begin{column}{.3\textwidth}
+% \begin{center}
+% \bl{\begin{tikzpicture}
+% \tikzset{level distance=12mm,sibling distance=4mm}
+% \tikzset{edge from parent/.style={draw,very thick}}
+% \Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
+% \end{tikzpicture}}
+% \end{center}
+% \end{column}
+% \begin{column}{.3\textwidth}
+% \begin{lstlisting}[language=JVMIS,numbers=none]
+% ldc 1
+% ldc 2
+% ldc 3
+% imul
+% ldc 4
+% ldc 3
+% isub
+% iadd
+% iadd
+% \end{lstlisting}
+% \end{column}
+% \end{columns}\bigskip
-\small
-Traverse tree in post-order \bl{$\Rightarrow$} code for
-stack-machine
+% \small
+% Traverse tree in post-order \bl{$\Rightarrow$} code for
+% stack-machine
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling AExps}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling AExps}
-\bl{
-\begin{center}
-\begin{tabular}{lcl}
-$\textit{compile}(n, E)$ & $\dn$ & $\pcode{ldc}\;n$\smallskip\\
-$\textit{compile}(a_1 + a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\;\textit{compile}(a_2, E)\;@\; \pcode{iadd}$}\smallskip\\
-$\textit{compile}(a_1 - a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{isub}$}\smallskip\\
-$\textit{compile}(a_1 * a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{imul}$}\smallskip\\
-$\textit{compile}(a_1 \backslash a_2, E)$ & $\dn$\\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{idiv}$}\smallskip\\
-$\textit{compile}(x, E)$ & $\dn$ & $\pcode{iload}\;E(x)$\\
-\end{tabular}
-\end{center}}
+% \bl{
+% \begin{center}
+% \begin{tabular}{lcl}
+% $\textit{compile}(n, E)$ & $\dn$ & $\pcode{ldc}\;n$\smallskip\\
+% $\textit{compile}(a_1 + a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\;\textit{compile}(a_2, E)\;@\; \pcode{iadd}$}\smallskip\\
+% $\textit{compile}(a_1 - a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{isub}$}\smallskip\\
+% $\textit{compile}(a_1 * a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{imul}$}\smallskip\\
+% $\textit{compile}(a_1 \backslash a_2, E)$ & $\dn$\\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{idiv}$}\smallskip\\
+% $\textit{compile}(x, E)$ & $\dn$ & $\pcode{iload}\;E(x)$\\
+% \end{tabular}
+% \end{center}}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Ifs}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Ifs}
-For example
+% For example
-\begin{lstlisting}[mathescape,numbers=none,language=While]
-if 1 = 1 then x := 2 else y := 3
-\end{lstlisting}
+% \begin{lstlisting}[mathescape,numbers=none,language=While]
+% if 1 = 1 then x := 2 else y := 3
+% \end{lstlisting}
-\begin{center}
-\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
- ldc 1
- ldc 1
- if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$
- ldc 2
- istore 0
- goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$
-L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$
- ldc 3
- istore 1
-L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
-\end{lstlisting}
-\end{center}
+% \begin{center}
+% \begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
+% ldc 1
+% ldc 1
+% if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$
+% ldc 2
+% istore 0
+% goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$
+% L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$
+% ldc 3
+% istore 1
+% L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
+% \end{lstlisting}
+% \end{center}
-\begin{tikzpicture}[remember picture,overlay]
- \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm)
- -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
- \draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm)
- -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
-\end{tikzpicture}
+% \begin{tikzpicture}[remember picture,overlay]
+% \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm)
+% -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
+% \draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm)
+% -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
+% \end{tikzpicture}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Whiles}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Whiles}
-For example
+% For example
-\begin{lstlisting}[mathescape,numbers=none,language=While]
-while x <= 10 do x := x + 1
-\end{lstlisting}
+% \begin{lstlisting}[mathescape,numbers=none,language=While]
+% while x <= 10 do x := x + 1
+% \end{lstlisting}
-\begin{center}
-\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
-L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$
- iload 0
- ldc 10
- if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$
- iload 0
- ldc 1
- iadd
- istore 0
- goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$
-L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
-\end{lstlisting}
-\end{center}
+% \begin{center}
+% \begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
+% L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$
+% iload 0
+% ldc 10
+% if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$
+% iload 0
+% ldc 1
+% iadd
+% istore 0
+% goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$
+% L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
+% \end{lstlisting}
+% \end{center}
-\begin{tikzpicture}[remember picture,overlay]
- \draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm)
- -- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
- \draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm)
- -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
-\end{tikzpicture}
+% \begin{tikzpicture}[remember picture,overlay]
+% \draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm)
+% -- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
+% \draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm)
+% -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
+% \end{tikzpicture}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Writes}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Writes}
-\small
-\begin{lstlisting}[language=JVMIS,mathescape,
- numbers=none,xleftmargin=-6mm]
-.method public static write(I)V
- .limit locals 1
- .limit stack 2
- getstatic java/lang/System/out
- Ljava/io/PrintStream;
- iload 0
- invokevirtual java/io/PrintStream/println(I)V
- return
-.end method
+% \small
+% \begin{lstlisting}[language=JVMIS,mathescape,
+% numbers=none,xleftmargin=-6mm]
+% .method public static write(I)V
+% .limit locals 1
+% .limit stack 2
+% getstatic java/lang/System/out
+% Ljava/io/PrintStream;
+% iload 0
+% invokevirtual java/io/PrintStream/println(I)V
+% return
+% .end method
-iload $E(x)$
-invokestatic XXX/XXX/write(I)V
-\end{lstlisting}
+% iload $E(x)$
+% invokestatic XXX/XXX/write(I)V
+% \end{lstlisting}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Main}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Main}
-\footnotesize
-\begin{lstlisting}[language=JVMIS,mathescape,
- numbers=none,xleftmargin=-6mm]
-.class public XXX.XXX
-.super java/lang/Object
+% \footnotesize
+% \begin{lstlisting}[language=JVMIS,mathescape,
+% numbers=none,xleftmargin=-6mm]
+% .class public XXX.XXX
+% .super java/lang/Object
-.method public <init>()V
- aload_0
- invokenonvirtual java/lang/Object/<init>()V
- return
-.end method
+% .method public <init>()V
+% aload_0
+% invokenonvirtual java/lang/Object/<init>()V
+% return
+% .end method
-.method public static main([Ljava/lang/String;)V
- .limit locals 200
- .limit stack 200
+% .method public static main([Ljava/lang/String;)V
+% .limit locals 200
+% .limit stack 200
- $\textit{\ldots{}here comes the compiled code\ldots}$
+% $\textit{\ldots{}here comes the compiled code\ldots}$
- return
-.end method
-\end{lstlisting}
+% return
+% .end method
+% \end{lstlisting}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%