Class: Minjs::ECMA262::ECMA262RegExp

Inherits:
Literal show all
Defined in:
lib/minjs/ecma262/literal.rb

Overview

Class of ECMA262 RegExp element

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Literal

#lt?, #priority, #side_effect?, #ws?

Methods inherited from Base

#add_remove_paren, #concat, #replace

Constructor Details

#initialize(body, flags) ⇒ ECMA262RegExp

Returns a new instance of ECMA262RegExp.



919
920
921
922
# File 'lib/minjs/ecma262/literal.rb', line 919

def initialize(body, flags)
  @body = body
  @flags = flags
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



917
918
919
# File 'lib/minjs/ecma262/literal.rb', line 917

def body
  @body
end

#flagsObject (readonly)

Returns the value of attribute flags.



917
918
919
# File 'lib/minjs/ecma262/literal.rb', line 917

def flags
  @flags
end

Instance Method Details

#==(obj) ⇒ Object

compare object



950
951
952
# File 'lib/minjs/ecma262/literal.rb', line 950

def ==(obj)
  self.class == obj.class and @body == obj.body and @flags == obj.flags
end

#deep_dupObject

duplicate object

See Also:



926
927
928
# File 'lib/minjs/ecma262/literal.rb', line 926

def deep_dup
  self.class.new(@body, @flags)
end

#left_hand_side_exp?Boolean

Returns true if expression is kind of LeftHandSideExpression.

Returns:

  • (Boolean)

    true if expression is kind of LeftHandSideExpression.



961
962
963
# File 'lib/minjs/ecma262/literal.rb', line 961

def left_hand_side_exp?
  true
end

#to_ecma262_booleanBoolean

Returns results of ToBoolean()

Returns true or false if trivial, otherwise nil.

Returns:

See Also:



945
946
947
# File 'lib/minjs/ecma262/literal.rb', line 945

def to_ecma262_boolean
  true
end

#to_js(options = {}) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



956
957
958
# File 'lib/minjs/ecma262/literal.rb', line 956

def to_js(options = {})
  "/#{@body}/#{@flags}"
end

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

Traverses this children and itself with given block.

Yields:

Yield Parameters:

See Also:



933
934
935
# File 'lib/minjs/ecma262/literal.rb', line 933

def traverse(parent)
  yield parent, self
end