This commit is contained in:
Leandro Ostera 2013-11-08 18:39:16 -08:00
commit bf87eb4b4d
9 changed files with 33 additions and 31 deletions

View File

@ -43,7 +43,7 @@
"use strict";
function DEFNODE(type, props, methods, base) {
var DEFNODE = function DEFNODE(type, props, methods, base) {
if (arguments.length < 4) base = AST_Node;
if (!props) props = [];
else props = props.split(/\s+/);
@ -918,7 +918,7 @@ var AST_True = DEFNODE("True", null, {
/* -----[ TreeWalker ]----- */
function TreeWalker(callback) {
var TreeWalker = function TreeWalker(callback) {
this.visit = callback;
this.stack = [];
};

View File

@ -43,7 +43,7 @@
"use strict";
function Compressor(options, false_by_default) {
var Compressor = function Compressor(options, false_by_default) {
if (!(this instanceof Compressor))
return new Compressor(options, false_by_default);
TreeTransformer.call(this, this.before, this.after);

View File

@ -43,7 +43,7 @@
"use strict";
function OutputStream(options) {
var OutputStream = function OutputStream(options) {
options = defaults(options, {
indent_start : 0,

View File

@ -608,7 +608,9 @@ var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "nam
/* -----[ Parser ]----- */
function parse($TEXT, options) {
var parse = function parse($TEXT, options) {
options = defaults(options, {
strict : false,
@ -1454,4 +1456,4 @@ function parse($TEXT, options) {
return toplevel;
})();
};
};

View File

@ -43,7 +43,7 @@
"use strict";
function SymbolDef(scope, index, orig) {
var SymbolDef = function SymbolDef(scope, index, orig) {
this.name = orig.name;
this.orig = [ orig ];
this.scope = scope;

View File

@ -44,7 +44,7 @@
"use strict";
// a small wrapper around fitzgen's source-map library
function SourceMap(options) {
var SourceMap = function SourceMap(options) {
options = defaults(options, {
file : null,
root : null,
@ -78,4 +78,4 @@ function SourceMap(options) {
get : function() { return generator },
toString : function() { return generator.toString() }
};
};
};

View File

@ -45,7 +45,7 @@
// Tree transformer helpers.
function TreeTransformer(before, after) {
var TreeTransformer = function TreeTransformer(before, after) {
TreeWalker.call(this);
this.before = before;
this.after = after;
@ -215,4 +215,4 @@ TreeTransformer.prototype = new TreeWalker;
self.value = self.value.transform(tw);
});
})();
})();

View File

@ -43,36 +43,36 @@
"use strict";
function array_to_hash(a) {
var array_to_hash = function array_to_hash(a) {
var ret = Object.create(null);
for (var i = 0; i < a.length; ++i)
ret[a[i]] = true;
return ret;
};
function slice(a, start) {
var slice = function slice(a, start) {
return Array.prototype.slice.call(a, start || 0);
};
function characters(str) {
var characters = function characters(str) {
return str.split("");
};
function member(name, array) {
var member = function member(name, array) {
for (var i = array.length; --i >= 0;)
if (array[i] == name)
return true;
return false;
};
function find_if(func, array) {
var find_if = function find_if(func, array) {
for (var i = 0, n = array.length; i < n; ++i) {
if (func(array[i]))
return array[i];
}
};
function repeat_string(str, i) {
var repeat_string = function repeat_string(str, i) {
if (i <= 0) return "";
if (i == 1) return str;
var d = repeat_string(str, i >> 1);
@ -81,12 +81,12 @@ function repeat_string(str, i) {
return d;
};
function DefaultsError(msg, defs) {
var DefaultsError = function DefaultsError(msg, defs) {
this.msg = msg;
this.defs = defs;
};
function defaults(args, defs, croak) {
var defaults = function defaults(args, defs, croak) {
if (args === true)
args = {};
var ret = args || {};
@ -98,14 +98,14 @@ function defaults(args, defs, croak) {
return ret;
};
function merge(obj, ext) {
var merge = function merge(obj, ext) {
for (var i in ext) if (ext.hasOwnProperty(i)) {
obj[i] = ext[i];
}
return obj;
};
function noop() {};
var noop = function noop() {};
var MAP = (function(){
function MAP(a, f, backwards) {
@ -155,24 +155,24 @@ var MAP = (function(){
return MAP;
})();
function push_uniq(array, el) {
var push_uniq = function push_uniq(array, el) {
if (array.indexOf(el) < 0)
array.push(el);
};
function string_template(text, props) {
var string_template = function string_template(text, props) {
return text.replace(/\{(.+?)\}/g, function(str, p){
return props[p];
});
};
function remove(array, el) {
var remove = function remove(array, el) {
for (var i = array.length; --i >= 0;) {
if (array[i] === el) array.splice(i, 1);
}
};
function mergeSort(array, cmp) {
var mergeSort = function mergeSort(array, cmp) {
if (array.length < 2) return array.slice();
function merge(a, b) {
var r = [], ai = 0, bi = 0, i = 0;
@ -196,13 +196,13 @@ function mergeSort(array, cmp) {
return _ms(array);
};
function set_difference(a, b) {
var set_difference = function set_difference(a, b) {
return a.filter(function(el){
return b.indexOf(el) < 0;
});
};
function set_intersection(a, b) {
var set_intersection = function set_intersection(a, b) {
return a.filter(function(el){
return b.indexOf(el) >= 0;
});
@ -210,7 +210,7 @@ function set_intersection(a, b) {
// this function is taken from Acorn [1], written by Marijn Haverbeke
// [1] https://github.com/marijnh/acorn
function makePredicate(words) {
var makePredicate = function makePredicate(words) {
if (!(words instanceof Array)) words = words.split(" ");
var f = "", cats = [];
out: for (var i = 0; i < words.length; ++i) {
@ -245,14 +245,14 @@ function makePredicate(words) {
return new Function("str", f);
};
function all(array, predicate) {
var all = function all(array, predicate) {
for (var i = array.length; --i >= 0;)
if (!predicate(array[i]))
return false;
return true;
};
function Dictionary() {
var Dictionary = function Dictionary() {
this._values = Object.create(null);
this._size = 0;
};

View File

@ -25,7 +25,7 @@ function tmpl() {
function log() {
var txt = tmpl.apply(this, arguments);
sys.puts(txt);
console.log(txt);
}
function log_directory(dir) {