class Minjs::ECMA262::ExpPropBrac

Class of the Property Accessors expression element.

This is another expression of ExpProp. This class uses bracket instead of period.

@see ExpProp @see www.ecma-international.org/ecma-262 ECMA262 11.2.1

Attributes

val[R]
val2[R]

Public Class Methods

new(val, val2) click to toggle source
# File lib/minjs/ecma262/expression.rb, line 434
def initialize(val, val2)
  @val = val
  @val2 = val2
end

Public Instance Methods

==(obj) click to toggle source

compare object

# File lib/minjs/ecma262/expression.rb, line 469
def ==(obj)
  self.class == obj.class and
    @val == obj.val and
    @val2 == obj.val2
end
add_paren() click to toggle source

add parenthesis if need

# File lib/minjs/ecma262/expression.rb, line 498
def add_paren
  if @val.priority > PRIORITY_LEFT_HAND_SIDE
    @val = ExpParen.new(@val)
  end
  self
end
deep_dup() click to toggle source

duplicate object @see Base#deep_dup

# File lib/minjs/ecma262/expression.rb, line 441
def deep_dup
  self.class.new(@val.deep_dup, @val2.deep_dup)
end
left_hand_side_exp?() click to toggle source

@return [Boolean] true if expression is kind of LeftHandSideExpression.

# File lib/minjs/ecma262/expression.rb, line 482
def left_hand_side_exp?
  true
end
priority() click to toggle source

@return [Fixnum] expression priority

# File lib/minjs/ecma262/expression.rb, line 456
def priority
  PRIORITY_LEFT_HAND_SIDE
end
remove_paren() click to toggle source

remove parenthesis if possible

# File lib/minjs/ecma262/expression.rb, line 487
def remove_paren
  if @val.kind_of? ExpParen and @val.val.priority <= PRIORITY_LEFT_HAND_SIDE
    @val = @val.val if @val.remove_paren?
  end
  if @val2.kind_of? ExpParen
    @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 447
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 477
def to_js(options = {})
  "#{@val.to_js(options)}[#{@val2.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 462
def traverse(parent, &block)
  @val.traverse(self, &block)
  @val2.traverse(self, &block)
  yield parent, self
end