Class: KoiReferenceCompiler::If

Inherits:
SyntaxNode show all
Defined in:
lib/koi-reference-compiler/node_extensions/control_flow/if.rb

Instance Attribute Summary

Attributes inherited from SyntaxNode

#elements, #offset, #parent, #text_value

Instance Method Summary collapse

Methods inherited from SyntaxNode

#initialize

Constructor Details

This class inherits a constructor from KoiReferenceCompiler::SyntaxNode

Instance Method Details

#compileObject



4
5
6
7
8
9
10
11
# File 'lib/koi-reference-compiler/node_extensions/control_flow/if.rb', line 4

def compile
  bytecode = self.elements[0].compile
  block = self.elements[1].compile
  bytecode.concat([
    JUMP_UNLESS, block.length + 2
  ])
  bytecode.concat( block )
end