Class: Yadriggy::Const

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

Overview

Constant variable such as a class name.

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, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string

Constructor Details

#initialize(sexp) ⇒ Const

Returns a new instance of Const.



129
130
131
# File 'lib/yadriggy/ast.rb', line 129

def initialize(sexp)
  super(sexp)
end

Class Method Details

.tagObject



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

def self.tag() :@const 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.



136
137
138
# File 'lib/yadriggy/ast.rb', line 136

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

#const_valueObject



148
# File 'lib/yadriggy/ast_value.rb', line 148

def const_value() value end

#const_value_in_class(clazz) ⇒ Object



158
159
160
# File 'lib/yadriggy/ast_value.rb', line 158

def const_value_in_class(clazz)
  value_in_class(clazz)
end

#valueObject



144
145
146
# File 'lib/yadriggy/ast_value.rb', line 144

def value()
  value_in_class(get_context_class)
end

#value_in_class(clazz) ⇒ Object



150
151
152
153
154
155
156
# File 'lib/yadriggy/ast_value.rb', line 150

def value_in_class(clazz)
  if clazz.const_defined?(@name)
    clazz.const_get(@name)
  else
    Undef
  end
end