class Minjs::ECMA262::StTry

Base class of ECMA262 TryStatement element.

@see www.ecma-international.org/ecma-262 ECMA262 12.14

Attributes

catch[R]
finally[R]
try[R]
var_env[R]

Public Class Methods

new(var_env, try, catch, finally) click to toggle source
# 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

Public Instance Methods

==(obj) click to toggle source

compare object

# 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() click to toggle source

duplicate object @see Base#deep_dup

# 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) click to toggle source

Replaces children object. @see Base#replace

# 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 = {}) click to toggle source

Returns a ECMAScript string containg the representation of element. @see Base#to_js

# File lib/minjs/ecma262/statement.rb, line 1489
def to_js(options = {})
  if @catch and @finally
    concat(options, :try, @try, @catch, :finally, @finally)
  elsif @catch
    concat(options, :try, @try, @catch)
  else
    concat(options, :try, @try, :finally, @finally)
  end
end
traverse(parent) { |parent, self| ... } click to toggle source

Traverses this children and itself with given block.

# 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