class Yadriggy::InstanceVariable
Instance variable and class variable, such as `@x` and `@@x`. The value returned by `name` contains `@`.
Public Class Methods
new(sexp)
click to toggle source
Calls superclass method
Yadriggy::Name::new
# File lib/yadriggy/ast.rb, line 202 def initialize(sexp) super(sexp) end
Public Instance Methods
accept(evaluator)
click to toggle source
A method for Visitor pattern. @param [Eval] evaluator the visitor of Visitor pattern. @return [void]
# File lib/yadriggy/ast.rb, line 209 def accept(evaluator) evaluator.instance_variable(self) end
const_value()
click to toggle source
# File lib/yadriggy/ast_value.rb, line 218 def const_value() if name.start_with?("@@") clazz = get_context_class if clazz.frozen? && clazz.class_variable_defined?(name) return clazz.class_variable_get(name) end elsif name.start_with?("@") obj = get_receiver_object if obj.frozen? && obj&.instance_variable_defined?(name) return obj.instance_variable_get(name) end end Undef end
value()
click to toggle source
# File lib/yadriggy/ast_value.rb, line 190 def value() if name.start_with?("@@") clazz = get_context_class if clazz.class_variable_defined?(name) return clazz.class_variable_get(name) end elsif name.start_with?("@") obj = get_receiver_object if obj&.instance_variable_defined?(name) return obj.instance_variable_get(name) end end Undef end
value_in_class(clazz)
click to toggle source
# File lib/yadriggy/ast_value.rb, line 206 def value_in_class(clazz) if name.start_with?("@@") if clazz.class_variable_defined?(name) return clazz.class_variable_get(name) else Undef end else value end end