test_functions.coffee compiles and runs successfully.

This commit is contained in:
Jeremy Ashkenas
2010-02-11 23:57:31 -05:00
parent 04f07f4c15
commit 12685aa54a
4 changed files with 26 additions and 18 deletions

View File

@@ -239,10 +239,10 @@
},
// Is the node last in this block of expressions?
is_last: function is_last(node) {
var l;
var l, last_index;
l = this.expressions.length;
this.last_index = this.last_index || this.expressions[l - 1] instanceof CommentNode ? 2 : 1;
return node === this.expressions[l - this.last_index];
last_index = this.expressions[l - 1] instanceof CommentNode ? 2 : 1;
return node === this.expressions[l - last_index];
},
compile: function compile(o) {
o = o || {
@@ -437,7 +437,7 @@
},
compile_node: function compile_node(o) {
var delimiter;
delimiter = "\n" + this.idt() + '//';
delimiter = this.idt() + '//';
return delimiter + this.lines.join(delimiter);
}
}));
@@ -642,7 +642,7 @@
// AssignNodes get interleaved correctly, with no trailing commas or
// commas affixed to comments. TODO: Extract this and add it to ArrayNode.
compile_node: function compile_node(o) {
var __a, __b, __c, __d, __e, i, indent, join, last_noncom, non_comments, prop, props;
var __a, __b, __c, __d, __e, i, indent, inner, join, last_noncom, non_comments, prop, props;
o.indent = this.idt(1);
non_comments = (function() {
__a = []; __b = this.properties;
@@ -673,7 +673,9 @@
}
return __d;
}).call(this);
return '{\n' + props.join('') + '\n' + this.idt() + '}';
props = props.join('');
inner = props ? '\n' + props + '\n' + this.idt() : '';
return '{' + inner + '}';
}
}));
// An array literal.
@@ -885,11 +887,14 @@
SplatNode = (exports.SplatNode = inherit(Node, {
type: 'Splat',
constructor: function constructor(name) {
if (!(name.compile)) {
name = new LiteralNode(name);
}
this.children = [(this.name = name)];
return this;
},
compile_node: function compile_node(o) {
return this.index ? this.compile_param(o) : this.name.compile(o);
return (typeof this.index !== "undefined" && this.index !== null) ? this.compile_param(o) : this.name.compile(o);
},
compile_param: function compile_param(o) {
var name;
@@ -1261,7 +1266,7 @@
compile_condition: function compile_condition(o) {
var __a, __b, __c, cond;
return ((function() {
__a = []; __b = flatten(this.condition);
__a = []; __b = flatten([this.condition]);
for (__c = 0; __c < __b.length; __c++) {
cond = __b[__c];
__a.push(cond.compile(o));
@@ -1284,7 +1289,7 @@
if_dent = child ? '' : this.idt();
com_dent = child ? this.idt() : '';
prefix = this.comment ? this.comment.compile(cond_o) + '\n' + com_dent : '';
body = Expressions.wrap([body]).compile(o);
body = Expressions.wrap([this.body]).compile(o);
if_part = prefix + if_dent + 'if (' + this.compile_condition(cond_o) + ') {\n' + body + '\n' + this.idt() + '}';
if (!(this.else_body)) {
return if_part;