Class: Minjs::ECMA262::StDoWhile
- Defined in:
- lib/minjs/ecma262/statement.rb
Overview
Base class of ECMA262 ‘do-while’ IterationStatement element.
Instance Attribute Summary collapse
-
#exp ⇒ Object
readonly
Returns the value of attribute exp.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
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(exp, statement) ⇒ StDoWhile
constructor
A new instance of StDoWhile.
-
#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 Statement
#empty?, #priority, #to_exp?, #to_return?
Methods inherited from Base
Constructor Details
#initialize(exp, statement) ⇒ StDoWhile
Returns a new instance of StDoWhile.
571 572 573 |
# File 'lib/minjs/ecma262/statement.rb', line 571 def initialize(exp, statement) @exp, @statement = exp, statement end |
Instance Attribute Details
#exp ⇒ Object (readonly)
Returns the value of attribute exp.
569 570 571 |
# File 'lib/minjs/ecma262/statement.rb', line 569 def exp @exp end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
569 570 571 |
# File 'lib/minjs/ecma262/statement.rb', line 569 def statement @statement end |
Instance Method Details
#==(obj) ⇒ Object
compare object
597 598 599 600 601 |
# File 'lib/minjs/ecma262/statement.rb', line 597 def ==(obj) self.class == obj.class and @exp == obj.exp and @statement == obj.statement end |
#add_paren ⇒ Object
add parenthesis if need
624 625 626 |
# File 'lib/minjs/ecma262/statement.rb', line 624 def add_paren self end |
#deep_dup ⇒ Object
duplicate object
577 578 579 |
# File 'lib/minjs/ecma262/statement.rb', line 577 def deep_dup self.class.new(@exp.deep_dup, @statement.deep_dup) end |
#remove_paren ⇒ Object
remove parenthesis if possible
616 617 618 619 620 621 |
# File 'lib/minjs/ecma262/statement.rb', line 616 def remove_paren if @exp.kind_of? ExpParen @exp = @exp.val end self end |
#replace(from, to) ⇒ Object
Replaces children object.
583 584 585 586 587 |
# File 'lib/minjs/ecma262/statement.rb', line 583 def replace(from, to) if from .eql? @statement @statement = to end end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
605 606 607 608 609 610 611 612 613 |
# File 'lib/minjs/ecma262/statement.rb', line 605 def to_js( = {}) if @statement.kind_of? StBlock and @statement.statement_list.length == 1 statement = @statement.statement_list.statement_list[0] else statement = @statement end concat , :do, statement, :while, "(", @exp, ")", ";" end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
590 591 592 593 594 |
# File 'lib/minjs/ecma262/statement.rb', line 590 def traverse(parent, &block) @exp.traverse(self, &block) @statement.traverse(self, &block) yield parent, self end |