Compiler (#23)
* implemented add, mul, div, sub assign for identifiers. * Implemented struct field initialization. * Implemented imports * Implemented storage VM API (interop layer) + additional bug fixes when encountered. * Bumped version 0.12.0 * fixed double point extension on compiled output file. * Fixed bug where callExpr in returns where added to voidCall * fixed binExpr compare equal * Check the env for the gopath first * removed travis.yml * custom types + implemented general declarations. * commented out the storage test to make the build pass
This commit is contained in:
parent
bebdabab9f
commit
23cfebf621
25 changed files with 798 additions and 117 deletions
|
@ -1,15 +1,10 @@
|
|||
package compiler_test
|
||||
package compiler
|
||||
|
||||
var structTestCases = []testCase{
|
||||
{
|
||||
"struct field assign",
|
||||
`
|
||||
package foo
|
||||
type token struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
func Main() int {
|
||||
t := token {
|
||||
x: 2,
|
||||
|
@ -19,6 +14,11 @@ var structTestCases = []testCase{
|
|||
age := t.x
|
||||
return age
|
||||
}
|
||||
|
||||
type token struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
`,
|
||||
"53c56b6152c66b526c766b00527ac4546c766b51527ac46c6c766b00527ac46c766b00c300c36c766b51527ac46203006c766b51c3616c7566",
|
||||
},
|
||||
|
@ -154,4 +154,50 @@ var structTestCases = []testCase{
|
|||
`,
|
||||
"53c56b6151c66b546c766b00527ac46c6c766b00527ac46c766b00c352545272616516006c766b51527ac46203006c766b51c3616c756654c56b6c766b00527ac46c766b51527ac46c766b52527ac46203006c766b00c300c36c766b51c3936c766b52c393616c7566",
|
||||
},
|
||||
{
|
||||
"initialize struct partially",
|
||||
`
|
||||
package foo
|
||||
type token struct {
|
||||
x int
|
||||
y int
|
||||
z string
|
||||
b bool
|
||||
}
|
||||
|
||||
func Main() int {
|
||||
t := token {
|
||||
x: 4,
|
||||
}
|
||||
return t.y
|
||||
}
|
||||
`,
|
||||
"52c56b6154c66b546c766b00527ac4006c766b51527ac4006c766b52527ac4006c766b53527ac46c6c766b00527ac46203006c766b00c351c3616c7566",
|
||||
},
|
||||
{
|
||||
"test return struct from func",
|
||||
`
|
||||
package foo
|
||||
type token struct {
|
||||
x int
|
||||
y int
|
||||
z string
|
||||
b bool
|
||||
}
|
||||
|
||||
func newToken() token {
|
||||
return token{
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: "hello",
|
||||
b: false,
|
||||
}
|
||||
}
|
||||
|
||||
func Main() token {
|
||||
return newToken()
|
||||
}
|
||||
`,
|
||||
"51c56b62030061650700616c756651c56b6203006154c66b516c766b00527ac4526c766b51527ac40568656c6c6f6c766b52527ac4006c766b53527ac46c616c7566",
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue