Class: Yadriggy::Assign
- Defined in:
- lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb
Overview
Assignment such as =
and +=
.
Assign#left
and Assign#right
return an ASTnode
,
or an array of ASTnode
if the node represents multiple
assignment.
Instance Attribute Summary
Attributes inherited from Binary
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
- #const_value ⇒ Object
- #const_value_in_class(klass) ⇒ Object
-
#initialize(sexp) ⇒ Assign
constructor
A new instance of Assign.
- #value ⇒ Object
- #value_in_class(klass) ⇒ Object
Methods inherited from Binary
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.
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'lib/yadriggy/ast.rb', line 708 def initialize(sexp) case sexp[0] when :assign @left = to_node(sexp[1]) add_child(@left) @op = :'=' init_right(sexp[2]) when :opassign @left = to_node(sexp[1]) add_child(@left) @op = has_tag?(sexp[2], :@op)[1].to_sym init_right(sexp[3]) when :massign @left = to_nodes(sexp[1]) add_children(@left) @op = :'=' init_right(sexp[2]) else raise "unknown assignment " + sexp[0].to_s end end |
Class Method Details
.tags ⇒ Object
706 |
# File 'lib/yadriggy/ast.rb', line 706 def self.() [:assign, :opassign, :massign] end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
733 734 735 |
# File 'lib/yadriggy/ast.rb', line 733 def accept(evaluator) evaluator.assign(self) end |
#const_value ⇒ Object
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 |
#value ⇒ Object
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 |