Class: Minjs::ECMA262::ECMA262Array
- Defined in:
- lib/minjs/ecma262/literal.rb
Overview
Class of ECMA262 Array element
Instance Attribute Summary collapse
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Attributes inherited from Base
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(val) ⇒ ECMA262Array
constructor
A new instance of ECMA262Array.
-
#left_hand_side_exp? ⇒ Boolean
True if expression is kind of LeftHandSideExpression.
-
#to_ecma262_boolean ⇒ Boolean
Returns results of ToBoolean().
-
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
-
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
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
#val ⇒ Object (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_dup ⇒ Object
duplicate object
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.
1004 1005 1006 |
# File 'lib/minjs/ecma262/literal.rb', line 1004 def left_hand_side_exp? true end |
#to_ecma262_boolean ⇒ Boolean
Returns results of ToBoolean()
Returns true or false if trivial, otherwise nil.
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.
999 1000 1001 |
# File 'lib/minjs/ecma262/literal.rb', line 999 def to_js( = {}) "[" + @val.collect{|x| x ? x.to_js : ""}.join(",") + "]" end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
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 |