mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
__extend back to __extends, as is the correct name.
This commit is contained in:
parent
572aa4e98f
commit
f9b028b78c
2 changed files with 53 additions and 53 deletions
66
lib/nodes.js
66
lib/nodes.js
|
@ -1,6 +1,6 @@
|
|||
(function(){
|
||||
var AccessorNode, ArrayNode, AssignNode, BaseNode, CallNode, ClassNode, ClosureNode, CodeNode, CommentNode, CurryNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, Scope, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThrowNode, TryNode, UTILITIES, ValueNode, WhileNode, compact, del, flatten, helpers, literal, merge, statement, utility;
|
||||
var __extend = function(child, parent) {
|
||||
var __extends = function(child, parent) {
|
||||
var ctor = function(){ };
|
||||
ctor.prototype = parent.prototype;
|
||||
child.__superClass__ = parent.prototype;
|
||||
|
@ -193,7 +193,7 @@
|
|||
this.children = (this.expressions = compact(flatten(nodes || [])));
|
||||
return this;
|
||||
};
|
||||
__extend(Expressions, BaseNode);
|
||||
__extends(Expressions, BaseNode);
|
||||
Expressions.prototype.type = 'Expressions';
|
||||
// Tack an expression on to the end of this expression list.
|
||||
Expressions.prototype.push = function push(node) {
|
||||
|
@ -321,7 +321,7 @@
|
|||
this.value = value;
|
||||
return this;
|
||||
};
|
||||
__extend(LiteralNode, BaseNode);
|
||||
__extends(LiteralNode, BaseNode);
|
||||
LiteralNode.prototype.type = 'Literal';
|
||||
// Break and continue must be treated as pure statements -- they lose their
|
||||
// meaning when wrapped in a closure.
|
||||
|
@ -348,7 +348,7 @@
|
|||
this.children = [(this.expression = expression)];
|
||||
return this;
|
||||
};
|
||||
__extend(ReturnNode, BaseNode);
|
||||
__extends(ReturnNode, BaseNode);
|
||||
ReturnNode.prototype.type = 'Return';
|
||||
ReturnNode.prototype.top_sensitive = function top_sensitive() {
|
||||
return true;
|
||||
|
@ -376,7 +376,7 @@
|
|||
this.children = flatten([(this.base = base), (this.properties = (properties || []))]);
|
||||
return this;
|
||||
};
|
||||
__extend(ValueNode, BaseNode);
|
||||
__extends(ValueNode, BaseNode);
|
||||
ValueNode.prototype.type = 'Value';
|
||||
ValueNode.prototype.SOAK = " == undefined ? undefined : ";
|
||||
// A **ValueNode** has a base and a list of property accesses.
|
||||
|
@ -470,7 +470,7 @@
|
|||
this;
|
||||
return this;
|
||||
};
|
||||
__extend(CommentNode, BaseNode);
|
||||
__extends(CommentNode, BaseNode);
|
||||
CommentNode.prototype.type = 'Comment';
|
||||
CommentNode.prototype.make_return = function make_return() {
|
||||
return this;
|
||||
|
@ -493,7 +493,7 @@
|
|||
this.compile_splat_arguments = __bind(SplatNode.compile_mixed_array, this, [this.args]);
|
||||
return this;
|
||||
};
|
||||
__extend(CallNode, BaseNode);
|
||||
__extends(CallNode, BaseNode);
|
||||
CallNode.prototype.type = 'Call';
|
||||
// Tag this invocation as creating a new instance.
|
||||
CallNode.prototype.new_instance = function new_instance() {
|
||||
|
@ -563,7 +563,7 @@
|
|||
this.compile_splat_arguments = __bind(SplatNode.compile_mixed_array, this, [this.args]);
|
||||
return this;
|
||||
};
|
||||
__extend(CurryNode, CallNode);
|
||||
__extends(CurryNode, CallNode);
|
||||
CurryNode.prototype.type = 'Curry';
|
||||
CurryNode.prototype.arguments = function arguments(o) {
|
||||
var _a, _b, _c, arg;
|
||||
|
@ -593,12 +593,12 @@
|
|||
this.children = [(this.child = child), (this.parent = parent)];
|
||||
return this;
|
||||
};
|
||||
__extend(ExtendsNode, BaseNode);
|
||||
__extends(ExtendsNode, BaseNode);
|
||||
ExtendsNode.prototype.type = 'Extends';
|
||||
// Hooks one constructor into another's prototype chain.
|
||||
ExtendsNode.prototype.compile_node = function compile_node(o) {
|
||||
var ref;
|
||||
ref = new ValueNode(literal(utility('extend')));
|
||||
ref = new ValueNode(literal(utility('extends')));
|
||||
return (new CallNode(ref, [this.child, this.parent])).compile(o);
|
||||
};
|
||||
return ExtendsNode;
|
||||
|
@ -614,7 +614,7 @@
|
|||
this;
|
||||
return this;
|
||||
};
|
||||
__extend(AccessorNode, BaseNode);
|
||||
__extends(AccessorNode, BaseNode);
|
||||
AccessorNode.prototype.type = 'Accessor';
|
||||
AccessorNode.prototype.compile_node = function compile_node(o) {
|
||||
var proto_part;
|
||||
|
@ -631,7 +631,7 @@
|
|||
this.soak_node = tag === 'soak';
|
||||
return this;
|
||||
};
|
||||
__extend(IndexNode, BaseNode);
|
||||
__extends(IndexNode, BaseNode);
|
||||
IndexNode.prototype.type = 'Index';
|
||||
IndexNode.prototype.compile_node = function compile_node(o) {
|
||||
var idx;
|
||||
|
@ -650,7 +650,7 @@
|
|||
this.exclusive = !!exclusive;
|
||||
return this;
|
||||
};
|
||||
__extend(RangeNode, BaseNode);
|
||||
__extends(RangeNode, BaseNode);
|
||||
RangeNode.prototype.type = 'Range';
|
||||
// Compiles the range's source variables -- where it starts and where it ends.
|
||||
RangeNode.prototype.compile_variables = function compile_variables(o) {
|
||||
|
@ -706,7 +706,7 @@
|
|||
this;
|
||||
return this;
|
||||
};
|
||||
__extend(SliceNode, BaseNode);
|
||||
__extends(SliceNode, BaseNode);
|
||||
SliceNode.prototype.type = 'Slice';
|
||||
SliceNode.prototype.compile_node = function compile_node(o) {
|
||||
var from, plus_part, to;
|
||||
|
@ -724,7 +724,7 @@
|
|||
this.children = (this.objects = (this.properties = props || []));
|
||||
return this;
|
||||
};
|
||||
__extend(ObjectNode, BaseNode);
|
||||
__extends(ObjectNode, BaseNode);
|
||||
ObjectNode.prototype.type = 'Object';
|
||||
// All the mucking about with commas is to make sure that CommentNodes and
|
||||
// AssignNodes get interleaved correctly, with no trailing commas or
|
||||
|
@ -774,7 +774,7 @@
|
|||
this.compile_splat_literal = __bind(SplatNode.compile_mixed_array, this, [this.objects]);
|
||||
return this;
|
||||
};
|
||||
__extend(ArrayNode, BaseNode);
|
||||
__extends(ArrayNode, BaseNode);
|
||||
ArrayNode.prototype.type = 'Array';
|
||||
ArrayNode.prototype.compile_node = function compile_node(o) {
|
||||
var _a, _b, code, ending, i, obj, objects;
|
||||
|
@ -808,7 +808,7 @@
|
|||
this.returns = false;
|
||||
return this;
|
||||
};
|
||||
__extend(ClassNode, BaseNode);
|
||||
__extends(ClassNode, BaseNode);
|
||||
ClassNode.prototype.type = 'Class';
|
||||
// Initialize a **ClassNode** with its name, an optional superclass, and a
|
||||
// list of prototype property assignments.
|
||||
|
@ -868,7 +868,7 @@
|
|||
this.context = context;
|
||||
return this;
|
||||
};
|
||||
__extend(AssignNode, BaseNode);
|
||||
__extends(AssignNode, BaseNode);
|
||||
AssignNode.prototype.type = 'Assign';
|
||||
// Matchers for detecting prototype assignments.
|
||||
AssignNode.prototype.PROTO_ASSIGN = /^(\S+)\.prototype/;
|
||||
|
@ -992,7 +992,7 @@
|
|||
this.bound = tag === 'boundfunc';
|
||||
return this;
|
||||
};
|
||||
__extend(CodeNode, BaseNode);
|
||||
__extends(CodeNode, BaseNode);
|
||||
CodeNode.prototype.type = 'Code';
|
||||
// Compilation creates a new scope unless explicitly asked to share with the
|
||||
// outer scope. Handles splat parameters in the parameter list by peeking at
|
||||
|
@ -1098,7 +1098,7 @@
|
|||
this.children = [(this.name = name)];
|
||||
return this;
|
||||
};
|
||||
__extend(SplatNode, BaseNode);
|
||||
__extends(SplatNode, BaseNode);
|
||||
SplatNode.prototype.type = 'Splat';
|
||||
SplatNode.prototype.compile_node = function compile_node(o) {
|
||||
var _a;
|
||||
|
@ -1169,7 +1169,7 @@
|
|||
this.filter = opts && opts.filter;
|
||||
return this;
|
||||
};
|
||||
__extend(WhileNode, BaseNode);
|
||||
__extends(WhileNode, BaseNode);
|
||||
WhileNode.prototype.type = 'While';
|
||||
WhileNode.prototype.add_body = function add_body(body) {
|
||||
this.children.push((this.body = body));
|
||||
|
@ -1225,7 +1225,7 @@
|
|||
this.flip = !!flip;
|
||||
return this;
|
||||
};
|
||||
__extend(OpNode, BaseNode);
|
||||
__extends(OpNode, BaseNode);
|
||||
OpNode.prototype.type = 'Op';
|
||||
// The map of conversions from CoffeeScript to JavaScript symbols.
|
||||
OpNode.prototype.CONVERSIONS = {
|
||||
|
@ -1326,7 +1326,7 @@
|
|||
this;
|
||||
return this;
|
||||
};
|
||||
__extend(TryNode, BaseNode);
|
||||
__extends(TryNode, BaseNode);
|
||||
TryNode.prototype.type = 'Try';
|
||||
TryNode.prototype.make_return = function make_return() {
|
||||
if (this.attempt) {
|
||||
|
@ -1359,7 +1359,7 @@
|
|||
this.children = [(this.expression = expression)];
|
||||
return this;
|
||||
};
|
||||
__extend(ThrowNode, BaseNode);
|
||||
__extends(ThrowNode, BaseNode);
|
||||
ThrowNode.prototype.type = 'Throw';
|
||||
// A **ThrowNode** is already a return, of sorts...
|
||||
ThrowNode.prototype.make_return = function make_return() {
|
||||
|
@ -1380,7 +1380,7 @@
|
|||
this.children = [(this.expression = expression)];
|
||||
return this;
|
||||
};
|
||||
__extend(ExistenceNode, BaseNode);
|
||||
__extends(ExistenceNode, BaseNode);
|
||||
ExistenceNode.prototype.type = 'Existence';
|
||||
ExistenceNode.prototype.compile_node = function compile_node(o) {
|
||||
return ExistenceNode.compile_test(o, this.expression);
|
||||
|
@ -1415,7 +1415,7 @@
|
|||
this.children = [(this.expression = expression)];
|
||||
return this;
|
||||
};
|
||||
__extend(ParentheticalNode, BaseNode);
|
||||
__extends(ParentheticalNode, BaseNode);
|
||||
ParentheticalNode.prototype.type = 'Paren';
|
||||
ParentheticalNode.prototype.is_statement = function is_statement() {
|
||||
return this.expression.is_statement();
|
||||
|
@ -1467,7 +1467,7 @@
|
|||
this.returns = false;
|
||||
return this;
|
||||
};
|
||||
__extend(ForNode, BaseNode);
|
||||
__extends(ForNode, BaseNode);
|
||||
ForNode.prototype.type = 'For';
|
||||
ForNode.prototype.top_sensitive = function top_sensitive() {
|
||||
return true;
|
||||
|
@ -1571,7 +1571,7 @@
|
|||
}
|
||||
return this;
|
||||
};
|
||||
__extend(IfNode, BaseNode);
|
||||
__extends(IfNode, BaseNode);
|
||||
IfNode.prototype.type = 'If';
|
||||
// Add a new *else* clause to this **IfNode**, or push it down to the bottom
|
||||
// of the chain recursively.
|
||||
|
@ -1738,12 +1738,12 @@
|
|||
// Correctly set up a prototype chain for inheritance, including a reference
|
||||
// to the superclass for `super()` calls. See:
|
||||
// [goog.inherits](http://closure-library.googlecode.com/svn/docs/closure_goog_base.js.source.html#line1206)
|
||||
extend: "function(child, parent) {\n var ctor = function(){ };\n ctor.prototype = parent.prototype;\n child.__superClass__ = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n }",
|
||||
__extends: "function(child, parent) {\n var ctor = function(){ };\n ctor.prototype = parent.prototype;\n child.__superClass__ = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n }",
|
||||
// Bind a function to a calling context, optionally including curried arguments.
|
||||
// See [Underscore's implementation](http://jashkenas.github.com/coffee-script/documentation/docs/underscore.html#section-47)
|
||||
bind: "function(func, obj, args) {\n return function() {\n return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);\n };\n }",
|
||||
hasProp: 'Object.prototype.hasOwnProperty',
|
||||
slice: 'Array.prototype.slice'
|
||||
__bind: "function(func, obj, args) {\n return function() {\n return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);\n };\n }",
|
||||
__hasProp: 'Object.prototype.hasOwnProperty',
|
||||
__slice: 'Array.prototype.slice'
|
||||
};
|
||||
// Constants
|
||||
// ---------
|
||||
|
@ -1764,7 +1764,7 @@
|
|||
utility = function utility(name) {
|
||||
var ref;
|
||||
ref = "__" + name;
|
||||
Scope.root.assign(ref, UTILITIES[name]);
|
||||
Scope.root.assign(ref, UTILITIES[ref]);
|
||||
return ref;
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -436,7 +436,7 @@ exports.ExtendsNode: class ExtendsNode extends BaseNode
|
|||
|
||||
# Hooks one constructor into another's prototype chain.
|
||||
compile_node: (o) ->
|
||||
ref: new ValueNode literal utility 'extend'
|
||||
ref: new ValueNode literal utility 'extends'
|
||||
(new CallNode ref, [@child, @parent]).compile o
|
||||
|
||||
#### AccessorNode
|
||||
|
@ -1305,29 +1305,29 @@ UTILITIES: {
|
|||
# Correctly set up a prototype chain for inheritance, including a reference
|
||||
# to the superclass for `super()` calls. See:
|
||||
# [goog.inherits](http://closure-library.googlecode.com/svn/docs/closure_goog_base.js.source.html#line1206)
|
||||
extend: """
|
||||
function(child, parent) {
|
||||
var ctor = function(){ };
|
||||
ctor.prototype = parent.prototype;
|
||||
child.__superClass__ = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
child.prototype.constructor = child;
|
||||
}
|
||||
"""
|
||||
__extends: """
|
||||
function(child, parent) {
|
||||
var ctor = function(){ };
|
||||
ctor.prototype = parent.prototype;
|
||||
child.__superClass__ = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
child.prototype.constructor = child;
|
||||
}
|
||||
"""
|
||||
|
||||
# Bind a function to a calling context, optionally including curried arguments.
|
||||
# See [Underscore's implementation](http://jashkenas.github.com/coffee-script/documentation/docs/underscore.html#section-47)
|
||||
bind: """
|
||||
function(func, obj, args) {
|
||||
return function() {
|
||||
return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
|
||||
};
|
||||
}
|
||||
"""
|
||||
__bind: """
|
||||
function(func, obj, args) {
|
||||
return function() {
|
||||
return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
|
||||
};
|
||||
}
|
||||
"""
|
||||
|
||||
hasProp: 'Object.prototype.hasOwnProperty'
|
||||
__hasProp:'Object.prototype.hasOwnProperty'
|
||||
|
||||
slice: 'Array.prototype.slice'
|
||||
__slice: 'Array.prototype.slice'
|
||||
|
||||
}
|
||||
|
||||
|
@ -1354,5 +1354,5 @@ literal: (name) ->
|
|||
# Helper for ensuring that utility functions are assigned at the top level.
|
||||
utility: (name) ->
|
||||
ref: "__$name"
|
||||
Scope.root.assign ref, UTILITIES[name]
|
||||
Scope.root.assign ref, UTILITIES[ref]
|
||||
ref
|
||||
|
|
Loading…
Add table
Reference in a new issue