compiler: process _ as a special variable
It is more convenient to drop values inside `emitStoreVar` because this makes other code has less special cases.
This commit is contained in:
parent
3926456d86
commit
fdb217ec81
1 changed files with 5 additions and 6 deletions
|
@ -207,6 +207,10 @@ func (c *codegen) emitLoadVar(name string) {
|
|||
|
||||
// emitStoreVar stores top value from the evaluation stack in the specified variable.
|
||||
func (c *codegen) emitStoreVar(name string) {
|
||||
if name == "_" {
|
||||
emit.Opcode(c.prog.BinWriter, opcode.DROP)
|
||||
return
|
||||
}
|
||||
t, i := c.getVarIndex(name)
|
||||
_, base := getBaseOpcode(t)
|
||||
if i < 7 {
|
||||
|
@ -401,12 +405,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
if i == 0 || !multiRet {
|
||||
ast.Walk(c, n.Rhs[i])
|
||||
}
|
||||
|
||||
if t.Name == "_" {
|
||||
emit.Opcode(c.prog.BinWriter, opcode.DROP)
|
||||
} else {
|
||||
c.emitStoreVar(t.Name)
|
||||
}
|
||||
c.emitStoreVar(t.Name)
|
||||
}
|
||||
|
||||
case *ast.SelectorExpr:
|
||||
|
|
Loading…
Reference in a new issue