Class: Minjs::ECMA262::Null

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

Overview

Class of ECMA262 Null element

Every Null literal in source elements is converted to this class object.

This class is singleton

See Also:

Constant Summary collapse

@@instance =
self.new(nil)

Instance Attribute Summary

Attributes inherited from Base

#parent

Class Method Summary collapse

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) ⇒ Null

Returns a new instance of Null.



187
188
189
# File 'lib/minjs/ecma262/literal.rb', line 187

def initialize(val)
  @val = :null
end

Class Method Details

.getObject

get instance



223
224
225
# File 'lib/minjs/ecma262/literal.rb', line 223

def self.get
  @@instance
end

Instance Method Details

#==(obj) ⇒ Object

compare object



205
206
207
# File 'lib/minjs/ecma262/literal.rb', line 205

def ==(obj)
  self.class == obj.class
end

#deep_dupObject

duplicate object

See Also:



193
194
195
# File 'lib/minjs/ecma262/literal.rb', line 193

def deep_dup
  self #not dup
end

#ecma262_typeofSymbol

return results of ‘typeof’ operator.

Returns:

  • (Symbol)

    :boolean



266
267
268
# File 'lib/minjs/ecma262/literal.rb', line 266

def ecma262_typeof
  :boolean
end

#left_hand_side_exp?Boolean

Returns true if expression is kind of LeftHandSideExpression.

Returns:

  • (Boolean)

    true if expression is kind of LeftHandSideExpression.



216
217
218
# File 'lib/minjs/ecma262/literal.rb', line 216

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:



235
236
237
# File 'lib/minjs/ecma262/literal.rb', line 235

def to_ecma262_boolean
  false
end

#to_ecma262_numberNumeric

Returns results of ToNumber()

Returns number if value is trivial, otherwise nil.

Returns:

  • (Numeric)

See Also:



259
260
261
# File 'lib/minjs/ecma262/literal.rb', line 259

def to_ecma262_number
  0
end

#to_ecma262_stringNumeric

Returns results of ToString()

Returns string if value is trivial, otherwise nil.

Returns:

  • (Numeric)

See Also:



247
248
249
# File 'lib/minjs/ecma262/literal.rb', line 247

def to_ecma262_string
  "null"
end

#to_js(options = {}) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



211
212
213
# File 'lib/minjs/ecma262/literal.rb', line 211

def to_js(options = {})
  "null"
end

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

Traverses this children and itself with given block.

Yields:

Yield Parameters:

See Also:



200
201
202
# File 'lib/minjs/ecma262/literal.rb', line 200

def traverse(parent, &block)
  yield parent, self
end