class Minjs::ECMA262::ExpCond
Class of the Conditional operator expression element.
@see www.ecma-international.org/ecma-262 ECMA262
11.12
Attributes
cond[R]
val[R]
val2[R]
val3[R]
Public Class Methods
new(val, val2, val3)
click to toggle source
# File lib/minjs/ecma262/expression.rb, line 1893 def initialize(val, val2, val3) @val = val @val2 = val2 @val3 = val3 end
Public Instance Methods
==(obj)
click to toggle source
compare object
# File lib/minjs/ecma262/expression.rb, line 1960 def ==(obj) self.class == obj.class and @val == obj.val and @val2 == obj.val2 and @val3 == obj.val3 end
add_paren()
click to toggle source
add parenthesis if need
# File lib/minjs/ecma262/expression.rb, line 1919 def add_paren if @val.priority > PRIORITY_CONDITIONAL @val = ExpParen.new(@val) end if @val2.priority > PRIORITY_ASSIGNMENT @val2 = ExpParen.new(@val2) end if @val3.priority > PRIORITY_ASSIGNMENT @val3 = ExpParen.new(@val3) end self end
deep_dup()
click to toggle source
duplicate object @see Base#deep_dup
# File lib/minjs/ecma262/expression.rb, line 1934 def deep_dup self.class.new(@val.deep_dup, @val2.deep_dup, @val3.deep_dup) end
ecma262_typeof()
click to toggle source
return results of ‘typeof’ operator.
@return [Symbol] typeof val2 if typeof val2 equals to val3
# File lib/minjs/ecma262/expression.rb, line 1976 def ecma262_typeof if @val2.respond_to? :ecma262_typeof and @val3.respond_to? :ecma262_typeof if @val2.ecma262_typeof == @val3.ecma262_typeof return @val2.ecma262_typeof end end nil end
priority()
click to toggle source
@return [Fixnum] expression priority
# File lib/minjs/ecma262/expression.rb, line 1900 def priority PRIORITY_CONDITIONAL end
remove_paren()
click to toggle source
remove parenthesis if possible
# File lib/minjs/ecma262/expression.rb, line 1905 def remove_paren if @val.kind_of? ExpParen and @val.val.priority < PRIORITY_CONDITIONAL @val = @val.val if @val.remove_paren? end if @val2.kind_of? ExpParen and @val2.val.priority <= PRIORITY_ASSIGNMENT @val2 = @val2.val end if @val3.kind_of? ExpParen and @val3.val.priority <= PRIORITY_ASSIGNMENT @val3 = @val3.val end self end
replace(from, to)
click to toggle source
Replaces children object. @see Base#replace
# File lib/minjs/ecma262/expression.rb, line 1940 def replace(from, to) if from .eql? @val @val = to elsif from .eql? @val2 @val2 = to elsif from .eql? @val3 @val3 = 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 1969 def to_js(options = {}) "#{@val.to_js(options)}?#{@val2.to_js(options)}:#{@val3.to_js(options)}" 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 1952 def traverse(parent, &block) @val.traverse(self, &block) @val2.traverse(self, &block) @val3.traverse(self, &block) yield parent, self end