equal
deleted
inserted
replaced
96 i"goto $if_end" ++ |
96 i"goto $if_end" ++ |
97 l"$if_else" ++ |
97 l"$if_else" ++ |
98 compile_expT(a2, env, name) ++ |
98 compile_expT(a2, env, name) ++ |
99 l"$if_end" |
99 l"$if_end" |
100 } |
100 } |
101 case Call(n, args) => if (name == n) { |
101 case Call(n, args) => if (name == n) { // can apply tail-call optimisation |
102 val stores = args.zipWithIndex.map { case (x, y) => i"istore $y" } |
102 val stores = args.zipWithIndex.map { case (x, y) => i"istore $y" } |
103 args.map(a => compile_expT(a, env, "")).mkString ++ |
103 args.map(a => compile_expT(a, env, "")).mkString ++ |
104 stores.reverse.mkString ++ |
104 stores.reverse.mkString ++ |
105 i"goto ${n}_Start" |
105 i"goto ${n}_Start" |
106 } else { |
106 } else { // normal call |
107 val is = "I" * args.length |
107 val is = "I" * args.length |
108 args.map(a => compile_expT(a, env, "")).mkString ++ |
108 args.map(a => compile_expT(a, env, "")).mkString ++ |
109 i"invokestatic XXX/XXX/${n}(${is})I" |
109 i"invokestatic XXX/XXX/${n}(${is})I" |
110 } |
110 } |
111 case Sequence(a1, a2) => { |
111 case Sequence(a1, a2) => { |