Class: Minjs::ECMA262::ExpMul
- Inherits:
-
Expression
- Object
- Base
- Expression
- Minjs::ECMA262::ExpMul
- Includes:
- BinaryOperation
- Defined in:
- lib/minjs/ecma262/expression.rb
Overview
Class of the Multiprication 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) ⇒ ExpMul
constructor
A new instance of ExpMul.
-
#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) ⇒ ExpMul
Returns a new instance of ExpMul.
1154 1155 1156 1157 |
# File 'lib/minjs/ecma262/expression.rb', line 1154 def initialize(val, val2) @val = val @val2 = val2 end |
Instance Method Details
#ecma262_typeof ⇒ Symbol
return results of ‘typeof’ operator.
1185 1186 1187 |
# File 'lib/minjs/ecma262/expression.rb', line 1185 def ecma262_typeof :number end |
#priority ⇒ Fixnum
Returns expression priority.
1165 1166 1167 |
# File 'lib/minjs/ecma262/expression.rb', line 1165 def priority PRIORITY_MULTIPLICATIVE end |
#reduce(parent) ⇒ Object
reduce expression if available
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
# File 'lib/minjs/ecma262/expression.rb', line 1171 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
1160 1161 1162 |
# File 'lib/minjs/ecma262/expression.rb', line 1160 def sym "*" end |