Class: Minjs::ECMA262::ECMA262Object
- Includes:
- Ctype
- 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) ⇒ ECMA262Object
constructor
val is tupple [[k,v],,…].
-
#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 included from Ctype
#decimal_digit?, #hex_digit?, #identifier_part?, #identifier_start?, #idname?, #line_terminator?, #octal_digit?, #white_space?
Methods inherited from Literal
#lt?, #priority, #side_effect?, #ws?
Methods inherited from Base
#add_remove_paren, #concat, #replace
Constructor Details
#initialize(val) ⇒ ECMA262Object
val is tupple [[k,v],,…]
1029 1030 1031 |
# File 'lib/minjs/ecma262/literal.rb', line 1029 def initialize(val) @val = val end |
Instance Attribute Details
#val ⇒ Object (readonly)
Returns the value of attribute val.
1026 1027 1028 |
# File 'lib/minjs/ecma262/literal.rb', line 1026 def val @val end |
Instance Method Details
#==(obj) ⇒ Object
compare object
1051 1052 1053 |
# File 'lib/minjs/ecma262/literal.rb', line 1051 def ==(obj) self.class == obj.class and @val == obj.val end |
#deep_dup ⇒ Object
duplicate object
1035 1036 1037 |
# File 'lib/minjs/ecma262/literal.rb', line 1035 def deep_dup self.class.new(@val.collect{|x, y| [x.deep_dup, y ? y.deep_dup : y]}) end |
#left_hand_side_exp? ⇒ Boolean
Returns true if expression is kind of LeftHandSideExpression.
1078 1079 1080 |
# File 'lib/minjs/ecma262/literal.rb', line 1078 def left_hand_side_exp? true end |
#to_ecma262_boolean ⇒ Boolean
Returns results of ToBoolean()
Returns true or false if trivial, otherwise nil.
1090 1091 1092 |
# File 'lib/minjs/ecma262/literal.rb', line 1090 def to_ecma262_boolean true end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 |
# File 'lib/minjs/ecma262/literal.rb', line 1057 def to_js( = {}) concat(, "{" + @val.collect{|x, y| if y.kind_of? StFunc and (y.getter? || y.setter?) if y.name.val == :get t = concat , "get", x.val, "()", "{", y.statements, "}" else t = concat , "set", x.val, "(", y.args[0], ")", "{", y.statements, "}" end else if x.kind_of? ECMA262Numeric t = concat , x.to_ecma262_string, ":", y elsif idname?(x.val.to_s) t = concat , x.val, ":", y else t = concat , x, ":", y end end }.join(","), "}") end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
1042 1043 1044 1045 1046 1047 1048 |
# File 'lib/minjs/ecma262/literal.rb', line 1042 def traverse(parent, &block) yield parent, self @val.each do |k, v| k.traverse(parent, &block) v.traverse(parent, &block) end end |