|
|
@@ -120,17 +120,15 @@ func (c *Compiler) Compile(node ast.Node) error {
|
|
|
c.removeLastPop()
|
|
|
}
|
|
|
|
|
|
- if node.Alternative == nil {
|
|
|
- afterConsequencePos := len(c.instructions)
|
|
|
-
|
|
|
- c.changOperand(jumpNotTruthyPos, afterConsequencePos)
|
|
|
- } else {
|
|
|
- // Emit an `OpJump` with a bogus value
|
|
|
- jumpPos := c.emit(code.OpJump, 9999)
|
|
|
+ // Emit an `OpJump` with a bogus value
|
|
|
+ jumpPos := c.emit(code.OpJump, 9999)
|
|
|
|
|
|
- afterConsequencePos := len(c.instructions)
|
|
|
- c.changOperand(jumpNotTruthyPos, afterConsequencePos)
|
|
|
+ afterConsequencePos := len(c.instructions)
|
|
|
+ c.changOperand(jumpNotTruthyPos, afterConsequencePos)
|
|
|
|
|
|
+ if node.Alternative == nil {
|
|
|
+ c.emit(code.OpNull)
|
|
|
+ } else {
|
|
|
err := c.Compile(node.Alternative)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -138,10 +136,10 @@ func (c *Compiler) Compile(node ast.Node) error {
|
|
|
if c.lastInstructionIsPop() {
|
|
|
c.removeLastPop()
|
|
|
}
|
|
|
-
|
|
|
- afterAlternativePos := len(c.instructions)
|
|
|
- c.changOperand(jumpPos, afterAlternativePos)
|
|
|
}
|
|
|
+
|
|
|
+ afterAlternativePos := len(c.instructions)
|
|
|
+ c.changOperand(jumpPos, afterAlternativePos)
|
|
|
case *ast.BlockStatement:
|
|
|
for _, s := range node.Statements {
|
|
|
err := c.Compile(s)
|