Class: Minjs::ECMA262::ECMA262Array

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

Overview

Class of ECMA262 Array 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(val) ⇒ ECMA262Array

Returns a new instance of ECMA262Array.



972
973
974
# File 'lib/minjs/ecma262/literal.rb', line 972

def initialize(val)
  @val = val # val is Array
end

Instance Attribute Details

#valObject (readonly)

Returns the value of attribute val.



970
971
972
# File 'lib/minjs/ecma262/literal.rb', line 970

def val
  @val
end

Instance Method Details

#==(obj) ⇒ Object

compare object



993
994
995
# File 'lib/minjs/ecma262/literal.rb', line 993

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

#deep_dupObject

duplicate object

See Also:



978
979
980
# File 'lib/minjs/ecma262/literal.rb', line 978

def deep_dup
  self.class.new(@val.collect{|x| x ? x.deep_dup : nil})
end

#left_hand_side_exp?Boolean

Returns true if expression is kind of LeftHandSideExpression.

Returns:

  • (Boolean)

    true if expression is kind of LeftHandSideExpression.



1004
1005
1006
# File 'lib/minjs/ecma262/literal.rb', line 1004

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:



1016
1017
1018
# File 'lib/minjs/ecma262/literal.rb', line 1016

def to_ecma262_boolean
  true
end

#to_js(options = {}) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



999
1000
1001
# File 'lib/minjs/ecma262/literal.rb', line 999

def to_js(options = {})
  "[" + @val.collect{|x| x ? x.to_js : ""}.join(",") + "]"
end

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

Traverses this children and itself with given block.

Yields:

Yield Parameters:

See Also:



985
986
987
988
989
990
# File 'lib/minjs/ecma262/literal.rb', line 985

def traverse(parent, &block)
  yield parent, self
  @val.each do |k|
    k.traverse(parent, &block) if k
  end
end