class Lignite::Condition
Compile a conditional jump forward or backward
Public Instance Methods
cond_jump(_compiler, _offset)
click to toggle source
Call that instruction of the compiler that jumps by offset according to the condition that we implement
# File lib/lignite/condition.rb, line 6 def cond_jump(_compiler, _offset) raise ScriptError, "subclasses must override this" end
jump_back(compiler, body_size, self_size = nil)
click to toggle source
# File lib/lignite/condition.rb, line 20 def jump_back(compiler, body_size, self_size = nil) if self_size.nil? fake = compiler.clone_context jump_back(fake, body_size, 0) self_size = fake.bytes.bytesize end cond_jump(compiler, - (body_size + self_size)) end
jump_forward(compiler, body_size)
click to toggle source
# File lib/lignite/condition.rb, line 16 def jump_forward(compiler, body_size) cond_jump(compiler, body_size) end
not()
click to toggle source
Negation of this condition. An `if(cond){ body }` becomes roughly `cond.not.jump_forward(body.size); body`
# File lib/lignite/condition.rb, line 12 def not raise ScriptError, "subclasses must override this" end