-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append bytes bigger than 0x79 properly #1750
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1750 +/- ##
==========================================
+ Coverage 82.52% 82.55% +0.02%
==========================================
Files 272 272
Lines 22152 22177 +25
==========================================
+ Hits 18281 18308 +27
+ Misses 2745 2744 -1
+ Partials 1126 1125 -1
Continue to review full report at Codecov.
|
Like |
pkg/compiler/codegen.go
Outdated
emit.Opcodes(c.prog.BinWriter, opcode.APPEND) | ||
if expr.Ellipsis.IsValid() { | ||
ast.Walk(c, expr.Args[1]) // append(x, y...) -> x, y on stack | ||
emit.Opcodes(c.prog.BinWriter, opcode.DUP, opcode.REVERSEITEMS) // POPITEM pops last element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this will change y
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, inserted conversion to Struct
, added test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVERSEITEMS
is quite costly and now we also CONVERT
, maybe it's easier with PICKITEM
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
NeoVM encoding for int(0x80) is []byte{0x80, 0x00} and byte constant can be used both as integer and as an element of byte-slice. Thus special case needs to be taken in `append`.
NeoVM lacks opcode for array append, thus some kind of loop is needed for this.
Close #1749 .
I works, but I am currently thinking how we can handle byte varargs in a more general way, including user-defined functions.