module SyntaxTree::YARV

This module provides an object representation of the YARV bytecode.

This module provides an object representation of the YARV bytecode.

This module provides an object representation of the YARV bytecode.

Public Class Methods

calldata( method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil ) click to toggle source

A convenience method for creating a CallData object.

# File lib/syntax_tree/yarv/calldata.rb, line 88
def self.calldata(
  method,
  argc = 0,
  flags = CallData::CALL_ARGS_SIMPLE,
  kw_arg = nil
)
  CallData.new(method, argc, flags, kw_arg)
end
compile(source, options = Compiler::Options.new) click to toggle source

Compile the given source into a YARV instruction sequence.

# File lib/syntax_tree/yarv.rb, line 25
def self.compile(source, options = Compiler::Options.new)
  SyntaxTree.parse(source).accept(Compiler.new(options))
end
interpret(source, options = Compiler::Options.new) click to toggle source

Compile and interpret the given source.

# File lib/syntax_tree/yarv.rb, line 30
def self.interpret(source, options = Compiler::Options.new)
  iseq = RubyVM::InstructionSequence.compile(source, **options)
  iseq = InstructionSequence.from(iseq.to_a)
  VM.new.run_top_frame(iseq)
end