compiler: allow to declare variables of struct type
Previously, struct variables were initialize with VM's nil value which is of primitive type. Thus SETITEM used for struct's field updating wasn't working.
This commit is contained in:
parent
6baed7a010
commit
3cbd138b67
3 changed files with 43 additions and 0 deletions
|
@ -287,6 +287,11 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
emit.Opcode(c.prog.BinWriter, opcode.NEWARRAY)
|
||||
l := c.scope.newLocal(t.Names[0].Name)
|
||||
c.emitStoreLocal(l)
|
||||
} else if n, ok := c.isStructType(t.Type); ok {
|
||||
emit.Int(c.prog.BinWriter, int64(n))
|
||||
emit.Opcode(c.prog.BinWriter, opcode.NEWSTRUCT)
|
||||
l := c.scope.newLocal(t.Names[0].Name)
|
||||
c.emitStoreLocal(l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue