compiler: add contract.CallEx interop

This commit is contained in:
Evgenii Stratonikov 2020-12-08 15:37:03 +03:00
parent ec58bec803
commit 37a8550215
5 changed files with 93 additions and 5 deletions

View file

@ -850,7 +850,14 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
emit.Opcodes(c.prog.BinWriter, opcode.PACK)
numArgs -= varSize - 1
}
c.emitReverse(numArgs)
// CallFlag in CallEx interop should be the last argument
// but this can't be reflected in signature due to varargs.
// It is first in compiler interop though, thus we just need to reverse 1 values less.
if f != nil && isSyscall(f) && f.pkg.Name() == "contract" && f.name == "CallEx" {
c.emitReverse(numArgs - 1)
} else {
c.emitReverse(numArgs)
}
}
// Check builtin first to avoid nil pointer on funcScope!