Permalink
Browse files

-b command line flag corresponds to --bare tame output

  • Loading branch information...
1 parent 43e8478 commit 6c91d9e535326830d4a444a6be96890429ca34b3 @maxtaco committed with Jan 7, 2012
Showing with 26 additions and 19 deletions.
  1. +1 −1 lib/coffee-script/nodes.js
  2. +25 −18 src/nodes.coffee
View
2 lib/coffee-script/nodes.js
@@ -2805,7 +2805,7 @@
TameRequire.prototype.compileNode = function(o) {
var access, call, callv, file, inc, k, lhs, ns, out, req, rhs, v;
this.tab = o.indent;
- v = this.typ ? this.typ.compile(o) : "inline";
+ v = this.typ ? this.typ.compile(o) : o.bare ? 'none' : "inline";
inc = null;
inc = (function() {
switch (v) {
View
43 src/nodes.coffee
@@ -45,7 +45,7 @@ exports.Base = class Base
@tameGotCpsSplitFlag = false
@tameCpsPivotFlag = false
@tameHasAutocbFlag = false
-
+
@tameParentAwait = null
@tameCallContinuationFlag = false
@@ -90,7 +90,7 @@ exports.Base = class Base
# In the case of expressions with nested await'ing, things are sadly way
# more complicated. We could have an arbitrarily deep chain here, hence
# the calls to CpsCascading in a loop.
- #
+ #
compileCps : (o) ->
@tameGotCpsSplitFlag = true
@@ -100,25 +100,25 @@ exports.Base = class Base
# Optimization: We smush the "this" expression and the continuation
# into a flat block.
[ this, @tameContinuationBlock ]
-
+
else if @tameWrapContinuation()
# For some types of objects, we wrap the value of the object in a
# tamed tail call here. We might have done this earlier (in
# tameCallContinuation) but at that point we don't have the option
# to replace an AST node with TameTailCall(this). So instead, we
# do that now.
new TameTailCall null, this
-
+
else
# The simple case is no continuation, and no added TameTailCall
# needed.
this
-
+
while l--
pb = @tamePrequels[l]
k = CpsCascade.wrap pb.block, k, pb.retval, o
code = k
-
+
else
code = CpsCascade.wrap this, @tameContinuationBlock, null, o
@@ -248,7 +248,7 @@ exports.Base = class Base
#
# tameWalkAst
- #
+ #
# Walk the AST looking for taming. Mark a node as with tame flags
# if any of its children are tamed, but don't cross scope boundary
# when considering the children.
@@ -335,7 +335,7 @@ exports.Base = class Base
this
else
if @tameHasContinuation()
- e.tameContinuationBlock = @tameContinuationBlock
+ e.tameContinuationBlock = @tameContinuationBlock
e.tamePrequels = @tamePrequels
e
@@ -406,7 +406,7 @@ exports.Block = class Block extends Base
foundReturn = false
while len--
expr = @expressions[len]
-
+
# If the last expression in the block is either a bonafide statement
# or if it's going to be pivoted, then don't thread the return value
# through the TameTailCall, just bolt it onto the end.
@@ -419,7 +419,7 @@ exports.Block = class Block extends Base
call.assignValue expr
@expressions[len] = call
return
-
+
# if nothing was found, just push the call on
@expressions.push call
@@ -552,7 +552,7 @@ exports.Block = class Block extends Base
#
tameCpsRotate : ->
pivot = null
-
+
# Go ahead an look for a pivot
for e,i in @expressions
if e.tameIsCpsPivot()
@@ -573,7 +573,7 @@ exports.Block = class Block extends Base
# If there's no pivot, then the above should be as in the base
# class, and it's safe to return out of here.
- #
+ #
# We find a pivot if this node has taming, and it's not an Await
# itself.
return this unless pivot
@@ -635,12 +635,12 @@ exports.Block = class Block extends Base
# short-circuit here for optimization. If we didn't find await
# then no need to tame anything in this AST
- if obj.foundAwait
+ if obj.foundAwait
@tameAddRuntime() if obj.foundDefer and not obj.foundRequire
@tameWalkAstLoops(false)
@tameWalkCpsPivots()
@tameCpsRotate()
-
+
this
#### Literal
@@ -1837,7 +1837,7 @@ exports.While = class While extends Base
body = d.body
rvar = d.rvar
outStatements = []
-
+
if rvar
rvar_value = new Value new Literal rvar
@@ -2333,7 +2333,14 @@ exports.TameRequire = class TameRequire extends Base
compileNode: (o) ->
@tab = o.indent
- v = if @typ then @typ.compile(o) else "inline"
+
+ v = if @typ
+ @typ.compile(o)
+ else if o.bare
+ 'none'
+ else
+ "inline"
+
inc = null
inc = switch (v)
when "inline"
@@ -2864,7 +2871,7 @@ CpsCascade =
if returnValue
returnValue.bindName o
args.push returnValue
-
+
block = Block.wrap [ rest ]
# Optimization! If the block is just a tail call to another continuation
@@ -2873,7 +2880,7 @@ CpsCascade =
cont = e.extractFunc()
else
cont = new Code args, block, 'tamegen'
-
+
call = new Call func, [ cont ]
new Block [ call ]

0 comments on commit 6c91d9e

Please sign in to comment.