Make power operator compilation use proper AST nodes
This commit is contained in:
parent
e237abff84
commit
fbc019171c
|
@ -2348,11 +2348,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Op.prototype.compilePower = function(o) {
|
Op.prototype.compilePower = function(o) {
|
||||||
var left, parts, right;
|
var pow;
|
||||||
left = this.first.compileToFragments(o, LEVEL_OP);
|
pow = new Value(new Literal('Math'), [new Access(new Literal('pow'))]);
|
||||||
right = this.second.compileToFragments(o, LEVEL_OP);
|
return new Call(pow, [this.first, this.second]).compileToFragments(o);
|
||||||
parts = [this.makeCode('Math.pow('), left, this.makeCode(', '), right, this.makeCode(')')];
|
|
||||||
return this.joinFragmentArrays(parts, '');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Op.prototype.toString = function(idt) {
|
Op.prototype.toString = function(idt) {
|
||||||
|
|
|
@ -1669,10 +1669,9 @@ exports.Op = class Op extends Base
|
||||||
@joinFragmentArrays parts, ''
|
@joinFragmentArrays parts, ''
|
||||||
|
|
||||||
compilePower: (o) ->
|
compilePower: (o) ->
|
||||||
left = @first.compileToFragments o, LEVEL_OP
|
# Make a Math.pow call
|
||||||
right = @second.compileToFragments o, LEVEL_OP
|
pow = new Value new Literal('Math'), [new Access new Literal 'pow']
|
||||||
parts = [@makeCode('Math.pow('), left, @makeCode(', '), right, @makeCode(')')]
|
new Call(pow, [@first, @second]).compileToFragments o
|
||||||
@joinFragmentArrays parts, ''
|
|
||||||
|
|
||||||
toString: (idt) ->
|
toString: (idt) ->
|
||||||
super idt, @constructor.name + ' ' + @operator
|
super idt, @constructor.name + ' ' + @operator
|
||||||
|
|
Loading…
Reference in New Issue