class SyntaxTree::YARV::Instruction

This is a base class for all YARV instructions. It provides a few convenience methods for working with instructions.

Public Instance Methods

branch_targets() click to toggle source

This returns an array of labels.

# File lib/syntax_tree/yarv/instructions.rb, line 33
def branch_targets
  []
end
canonical() click to toggle source

This method creates an instruction that represents the canonical (non-specialized) form of this instruction. If this instruction is not a specialized instruction, then this method returns ‘self`.

# File lib/syntax_tree/yarv/instructions.rb, line 11
def canonical
  self
end
falls_through?() click to toggle source

Whether or not this instruction falls through to the next instruction if its branching fails.

# File lib/syntax_tree/yarv/instructions.rb, line 44
def falls_through?
  false
end
leaves?() click to toggle source

Whether or not this instruction leaves the current frame.

# File lib/syntax_tree/yarv/instructions.rb, line 38
def leaves?
  false
end
length() click to toggle source

This returns the size of the instruction in terms of the number of slots it occupies in the instruction sequence. Effectively this is 1 plus the number of operands.

# File lib/syntax_tree/yarv/instructions.rb, line 18
def length
  1
end
pops() click to toggle source

This returns the number of values that are popped off the stack.

# File lib/syntax_tree/yarv/instructions.rb, line 28
def pops
  0
end
pushes() click to toggle source

This returns the number of values that are pushed onto the stack.

# File lib/syntax_tree/yarv/instructions.rb, line 23
def pushes
  0
end
side_effects?() click to toggle source

Does the instruction have side effects? Control-flow counts as a side-effect, as do some special-case instructions like Leave. By default every instruction is marked as having side effects.

# File lib/syntax_tree/yarv/instructions.rb, line 51
def side_effects?
  true
end