class Minjs::ECMA262::ExpParen
Class of the Grouping operator expression element.
@see www.ecma-international.org/ecma-262 ECMA262
11.1.6
Attributes
Public Class Methods
# File lib/minjs/ecma262/expression.rb, line 324 def initialize(val) @val = val end
Public Instance Methods
compare object
# File lib/minjs/ecma262/expression.rb, line 355 def ==(obj) self.class == obj.class and @val == obj.val end
add parenthesis if need
# File lib/minjs/ecma262/expression.rb, line 395 def add_paren self end
duplicate object @see Base#deep_dup
# File lib/minjs/ecma262/expression.rb, line 335 def deep_dup self.class.new(@val.deep_dup) end
return results of ‘typeof’ operator.
@return [Symbol] type of val
# File lib/minjs/ecma262/expression.rb, line 416 def ecma262_typeof if @val.respond_to? :ecma262_typeof @val.ecma262_typeof else nil end end
@return [Boolean] true if expression is kind of LeftHandSideExpression.
# File lib/minjs/ecma262/expression.rb, line 366 def left_hand_side_exp? true end
@return [Fixnum] expression priority
# File lib/minjs/ecma262/expression.rb, line 329 def priority PRIORITY_PRIMARY end
remove parenthesis if possible
# File lib/minjs/ecma262/expression.rb, line 387 def remove_paren if @val.kind_of? ExpParen @val = @val.val if @val.remove_paren? end self end
returns removing parenthesis is possible or not
ECMA262
expression-statement should not start with “function” or “{”. This
method checks inner of the parenthesis’ first literal.
@return [Boolean] true if possible
# File lib/minjs/ecma262/expression.rb, line 377 def remove_paren? js = @val.to_js if js.match(/^function/) or js.match(/^{/) false else true end end
Replaces children object. @see Base#replace
# File lib/minjs/ecma262/expression.rb, line 341 def replace(from, to) if @val .eql? from @val = to end end
Returns results of ToBoolean()
Returns true or false if trivial, otherwise nil.
@return [Boolean]
@see www.ecma-international.org/ecma-262 ECMA262
9.2
# File lib/minjs/ecma262/expression.rb, line 407 def to_ecma262_boolean return nil unless @val.respond_to? :to_ecma262_boolean return nil if @val.to_ecma262_boolean.nil? @val.to_ecma262_boolean end
Returns a ECMAScript string containg the representation of element. @see Base#to_js
# File lib/minjs/ecma262/expression.rb, line 361 def to_js(options = {}) "(#{@val.to_js(options)})" end
Traverses this children and itself with given block. @see Base#traverse
# File lib/minjs/ecma262/expression.rb, line 349 def traverse(parent, &block) @val.traverse(self, &block) yield parent, self end