Class: SyntaxTree::YARV::Decompiler

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/syntax_tree/yarv/decompiler.rb

Overview

This class is responsible for taking a compiled instruction sequence and walking through it to generate equivalent Ruby code.

Defined Under Namespace

Classes: BlockLabel

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

#ARef, #ARefField, #AliasNode, #ArgBlock, #ArgParen, #ArgStar, #Args, #ArgsForward, #ArrayLiteral, #AryPtn, #Assign, #Assoc, #AssocSplat, #BEGINBlock, #Backref, #Backtick, #BareAssocHash, #Begin, #Binary, #BlockArg, #BlockNode, #BlockVar, #BodyStmt, #Break, #CHAR, #CVar, #CallNode, #Case, #ClassDeclaration, #Comma, #Command, #CommandCall, #Comment, #Const, #ConstPathField, #ConstPathRef, #ConstRef, #DefNode, #Defined, #DynaSymbol, #ENDBlock, #Else, #Elsif, #EmbDoc, #EmbExprBeg, #EmbExprEnd, #EmbVar, #EndContent, #Ensure, #ExcessedComma, #Field, #FloatLiteral, #FndPtn, #For, #GVar, #HashLiteral, #Heredoc, #HeredocBeg, #HeredocEnd, #HshPtn, #IVar, #Ident, #IfNode, #IfOp, #Imaginary, #In, #Int, #Kw, #KwRestParam, #LBrace, #LBracket, #LParen, #Label, #LabelEnd, #Lambda, #LambdaVar, #MAssign, #MLHS, #MLHSParen, #MRHS, #MethodAddBlock, #ModuleDeclaration, #Next, #Not, #Op, #OpAssign, #Params, #Paren, #Period, #PinnedBegin, #PinnedVarRef, #Program, #QSymbols, #QSymbolsBeg, #QWords, #QWordsBeg, #RAssign, #RBrace, #RBracket, #RParen, #RangeNode, #RationalLiteral, #Redo, #RegexpBeg, #RegexpContent, #RegexpEnd, #RegexpLiteral, #Rescue, #RescueEx, #RescueMod, #RestParam, #Retry, #ReturnNode, #SClass, #Statements, #StringConcat, #StringContent, #StringDVar, #StringEmbExpr, #StringLiteral, #Super, #SymBeg, #SymbolContent, #SymbolLiteral, #Symbols, #SymbolsBeg, #TLamBeg, #TLambda, #TStringBeg, #TStringContent, #TStringEnd, #TopConstField, #TopConstRef, #Unary, #Undef, #UnlessNode, #UntilNode, #VCall, #VarField, #VarRef, #VoidStmt, #When, #WhileNode, #Word, #Words, #WordsBeg, #XString, #XStringLiteral, #YieldNode, #ZSuper

Constructor Details

#initialize(iseq) ⇒ Decompiler

Returns a new instance of Decompiler.



32
33
34
35
# File 'lib/syntax_tree/yarv/decompiler.rb', line 32

def initialize(iseq)
  @iseq = iseq
  @block_label = BlockLabel.new("__block_label")
end

Instance Attribute Details

#block_labelObject (readonly)

Returns the value of attribute block_label.



30
31
32
# File 'lib/syntax_tree/yarv/decompiler.rb', line 30

def block_label
  @block_label
end

#iseqObject (readonly)

Returns the value of attribute iseq.



30
31
32
# File 'lib/syntax_tree/yarv/decompiler.rb', line 30

def iseq
  @iseq
end

Instance Method Details

#to_rubyObject



37
38
39
# File 'lib/syntax_tree/yarv/decompiler.rb', line 37

def to_ruby
  Program(decompile(iseq))
end