compiler: drop unused call results

Close #683.
This commit is contained in:
Evgenii Stratonikov 2020-08-24 18:37:39 +03:00
parent f70cb4f34a
commit e58616b975
4 changed files with 80 additions and 15 deletions

View file

@ -795,6 +795,20 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
emit.Call(c.prog.BinWriter, opcode.CALLL, f.label)
}
if c.scope != nil && c.scope.voidCalls[n] {
var sz int
if f != nil {
sz = f.decl.Type.Results.NumFields()
} else if !isBuiltin {
// lambda invocation
f := c.typeOf(n.Fun).Underlying().(*types.Signature)
sz = f.Results().Len()
}
for i := 0; i < sz; i++ {
emit.Opcode(c.prog.BinWriter, opcode.DROP)
}
}
return nil
case *ast.SelectorExpr: