class Minjs::ECMA262::StExp

Base class of ECMA262 ExpressionStatement element.

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

Attributes

exp[R]

Public Class Methods

new(exp) click to toggle source
# File lib/minjs/ecma262/statement.rb, line 289
def initialize(exp)
  @exp = exp
end

Public Instance Methods

==(obj) click to toggle source

compare object

# File lib/minjs/ecma262/statement.rb, line 314
def ==(obj)
  self.class == obj.class and @exp == obj.exp
end
add_paren() click to toggle source

add parenthesis if need

# File lib/minjs/ecma262/statement.rb, line 343
def add_paren
  self
end
deep_dup() click to toggle source

duplicate object @see Base#deep_dup

# File lib/minjs/ecma262/statement.rb, line 295
def deep_dup
  self.class.new(@exp.deep_dup)
end
remove_paren() click to toggle source

remove parenthesis if possible

# File lib/minjs/ecma262/statement.rb, line 335
def remove_paren
  if @exp.kind_of? ExpParen
    @exp = @exp.val if @exp.remove_paren?
  end
  self
end
replace(from, to) click to toggle source

Replaces children object. @see Base#replace

# File lib/minjs/ecma262/statement.rb, line 301
def replace(from, to)
  if @exp .eql? from
    @exp = to
  end
end
to_exp(options = {}) click to toggle source

Converts statement to expression and returns it.

# File lib/minjs/ecma262/statement.rb, line 325
def to_exp(options = {})
  @exp.deep_dup
end
to_exp?() click to toggle source

true if statement can convert to expression

# File lib/minjs/ecma262/statement.rb, line 330
def to_exp?
  true
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 320
def to_js(options = {})
  concat(options, @exp, ";")
end
traverse(parent) { |parent, self| ... } click to toggle source

Traverses this children and itself with given block.

# File lib/minjs/ecma262/statement.rb, line 308
def traverse(parent, &block)
  @exp.traverse(self, &block)
  yield parent, self
end