Class: Minjs::ECMA262::StLabelled
- Defined in:
- lib/minjs/ecma262/statement.rb
Overview
Base class of ECMA262 LabelledStatement element.
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Attributes inherited from Base
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(label, statement) ⇒ StLabelled
constructor
A new instance of StLabelled.
-
#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(label, statement) ⇒ StLabelled
Returns a new instance of StLabelled.
1307 1308 1309 1310 |
# File 'lib/minjs/ecma262/statement.rb', line 1307 def initialize(label, statement) @label = label @statement = statement end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
1305 1306 1307 |
# File 'lib/minjs/ecma262/statement.rb', line 1305 def label @label end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
1305 1306 1307 |
# File 'lib/minjs/ecma262/statement.rb', line 1305 def statement @statement end |
Instance Method Details
#==(obj) ⇒ Object
compare object
1336 1337 1338 1339 1340 |
# File 'lib/minjs/ecma262/statement.rb', line 1336 def ==(obj) self.class == obj.class and @label == obj.label and @statement == obj.statement end |
#deep_dup ⇒ Object
duplicate object
1314 1315 1316 |
# File 'lib/minjs/ecma262/statement.rb', line 1314 def deep_dup self.class.new(@label.deep_dup, @statement.deep_dup) end |
#replace(from, to) ⇒ Object
Replaces children object.
1320 1321 1322 1323 1324 1325 1326 |
# File 'lib/minjs/ecma262/statement.rb', line 1320 def replace(from, to) if from .eql? @label @label = to elsif from .eql? @statement @statement = to end end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
1344 1345 1346 |
# File 'lib/minjs/ecma262/statement.rb', line 1344 def to_js( = {}) concat , @label, ":", @statement end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
1329 1330 1331 1332 1333 |
# File 'lib/minjs/ecma262/statement.rb', line 1329 def traverse(parent, &block) @label.traverse(self, &block) @statement.traverse(self, &block) yield parent, self end |