compiler: allow to use switch
without tag
This commit is contained in:
parent
e58616b975
commit
354645fbe3
2 changed files with 22 additions and 3 deletions
|
@ -578,9 +578,13 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
return nil
|
||||
|
||||
case *ast.SwitchStmt:
|
||||
ast.Walk(c, n.Tag)
|
||||
|
||||
eqOpcode, _ := convertToken(token.EQL, c.typeOf(n.Tag))
|
||||
eqOpcode := opcode.EQUAL
|
||||
if n.Tag != nil {
|
||||
ast.Walk(c, n.Tag)
|
||||
eqOpcode, _ = convertToken(token.EQL, c.typeOf(n.Tag))
|
||||
} else {
|
||||
emit.Bool(c.prog.BinWriter, true)
|
||||
}
|
||||
switchEnd, label := c.generateLabel(labelEnd)
|
||||
|
||||
lastSwitch := c.currentSwitch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue