mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
The moment of truth: CoffeeScript has now compiled itself ten times over.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
// Some helper functions
|
||||
// Tabs are two spaces for pretty printing.
|
||||
TAB = ' ';
|
||||
TRAILING_WHITESPACE = /\s+$/g;
|
||||
TRAILING_WHITESPACE = /\s+$/gm;
|
||||
// Keep the identifier regex in sync with the Lexer.
|
||||
IDENTIFIER = /^[a-zA-Z$_](\w|\$)*$/;
|
||||
// Flatten nested arrays recursively.
|
||||
@@ -46,8 +46,7 @@
|
||||
}
|
||||
return __a;
|
||||
} else {
|
||||
output = {
|
||||
};
|
||||
output = {};
|
||||
__d = input;
|
||||
for (key in __d) {
|
||||
val = __d[key];
|
||||
@@ -61,8 +60,7 @@
|
||||
// Merge objects.
|
||||
merge = function merge(src, dest) {
|
||||
var __a, __b, fresh, key, val;
|
||||
fresh = {
|
||||
};
|
||||
fresh = {};
|
||||
__a = src;
|
||||
for (key in __a) {
|
||||
val = __a[key];
|
||||
@@ -144,8 +142,7 @@
|
||||
// already been asked to return the result.
|
||||
Node.prototype.compile = function compile(o) {
|
||||
var closure, top;
|
||||
this.options = dup(o || {
|
||||
});
|
||||
this.options = dup(o || {});
|
||||
this.indent = o.indent;
|
||||
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) {
|
||||
@@ -245,8 +242,7 @@
|
||||
return node === this.expressions[l - last_index];
|
||||
},
|
||||
compile: function compile(o) {
|
||||
o = o || {
|
||||
};
|
||||
o = o || {};
|
||||
return o.scope ? Node.prototype.compile.call(this, o) : this.compile_root(o);
|
||||
},
|
||||
// Compile each expression in the Expressions body.
|
||||
@@ -525,11 +521,11 @@
|
||||
},
|
||||
// Hooking one constructor into another's prototype chain.
|
||||
compile_node: function compile_node(o) {
|
||||
var child, constructor, parent;
|
||||
constructor = o.scope.free_variable();
|
||||
var child, construct, parent;
|
||||
construct = o.scope.free_variable();
|
||||
child = this.child.compile(o);
|
||||
parent = this.parent.compile(o);
|
||||
return this.idt() + constructor + ' = function(){};\n' + this.idt() + constructor + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + constructor + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';';
|
||||
return this.idt() + construct + ' = function(){};\n' + this.idt() + construct + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + construct + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';';
|
||||
}
|
||||
}));
|
||||
statement(ExtendsNode);
|
||||
@@ -1215,8 +1211,7 @@
|
||||
this.body = body && body.unwrap();
|
||||
this.else_body = else_body && else_body.unwrap();
|
||||
this.children = compact([this.condition, this.body, this.else_body]);
|
||||
this.tags = tags || {
|
||||
};
|
||||
this.tags = tags || {};
|
||||
if (this.condition instanceof Array) {
|
||||
this.multiple = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user