diff --git a/lib/nodes.js b/lib/nodes.js index 0f1f157d..93b61946 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -512,6 +512,7 @@ }; __extends(CurryNode, CallNode); CurryNode.prototype.type = 'Curry'; + CurryNode.prototype.body = 'func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)))'; CurryNode.prototype.arguments = function arguments(o) { var _a, _b, _c, arg; _a = this.args; @@ -525,7 +526,7 @@ }; CurryNode.prototype.compile_node = function compile_node(o) { var body, curried, curry; - body = Expressions.wrap([literal('func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)));')]); + body = Expressions.wrap([literal(this.body)]); curried = new CodeNode([], body); curry = new CodeNode([literal('func'), literal('obj'), literal('args')], Expressions.wrap([curried])); return (new ParentheticalNode(new CallNode(curry, [this.meth, this.context, literal(this.arguments(o))]))).compile(o); diff --git a/src/nodes.coffee b/src/nodes.coffee index f8cbcd80..a277c41a 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -394,6 +394,8 @@ exports.CallNode: class CallNode extends BaseNode exports.CurryNode: class CurryNode extends CallNode type: 'Curry' + body: 'func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)))' + constructor: (meth, args) -> @children: flatten [@meth: meth, @context: args[0], @args: (args.slice(1) or [])] @@ -403,7 +405,7 @@ exports.CurryNode: class CurryNode extends CallNode (new ArrayNode(@args)).compile o compile_node: (o) -> - body: Expressions.wrap([literal('func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)));')]) + body: Expressions.wrap([literal @body]) curried: new CodeNode([], body) curry: new CodeNode([literal('func'), literal('obj'), literal('args')], Expressions.wrap([curried])) (new ParentheticalNode(new CallNode(curry, [@meth, @context, literal(@arguments(o))]))).compile o