Class: Minjs::ECMA262::ExpProp
- Inherits:
-
Expression
- Object
- Base
- Expression
- Minjs::ECMA262::ExpProp
- Defined in:
- lib/minjs/ecma262/expression.rb
Overview
Class of the Property Accessors expression element.
This is another expression of ExpPropBrac. This class uses period insted of bracket.
Instance Attribute Summary collapse
-
#val ⇒ Object
readonly
Returns the value of attribute val.
-
#val2 ⇒ Object
readonly
Returns the value of attribute val2.
Attributes inherited from Base
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#add_paren ⇒ Object
add parenthesis if need.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(val, val2) ⇒ ExpProp
constructor
A new instance of ExpProp.
-
#left_hand_side_exp? ⇒ Boolean
True if expression is kind of LeftHandSideExpression.
-
#priority ⇒ Fixnum
Expression priority.
-
#remove_paren ⇒ Object
remove parenthesis if possible.
-
#replace(from, to) ⇒ Object
Replaces children object.
-
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
-
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
Methods inherited from Expression
Methods inherited from Base
Constructor Details
#initialize(val, val2) ⇒ ExpProp
Returns a new instance of ExpProp.
515 516 517 518 519 520 521 522 |
# 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 |
Instance Attribute Details
#val ⇒ Object (readonly)
Returns the value of attribute val.
513 514 515 |
# File 'lib/minjs/ecma262/expression.rb', line 513 def val @val end |
#val2 ⇒ Object (readonly)
Returns the value of attribute val2.
513 514 515 |
# File 'lib/minjs/ecma262/expression.rb', line 513 def val2 @val2 end |
Instance Method Details
#==(obj) ⇒ Object
compare object
554 555 556 557 558 |
# 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 ⇒ Object
add parenthesis if need
580 581 582 583 584 585 |
# 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 ⇒ Object
duplicate object
526 527 528 |
# 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? ⇒ Boolean
Returns true if expression is kind of LeftHandSideExpression.
567 568 569 |
# File 'lib/minjs/ecma262/expression.rb', line 567 def left_hand_side_exp? true end |
#priority ⇒ Fixnum
Returns expression priority.
531 532 533 |
# File 'lib/minjs/ecma262/expression.rb', line 531 def priority PRIORITY_LEFT_HAND_SIDE end |
#remove_paren ⇒ Object
remove parenthesis if possible
572 573 574 575 576 577 |
# 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) ⇒ Object
Replaces children object.
537 538 539 540 541 542 543 |
# 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 = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
562 563 564 |
# File 'lib/minjs/ecma262/expression.rb', line 562 def to_js( = {}) "#{@val.to_js()}.#{@val2.val}" end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
547 548 549 550 551 |
# File 'lib/minjs/ecma262/expression.rb', line 547 def traverse(parent, &block) @val.traverse(self, &block) @val2.traverse(self, &block) yield parent, self end |