chore: refactor arrows in comments
This commit is contained in:
parent
fd35571f37
commit
90f2fad8ea
|
|
@ -304,7 +304,7 @@ var AST_With = DEFNODE("With", "expression", {
|
||||||
var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
|
var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
|
||||||
$documentation: "Base class for all statements introducing a lexical scope",
|
$documentation: "Base class for all statements introducing a lexical scope",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
|
variables: "[Object/S] a map of name ---> SymbolDef for all variables/functions defined in this scope",
|
||||||
functions: "[Object/S] like `variables`, but only lists function declarations",
|
functions: "[Object/S] like `variables`, but only lists function declarations",
|
||||||
uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
|
uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
|
||||||
uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
|
uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
|
||||||
|
|
@ -331,7 +331,7 @@ var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent
|
||||||
var AST_Toplevel = DEFNODE("Toplevel", "globals", {
|
var AST_Toplevel = DEFNODE("Toplevel", "globals", {
|
||||||
$documentation: "The toplevel scope",
|
$documentation: "The toplevel scope",
|
||||||
$propdoc: {
|
$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_commonjs: function(name) {
|
wrap_commonjs: function(name) {
|
||||||
var body = this.body;
|
var body = this.body;
|
||||||
|
|
|
||||||
|
|
@ -1625,7 +1625,7 @@ merge(Compressor.prototype, {
|
||||||
var value = stat.body.value;
|
var value = stat.body.value;
|
||||||
//---
|
//---
|
||||||
// pretty silly case, but:
|
// pretty silly case, but:
|
||||||
// if (foo()) return; return; ==> foo(); return;
|
// if (foo()) return; return; ---> foo(); return;
|
||||||
if (!value && !stat.alternative
|
if (!value && !stat.alternative
|
||||||
&& (in_lambda && !next || next instanceof AST_Return && !next.value)) {
|
&& (in_lambda && !next || next instanceof AST_Return && !next.value)) {
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
|
|
@ -1635,7 +1635,7 @@ merge(Compressor.prototype, {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//---
|
//---
|
||||||
// if (foo()) return x; return y; ==> return foo() ? x : y;
|
// if (foo()) return x; return y; ---> return foo() ? x : y;
|
||||||
if (value && !stat.alternative && next instanceof AST_Return && next.value) {
|
if (value && !stat.alternative && next instanceof AST_Return && next.value) {
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
stat = stat.clone();
|
stat = stat.clone();
|
||||||
|
|
@ -1645,7 +1645,7 @@ merge(Compressor.prototype, {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//---
|
//---
|
||||||
// if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
|
// if (foo()) return x; [ return ; ] ---> return foo() ? x : undefined;
|
||||||
if (value && !stat.alternative
|
if (value && !stat.alternative
|
||||||
&& (!next && in_lambda && multiple_if_returns
|
&& (!next && in_lambda && multiple_if_returns
|
||||||
|| next instanceof AST_Return)) {
|
|| next instanceof AST_Return)) {
|
||||||
|
|
@ -1659,7 +1659,7 @@ merge(Compressor.prototype, {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//---
|
//---
|
||||||
// if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
|
// if (a) return b; if (c) return d; e; ---> return a ? b : c ? d : void e;
|
||||||
//
|
//
|
||||||
// if sequences is not enabled, this can lead to an endless loop (issue #866).
|
// if sequences is not enabled, this can lead to an endless loop (issue #866).
|
||||||
// however, with sequences on this helps producing slightly better output for
|
// however, with sequences on this helps producing slightly better output for
|
||||||
|
|
@ -4992,7 +4992,7 @@ merge(Compressor.prototype, {
|
||||||
switch (self.operator) {
|
switch (self.operator) {
|
||||||
case "!":
|
case "!":
|
||||||
if (e instanceof AST_UnaryPrefix && e.operator == "!") {
|
if (e instanceof AST_UnaryPrefix && e.operator == "!") {
|
||||||
// !!foo ==> foo, if we're in boolean context
|
// !!foo ---> foo, if we're in boolean context
|
||||||
return e.expression;
|
return e.expression;
|
||||||
}
|
}
|
||||||
if (e instanceof AST_Binary) {
|
if (e instanceof AST_Binary) {
|
||||||
|
|
@ -5480,9 +5480,9 @@ merge(Compressor.prototype, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x && (y && z) ==> x && y && z
|
// x && (y && z) ---> x && y && z
|
||||||
// x || (y || z) ==> x || y || z
|
// x || (y || z) ---> x || y || z
|
||||||
// x + ("y" + z) ==> x + "y" + z
|
// x + ("y" + z) ---> x + "y" + z
|
||||||
// "x" + (y + "z")==> "x" + y + "z"
|
// "x" + (y + "z")==> "x" + y + "z"
|
||||||
if (self.right instanceof AST_Binary
|
if (self.right instanceof AST_Binary
|
||||||
&& self.right.operator == self.operator
|
&& self.right.operator == self.operator
|
||||||
|
|
|
||||||
|
|
@ -761,13 +761,13 @@ function OutputStream(options) {
|
||||||
var p = output.parent();
|
var p = output.parent();
|
||||||
return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
|
return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
|
||||||
|| p instanceof AST_Unary // !(foo, bar, baz)
|
|| p instanceof AST_Unary // !(foo, bar, baz)
|
||||||
|| p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
|
|| p instanceof AST_Binary // 1 + (2, 3) + 4 ---> 8
|
||||||
|| p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
|
|| p instanceof AST_VarDef // var a = (1, 2), b = a + a; ---> b == 4
|
||||||
|| p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
|
|| p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ---> 2
|
||||||
|| p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
|
|| p instanceof AST_Array // [ 1, (2, 3), 4 ] ---> [ 1, 3, 4 ]
|
||||||
|| p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
|
|| p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ---> 2
|
||||||
|| p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
|
|| p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
|
||||||
* ==> 20 (side effect, set a := 10 and b := 20) */
|
* ---> 20 (side effect, set a := 10 and b := 20) */
|
||||||
|| p instanceof AST_Arrow // x => (x, x)
|
|| p instanceof AST_Arrow // x => (x, x)
|
||||||
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
||||||
|| p instanceof AST_Expansion // [...(a, b)]
|
|| p instanceof AST_Expansion // [...(a, b)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user