Class: Minjs::ECMA262::StTryCatch

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

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(var_env, arg, block) ⇒ StTryCatch

Returns a new instance of StTryCatch.



1390
1391
1392
1393
1394
# File 'lib/minjs/ecma262/statement.rb', line 1390

def initialize(var_env, arg, block)
  @var_env = var_env
  @arg = arg
  @block = block
end

Instance Attribute Details

#argObject (readonly)

Returns the value of attribute arg.



1386
1387
1388
# File 'lib/minjs/ecma262/statement.rb', line 1386

def arg
  @arg
end

#blockObject (readonly)

Returns the value of attribute block.



1387
1388
1389
# File 'lib/minjs/ecma262/statement.rb', line 1387

def block
  @block
end

#exe_contextObject

Returns the value of attribute exe_context.



1388
1389
1390
# File 'lib/minjs/ecma262/statement.rb', line 1388

def exe_context
  @exe_context
end

#var_envObject (readonly)

Returns the value of attribute var_env.



1385
1386
1387
# File 'lib/minjs/ecma262/statement.rb', line 1385

def var_env
  @var_env
end

Instance Method Details

#deep_dupObject

duplicate object

See Also:



1402
1403
1404
1405
1406
# File 'lib/minjs/ecma262/statement.rb', line 1402

def deep_dup
  self.class.new(@var_env,
                 @arg.deep_dup,
                 @block.deep_dup)
end

#enter(outer_exe_context) ⇒ Object



1425
1426
1427
1428
1429
1430
1431
1432
1433
# File 'lib/minjs/ecma262/statement.rb', line 1425

def enter(outer_exe_context)
  catch_env = LexEnv.new_declarative_env(outer_exe_context.lex_env)
  catch_env.record.create_mutable_binding(@arg, nil)
  catch_env.record.set_mutable_binding(@arg, :undefined, nil, nil)

  new_exe_context = ExeContext.new
  new_exe_context.lex_env = catch_env
  new_exe_context
end

#replace(from, to) ⇒ Object

Replaces children object.

See Also:



1417
1418
1419
1420
1421
1422
1423
# File 'lib/minjs/ecma262/statement.rb', line 1417

def replace(from, to)
  if from .eql? @arg
    @arg = to
  elsif from .eql? @block
    @block = to
  end
end

#to_js(options = {}) ⇒ Object



1396
1397
1398
# File 'lib/minjs/ecma262/statement.rb', line 1396

def to_js(options = {})
  concat(options, :catch, "(", @arg, ")", @block)
end

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

Traverses this children and itself with given block.

Yields:

Yield Parameters:



1409
1410
1411
1412
1413
# File 'lib/minjs/ecma262/statement.rb', line 1409

def traverse(parent, &block)
  @arg.traverse(self, &block)
  @block.traverse(self, &block)
  yield parent, self
end