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.
1014 1015 1016 1017 1018 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1014 def initialize(name, cache, ) @name = name @cache = cache @message = end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
1012 1013 1014 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1012 def cache @cache end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
1012 1013 1014 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1012 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1012 1013 1014 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1012 def name @name end |
Instance Method Details
#==(other) ⇒ Object
1035 1036 1037 1038 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1035 def ==(other) other.is_a?(DefinedIVar) && other.name == name && other.cache == cache && other. == end |
#call(vm) ⇒ Object
1048 1049 1050 1051 1052 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1048 def call(vm) result = ( if vm.frame._self.instance_variable_defined?(name)) vm.push(result) end |
#deconstruct_keys(_keys) ⇒ Object
1031 1032 1033 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1031 def deconstruct_keys(_keys) { name: name, cache: cache, message: } end |
#disasm(fmt) ⇒ Object
1020 1021 1022 1023 1024 1025 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1020 def disasm(fmt) fmt.instruction( "definedivar", [fmt.object(name), fmt.inline_storage(cache), fmt.object()] ) end |
#length ⇒ Object
1040 1041 1042 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1040 def length 4 end |
#pushes ⇒ Object
1044 1045 1046 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1044 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1027 1028 1029 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1027 def to_a(_iseq) [:definedivar, name, cache, ] end |