Class: Minjs::ECMA262::StLabelled

Inherits:
Statement show all
Defined in:
lib/minjs/ecma262/statement.rb

Overview

Base class of ECMA262 LabelledStatement element.

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Statement

#empty?, #priority, #to_exp?, #to_return?

Methods inherited from Base

#add_remove_paren, #concat

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

#labelObject (readonly)

Returns the value of attribute label.



1305
1306
1307
# File 'lib/minjs/ecma262/statement.rb', line 1305

def label
  @label
end

#statementObject (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_dupObject

duplicate object

See Also:



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.

See Also:



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.

See Also:



1344
1345
1346
# File 'lib/minjs/ecma262/statement.rb', line 1344

def to_js(options = {})
  concat options, @label, ":", @statement
end

#traverse(parent) {|parent, _self| ... } ⇒ Object

Traverses this children and itself with given block.

Yields:

Yield Parameters:



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