Mercurial > repos > icfp2014
comparison code/lmc.tp @ 10:66d0858692a9
Fix operator argument order and add print primitive for the DBUG instruction
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 25 Jul 2014 14:59:52 -0700 |
parents | 526bec3b2090 |
children | 451043a65ff7 |
comparison
equal
deleted
inserted
replaced
9:526bec3b2090 | 10:66d0858692a9 |
---|---|
101 _opNames set: "=" "CEQ" | 101 _opNames set: "=" "CEQ" |
102 _opNames set: ">" "CGT" | 102 _opNames set: ">" "CGT" |
103 _opNames set: ">=" "CGTE" | 103 _opNames set: ">=" "CGTE" |
104 | 104 |
105 _exprHandlers set: (ast binary) :expr syms { | 105 _exprHandlers set: (ast binary) :expr syms { |
106 if: (expr op) = "|" { | 106 compileExpr: (expr left) syms: syms |
107 compileExpr: (expr left) syms: syms | 107 compileExpr: (expr right) syms: syms |
108 compileExpr: (expr right) syms: syms | |
109 } else: { | |
110 compileExpr: (expr right) syms: syms | |
111 compileExpr: (expr left) syms: syms | |
112 } | |
113 _opNames ifget: (expr op) :i { | 108 _opNames ifget: (expr op) :i { |
114 prog add: (inst: i #[]) | 109 prog add: (inst: i #[]) |
115 } else: { | 110 } else: { |
116 if: (expr op) = "<" { | 111 if: (expr op) = "<" { |
117 prog add: (inst: "CGTE" #[]) | 112 prog add: (inst: "CGTE" #[]) |
170 } | 165 } |
171 _funHandlers set: "not" :args syms { | 166 _funHandlers set: "not" :args syms { |
172 compileExpr: (args value) syms: syms | 167 compileExpr: (args value) syms: syms |
173 prog add: (inst: "LDC" #[0]) | 168 prog add: (inst: "LDC" #[0]) |
174 prog add: (inst: "CEQ" #[]) | 169 prog add: (inst: "CEQ" #[]) |
170 } | |
171 _funHandlers set: "print" :args syms { | |
172 compileExpr: (args value) syms: syms | |
173 prog add: (inst: "DBUG" #[]) | |
175 } | 174 } |
176 | 175 |
177 _exprHandlers set: (ast call) :expr syms { | 176 _exprHandlers set: (ast call) :expr syms { |
178 tc <- (expr tocall) | 177 tc <- (expr tocall) |
179 normal <- true | 178 normal <- true |