Module: SyntaxTree::YARV

Defined in:
lib/syntax_tree/yarv.rb,
lib/syntax_tree/yarv/bf.rb,
lib/syntax_tree/yarv/vm.rb,
lib/syntax_tree/yarv/legacy.rb,
lib/syntax_tree/yarv/calldata.rb,
lib/syntax_tree/yarv/compiler.rb,
lib/syntax_tree/yarv/assembler.rb,
lib/syntax_tree/yarv/decompiler.rb,
lib/syntax_tree/yarv/basic_block.rb,
lib/syntax_tree/yarv/local_table.rb,
lib/syntax_tree/yarv/disassembler.rb,
lib/syntax_tree/yarv/instructions.rb,
lib/syntax_tree/yarv/sea_of_nodes.rb,
lib/syntax_tree/yarv/data_flow_graph.rb,
lib/syntax_tree/yarv/control_flow_graph.rb,
lib/syntax_tree/yarv/instruction_sequence.rb

Overview

This module provides an object representation of the YARV bytecode.

Defined Under Namespace

Modules: Legacy Classes: AdjustStack, AnyToString, Assembler, BasicBlock, Bf, BranchIf, BranchNil, BranchUnless, CallData, CheckKeyword, CheckMatch, CheckType, Compiler, ConcatArray, ConcatStrings, ControlFlowGraph, DataFlowGraph, Decompiler, DefineClass, DefineMethod, DefineSMethod, Defined, DefinedIVar, Disassembler, Dup, DupArray, DupHash, DupN, ExpandArray, GetBlockParam, GetBlockParamProxy, GetClassVariable, GetConstant, GetGlobal, GetInstanceVariable, GetLocal, GetLocalWC0, GetLocalWC1, GetSpecial, Instruction, InstructionSequence, Intern, InvokeBlock, InvokeSuper, Jump, Leave, LocalTable, NewArray, NewArrayKwSplat, NewHash, NewRange, Nop, ObjToString, Once, OptAnd, OptAref, OptArefWith, OptAset, OptAsetWith, OptCaseDispatch, OptDiv, OptEmptyP, OptEq, OptGE, OptGT, OptGetConstantPath, OptLE, OptLT, OptLTLT, OptLength, OptMinus, OptMod, OptMult, OptNEq, OptNewArrayMax, OptNewArrayMin, OptNilP, OptNot, OptOr, OptPlus, OptRegExpMatch2, OptSendWithoutBlock, OptSize, OptStrFreeze, OptStrUMinus, OptSucc, Pop, PutNil, PutObject, PutObjectInt2Fix0, PutObjectInt2Fix1, PutSelf, PutSpecialObject, PutString, SeaOfNodes, Send, SetBlockParam, SetClassVariable, SetConstant, SetGlobal, SetInstanceVariable, SetLocal, SetLocalWC0, SetLocalWC1, SetN, SetSpecial, SplatArray, Swap, Throw, ToRegExp, TopN, VM

Class Method Summary collapse

Class Method Details

.calldata(method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil) ⇒ Object

A convenience method for creating a CallData object.



82
83
84
85
86
87
88
89
# File 'lib/syntax_tree/yarv/calldata.rb', line 82

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) ⇒ Object

Compile the given source into a YARV instruction sequence.



25
26
27
# 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) ⇒ Object

Compile and interpret the given source.



30
31
32
33
34
# 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