Make power operator compilation use proper AST nodes

This commit is contained in:
Demian Ferreiro 2013-03-25 00:02:21 -03:00
parent e237abff84
commit fbc019171c
2 changed files with 6 additions and 9 deletions

View File

@ -2348,11 +2348,9 @@
};
Op.prototype.compilePower = function(o) {
var left, parts, right;
left = this.first.compileToFragments(o, LEVEL_OP);
right = this.second.compileToFragments(o, LEVEL_OP);
parts = [this.makeCode('Math.pow('), left, this.makeCode(', '), right, this.makeCode(')')];
return this.joinFragmentArrays(parts, '');
var pow;
pow = new Value(new Literal('Math'), [new Access(new Literal('pow'))]);
return new Call(pow, [this.first, this.second]).compileToFragments(o);
};
Op.prototype.toString = function(idt) {

View File

@ -1669,10 +1669,9 @@ exports.Op = class Op extends Base
@joinFragmentArrays parts, ''
compilePower: (o) ->
left = @first.compileToFragments o, LEVEL_OP
right = @second.compileToFragments o, LEVEL_OP
parts = [@makeCode('Math.pow('), left, @makeCode(', '), right, @makeCode(')')]
@joinFragmentArrays parts, ''
# Make a Math.pow call
pow = new Value new Literal('Math'), [new Access new Literal 'pow']
new Call(pow, [@first, @second]).compileToFragments o
toString: (idt) ->
super idt, @constructor.name + ' ' + @operator