class Yadriggy::Binary
Binary
expression.
Attributes
left[R]
@return [ASTnode] the left operand.
op[R]
@return [Symbol] the operator.
right[R]
@return [ASTnode] the right operand.
Public Class Methods
new(sexp)
click to toggle source
# File lib/yadriggy/ast.rb, line 659 def initialize(sexp) @left = to_node(sexp[1]) @op = sexp[2] # symbol @right = to_node(sexp[3]) add_child(@left) add_child(@right) end
tag()
click to toggle source
# File lib/yadriggy/ast.rb, line 657 def self.tag() :binary end
Public Instance Methods
accept(evaluator)
click to toggle source
A method for Visitor pattern. @param [Eval] evaluator the visitor of Visitor pattern. @return [void]
# File lib/yadriggy/ast.rb, line 670 def accept(evaluator) evaluator.binary(self) end
const_value()
click to toggle source
# File lib/yadriggy/ast_value.rb, line 364 def const_value() send_op_to_value(@left.const_value, @right.const_value) end
const_value_in_class(klass)
click to toggle source
# File lib/yadriggy/ast_value.rb, line 368 def const_value_in_class(klass) send_op_to_value(@left.const_value_in_class(klass), @right.const_value_in_class(klass)) end
value()
click to toggle source
# File lib/yadriggy/ast_value.rb, line 355 def value() send_op_to_value(@left.value, @right.value) end
value_in_class(klass)
click to toggle source
# File lib/yadriggy/ast_value.rb, line 359 def value_in_class(klass) send_op_to_value(@left.value_in_class(klass), @right.value_in_class(klass)) end
Private Instance Methods
send_op_to_value(v, w)
click to toggle source
# File lib/yadriggy/ast_value.rb, line 374 def send_op_to_value(v, w) if v == Undef || w == Undef || is_proc?(v) || is_proc?(w) || !v.class.public_method_defined?(@op) Undef else v.send(@op, w) end end