done for now

This commit is contained in:
Jeremy Ashkenas
2010-02-11 02:39:57 -05:00
parent 872b36c11d
commit 713f6f32e1
7 changed files with 59 additions and 96 deletions

View File

@@ -147,8 +147,8 @@
this.options = dup(o || {
});
this.indent = o.indent;
top = this.top_sensitive() ? o.top : del(o, 'top');
closure = this.is_statement() && !this.is_statement_only() && !top && !o.returns && !this instanceof CommentNode && !this.contains(function(node) {
top = this.top_sensitive() ? this.options.top : del(this.options, 'top');
closure = this.is_statement() && !this.is_statement_only() && !top && !this.options.returns && !(this instanceof CommentNode) && !this.contains(function(node) {
return node.is_statement_only();
});
return closure ? this.compile_closure(this.options) : this.compile_node(this.options);
@@ -202,7 +202,7 @@
// A collection of nodes, each one representing an expression.
Expressions = (exports.Expressions = inherit(Node, {
constructor: function constructor(nodes) {
this.children = (this.expressions = flatten(nodes));
this.children = (this.expressions = compact(flatten(nodes)));
return this;
},
// Tack an expression on to the end of this expression list.
@@ -1235,14 +1235,14 @@
com_dent = child ? this.idt() : '';
prefix = this.comment ? this.comment.compile(cond_o) + '\n' + com_dent : '';
body = Expressions.wrap([body]).compile(o);
if_part = prefix + if_dent + 'if (' + compile_condition(cond_o) + ') {\n' + body + '\n' + this.idt() + '}';
if_part = prefix + if_dent + 'if (' + this.compile_condition(cond_o) + ') {\n' + body + '\n' + this.idt() + '}';
if (!(this.else_body)) {
return if_part;
}
else_part = this.is_chain() ? ' else ' + this.else_body.compile(merge(o, {
indent: this.idt(),
chain_child: true
})) : ' else {\n' + Expressions.wrap(this.else_body).compile(o) + '\n' + this.idt() + '}';
})) : ' else {\n' + Expressions.wrap([this.else_body]).compile(o) + '\n' + this.idt() + '}';
return if_part + else_part;
},
// Compile the IfNode into a ternary operator.