Class: Minjs::ECMA262::ExpNegative
- Inherits:
-
Expression
- Object
- Base
- Expression
- Minjs::ECMA262::ExpNegative
- Includes:
- UnaryOperation
- Defined in:
- lib/minjs/ecma262/expression.rb
Overview
Class of the Negative operator expression element.
Instance Attribute Summary
Attributes included from UnaryOperation
Attributes inherited from Base
Instance Method Summary collapse
-
#ecma262_typeof ⇒ Symbol
return results of ‘typeof’ operator.
-
#initialize(val) ⇒ ExpNegative
constructor
A new instance of ExpNegative.
-
#priority ⇒ Fixnum
Expression priority.
-
#reduce(parent) ⇒ Object
reduce expression if available.
-
#sym ⇒ Object
symbol of expression.
Methods included from UnaryOperation
#==, #add_paren, #deep_dup, #remove_paren, #replace, #side_effect?, #to_js, #traverse
Methods inherited from Expression
#left_hand_side_exp?, #side_effect?
Methods inherited from Base
#==, #add_remove_paren, #concat, #deep_dup, #replace, #to_js, #traverse
Constructor Details
#initialize(val) ⇒ ExpNegative
Returns a new instance of ExpNegative.
1008 1009 1010 |
# File 'lib/minjs/ecma262/expression.rb', line 1008 def initialize(val) @val = val end |
Instance Method Details
#ecma262_typeof ⇒ Symbol
return results of ‘typeof’ operator.
1039 1040 1041 |
# File 'lib/minjs/ecma262/expression.rb', line 1039 def ecma262_typeof :number end |
#priority ⇒ Fixnum
Returns expression priority.
1018 1019 1020 |
# File 'lib/minjs/ecma262/expression.rb', line 1018 def priority PRIORITY_UNARY end |
#reduce(parent) ⇒ Object
reduce expression if available
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# 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 ⇒ Object
symbol of expression
1013 1014 1015 |
# File 'lib/minjs/ecma262/expression.rb', line 1013 def sym "-" end |