storm-lua-minify 0.3.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +119 -41
  2. package/dist/aggregateSpecialization.js +406 -0
  3. package/dist/ast2lua.js +156 -68
  4. package/dist/astWalk.js +162 -0
  5. package/dist/callGraph.js +372 -0
  6. package/dist/cli.js +53 -58
  7. package/dist/cliOptions.js +36 -0
  8. package/dist/cliProgress.js +87 -0
  9. package/dist/config.js +73 -0
  10. package/dist/constantFold.js +798 -0
  11. package/dist/controlFlow.js +266 -0
  12. package/dist/functionRewrites.js +580 -0
  13. package/dist/generatedAst.js +108 -0
  14. package/dist/generatedNode.js +23 -0
  15. package/dist/globalRename.js +17 -4
  16. package/dist/interproceduralAnalysis.js +842 -0
  17. package/dist/interproceduralConstants.js +120 -0
  18. package/dist/luaString.js +157 -0
  19. package/dist/minifier.js +1219 -49
  20. package/dist/optimizerAnalysis.js +43 -0
  21. package/dist/optimizerDiagnostics.js +65 -0
  22. package/dist/optimizerFacts.js +529 -0
  23. package/dist/optimizerPass.js +96 -0
  24. package/dist/optimizerTransaction.js +56 -0
  25. package/dist/optimizerValueDomain.js +200 -0
  26. package/dist/options.js +233 -0
  27. package/dist/progress.js +2 -0
  28. package/dist/removeUnused.js +145 -0
  29. package/dist/renamer.js +280 -54
  30. package/dist/resolver.js +35 -11
  31. package/dist/runtimeEnvironment.js +105 -0
  32. package/dist/sourceMetadata.js +314 -0
  33. package/dist/statementDataflow.js +259 -0
  34. package/dist/statementScheduler.js +598 -0
  35. package/dist/symbolLiveness.js +92 -0
  36. package/dist/tableEffects.js +356 -0
  37. package/dist/transform.js +10 -371
  38. package/dist/valueFlow.js +409 -0
  39. package/dist/wholeProgramExports.js +646 -0
  40. package/dist/wholeProgramFieldRenames.js +583 -0
  41. package/dist/wholeProgramFields.js +672 -0
  42. package/dist/wholeProgramObjects.js +783 -0
  43. package/package.json +11 -2
  44. package/dist/index.js +0 -27
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyNodeOrigin = copyNodeOrigin;
4
+ exports.identifierWithOrigin = identifierWithOrigin;
5
+ function rangeOf(node) {
6
+ return node.range;
7
+ }
8
+ /** 合成・複製したAST nodeへSource Map上の由来位置を引き継ぐ。 */
9
+ function copyNodeOrigin(node, origin) {
10
+ node.loc = origin.loc;
11
+ const range = rangeOf(origin);
12
+ if (range) {
13
+ node.range = range;
14
+ }
15
+ }
16
+ function identifierWithOrigin(origin) {
17
+ const identifier = {
18
+ type: "Identifier",
19
+ name: origin.name,
20
+ };
21
+ copyNodeOrigin(identifier, origin);
22
+ return identifier;
23
+ }
@@ -1,16 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectProgramWrittenGlobals = collectProgramWrittenGlobals;
3
4
  exports.classifyAndRenameGlobals = classifyAndRenameGlobals;
4
5
  const renamer_1 = require("./renamer");
5
6
  const linker_1 = require("./linker");
7
+ /**
8
+ * Returns names whose shared global binding is written by any linked module.
9
+ * A module that only reads one of these names must not mistake it for a
10
+ * read-only value supplied by the runtime environment.
11
+ */
12
+ function collectProgramWrittenGlobals(moduleResolve) {
13
+ const written = new Set();
14
+ moduleResolve.forEach((resolved) => {
15
+ resolved.globals.forEach((binding) => {
16
+ if (binding.writes.length > 0)
17
+ written.add(binding.name);
18
+ });
19
+ });
20
+ return written;
21
+ }
6
22
  function classifyAndRenameGlobals(moduleResolve, neverRename, reserved) {
7
- const everWritten = new Set();
23
+ const everWritten = collectProgramWrittenGlobals(moduleResolve);
8
24
  const totalReferenceCount = new Map();
9
25
  moduleResolve.forEach((resolved) => {
10
26
  resolved.globals.forEach((binding) => {
11
- if (binding.writes.length > 0) {
12
- everWritten.add(binding.name);
13
- }
14
27
  totalReferenceCount.set(binding.name, (totalReferenceCount.get(binding.name) ?? 0) +
15
28
  binding.references.length);
16
29
  });