This commit is contained in:
Andrey Taritsyn 2015-01-09 09:12:21 +00:00
commit ad59a2ec28
6 changed files with 47 additions and 44 deletions

View File

@ -153,7 +153,7 @@ if (ARGS.r) {
var OUTPUT_OPTIONS = {
beautify: BEAUTIFY ? true : false,
preamble: ARGS.preamble || null,
preamble: ARGS.preamble || null
};
if (ARGS.screw_ie8) {
@ -234,7 +234,7 @@ var SOURCES_CONTENT = {};
var SOURCE_MAP = ARGS.source_map ? UglifyJS.SourceMap({
file: P_RELATIVE ? path.relative(path.dirname(ARGS.source_map), OUTPUT_FILE) : OUTPUT_FILE,
root: ARGS.source_map_root,
orig: ORIG_MAP,
orig: ORIG_MAP
}) : null;
OUTPUT_OPTIONS.source_map = SOURCE_MAP;
@ -287,7 +287,7 @@ async.eachLimit(files, 1, function (file, cb) {
filename : file,
toplevel : TOPLEVEL,
expression : ARGS.expr,
bare_returns : ARGS.bare_returns,
bare_returns : ARGS.bare_returns
});
} catch(ex) {
if (ex instanceof UglifyJS.JS_Parse_Error) {

View File

@ -113,11 +113,11 @@ AST_Node.warn = function(txt, props) {
/* -----[ statements ]----- */
var AST_Statement = DEFNODE("Statement", null, {
$documentation: "Base class of all statements",
$documentation: "Base class of all statements"
});
var AST_Debugger = DEFNODE("Debugger", null, {
$documentation: "Represents a debugger statement",
$documentation: "Represents a debugger statement"
}, AST_Statement);
var AST_Directive = DEFNODE("Directive", "value scope", {
@ -125,7 +125,7 @@ var AST_Directive = DEFNODE("Directive", "value scope", {
$propdoc: {
value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
scope: "[AST_Scope/S] The scope that this directive affects"
},
}
}, AST_Statement);
var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
@ -162,7 +162,7 @@ var AST_Block = DEFNODE("Block", "body", {
}, AST_Statement);
var AST_BlockStatement = DEFNODE("BlockStatement", null, {
$documentation: "A block statement",
$documentation: "A block statement"
}, AST_Block);
var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
@ -286,14 +286,14 @@ var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_
uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
parent_scope: "[AST_Scope?/S] link to the parent scope",
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
},
cname: "[integer/S] current index for mangling variables (used internally by the mangler)"
}
}, AST_Block);
var AST_Toplevel = DEFNODE("Toplevel", "globals", {
$documentation: "The toplevel scope",
$propdoc: {
globals: "[Object/S] a map of name -> SymbolDef for all undeclared names",
globals: "[Object/S] a map of name -> SymbolDef for all undeclared names"
},
wrap_enclose: function(arg_parameter_pairs) {
var self = this;
@ -343,11 +343,11 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
body: new AST_Assign({
left: new AST_Sub({
expression: new AST_SymbolRef({ name: "exports" }),
property: new AST_String({ value: sym.name }),
property: new AST_String({ value: sym.name })
}),
operator: "=",
right: new AST_SymbolRef(sym),
}),
right: new AST_SymbolRef(sym)
})
}));
});
return MAP.splice(body);
@ -417,7 +417,7 @@ var AST_Throw = DEFNODE("Throw", null, {
var AST_LoopControl = DEFNODE("LoopControl", "label", {
$documentation: "Base class for loop control statements (`break` and `continue`)",
$propdoc: {
label: "[AST_LabelRef?] the label, or null if none",
label: "[AST_LabelRef?] the label, or null if none"
},
_walk: function(visitor) {
return visitor._visit(this, this.label && function(){
@ -467,11 +467,11 @@ var AST_Switch = DEFNODE("Switch", "expression", {
}, AST_Block);
var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
$documentation: "Base class for `switch` branches",
$documentation: "Base class for `switch` branches"
}, AST_Block);
var AST_Default = DEFNODE("Default", null, {
$documentation: "A `default` switch branch",
$documentation: "A `default` switch branch"
}, AST_SwitchBranch);
var AST_Case = DEFNODE("Case", "expression", {
@ -720,7 +720,7 @@ var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative",
});
var AST_Assign = DEFNODE("Assign", null, {
$documentation: "An assignment expression — `a = b + 5`",
$documentation: "An assignment expression — `a = b + 5`"
}, AST_Binary);
/* -----[ LITERALS ]----- */
@ -767,15 +767,15 @@ var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
});
var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", null, {
$documentation: "A key: value object property",
$documentation: "A key: value object property"
}, AST_ObjectProperty);
var AST_ObjectSetter = DEFNODE("ObjectSetter", null, {
$documentation: "An object setter property",
$documentation: "An object setter property"
}, AST_ObjectProperty);
var AST_ObjectGetter = DEFNODE("ObjectGetter", null, {
$documentation: "An object getter property",
$documentation: "An object getter property"
}, AST_ObjectProperty);
var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
@ -784,7 +784,7 @@ var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
thedef: "[SymbolDef/S] the definition of this symbol"
},
$documentation: "Base class for all symbols",
$documentation: "Base class for all symbols"
});
var AST_SymbolAccessor = DEFNODE("SymbolAccessor", null, {
@ -799,7 +799,7 @@ var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
}, AST_Symbol);
var AST_SymbolVar = DEFNODE("SymbolVar", null, {
$documentation: "Symbol defining a variable",
$documentation: "Symbol defining a variable"
}, AST_SymbolDeclaration);
var AST_SymbolConst = DEFNODE("SymbolConst", null, {
@ -807,19 +807,19 @@ var AST_SymbolConst = DEFNODE("SymbolConst", null, {
}, AST_SymbolDeclaration);
var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
$documentation: "Symbol naming a function argument",
$documentation: "Symbol naming a function argument"
}, AST_SymbolVar);
var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
$documentation: "Symbol defining a function",
$documentation: "Symbol defining a function"
}, AST_SymbolDeclaration);
var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
$documentation: "Symbol naming a function expression",
$documentation: "Symbol naming a function expression"
}, AST_SymbolDeclaration);
var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
$documentation: "Symbol naming the exception in catch",
$documentation: "Symbol naming the exception in catch"
}, AST_SymbolDeclaration);
var AST_Label = DEFNODE("Label", "references", {
@ -834,15 +834,15 @@ var AST_Label = DEFNODE("Label", "references", {
}, AST_Symbol);
var AST_SymbolRef = DEFNODE("SymbolRef", null, {
$documentation: "Reference to some symbol (not definition/declaration)",
$documentation: "Reference to some symbol (not definition/declaration)"
}, AST_Symbol);
var AST_LabelRef = DEFNODE("LabelRef", null, {
$documentation: "Reference to a label symbol",
$documentation: "Reference to a label symbol"
}, AST_Symbol);
var AST_This = DEFNODE("This", null, {
$documentation: "The `this` symbol",
$documentation: "The `this` symbol"
}, AST_Symbol);
var AST_Constant = DEFNODE("Constant", null, {
@ -874,7 +874,7 @@ var AST_RegExp = DEFNODE("RegExp", "value", {
}, AST_Constant);
var AST_Atom = DEFNODE("Atom", null, {
$documentation: "Base class for atoms",
$documentation: "Base class for atoms"
}, AST_Constant);
var AST_Null = DEFNODE("Null", null, {
@ -903,7 +903,7 @@ var AST_Infinity = DEFNODE("Infinity", null, {
}, AST_Atom);
var AST_Boolean = DEFNODE("Boolean", null, {
$documentation: "Base class for booleans",
$documentation: "Base class for booleans"
}, AST_Atom);
var AST_False = DEFNODE("False", null, {

View File

@ -1350,7 +1350,7 @@ merge(Compressor.prototype, {
self.condition = make_node(AST_Binary, self.condition, {
left: self.condition,
operator: "&&",
right: first.condition.negate(compressor),
right: first.condition.negate(compressor)
});
} else {
self.condition = first.condition.negate(compressor);
@ -1363,7 +1363,7 @@ merge(Compressor.prototype, {
self.condition = make_node(AST_Binary, self.condition, {
left: self.condition,
operator: "&&",
right: first.condition,
right: first.condition
});
} else {
self.condition = first.condition;
@ -1820,7 +1820,7 @@ merge(Compressor.prototype, {
return make_node(AST_Binary, el[0], {
operator : "+",
left : prev,
right : el[0],
right : el[0]
});
}, first).transform(compressor);
}
@ -2369,7 +2369,7 @@ merge(Compressor.prototype, {
value : self.value,
file : p.start.file,
line : p.start.line,
col : p.start.col,
col : p.start.col
});
return make_node(AST_Number, self, {
value: +self.value

View File

@ -62,7 +62,7 @@ function OutputStream(options) {
comments : false,
preserve_line : false,
screw_ie8 : false,
preamble : null,
preamble : null
}, true);
var indentation = 0;
@ -187,13 +187,16 @@ function OutputStream(options) {
}
might_need_space = false;
}
var a = str.split(/\r?\n/), n = a.length - 1;
var a = str.split(/\r?\n/), len = a.length;
if (len > 0) {
var n = len - 1;
current_line += n;
if (n == 0) {
current_col += a[n].length;
} else {
current_col = a[n].length;
}
}
current_pos += str.length;
last = str;
OUTPUT += str;

View File

@ -617,7 +617,7 @@ function parse($TEXT, options) {
toplevel : null,
expression : false,
html5_comments : true,
bare_returns : false,
bare_returns : false
});
var S = {

View File

@ -51,7 +51,7 @@ function SourceMap(options) {
orig : null,
orig_line_diff : 0,
dest_line_diff : 0,
dest_line_diff : 0
});
var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
var generator;