From abef3f59be81cbc7f8dbd83bd3116a2068968ef3 Mon Sep 17 00:00:00 2001 From: satyr Date: Mon, 25 Oct 2010 00:14:58 +0900 Subject: [PATCH] rebuilt parser and rewrote the asserts wrapping loop in Cakefile using `do =>` --- Cakefile | 4 ++-- lib/nodes.js | 2 +- lib/parser.js | 2 +- src/nodes.coffee | 9 +++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cakefile b/Cakefile index 2fa46891..4f89ddfb 100644 --- a/Cakefile +++ b/Cakefile @@ -99,8 +99,8 @@ task 'loc', 'count the lines of source code in the CoffeeScript compiler', -> runTests = (CoffeeScript) -> startTime = Date.now() passedTests = failedTests = 0 - wrap = (name, func) -> global[name] = -> ++passedTests; func arguments... - wrap name, func for all name, func of require 'assert' + for all name, func of require 'assert' then do (name, func) => + global[name] = -> ++passedTests; func arguments... global.eq = global.strictEqual global.CoffeeScript = CoffeeScript process.on 'exit', -> diff --git a/lib/nodes.js b/lib/nodes.js index 6a4e0df1..d7ff6530 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1053,7 +1053,7 @@ this.bound = false; return new Call(new Value(this, [new Accessor(new Literal('call'))]), [new Literal('this')].concat(this.params)); } else { - return new Call(this, this.params); + return new Call(this); } }; return Code; diff --git a/lib/parser.js b/lib/parser.js index 7bf5634a..7c755142 100755 --- a/lib/parser.js +++ b/lib/parser.js @@ -115,7 +115,7 @@ case 52:this.$ = new yy.Comment($$[$0-1+1-1]); break; case 53:this.$ = new yy.Existence($$[$0-2+1-1]); break; -case 54:this.$ = new yy.Call($$[$0-2+2-1], $$[$0-2+2-1].params); +case 54:this.$ = $$[$0-2+2-1]["do"](); break; case 55:this.$ = new yy.Code($$[$0-5+2-1], $$[$0-5+5-1], $$[$0-5+4-1]); break; diff --git a/src/nodes.coffee b/src/nodes.coffee index 9eb8133e..687df72c 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -889,14 +889,15 @@ exports.Code = class Code extends Base # Short-circuit `traverseChildren` method to prevent it from crossing scope boundaries # unless `crossScope` is `true`. traverseChildren: (crossScope, func) -> super(crossScope, func) if crossScope - + # Automatically calls the defined function. do: -> if @bound @bound = no - new Call(new Value this, [new Accessor new Literal 'call'] - [new Literal 'this'].concat this.params) - else new Call this, this.params + new Call new Value(this, [new Accessor new Literal 'call']), + [new Literal 'this'].concat this.params + else + new Call this #### Param