mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
compiler: support byte slice declaration
This commit is contained in:
parent
582469028b
commit
34a4c15932
2 changed files with 13 additions and 0 deletions
|
@ -233,6 +233,8 @@ func (c *codegen) emitDefault(t types.Type) {
|
|||
case *types.Slice:
|
||||
if isCompoundSlice(t) {
|
||||
emit.Opcode(c.prog.BinWriter, opcode.NEWARRAY0)
|
||||
} else {
|
||||
emit.Bytes(c.prog.BinWriter, []byte{})
|
||||
}
|
||||
case *types.Struct:
|
||||
emit.Int(c.prog.BinWriter, int64(t.NumFields()))
|
||||
|
|
|
@ -130,6 +130,17 @@ var sliceTestCases = []testCase{
|
|||
}`,
|
||||
[]byte{2, 3},
|
||||
},
|
||||
{
|
||||
"declare byte slice",
|
||||
`package foo
|
||||
func Main() []byte {
|
||||
var a []byte
|
||||
a = append(a, 1)
|
||||
a = append(a, 2)
|
||||
return a
|
||||
}`,
|
||||
[]byte{1, 2},
|
||||
},
|
||||
{
|
||||
"declare compound slice",
|
||||
`package foo
|
||||
|
|
Loading…
Reference in a new issue