@markw65/monkeyc-optimizer 1.1.19 → 1.1.20

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.
package/README.md CHANGED
@@ -784,3 +784,12 @@ Bug Fixes
784
784
  - better optimization for arrays whose elements are all initialized to the same value (eg `[42, 42, 42, 42]`)
785
785
  - more efficient tests for symbols in case statements (ie `case: :foo`)
786
786
  - parallelize the post build optimizer when exporting a project
787
+
788
+ ### 1.1.20
789
+
790
+ - Bug fixes
791
+
792
+ - Fix a bug that could cause the optimizer to incorrectly substitute one local for another.
793
+
794
+ - Optimizations
795
+ - Improve dce in the post build optimizer a little, by computing which locals are live out of each block.
package/build/api.cjs CHANGED
@@ -18,42 +18,42 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var api_exports = {};
20
20
  __export(api_exports, {
21
- checkCompilerVersion: () => import_chunk_O5LFMOIG.checkCompilerVersion,
22
- collectNamespaces: () => import_chunk_O5LFMOIG.collectNamespaces,
23
- createDocumentationMap: () => import_chunk_O5LFMOIG.createDocumentationMap,
24
- diagnostic: () => import_chunk_O5LFMOIG.diagnostic,
25
- diagnosticHelper: () => import_chunk_O5LFMOIG.diagnosticHelper,
26
- findNamesInScope: () => import_chunk_O5LFMOIG.findNamesInScope,
27
- findUsingForNode: () => import_chunk_O5LFMOIG.findUsingForNode,
28
- formatAst: () => import_chunk_O5LFMOIG.formatAst,
29
- formatAstLongLines: () => import_chunk_O5LFMOIG.formatAstLongLines,
30
- getApiFunctionInfo: () => import_chunk_O5LFMOIG.getApiFunctionInfo,
31
- getApiMapping: () => import_chunk_O5LFMOIG.getApiMapping,
32
- getSuperClasses: () => import_chunk_O5LFMOIG.getSuperClasses,
33
- hasProperty: () => import_chunk_O5LFMOIG.hasProperty,
34
- isClassVariable: () => import_chunk_O5LFMOIG.isClassVariable,
35
- isLocal: () => import_chunk_O5LFMOIG.isLocal,
36
- isLookupCandidate: () => import_chunk_O5LFMOIG.isLookupCandidate,
37
- isStateNode: () => import_chunk_O5LFMOIG.isStateNode,
38
- lookupByFullName: () => import_chunk_O5LFMOIG.lookupByFullName,
39
- lookupNext: () => import_chunk_O5LFMOIG.lookupNext,
40
- lookupResultContains: () => import_chunk_O5LFMOIG.lookupResultContains,
41
- lookupWithType: () => import_chunk_O5LFMOIG.lookupWithType,
42
- makeToyboxLink: () => import_chunk_O5LFMOIG.makeToyboxLink,
43
- mapVarDeclsByType: () => import_chunk_O5LFMOIG.mapVarDeclsByType,
44
- markInvokeClassMethod: () => import_chunk_O5LFMOIG.markInvokeClassMethod,
45
- parseSdkVersion: () => import_chunk_O5LFMOIG.parseSdkVersion,
46
- sameLookupResult: () => import_chunk_O5LFMOIG.sameLookupResult,
47
- traverseAst: () => import_chunk_O5LFMOIG.traverseAst,
48
- variableDeclarationName: () => import_chunk_O5LFMOIG.variableDeclarationName,
49
- visitReferences: () => import_chunk_O5LFMOIG.visitReferences,
50
- visit_resources: () => import_chunk_O5LFMOIG.visit_resources,
51
- visitorNode: () => import_chunk_O5LFMOIG.visitorNode
21
+ checkCompilerVersion: () => import_chunk_DCGJCC63.checkCompilerVersion,
22
+ collectNamespaces: () => import_chunk_DCGJCC63.collectNamespaces,
23
+ createDocumentationMap: () => import_chunk_DCGJCC63.createDocumentationMap,
24
+ diagnostic: () => import_chunk_DCGJCC63.diagnostic,
25
+ diagnosticHelper: () => import_chunk_DCGJCC63.diagnosticHelper,
26
+ findNamesInScope: () => import_chunk_DCGJCC63.findNamesInScope,
27
+ findUsingForNode: () => import_chunk_DCGJCC63.findUsingForNode,
28
+ formatAst: () => import_chunk_DCGJCC63.formatAst,
29
+ formatAstLongLines: () => import_chunk_DCGJCC63.formatAstLongLines,
30
+ getApiFunctionInfo: () => import_chunk_DCGJCC63.getApiFunctionInfo,
31
+ getApiMapping: () => import_chunk_DCGJCC63.getApiMapping,
32
+ getSuperClasses: () => import_chunk_DCGJCC63.getSuperClasses,
33
+ hasProperty: () => import_chunk_DCGJCC63.hasProperty,
34
+ isClassVariable: () => import_chunk_DCGJCC63.isClassVariable,
35
+ isLocal: () => import_chunk_DCGJCC63.isLocal,
36
+ isLookupCandidate: () => import_chunk_DCGJCC63.isLookupCandidate,
37
+ isStateNode: () => import_chunk_DCGJCC63.isStateNode,
38
+ lookupByFullName: () => import_chunk_DCGJCC63.lookupByFullName,
39
+ lookupNext: () => import_chunk_DCGJCC63.lookupNext,
40
+ lookupResultContains: () => import_chunk_DCGJCC63.lookupResultContains,
41
+ lookupWithType: () => import_chunk_DCGJCC63.lookupWithType,
42
+ makeToyboxLink: () => import_chunk_DCGJCC63.makeToyboxLink,
43
+ mapVarDeclsByType: () => import_chunk_DCGJCC63.mapVarDeclsByType,
44
+ markInvokeClassMethod: () => import_chunk_DCGJCC63.markInvokeClassMethod,
45
+ parseSdkVersion: () => import_chunk_DCGJCC63.parseSdkVersion,
46
+ sameLookupResult: () => import_chunk_DCGJCC63.sameLookupResult,
47
+ traverseAst: () => import_chunk_DCGJCC63.traverseAst,
48
+ variableDeclarationName: () => import_chunk_DCGJCC63.variableDeclarationName,
49
+ visitReferences: () => import_chunk_DCGJCC63.visitReferences,
50
+ visit_resources: () => import_chunk_DCGJCC63.visit_resources,
51
+ visitorNode: () => import_chunk_DCGJCC63.visitorNode
52
52
  });
53
53
  module.exports = __toCommonJS(api_exports);
54
- var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
55
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
56
- (0, import_chunk_O5LFMOIG.init_api)();
54
+ var import_chunk_DCGJCC63 = require("./chunk-DCGJCC63.cjs");
55
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
56
+ (0, import_chunk_DCGJCC63.init_api)();
57
57
  // Annotate the CommonJS export names for ESM import in node:
58
58
  0 && (module.exports = {
59
59
  checkCompilerVersion,
@@ -26,8 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_IAUHYWVN_exports = {};
30
- __export(chunk_IAUHYWVN_exports, {
29
+ var chunk_APACX34C_exports = {};
30
+ __export(chunk_APACX34C_exports, {
31
+ GenericQueue: () => GenericQueue,
31
32
  __commonJS: () => __commonJS,
32
33
  __esm: () => __esm,
33
34
  __export: () => __export2,
@@ -56,7 +57,7 @@ __export(chunk_IAUHYWVN_exports, {
56
57
  spawnByLine: () => spawnByLine,
57
58
  wouldLog: () => wouldLog
58
59
  });
59
- module.exports = __toCommonJS(chunk_IAUHYWVN_exports);
60
+ module.exports = __toCommonJS(chunk_APACX34C_exports);
60
61
  var child_process = __toESM(require("child_process"));
61
62
  var fsc = __toESM(require("fs"));
62
63
  var fs = __toESM(require("fs/promises"));
@@ -5372,6 +5373,85 @@ var require_out4 = __commonJS({
5372
5373
  module2.exports = FastGlob;
5373
5374
  }
5374
5375
  });
5376
+ var require_priorityqueuejs = __commonJS({
5377
+ "node_modules/priorityqueuejs/index.js"(exports, module2) {
5378
+ module2.exports = PriorityQueue2;
5379
+ function PriorityQueue2(comparator) {
5380
+ this._comparator = comparator || PriorityQueue2.DEFAULT_COMPARATOR;
5381
+ this._elements = [];
5382
+ }
5383
+ PriorityQueue2.DEFAULT_COMPARATOR = function(a, b) {
5384
+ if (typeof a === "number" && typeof b === "number") {
5385
+ return a - b;
5386
+ } else {
5387
+ a = a.toString();
5388
+ b = b.toString();
5389
+ if (a == b)
5390
+ return 0;
5391
+ return a > b ? 1 : -1;
5392
+ }
5393
+ };
5394
+ PriorityQueue2.prototype.isEmpty = function() {
5395
+ return this.size() === 0;
5396
+ };
5397
+ PriorityQueue2.prototype.peek = function() {
5398
+ if (this.isEmpty())
5399
+ throw new Error("PriorityQueue is empty");
5400
+ return this._elements[0];
5401
+ };
5402
+ PriorityQueue2.prototype.deq = function() {
5403
+ var first = this.peek();
5404
+ var last = this._elements.pop();
5405
+ var size = this.size();
5406
+ if (size === 0)
5407
+ return first;
5408
+ this._elements[0] = last;
5409
+ var current = 0;
5410
+ while (current < size) {
5411
+ var largest = current;
5412
+ var left = 2 * current + 1;
5413
+ var right = 2 * current + 2;
5414
+ if (left < size && this._compare(left, largest) >= 0) {
5415
+ largest = left;
5416
+ }
5417
+ if (right < size && this._compare(right, largest) >= 0) {
5418
+ largest = right;
5419
+ }
5420
+ if (largest === current)
5421
+ break;
5422
+ this._swap(largest, current);
5423
+ current = largest;
5424
+ }
5425
+ return first;
5426
+ };
5427
+ PriorityQueue2.prototype.enq = function(element) {
5428
+ var size = this._elements.push(element);
5429
+ var current = size - 1;
5430
+ while (current > 0) {
5431
+ var parent = Math.floor((current - 1) / 2);
5432
+ if (this._compare(current, parent) <= 0)
5433
+ break;
5434
+ this._swap(parent, current);
5435
+ current = parent;
5436
+ }
5437
+ return size;
5438
+ };
5439
+ PriorityQueue2.prototype.size = function() {
5440
+ return this._elements.length;
5441
+ };
5442
+ PriorityQueue2.prototype.forEach = function(fn) {
5443
+ return this._elements.forEach(fn);
5444
+ };
5445
+ PriorityQueue2.prototype._compare = function(a, b) {
5446
+ return this._comparator(this._elements[a], this._elements[b]);
5447
+ };
5448
+ PriorityQueue2.prototype._swap = function(a, b) {
5449
+ var aux = this._elements[a];
5450
+ this._elements[a] = this._elements[b];
5451
+ this._elements[b] = aux;
5452
+ };
5453
+ }
5454
+ });
5375
5455
  function logger(module2, level, message) {
5376
5456
  if (wouldLog(module2, level)) {
5377
5457
  log(message);
@@ -5630,11 +5710,33 @@ function popcount(x) {
5630
5710
  x += x >> 16;
5631
5711
  return x & 127;
5632
5712
  }
5633
- var import_fast_glob;
5713
+ var import_fast_glob, import_priorityqueuejs, GenericQueue;
5634
5714
  var init_util = __esm({
5635
5715
  "src/util.ts"() {
5636
5716
  import_fast_glob = __toESM2(require_out4());
5717
+ import_priorityqueuejs = __toESM2(require_priorityqueuejs());
5637
5718
  init_logger();
5719
+ GenericQueue = class {
5720
+ enqueued = /* @__PURE__ */ new Set();
5721
+ queue;
5722
+ constructor(sort) {
5723
+ this.queue = new import_priorityqueuejs.default(sort);
5724
+ }
5725
+ enqueue(block) {
5726
+ if (!this.enqueued.has(block)) {
5727
+ this.enqueued.add(block);
5728
+ this.queue.enq(block);
5729
+ }
5730
+ }
5731
+ dequeue() {
5732
+ const block = this.queue.deq();
5733
+ this.enqueued.delete(block);
5734
+ return block;
5735
+ }
5736
+ empty() {
5737
+ return this.queue.isEmpty();
5738
+ }
5739
+ };
5638
5740
  }
5639
5741
  });
5640
5742
  /*! Bundled license information:
@@ -5687,6 +5789,7 @@ run-parallel/index.js:
5687
5789
  */
5688
5790
  // Annotate the CommonJS export names for ESM import in node:
5689
5791
  0 && (module.exports = {
5792
+ GenericQueue,
5690
5793
  __commonJS,
5691
5794
  __esm,
5692
5795
  __export,