Class: Yadriggy::Assign
- Defined in:
- lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb
Overview
Assignment such as ‘=` and `+=`.
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.
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
.tags ⇒ Object
678 |
# File 'lib/yadriggy/ast.rb', line 678 def self.() [:assign, :opassign] end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
700 701 702 |
# File 'lib/yadriggy/ast.rb', line 700 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 |