Mercurial > repos > icfp2014
comparison code/lmc.tp @ 5:80e224fff567
Fix handling of true case in if:else
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 25 Jul 2014 11:04:00 -0700 |
parents | eaf0a014d18b |
children | 0ab6eb5f0190 |
comparison
equal
deleted
inserted
replaced
4:eaf0a014d18b | 5:80e224fff567 |
---|---|
121 _funHandlers set: "if:else" :args { | 121 _funHandlers set: "if:else" :args { |
122 compileExpr: (args value) | 122 compileExpr: (args value) |
123 args <- args tail | 123 args <- args tail |
124 tlabel <- prog makeLabel: "true" | 124 tlabel <- prog makeLabel: "true" |
125 flabel <- prog makeLabel: "false" | 125 flabel <- prog makeLabel: "false" |
126 elabel <- prog makeLabel: "end" | |
126 prog add: (inst: "TSEL" #[ | 127 prog add: (inst: "TSEL" #[ |
127 tlabel | 128 tlabel |
128 flabel | 129 flabel |
129 ]) | 130 ]) |
130 prog setLabel: tlabel | 131 prog setLabel: tlabel |
131 foreach: ((args value) expressions) :idx expr { | 132 foreach: ((args value) expressions) :idx expr { |
132 compileExpr: expr | 133 compileExpr: expr |
133 } | 134 } |
135 prog add: (inst: "LDC" #[1]) | |
136 prog add: (inst: "TSEL" #[ | |
137 elabel | |
138 elabel | |
139 ]) | |
134 args <- args tail | 140 args <- args tail |
135 prog setLabel: flabel | 141 prog setLabel: flabel |
136 foreach: ((args value) expressions) :idx expr { | 142 foreach: ((args value) expressions) :idx expr { |
137 compileExpr: expr | 143 compileExpr: expr |
138 } | 144 } |
145 prog setLabel: elabel | |
139 } | 146 } |
140 _funHandlers set: "isInteger?" :args { | 147 _funHandlers set: "isInteger?" :args { |
141 compileExpr: (args value) | 148 compileExpr: (args value) |
142 prog add: (inst: "ATOM" #[]) | 149 prog add: (inst: "ATOM" #[]) |
143 } | 150 } |