Class: Yadriggy::Identifier

Inherits:
IdentifierOrCall show all
Defined in:
lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb

Overview

Identifier.

Instance Attribute Summary

Attributes inherited from Name

#column, #line_no, #name

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Name

#to_sym

Methods inherited from ASTnode

#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value_in_class

Constructor Details

#initialize(sexp) ⇒ Identifier

Returns a new instance of Identifier.



112
113
114
# File 'lib/yadriggy/ast.rb', line 112

def initialize(sexp)
  super(sexp)
end

Class Method Details

.tagsObject



110
# File 'lib/yadriggy/ast.rb', line 110

def self.tags() [:@ident, :@op] end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.

Parameters:

  • evaluator (Eval)

    the visitor of Visitor pattern.



119
120
121
# File 'lib/yadriggy/ast.rb', line 119

def accept(evaluator)
  evaluator.identifier(self)
end

#valueObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/yadriggy/ast_value.rb', line 67

def value()
  c = root.context
  if c.is_a?(Proc)
    if c.binding.local_variable_defined?(name)
      c.binding.local_variable_get(name)
    else
      Undef
    end
  else # c is Method or UnboundMethod
    Undef
  end
end