class Minjs::ECMA262::ExpNegative

Class of the Negative operator expression element.

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

Public Class Methods

new(val) click to toggle source
# File lib/minjs/ecma262/expression.rb, line 1008
def initialize(val)
  @val = val
end

Public Instance Methods

ecma262_typeof() click to toggle source

return results of ‘typeof’ operator.

@return [Symbol] :number

# File lib/minjs/ecma262/expression.rb, line 1039
def ecma262_typeof
  :number
end
priority() click to toggle source

@return [Fixnum] expression priority

# File lib/minjs/ecma262/expression.rb, line 1018
def priority
  PRIORITY_UNARY
end
reduce(parent) click to toggle source

reduce expression if available @param parent [Base] parent element

# File lib/minjs/ecma262/expression.rb, line 1024
def reduce(parent)
  if @val.kind_of? ECMA262Numeric
    if @val.integer.match(/^\-/)
      integer = $'
    else
      integer = "-#{@val.integer}"
    end
    val = ECMA262Numeric.new(integer, @val.decimal, @val.exp)
    parent.replace(self, val)
  end
end
sym() click to toggle source

symbol of expression

# File lib/minjs/ecma262/expression.rb, line 1013
def sym
  "-"
end