class Minjs::ECMA262::IdentifierName

Class of ECMA262 IdentifierName Element

@see www.ecma-international.org/ecma-262 ECMA262 7.6

Constants

RESERVED_WORD

reserved word list

@see www.ecma-international.org/ecma-262 ECMA262 7.6.1

Attributes

exe_context[RW]
val[R]

Public Class Methods

get(val) click to toggle source

get instance

# 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
new(val) click to toggle source
# File lib/minjs/ecma262/literal.rb, line 1182
def initialize(val)
  @val = val.to_sym
end
reserved?(val) click to toggle source

Returns true if val is reserved word. @param val [String] value

# File lib/minjs/ecma262/literal.rb, line 1223
def self.reserved?(val)
  RESERVED_WORD.include?(val)
end

Public Instance Methods

==(obj) click to toggle source

compare object

# File lib/minjs/ecma262/literal.rb, line 1241
def ==(obj)
  self.class == obj.class and self.val == obj.val
end
binding_env(lex_env) click to toggle source

@return [EnvRecord] binding environment

# 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() click to toggle source

duplicate object @see Base#deep_dup

# File lib/minjs/ecma262/literal.rb, line 1236
def deep_dup
  self.class.new(@val)
end
left_hand_side_exp?() click to toggle source

@return [Boolean] true if expression is kind of LeftHandSideExpression.

# File lib/minjs/ecma262/literal.rb, line 1256
def left_hand_side_exp?
  true
end
reserved?() click to toggle source

Returns true if this literal is reserved word.

# File lib/minjs/ecma262/literal.rb, line 1217
def reserved?
  RESERVED_WORD.include?(val)
end
to_js(options = {}) click to toggle source

Returns a ECMAScript string containg the representation of element. @see Base#to_js

# File lib/minjs/ecma262/literal.rb, line 1247
def to_js(options = {})
  val.to_s
end
to_s() click to toggle source
# File lib/minjs/ecma262/literal.rb, line 1251
def to_s
  val.to_s
end
traverse(parent) { |parent, self| ... } click to toggle source

Traverses this children and itself with given block.

@see Base#traverse

# File lib/minjs/ecma262/literal.rb, line 1230
def traverse(parent)
  yield parent, self
end