Permalink
Browse files

I think I see what's slow about parsing -- the tame AST passes. I thi…

…nk this fixes it, or at least works around it. Remove all tame from the core libraries
  • Loading branch information...
maxtaco committed Dec 19, 2011
1 parent ce2bdca commit 618305ce1fa05bdbcf0a2448096593e60a93dd1c
Showing with 49 additions and 121 deletions.
  1. +8 −14 Cakefile
  2. +12 −87 lib/coffee-script/cake.js
  3. +15 −4 lib/coffee-script/nodes.js
  4. +4 −12 src/cake.coffee
  5. +10 −4 src/nodes.coffee
View
@@ -30,7 +30,7 @@ header = """
sources = [
'coffee-script', 'grammar', 'helpers'
'lexer', 'nodes', 'rewriter', 'scope',
- 'tame', 'tamelib'
+ 'tame'
].map (filename) -> "src/#{filename}.coffee"
# Run a CoffeeScript through our node/coffee interpreter.
@@ -192,13 +192,13 @@ runTests = (CoffeeScript) ->
global.atest = (description, fn) ->
++attemptedTests
fn.test = { description, currentFile }
- await fn.call(fn, defer(ok, e))
- if ok
- ++passedTests
- else
- e.description = description if description?
- e.source = fn.toString() if fn.toString?
- failures.push filename : currentFile, error : e
+ fn.call fn, (ok, e) =>
+ if ok
+ ++passedTests
+ else
+ e.description = description if description?
+ e.source = fn.toString() if fn.toString?
+ failures.push filename : currentFile, error : e
# See http://wiki.ecmascript.org/doku.php?id=harmony:egal
egal = (a, b) ->
@@ -262,9 +262,3 @@ task 'test:browser', 'run the test suite against the merged browser script', ->
(-> eval source).call result
runTests result.CoffeeScript
-atask 'test:acake', 'run a test for Cakefile async', (opts,cb) ->
- console.log "start sleep"
- await setTimeout defer(), 1000
- console.log "end sleep"
- cb()
-
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -17,7 +17,6 @@ CoffeeScript = require './coffee-script'
# Keep track of the list of defined tasks, the accepted options, and so on.
tasks = {}
-atasks = {}
options = {}
switches = []
oparse = null
@@ -27,12 +26,9 @@ helpers.extend global,
# Define a Cake task with a short name, an optional sentence description,
# and the function to run as the action itself.
- task: (name, description, action, async) ->
+ task: (name, description, action) ->
[action, description] = [description, action] unless action
- tasks[name] = {name, description, action, async}
-
- atask: (name, description, action) ->
- task name, description, action, true
+ tasks[name] = {name, description, action}
# Define an option that the Cakefile accepts. The parsed options hash,
# containing all of the command-line options passed, will be made available
@@ -43,11 +39,7 @@ helpers.extend global,
# Invoke another task in the current Cakefile.
invoke: (name, cb) ->
missingTask name unless (t = tasks[name])
- if t.async
- await t.action(options, defer())
- else
- t.action options
- cb()
+ t.action options
# Run `cake`. Executes all of the tasks you pass, in order. Note that Node's
# asynchrony may cause tasks to execute in a different order than you'd expect.
@@ -65,7 +57,7 @@ exports.run = (cb) ->
catch e
return fatalError "#{e}"
for arg in options.arguments
- await invoke(arg,defer())
+ invoke arg
# Display the list of Cake tasks in a format similar to `rake -T`
printTasks = ->
View
@@ -101,17 +101,17 @@ exports.Base = class Base
# Recursively traverses down the *children* of the nodes, yielding to a block
# and returning true when the block finds a match. `contains` does not cross
# scope boundaries.
- contains: (pred) ->
+ contains: (pred, traverseFuncBoundary) ->
contains = no
- @traverseChildren no, (node) ->
+ @traverseChildren traverseFuncBoundary, (node) ->
if pred node
contains = yes
return no
contains
# Is this node of a certain type, or does it contain the type?
- containsType: (type) ->
- this instanceof type or @contains (node) -> node instanceof type
+ containsType: (type, traverseFuncBoundary) ->
+ this instanceof type or @contains (node, traverseFuncBoundary) -> node instanceof type
# Pull out the last non-comment node of a node list.
lastNonComment: (list) ->
@@ -248,6 +248,11 @@ exports.Base = class Base
@tameCpsPivotFlag = true if child.tameWalkCpsPivots()
@tameCpsPivotFlag
+ tameGo : ->
+ for child in @flattenChildren()
+ return true if (child instanceof Await) or child.tameGo()
+ return false
+
# Default implementations of the common node properties and methods. Nodes
# will override these with custom logic, if needed.
children: []
@@ -539,6 +544,7 @@ exports.Block = class Block extends Base
# Perform all steps of the Tame transform
tameTransform : ->
+ return this unless @tameGo()
@tameExtractExpressions(true)
@tameAssignDefersToAwait()
@tameWalkAst()

0 comments on commit 618305c

Please sign in to comment.