class Minjs::ECMA262::ExpProp

Class of the Property Accessors expression element.

This is another expression of ExpPropBrac. This class uses period insted of bracket.

@see ExpPropBrac @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 515
def initialize(val, val2)
  @val = val
  if val2.kind_of? IdentifierName
    @val2 = ECMA262::ECMA262String.new(val2.val)
  elsif val2.kind_of? ECMA262String
    @val2 = val2
  end
end

Public Instance Methods

==(obj) click to toggle source

compare object

# File lib/minjs/ecma262/expression.rb, line 554
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 580
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 526
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 567
def left_hand_side_exp?
  true
end
priority() click to toggle source

@return [Fixnum] expression priority

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

remove parenthesis if possible

# File lib/minjs/ecma262/expression.rb, line 572
def remove_paren
  if @val.kind_of? ExpParen and @val.val.priority <= PRIORITY_LEFT_HAND_SIDE
    @val = @val.val if @val.remove_paren?
  end
  self
end
replace(from, to) click to toggle source

Replaces children object. @see Base#replace

# File lib/minjs/ecma262/expression.rb, line 537
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 562
def to_js(options = {})
  "#{@val.to_js(options)}.#{@val2.val}"
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 547
def traverse(parent, &block)
  @val.traverse(self, &block)
  @val2.traverse(self, &block)
  yield parent, self
end