Class: Minjs::ECMA262::ExpSub
- Inherits:
-
Expression
- Object
- Base
- Expression
- Minjs::ECMA262::ExpSub
- Includes:
- BinaryOperation
- Defined in:
- lib/minjs/ecma262/expression.rb
Overview
Class of the Subtraction operator expression element.
Instance Attribute Summary
Attributes included from BinaryOperation
Attributes inherited from Base
Instance Method Summary collapse
-
#ecma262_typeof ⇒ Symbol
return results of ‘typeof’ operator.
-
#initialize(val, val2) ⇒ ExpSub
constructor
A new instance of ExpSub.
-
#priority ⇒ Fixnum
Expression priority.
-
#reduce(parent) ⇒ Object
reduce expression if available.
-
#sym ⇒ Object
symbol of expression.
Methods included from BinaryOperation
#==, #add_paren, #deep_dup, #remove_paren, #replace, #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, val2) ⇒ ExpSub
Returns a new instance of ExpSub.
1295 1296 1297 1298 |
# File 'lib/minjs/ecma262/expression.rb', line 1295 def initialize(val, val2) @val = val @val2 = val2 end |
Instance Method Details
#ecma262_typeof ⇒ Symbol
return results of ‘typeof’ operator.
1326 1327 1328 |
# File 'lib/minjs/ecma262/expression.rb', line 1326 def ecma262_typeof :number end |
#priority ⇒ Fixnum
Returns expression priority.
1306 1307 1308 |
# File 'lib/minjs/ecma262/expression.rb', line 1306 def priority PRIORITY_ADDITIVE end |
#reduce(parent) ⇒ Object
reduce expression if available
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 |
# File 'lib/minjs/ecma262/expression.rb', line 1312 def reduce(parent) # A - B if @val.respond_to? :to_ecma262_number and @val2.respond_to? :to_ecma262_number v = @val.to_ecma262_number v2 = @val2.to_ecma262_number if !v.nil? and !v2.nil? parent.replace(self, ECMA262Numeric.new(v - v2)) end end end |
#sym ⇒ Object
symbol of expression
1301 1302 1303 |
# File 'lib/minjs/ecma262/expression.rb', line 1301 def sym "-" end |