progs/while/compile.sc
changeset 810 ba25eaf6043c
parent 809 2b9956d29038
child 811 86406d70d6f0
equal deleted inserted replaced
809:2b9956d29038 810:ba25eaf6043c
   102   case Num(i) => i"ldc $i"
   102   case Num(i) => i"ldc $i"
   103   case Var(s) => i"iload ${env(s)} \t\t; $s"
   103   case Var(s) => i"iload ${env(s)} \t\t; $s"
   104   case Aop(op, a1, a2) => 
   104   case Aop(op, a1, a2) => 
   105     compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_op(op)
   105     compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_op(op)
   106 }
   106 }
   107 
       
   108 
   107 
   109 // boolean expression compilation
   108 // boolean expression compilation
   110 //  - the jump-label is for where to jump if the condition is not true
   109 //  - the jump-label is for where to jump if the condition is not true
   111 def compile_bexp(b: BExp, env : Env, jmp: String) : String = b match {
   110 def compile_bexp(b: BExp, env : Env, jmp: String) : String = b match {
   112   case True => ""
   111   case True => ""