Class: SyntaxTree::YARV::DefinedIVar
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::DefinedIVar
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
‘definedivar` checks if an instance variable is defined. It is a specialization of the `defined` instruction. It accepts three arguments: the name of the instance variable, an inline cache, and the string that should be pushed onto the stack in the event that the instance variable is defined.
### Usage
~~~ruby defined?(@value) ~~~
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(name, cache, message) ⇒ DefinedIVar
constructor
A new instance of DefinedIVar.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(name, cache, message) ⇒ DefinedIVar
Returns a new instance of DefinedIVar.
1067 1068 1069 1070 1071 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1067 def initialize(name, cache, ) @name = name @cache = cache @message = end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
1065 1066 1067 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1065 def cache @cache end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
1065 1066 1067 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1065 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1065 1066 1067 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1065 def name @name end |
Instance Method Details
#==(other) ⇒ Object
1088 1089 1090 1091 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1088 def ==(other) other.is_a?(DefinedIVar) && other.name == name && other.cache == cache && other. == end |
#call(vm) ⇒ Object
1101 1102 1103 1104 1105 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1101 def call(vm) result = ( if vm.frame._self.instance_variable_defined?(name)) vm.push(result) end |
#deconstruct_keys(_keys) ⇒ Object
1084 1085 1086 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1084 def deconstruct_keys(_keys) { name: name, cache: cache, message: } end |
#disasm(fmt) ⇒ Object
1073 1074 1075 1076 1077 1078 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1073 def disasm(fmt) fmt.instruction( "definedivar", [fmt.object(name), fmt.inline_storage(cache), fmt.object()] ) end |
#length ⇒ Object
1093 1094 1095 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1093 def length 4 end |
#pushes ⇒ Object
1097 1098 1099 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1097 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1080 1081 1082 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1080 def to_a(_iseq) [:definedivar, name, cache, ] end |