mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 02:51:25 -05:00
things are in motion -- bin/node_coffee is the new JS-only command line ... it can pass some of the tests
This commit is contained in:
@@ -2,148 +2,6 @@
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
process.mixin(require('./scope'));
|
||||
// The abstract base class for all CoffeeScript nodes.
|
||||
// All nodes are implement a "compile_node" method, which performs the
|
||||
// code generation for that node. To compile a node, call the "compile"
|
||||
// method, which wraps "compile_node" in some extra smarts, to know when the
|
||||
// generated code should be wrapped up in a closure. An options hash is passed
|
||||
// and cloned throughout, containing messages from higher in the AST,
|
||||
// information about the current scope, and indentation level.
|
||||
exports.Expressions = function Expressions() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.LiteralNode = function LiteralNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ReturnNode = function ReturnNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.CommentNode = function CommentNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.CallNode = function CallNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ExtendsNode = function ExtendsNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ValueNode = function ValueNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.AccessorNode = function AccessorNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.IndexNode = function IndexNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.RangeNode = function RangeNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.SliceNode = function SliceNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ThisNode = function ThisNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.AssignNode = function AssignNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.OpNode = function OpNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.CodeNode = function CodeNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.SplatNode = function SplatNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ObjectNode = function ObjectNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ArrayNode = function ArrayNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.PushNode = function PushNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ClosureNode = function ClosureNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.WhileNode = function WhileNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ForNode = function ForNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.TryNode = function TryNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ThrowNode = function ThrowNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ExistenceNode = function ExistenceNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.ParentheticalNode = function ParentheticalNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
exports.IfNode = function IfNode() {
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
this.name = this.constructor.name;
|
||||
return this.values = arguments;
|
||||
};
|
||||
// Some helper functions
|
||||
// Tabs are two spaces for pretty printing.
|
||||
TAB = ' ';
|
||||
@@ -261,11 +119,6 @@
|
||||
}
|
||||
return klass;
|
||||
};
|
||||
// # Provide a quick implementation of a children method.
|
||||
// children: (klass, attrs...) ->
|
||||
// klass::children: ->
|
||||
// nodes: this[attr] for attr in attrs
|
||||
// compact flatten nodes
|
||||
// Mark a node as a statement, or a statement only.
|
||||
statement = function statement(klass, only) {
|
||||
klass.prototype.is_statement = function is_statement() {
|
||||
@@ -528,7 +381,7 @@
|
||||
var __a, __b, baseline, code, only, part, parts, prop, props, soaked, temp;
|
||||
soaked = false;
|
||||
only = del(o, 'only_first');
|
||||
props = only ? this.properties.slice(0, this.properties.length) : this.properties;
|
||||
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
||||
baseline = this.base.compile(o);
|
||||
parts = [baseline];
|
||||
__a = props;
|
||||
@@ -931,11 +784,12 @@
|
||||
return assigns.join("\n");
|
||||
},
|
||||
compile_splice: function compile_splice(o) {
|
||||
var from, name, plus, range, to;
|
||||
var from, l, name, plus, range, to;
|
||||
name = this.variable.compile(merge(o, {
|
||||
only_first: true
|
||||
}));
|
||||
range = this.variable.properties.last.range;
|
||||
l = this.variable.properties.length;
|
||||
range = this.variable.properties[l - 1].range;
|
||||
plus = range.exclusive ? '' : ' + 1';
|
||||
from = range.from.compile(o);
|
||||
to = range.to.compile(o) + ' - ' + from + plus;
|
||||
|
||||
Reference in New Issue
Block a user