Class: Minjs::ECMA262::ExpAdd
- Includes:
- BinaryOperation
- Defined in:
- lib/minjs/ecma262/exp.rb
Overview
11.6.1 The Addition operator ( + )
Instance Attribute Summary
Attributes inherited from ExpArg2
Instance Method Summary collapse
Methods included from BinaryOperation
#==, #add_paren, #remove_paren
Methods inherited from ExpArg2
#deep_dup, #initialize, #replace, #to_js, #traverse
Methods inherited from Exp
Methods inherited from Base
#==, #concat, #deep_dup, #replace, #to_js, #to_s
Constructor Details
This class inherits a constructor from Minjs::ECMA262::ExpArg2
Instance Method Details
#priority ⇒ Object
807 808 809 |
# File 'lib/minjs/ecma262/exp.rb', line 807 def priority PRIORITY_ADDITIVE end |
#reduce(parent) ⇒ Object
817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
# File 'lib/minjs/ecma262/exp.rb', line 817 def reduce(parent) # a + 0 => a if @val.kind_of? ECMA262Numeric and @val2.kind_of? ECMA262Numeric and @val.to_num == 0 parent.replace(self, @val2) end # 0 + b => b if @val.kind_of? ECMA262Numeric and @val2.kind_of? ECMA262Numeric and @val2.to_num == 0 parent.replace(self, @val) end # N + M => (N + M) if @val.kind_of? ECMA262Numeric and @val2.kind_of? ECMA262Numeric and @val.integer? and @val2.integer? parent.replace(self, ECMA262Numeric.new(@val.to_num + @val2.to_num)) end end |
#swap ⇒ Object
811 812 813 814 815 |
# File 'lib/minjs/ecma262/exp.rb', line 811 def swap t = @val @val = @val2 @val2 = t end |
#sym ⇒ Object
803 804 805 |
# File 'lib/minjs/ecma262/exp.rb', line 803 def sym "+" end |