@markw65/monkeyc-optimizer 1.0.17 → 1.0.18

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
@@ -193,3 +193,8 @@ More fixes found via open source projects.
193
193
 
194
194
  - Bug Fixes
195
195
  - Fix a bug affecting lookup of types, which could cause definitions, references and links to the api docs to be missed in the vscode extension
196
+
197
+ ### 1.0.18
198
+
199
+ - Bug Fixes
200
+ - The new inliner was too agressive at constant propagating literal parameters to their point of use.
package/build/api.cjs CHANGED
@@ -181,7 +181,7 @@ function getArgSafety(state, func, args, requireAll) {
181
181
  })) {
182
182
  return false;
183
183
  }
184
- if (allSafe)
184
+ if (allSafe && requireAll)
185
185
  return true;
186
186
  let callSeen = false;
187
187
  let ok = true;
@@ -204,10 +204,16 @@ function getArgSafety(state, func, args, requireAll) {
204
204
  .map(([key]) => key);
205
205
  }, (node) => {
206
206
  switch (node.type) {
207
+ case "AssignmentExpression":
208
+ case "UpdateExpression": {
209
+ const v = node.type == "UpdateExpression" ? node.argument : node.left;
210
+ if (v.type === "Identifier" && hasProperty(params, v.name)) {
211
+ safeArgs[params[v.name]] = null;
212
+ }
213
+ }
214
+ // fall through
207
215
  case "CallExpression":
208
216
  case "NewExpression":
209
- case "AssignmentExpression":
210
- case "UpdateExpression":
211
217
  callSeen = true;
212
218
  break;
213
219
  case "Identifier":
@@ -10902,7 +10902,7 @@ function getArgSafety(state, func, args, requireAll) {
10902
10902
  })) {
10903
10903
  return false;
10904
10904
  }
10905
- if (allSafe)
10905
+ if (allSafe && requireAll)
10906
10906
  return true;
10907
10907
  let callSeen = false;
10908
10908
  let ok = true;
@@ -10925,10 +10925,16 @@ function getArgSafety(state, func, args, requireAll) {
10925
10925
  .map(([key]) => key);
10926
10926
  }, (node) => {
10927
10927
  switch (node.type) {
10928
+ case "AssignmentExpression":
10929
+ case "UpdateExpression": {
10930
+ const v = node.type == "UpdateExpression" ? node.argument : node.left;
10931
+ if (v.type === "Identifier" && (0,external_api_cjs_namespaceObject.hasProperty)(params, v.name)) {
10932
+ safeArgs[params[v.name]] = null;
10933
+ }
10934
+ }
10935
+ // fall through
10928
10936
  case "CallExpression":
10929
10937
  case "NewExpression":
10930
- case "AssignmentExpression":
10931
- case "UpdateExpression":
10932
10938
  callSeen = true;
10933
10939
  break;
10934
10940
  case "Identifier":
@@ -12571,7 +12577,7 @@ async function generateOneConfig(buildConfig, dependencyFiles, config) {
12571
12577
  // the oldest optimized file, we don't need to regenerate
12572
12578
  const source_time = await (0,external_util_cjs_namespaceObject.last_modified)(Object.keys(fnMap).concat(dependencyFiles));
12573
12579
  const opt_time = await (0,external_util_cjs_namespaceObject.first_modified)(Object.values(fnMap).map((v) => v.output));
12574
- if (source_time < opt_time && 1654384985724 < opt_time) {
12580
+ if (source_time < opt_time && 1654389404778 < opt_time) {
12575
12581
  return hasTests;
12576
12582
  }
12577
12583
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.0.17",
4
+ "version": "1.0.18",
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",