Class: Minjs::ECMA262::StTry
- Defined in:
- lib/minjs/ecma262/statement.rb
Overview
Base class of ECMA262 TryStatement element.
Instance Attribute Summary collapse
-
#catch ⇒ Object
readonly
Returns the value of attribute catch.
-
#finally ⇒ Object
readonly
Returns the value of attribute finally.
-
#try ⇒ Object
readonly
Returns the value of attribute try.
-
#var_env ⇒ Object
readonly
Returns the value of attribute var_env.
Attributes inherited from Base
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(var_env, try, catch, finally) ⇒ StTry
constructor
A new instance of StTry.
-
#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(var_env, try, catch, finally) ⇒ StTry
Returns a new instance of StTry.
1443 1444 1445 1446 1447 1448 |
# File 'lib/minjs/ecma262/statement.rb', line 1443 def initialize(var_env, try, catch, finally) @var_env = var_env @try = try @catch = catch @finally = finally end |
Instance Attribute Details
#catch ⇒ Object (readonly)
Returns the value of attribute catch.
1441 1442 1443 |
# File 'lib/minjs/ecma262/statement.rb', line 1441 def catch @catch end |
#finally ⇒ Object (readonly)
Returns the value of attribute finally.
1441 1442 1443 |
# File 'lib/minjs/ecma262/statement.rb', line 1441 def finally @finally end |
#try ⇒ Object (readonly)
Returns the value of attribute try.
1441 1442 1443 |
# File 'lib/minjs/ecma262/statement.rb', line 1441 def try @try end |
#var_env ⇒ Object (readonly)
Returns the value of attribute var_env.
1440 1441 1442 |
# File 'lib/minjs/ecma262/statement.rb', line 1440 def var_env @var_env end |
Instance Method Details
#==(obj) ⇒ Object
compare object
1480 1481 1482 1483 1484 1485 |
# File 'lib/minjs/ecma262/statement.rb', line 1480 def ==(obj) self.class == obj.class and self.try == obj.try and self.catch == obj.catch and self.finally == obj.finally end |
#deep_dup ⇒ Object
duplicate object
1452 1453 1454 1455 1456 1457 |
# File 'lib/minjs/ecma262/statement.rb', line 1452 def deep_dup self.class.new(@var_env, @try.deep_dup, @catch ? @catch.deep_dup : nil, @finally ? @finally.deep_dup : nil) end |
#replace(from, to) ⇒ Object
Replaces children object.
1461 1462 1463 1464 1465 1466 1467 1468 1469 |
# File 'lib/minjs/ecma262/statement.rb', line 1461 def replace(from, to) if from .eql? @try @try = to elsif from .eql? @catch @catch = to elsif from .eql? @finally @finally = to end end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
1489 1490 1491 1492 1493 1494 1495 1496 1497 |
# File 'lib/minjs/ecma262/statement.rb', line 1489 def to_js( = {}) if @catch and @finally concat(, :try, @try, @catch, :finally, @finally) elsif @catch concat(, :try, @try, @catch) else concat(, :try, @try, :finally, @finally) end end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
1472 1473 1474 1475 1476 1477 |
# File 'lib/minjs/ecma262/statement.rb', line 1472 def traverse(parent, &block) @try.traverse(self, &block) @catch.traverse(self, &block) if @catch @finally.traverse(self, &block) if @finally yield parent, self end |