Null my old friend
This commit is contained in:
@@ -134,16 +134,15 @@ func (c *Compiler) Compile(node ast.Node) error {
|
||||
c.removeLastPop()
|
||||
}
|
||||
|
||||
// Emit an `OnJump` with a bogus value
|
||||
jumpPos := c.emit(code.OpJump, 9999)
|
||||
|
||||
afterConsequencePos := len(c.instructions)
|
||||
c.changeOperand(jumpNotTruthyPos, afterConsequencePos)
|
||||
|
||||
if node.Alternative == nil {
|
||||
afterConsequencePos := len(c.instructions)
|
||||
c.changeOperand(jumpNotTruthyPos, afterConsequencePos)
|
||||
c.emit(code.OpNull)
|
||||
} else {
|
||||
// Emit an `OnJump` with a bogus value
|
||||
jumpPos := c.emit(code.OpJump, 9999)
|
||||
|
||||
afterConsequencePos := len(c.instructions)
|
||||
c.changeOperand(jumpNotTruthyPos, afterConsequencePos)
|
||||
|
||||
err = c.Compile(node.Alternative)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -152,12 +151,11 @@ func (c *Compiler) Compile(node ast.Node) error {
|
||||
if c.lastInstructionIsPop() {
|
||||
c.removeLastPop()
|
||||
}
|
||||
|
||||
afterAlternativePos := len(c.instructions)
|
||||
c.changeOperand(jumpPos, afterAlternativePos)
|
||||
|
||||
}
|
||||
|
||||
afterAlternativePos := len(c.instructions)
|
||||
c.changeOperand(jumpPos, afterAlternativePos)
|
||||
|
||||
case *ast.BlockStatement:
|
||||
for _, s := range node.Statements {
|
||||
err := c.Compile(s)
|
||||
|
||||
Reference in New Issue
Block a user