Class: SyntaxTree::YARV::DefinedIVar
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
defined?(@value)
Instance Attribute Summary collapse
Instance Method Summary
collapse
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, message)
@name = name
@cache = cache
@message = message
end
|
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
1065
1066
1067
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1065
def cache
@cache
end
|
#message ⇒ Object
Returns the value of attribute message.
1065
1066
1067
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1065
def message
@message
end
|
#name ⇒ Object
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.message == message
end
|
#call(vm) ⇒ Object
1101
1102
1103
1104
1105
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1101
def call(vm)
result = (message 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: 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(message)]
)
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, message]
end
|