Class: Yadriggy::Assign

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

Overview

Assignment such as ‘=` and `+=`.

Instance Attribute Summary

Attributes inherited from Binary

#left, #op, #right

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Binary

tag

Methods included from AstHelper

#has_tag?, #to_node, #to_nodes

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

Returns a new instance of Assign.



680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
# File 'lib/yadriggy/ast.rb', line 680

def initialize(sexp)
  case sexp[0]
  when :assign
    @left = to_node(sexp[1])
    @op = :'='
    @right = to_node(sexp[2])
  when :opassign
    @left = to_node(sexp[1])
    @op = has_tag?(sexp[2], :@op)[1].to_sym
    @right = to_node(sexp[3])
  else
    raise "unknown assignment " + sexp[0].to_s
  end
  add_child(@left)
  add_child(@right)
end

Class Method Details

.tagsObject



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

def self.tags() [:assign, :opassign] 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.



700
701
702
# File 'lib/yadriggy/ast.rb', line 700

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

#const_valueObject



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

def const_value() Undef end

#const_value_in_class(klass) ⇒ Object



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

def const_value_in_class(klass) Undef end

#valueObject



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

def value() Undef end

#value_in_class(klass) ⇒ Object



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

def value_in_class(klass) Undef end