Class: Yadriggy::GlobalVariable

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

Overview

Global variable.

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) ⇒ GlobalVariable

Returns a new instance of GlobalVariable.



184
185
186
# File 'lib/yadriggy/ast.rb', line 184

def initialize(sexp)
  super(sexp)
end

Class Method Details

.tagObject



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

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



191
192
193
# File 'lib/yadriggy/ast.rb', line 191

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

#valueObject

The current value of this global variable.



184
185
186
# File 'lib/yadriggy/ast_value.rb', line 184

def value()
  eval(@name)
end