Class: Minjs::ECMA262::IdentifierName
- Defined in:
- lib/minjs/ecma262/literal.rb
Overview
Class of ECMA262 IdentifierName Element
Constant Summary collapse
- RESERVED_WORD =
reserved word list
Set.new [ #keywords :break, :do, :instanceof, :typeof, :case, :else, :new, :var, :catch, :finally, :return, :void, :continue, :for, :switch, :while, :debugger, :function, :this, :with, :default, :if, :throw, :delete, :in, :try, #future reserved words :class, :enum, :extends, :super, :const, :export, :import, #future reserved words(strict mode) (TODO) #:implements, :let, :private, :public, :yield, #:interface, :package, :protected, :static, :null, :false, :true ]
- @@sym =
{}
Instance Attribute Summary collapse
-
#exe_context ⇒ Object
Returns the value of attribute exe_context.
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Attributes inherited from Base
Class Method Summary collapse
-
.get(val) ⇒ Object
get instance.
-
.reserved?(val) ⇒ Boolean
Returns true if val is reserved word.
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#binding_env(lex_env) ⇒ EnvRecord
Binding environment.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(val) ⇒ IdentifierName
constructor
A new instance of IdentifierName.
-
#left_hand_side_exp? ⇒ Boolean
True if expression is kind of LeftHandSideExpression.
-
#reserved? ⇒ Boolean
Returns true if this literal is reserved word.
-
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
- #to_s ⇒ Object
-
#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) ⇒ IdentifierName
Returns a new instance of IdentifierName.
1182 1183 1184 |
# File 'lib/minjs/ecma262/literal.rb', line 1182 def initialize(val) @val = val.to_sym end |
Instance Attribute Details
#exe_context ⇒ Object
Returns the value of attribute exe_context.
1177 1178 1179 |
# File 'lib/minjs/ecma262/literal.rb', line 1177 def exe_context @exe_context end |
#val ⇒ Object (readonly)
Returns the value of attribute val.
1178 1179 1180 |
# File 'lib/minjs/ecma262/literal.rb', line 1178 def val @val end |
Class Method Details
.get(val) ⇒ Object
get instance
1187 1188 1189 1190 1191 1192 1193 |
# File 'lib/minjs/ecma262/literal.rb', line 1187 def self.get(val) if reserved?(val) @@sym[val] ||= self.new(val) else self.new(val) end end |
.reserved?(val) ⇒ Boolean
Returns true if val is reserved word.
1223 1224 1225 |
# File 'lib/minjs/ecma262/literal.rb', line 1223 def self.reserved?(val) RESERVED_WORD.include?(val) end |
Instance Method Details
#==(obj) ⇒ Object
compare object
1241 1242 1243 |
# File 'lib/minjs/ecma262/literal.rb', line 1241 def ==(obj) self.class == obj.class and self.val == obj.val end |
#binding_env(lex_env) ⇒ EnvRecord
Returns binding environment.
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/minjs/ecma262/literal.rb', line 1261 def binding_env(lex_env) return nil if lex_env.nil? v = lex_env while v if v.record.binding[val] return v else v = v.outer end end nil end |
#deep_dup ⇒ Object
duplicate object
1236 1237 1238 |
# File 'lib/minjs/ecma262/literal.rb', line 1236 def deep_dup self.class.new(@val) end |
#left_hand_side_exp? ⇒ Boolean
Returns true if expression is kind of LeftHandSideExpression.
1256 1257 1258 |
# File 'lib/minjs/ecma262/literal.rb', line 1256 def left_hand_side_exp? true end |
#reserved? ⇒ Boolean
Returns true if this literal is reserved word.
1217 1218 1219 |
# File 'lib/minjs/ecma262/literal.rb', line 1217 def reserved? RESERVED_WORD.include?(val) end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
1247 1248 1249 |
# File 'lib/minjs/ecma262/literal.rb', line 1247 def to_js( = {}) val.to_s end |
#to_s ⇒ Object
1251 1252 1253 |
# File 'lib/minjs/ecma262/literal.rb', line 1251 def to_s val.to_s end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
1230 1231 1232 |
# File 'lib/minjs/ecma262/literal.rb', line 1230 def traverse(parent) yield parent, self end |