@markw65/monkeyc-optimizer 1.0.27 → 1.0.28

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
@@ -298,3 +298,8 @@ More fixes found via open source projects.
298
298
  - Bug fixes
299
299
  - Update to `@markw65/prettier-plugin-monkeyc@1.0.29` to fix certain obscure comment related bugs
300
300
  - When replacing a node (espcially when inlining), delete any comments contained in the old node.
301
+
302
+ ### 1.0.28
303
+
304
+ - Bug fixes
305
+ - In some circumstances, while inlining, a parameter could be substituted, and then reprocessed. During reprocessing, it would attempt to lookup the replacement symbol, and if that was a local from the calling function it would fail (since an inline function never has access to the caller's locals). Prevent the reprocessing step from happening.
package/build/api.cjs CHANGED
@@ -463,6 +463,7 @@ function processInlineBody(state, func, call, root, params) {
463
463
  const post = state.post;
464
464
  state.inlining = true;
465
465
  let insertedVariableDecls = null;
466
+ const replacements = new Set();
466
467
  try {
467
468
  state.pre = (node) => {
468
469
  if (failed)
@@ -470,7 +471,7 @@ function processInlineBody(state, func, call, root, params) {
470
471
  node.start = call.start;
471
472
  node.end = call.end;
472
473
  node.loc = call.loc;
473
- if (node === insertedVariableDecls)
474
+ if (replacements.has(node))
474
475
  return false;
475
476
  const result = pre(node, state);
476
477
  if (!insertedVariableDecls && node.type === "BlockStatement") {
@@ -498,6 +499,7 @@ function processInlineBody(state, func, call, root, params) {
498
499
  kind: "var",
499
500
  };
500
501
  node.body.unshift(insertedVariableDecls);
502
+ replacements.add(insertedVariableDecls);
501
503
  }
502
504
  return result;
503
505
  };
@@ -513,6 +515,8 @@ function processInlineBody(state, func, call, root, params) {
513
515
  const ix = params[node.name];
514
516
  if (ix >= 0) {
515
517
  replacement = call.arguments[ix];
518
+ replacements.add(replacement);
519
+ return replacement;
516
520
  }
517
521
  break;
518
522
  }
@@ -11187,6 +11187,7 @@ function processInlineBody(state, func, call, root, params) {
11187
11187
  const post = state.post;
11188
11188
  state.inlining = true;
11189
11189
  let insertedVariableDecls = null;
11190
+ const replacements = new Set();
11190
11191
  try {
11191
11192
  state.pre = (node) => {
11192
11193
  if (failed)
@@ -11194,7 +11195,7 @@ function processInlineBody(state, func, call, root, params) {
11194
11195
  node.start = call.start;
11195
11196
  node.end = call.end;
11196
11197
  node.loc = call.loc;
11197
- if (node === insertedVariableDecls)
11198
+ if (replacements.has(node))
11198
11199
  return false;
11199
11200
  const result = pre(node, state);
11200
11201
  if (!insertedVariableDecls && node.type === "BlockStatement") {
@@ -11222,6 +11223,7 @@ function processInlineBody(state, func, call, root, params) {
11222
11223
  kind: "var",
11223
11224
  };
11224
11225
  node.body.unshift(insertedVariableDecls);
11226
+ replacements.add(insertedVariableDecls);
11225
11227
  }
11226
11228
  return result;
11227
11229
  };
@@ -11237,6 +11239,8 @@ function processInlineBody(state, func, call, root, params) {
11237
11239
  const ix = params[node.name];
11238
11240
  if (ix >= 0) {
11239
11241
  replacement = call.arguments[ix];
11242
+ replacements.add(replacement);
11243
+ return replacement;
11240
11244
  }
11241
11245
  break;
11242
11246
  }
@@ -13105,7 +13109,7 @@ async function generateOneConfig(buildConfig, dependencyFiles, config) {
13105
13109
  // the oldest optimized file, we don't need to regenerate
13106
13110
  const source_time = await (0,external_util_cjs_namespaceObject.last_modified)(Object.keys(fnMap).concat(dependencyFiles));
13107
13111
  const opt_time = await (0,external_util_cjs_namespaceObject.first_modified)(Object.values(fnMap).map((v) => v.output));
13108
- if (source_time < opt_time && 1655851904193 < opt_time) {
13112
+ if (source_time < opt_time && 1655916886685 < opt_time) {
13109
13113
  return { hasTests, diagnostics: prevDiagnostics };
13110
13114
  }
13111
13115
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.0.27",
4
+ "version": "1.0.28",
5
5
  "description": "Source to source optimizer for Garmin Monkey C code",
6
6
  "main": "build/optimizer.cjs",
7
7
  "types": "build/src/optimizer.d.ts",