Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't abuse parameters to functions. pass Parameters, not Values

  • Loading branch information...
commit 8323d3c961ac70316dd6ad971bb9dd5a4fe9c549 1 parent ba5b6db
@maxtaco authored
Showing with 12 additions and 12 deletions.
  1. +7 −7 lib/coffee-script/nodes.js
  2. +5 −5 src/nodes.coffee
View
14 lib/coffee-script/nodes.js
@@ -2233,7 +2233,7 @@
};
While.prototype.tameWrap = function(d) {
- var body, break_assign, break_block, break_body, break_expr, break_id, call1, call2, cond, condition, continue_assign, continue_block, continue_body, continue_id, f, k_id, next_arg, next_assign, next_block, next_body, next_id, outStatements, rvar, rvar_init, rvar_value, top_assign, top_block, top_body, top_call, top_func, top_id, top_statements;
+ var body, break_assign, break_block, break_body, break_expr, break_id, call1, call2, cond, condition, continue_assign, continue_block, continue_body, continue_id, f, k_id, k_param, next_arg, next_assign, next_block, next_body, next_id, outStatements, rvar, rvar_init, rvar_value, top_assign, top_block, top_body, top_call, top_func, top_id, top_statements;
condition = d.condition;
body = d.body;
rvar = d.rvar;
@@ -2241,6 +2241,7 @@
if (rvar) rvar_value = new Value(new Literal(rvar));
top_id = new Value(new Literal(tame["const"].t_while));
k_id = new Value(new Literal(tame["const"].k));
+ k_param = new Param(new Literal(tame["const"].k));
break_id = new Value(new Literal(tame["const"].b_while));
if (rvar) {
break_expr = new Call(k_id, [rvar_value]);
@@ -2263,7 +2264,7 @@
});
next_id = new Value(new Literal(tame["const"].n_while));
if (rvar) {
- next_arg = new Value(new Literal(tame["const"].n_arg));
+ next_arg = new Param(new Literal(tame["const"].n_arg));
f = rvar_value.copy();
f.add(new Access(new Value(new Literal('push'))));
call1 = new Call(f, [next_arg]);
@@ -2279,7 +2280,7 @@
cond = new If(condition, body);
cond.addElse(new Block([new Call(break_id, [])]));
top_body = new Block([break_assign, continue_assign, next_assign, cond]);
- top_func = new Code([k_id], top_body, 'tamegen');
+ top_func = new Code([k_param], top_body, 'tamegen');
top_assign = new Assign(top_id, top_func, null, {
tamelocal: true
});
@@ -2650,11 +2651,10 @@
Defer.prototype.children = ['slots'];
Defer.prototype.newParam = function() {
- var l, v;
+ var l;
l = "" + tame["const"].slot + "_" + (this.params.length + 1);
- v = new Value(new Literal(l));
- this.params.push(v.copy());
- return v;
+ this.params.push(new Param(new Literal(l)));
+ return new Value(new Literal(l));
};
Defer.prototype.makeAssignFn = function(o) {
View
10 src/nodes.coffee
@@ -1862,6 +1862,7 @@ exports.While = class While extends Base
# Set up all of the IDs
top_id = new Value new Literal tame.const.t_while
k_id = new Value new Literal tame.const.k
+ k_param = new Param new Literal tame.const.k
# Break will just call the parent continuation, but in some
# cases, there will be a return value, so then we have to pass
@@ -1888,7 +1889,7 @@ exports.While = class While extends Base
# value, if required!
next_id = new Value new Literal tame.const.n_while
if rvar
- next_arg = new Value new Literal tame.const.n_arg
+ next_arg = new Param new Literal tame.const.n_arg
f = rvar_value.copy()
f.add new Access new Value new Literal 'push'
call1 = new Call f, [ next_arg ]
@@ -1907,7 +1908,7 @@ exports.While = class While extends Base
# The top of the loop construct.
top_body = new Block [ break_assign, continue_assign, next_assign, cond ]
- top_func = new Code [ k_id ], top_body, 'tamegen'
+ top_func = new Code [ k_param ], top_body, 'tamegen'
top_assign = new Assign top_id, top_func, null, { tamelocal : yes }
top_call = new Call top_id, [ k_id ]
top_statements = []
@@ -2178,9 +2179,8 @@ exports.Defer = class Defer extends Base
# it later before we output it.
newParam : ->
l = "#{tame.const.slot}_#{@params.length + 1}"
- v = new Value new Literal l
- @params.push v.copy()
- v
+ @params.push new Param new Literal l
+ new Value new Literal l
#
# makeAssignFn
Please sign in to comment.
Something went wrong with that request. Please try again.