diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 7599dc8f..dcd81c7c 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -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) { diff --git a/src/nodes.coffee b/src/nodes.coffee index a2975068..8b816649 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -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