module Minjs::ECMA262::BinaryOperation
Module of typically binary operation expression.
Typically binary operation expression has two values(val, val2) and operation symbol.
Attributes
val[R]
val2[R]
Public Instance Methods
==(obj)
click to toggle source
compare object
# File lib/minjs/ecma262/expression.rb, line 91 def ==(obj) self.class == obj.class and self.val == obj.val and self.val2 == obj.val2 end
add_paren()
click to toggle source
add parenthesis if need
# File lib/minjs/ecma262/expression.rb, line 79 def add_paren if @val.priority > self.priority @val = ExpParen.new(@val) end if @val2.priority > self.priority @val2 = ExpParen.new(@val2) end self end
deep_dup()
click to toggle source
duplicate object @see Base#deep_dup
# File lib/minjs/ecma262/expression.rb, line 97 def deep_dup self.class.new(@val.deep_dup, @val2.deep_dup) end
remove_paren()
click to toggle source
remove parenthesis if possible
# File lib/minjs/ecma262/expression.rb, line 68 def remove_paren if @val.kind_of? ExpParen and @val.val.priority <= self.priority @val = @val.val if @val.remove_paren? end if @val2.kind_of? ExpParen and @val2.val.priority < self.priority @val2 = @val2.val end self end
replace(from, to)
click to toggle source
Replaces children object. @see Base#replace
# File lib/minjs/ecma262/expression.rb, line 103 def replace(from, to) if @val .eql? from @val = to elsif @val2 .eql? from @val2 = to end end
to_js(options = {})
click to toggle source
Returns a ECMAScript string containg the representation of element. @see Base#to_js
# File lib/minjs/ecma262/expression.rb, line 121 def to_js(options = {}) concat options, @val, sym, @val2 end
traverse(parent) { |parent, self| ... }
click to toggle source
Traverses this children and itself with given block. @see Base#traverse
# File lib/minjs/ecma262/expression.rb, line 113 def traverse(parent, &block) @val.traverse(self, &block) @val2.traverse(self, &block) yield parent, self end