Skip to content

Commit 019de20

Browse files
committed
Added some lame tests for IRExpr to Low conversion
1 parent 2f9eb47 commit 019de20

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

.idea/libraries/picocli_4_5_2.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package deep.decaf.tester
2+
3+
import deep.decaf.ir.*
4+
import deep.decaf.low.amd64.*
5+
6+
fun main() {
7+
val pos = Position.unknown()
8+
val expressions = listOf(
9+
IRBinOpExpr(
10+
IRBinOpExpr(
11+
IRIntLiteral(1, pos), IRIntLiteral(2, pos), BinOp.MULTIPLY, pos
12+
),
13+
IRBinOpExpr(
14+
IRBinOpExpr(
15+
IRIntLiteral(3, pos), IRIntLiteral(4, pos), BinOp.MULTIPLY, pos
16+
),
17+
IRBinOpExpr(
18+
IRIntLiteral(5, pos), IRIntLiteral(6, pos), BinOp.MULTIPLY, pos
19+
),
20+
BinOp.SUBTRACT,
21+
pos
22+
),
23+
BinOp.ADD,
24+
pos
25+
),
26+
27+
IRBinOpExpr(
28+
IRBinOpExpr(
29+
IRLocationExpression(IRIDLocation("a", pos), pos),
30+
IRLocationExpression(IRIDLocation("b", pos), pos),
31+
BinOp.MORE,
32+
pos
33+
),
34+
IRBinOpExpr(
35+
IRLocationExpression(IRIDLocation("c", pos), pos),
36+
IRLocationExpression(IRIDLocation("d", pos), pos),
37+
BinOp.EQ,
38+
pos
39+
),
40+
BinOp.AND,
41+
pos
42+
)
43+
)
44+
45+
expressions.forEach { expr ->
46+
val statements = irExprToLow(expr)
47+
val asm = statements.joinToString("\n") { it.toString() }
48+
println(asm)
49+
println()
50+
}
51+
}

0 commit comments

Comments
 (0)