chore: refactor arrows in comments

This commit is contained in:
Mark Vayngrib 2023-10-31 14:36:46 +08:00
parent fd35571f37
commit 90f2fad8ea
No known key found for this signature in database
GPG Key ID: AA48332BE2806A28
3 changed files with 16 additions and 16 deletions

View File

@ -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", {
$documentation: "Base class for all statements introducing a lexical scope",
$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",
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`",
@ -331,7 +331,7 @@ var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent
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_commonjs: function(name) {
var body = this.body;

View File

@ -1625,7 +1625,7 @@ merge(Compressor.prototype, {
var value = stat.body.value;
//---
// pretty silly case, but:
// if (foo()) return; return; ==> foo(); return;
// if (foo()) return; return; ---> foo(); return;
if (!value && !stat.alternative
&& (in_lambda && !next || next instanceof AST_Return && !next.value)) {
CHANGED = true;
@ -1635,7 +1635,7 @@ merge(Compressor.prototype, {
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) {
CHANGED = true;
stat = stat.clone();
@ -1645,7 +1645,7 @@ merge(Compressor.prototype, {
continue;
}
//---
// if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
// if (foo()) return x; [ return ; ] ---> return foo() ? x : undefined;
if (value && !stat.alternative
&& (!next && in_lambda && multiple_if_returns
|| next instanceof AST_Return)) {
@ -1659,7 +1659,7 @@ merge(Compressor.prototype, {
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).
// however, with sequences on this helps producing slightly better output for
@ -4992,7 +4992,7 @@ merge(Compressor.prototype, {
switch (self.operator) {
case "!":
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;
}
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"
if (self.right instanceof AST_Binary
&& self.right.operator == self.operator

View File

@ -761,13 +761,13 @@ function OutputStream(options) {
var p = output.parent();
return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
|| p instanceof AST_Unary // !(foo, bar, baz)
|| 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_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_ObjectProperty // { foo: (1, 2) }.foo ==> 2
|| 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_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_ObjectProperty // { foo: (1, 2) }.foo ---> 2
|| 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_DefaultAssign // x => (x = (0, function(){}))
|| p instanceof AST_Expansion // [...(a, b)]