Class: Minjs::ECMA262::StBreak

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

Overview

Base class of ECMA262 BreakStatement 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, #replace

Constructor Details

#initialize(exp = nil) ⇒ StBreak

Returns a new instance of StBreak.



1050
1051
1052
# File 'lib/minjs/ecma262/statement.rb', line 1050

def initialize(exp = nil)
  @exp = exp
end

Instance Attribute Details

#expObject (readonly)

Returns the value of attribute exp.



1048
1049
1050
# File 'lib/minjs/ecma262/statement.rb', line 1048

def exp
  @exp
end

Instance Method Details

#==(obj) ⇒ Object

compare object



1067
1068
1069
1070
# File 'lib/minjs/ecma262/statement.rb', line 1067

def ==(obj)
  self.class == obj.class and
    @exp == obj.exp
end

#deep_dupObject

duplicate object

See Also:



1056
1057
1058
# File 'lib/minjs/ecma262/statement.rb', line 1056

def deep_dup
  self.class.new(@exp ? @exp.deep_dup : nil)
end

#to_js(options = {}) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



1074
1075
1076
1077
1078
1079
1080
# File 'lib/minjs/ecma262/statement.rb', line 1074

def to_js(options = {})
  if @exp
    concat options, :break, @exp, ";"
  else
    concat options, :break, ";"
  end
end

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

Traverses this children and itself with given block.

Yields:

Yield Parameters:



1061
1062
1063
1064
# File 'lib/minjs/ecma262/statement.rb', line 1061

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