Class: SyntaxTree::YARV::Instruction
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::Instruction
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
This is a base class for all YARV instructions. It provides a few convenience methods for working with instructions.
Direct Known Subclasses
AdjustStack, AnyToString, BranchIf, BranchNil, BranchUnless, CheckKeyword, CheckMatch, CheckType, ConcatArray, ConcatStrings, DefineClass, DefineMethod, DefineSMethod, Defined, DefinedIVar, Dup, DupArray, DupHash, DupN, ExpandArray, GetBlockParam, GetBlockParamProxy, GetClassVariable, GetConstant, GetGlobal, GetInstanceVariable, GetLocal, GetLocalWC0, GetLocalWC1, GetSpecial, Intern, InvokeBlock, InvokeSuper, Jump, Leave, Legacy::GetClassVariable, Legacy::OptGetInlineCache, Legacy::OptNewArrayMax, Legacy::OptNewArrayMin, Legacy::OptSetInlineCache, Legacy::SetClassVariable, 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, OptNewArraySend, OptNilP, OptNot, OptOr, OptPlus, OptRegExpMatch2, OptSendWithoutBlock, OptSize, OptStrFreeze, OptStrUMinus, OptSucc, Pop, PutNil, PutObject, PutObjectInt2Fix0, PutObjectInt2Fix1, PutSelf, PutSpecialObject, PutString, Send, SetBlockParam, SetClassVariable, SetConstant, SetGlobal, SetInstanceVariable, SetLocal, SetLocalWC0, SetLocalWC1, SetN, SetSpecial, SplatArray, Swap, Throw, ToRegExp, TopN
Instance Method Summary collapse
-
#branch_targets ⇒ Object
This returns an array of labels.
-
#canonical ⇒ Object
This method creates an instruction that represents the canonical (non-specialized) form of this instruction.
-
#falls_through? ⇒ Boolean
Whether or not this instruction falls through to the next instruction if its branching fails.
-
#leaves? ⇒ Boolean
Whether or not this instruction leaves the current frame.
-
#length ⇒ Object
This returns the size of the instruction in terms of the number of slots it occupies in the instruction sequence.
-
#pops ⇒ Object
This returns the number of values that are popped off the stack.
-
#pushes ⇒ Object
This returns the number of values that are pushed onto the stack.
-
#side_effects? ⇒ Boolean
Does the instruction have side effects? Control-flow counts as a side-effect, as do some special-case instructions like Leave.
Instance Method Details
#branch_targets ⇒ Object
This returns an array of labels.
33 34 35 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 33 def branch_targets [] end |
#canonical ⇒ Object
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`.
11 12 13 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 11 def canonical self end |
#falls_through? ⇒ Boolean
Whether or not this instruction falls through to the next instruction if its branching fails.
44 45 46 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 44 def falls_through? false end |
#leaves? ⇒ Boolean
Whether or not this instruction leaves the current frame.
38 39 40 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 38 def leaves? false end |
#length ⇒ Object
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.
18 19 20 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 18 def length 1 end |
#pops ⇒ Object
This returns the number of values that are popped off the stack.
28 29 30 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 28 def pops 0 end |
#pushes ⇒ Object
This returns the number of values that are pushed onto the stack.
23 24 25 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 23 def pushes 0 end |
#side_effects? ⇒ Boolean
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.
51 52 53 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 51 def side_effects? true end |