Update compiler (#22)
* refactor to use ast.Walk for recursive converting * added lots of test cases * added a new way to handle jump labels * function calls with multiple arguments * binary expression (LOR LAND) * struct types + method receives * cleaner opcode dumps, side by side diff for debugging test cases
This commit is contained in:
parent
b257a06f3e
commit
8fe079ec8e
19 changed files with 1298 additions and 1064 deletions
31
pkg/vm/compiler/tests/assign_test.go
Normal file
31
pkg/vm/compiler/tests/assign_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package compiler_test
|
||||
|
||||
var assignTestCases = []testCase{
|
||||
{
|
||||
"chain define",
|
||||
`
|
||||
package foo
|
||||
func Main() int {
|
||||
x := 4
|
||||
y := x
|
||||
z := y
|
||||
foo := z
|
||||
bar := foo
|
||||
return bar
|
||||
}
|
||||
`,
|
||||
"56c56b546c766b00527ac46c766b00c36c766b51527ac46c766b51c36c766b52527ac46c766b52c36c766b53527ac46c766b53c36c766b54527ac46203006c766b54c3616c7566",
|
||||
},
|
||||
{
|
||||
"simple assign",
|
||||
`
|
||||
package foo
|
||||
func Main() int {
|
||||
x := 4
|
||||
x = 8
|
||||
return x
|
||||
}
|
||||
`,
|
||||
"53c56b546c766b00527ac4586c766b00527ac46203006c766b00c3616c7566",
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue