mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Cleaning up.
This commit is contained in:
parent
2a3a713811
commit
76f9596f22
2 changed files with 8 additions and 8 deletions
|
@ -1462,7 +1462,7 @@
|
|||
this.index = _b[1];
|
||||
}
|
||||
this.pattern = this.name instanceof ValueNode;
|
||||
if (this.index instanceof ObjectNode) {
|
||||
if (this.index instanceof ValueNode) {
|
||||
throw new Error('index cannot be a pattern matching expression');
|
||||
}
|
||||
this.children = compact([this.body, this.source, this.filter]);
|
||||
|
@ -1520,13 +1520,12 @@
|
|||
svar = scope.free_variable();
|
||||
index_var = null;
|
||||
source_part = ("" + svar + " = " + (this.source.compile(o)) + ";\n" + this.tab);
|
||||
if (name && !this.pattern) {
|
||||
var_part = ("" + body_dent + name + " = " + svar + "[" + ivar + "];\n");
|
||||
}
|
||||
if (this.pattern) {
|
||||
o.indent = this.idt(1);
|
||||
o.top = true;
|
||||
var_part = new AssignNode(this.name, literal(("" + svar + "[" + ivar + "]"))).compile(o) + "\n";
|
||||
} else if (name) {
|
||||
var_part = ("" + body_dent + name + " = " + svar + "[" + ivar + "];\n");
|
||||
}
|
||||
if (!this.object) {
|
||||
lvar = scope.free_variable();
|
||||
|
|
|
@ -1079,10 +1079,10 @@ exports.ForNode: class ForNode extends BaseNode
|
|||
@step: source.step
|
||||
@object: !!source.object
|
||||
[@name, @index]: [@index, @name] if @object
|
||||
@pattern: @name instanceof ValueNode
|
||||
throw new Error('index cannot be a pattern matching expression') if @index instanceof ObjectNode
|
||||
@pattern: @name instanceof ValueNode
|
||||
throw new Error('index cannot be a pattern matching expression') if @index instanceof ValueNode
|
||||
@children: compact [@body, @source, @filter]
|
||||
@returns: false
|
||||
@returns: false
|
||||
|
||||
top_sensitive: ->
|
||||
true
|
||||
|
@ -1122,11 +1122,12 @@ exports.ForNode: class ForNode extends BaseNode
|
|||
svar: scope.free_variable()
|
||||
index_var: null
|
||||
source_part: "$svar = ${ @source.compile(o) };\n$@tab"
|
||||
var_part: "$body_dent$name = $svar[$ivar];\n" if name and not @pattern
|
||||
if @pattern
|
||||
o.indent: @idt 1
|
||||
o.top: true
|
||||
var_part: new AssignNode(@name, literal("$svar[$ivar]")).compile(o) + "\n"
|
||||
else
|
||||
var_part: "$body_dent$name = $svar[$ivar];\n" if name
|
||||
if not @object
|
||||
lvar: scope.free_variable()
|
||||
step_part: if @step then "$ivar += ${ @step.compile(o) }" else "$ivar++"
|
||||
|
|
Loading…
Add table
Reference in a new issue