@markw65/monkeyc-optimizer 1.1.73 → 1.1.75

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to the "monkeyc-optimizer" package will be documented in this file.
4
4
 
5
+ ### 1.1.75
6
+
7
+ - Fix issues using personality files from barrels
8
+ - Fix issues with enums values as the base of member expressions
9
+ - Handle `new` expressions as references to the `initialize` method
10
+ - Classes without an explicit `initialize` method get an implicit, empty `initialize`, rather than inheriting the parent's
11
+ - Fix `subtypeOf` for function types.
12
+ - Update tests to work with sdk-7.2.1 and later
13
+
14
+ ### 1.1.74
15
+
16
+ - Add refs from drawable-ids to the corresponding drawable (Fixes prettier-extension-monkeyc#20)
17
+ - Fix handling of 'identifier' params in resource files (Fixes prettier-extension-monkeyc#21)
18
+ - Fix a bug filtering out generated files on Windows (Fixes #45)
19
+
5
20
  ### 1.1.73
6
21
 
7
22
  - Fix an issue formatting body-less class/module/program nodes.
package/build/api.cjs CHANGED
@@ -18,50 +18,50 @@ 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_XNAPUWVE.checkCompilerVersion,
22
- collectNamespaces: () => import_chunk_XNAPUWVE.collectNamespaces,
23
- createDocumentationMap: () => import_chunk_XNAPUWVE.createDocumentationMap,
24
- diagnostic: () => import_chunk_XNAPUWVE.diagnostic,
25
- diagnosticHelper: () => import_chunk_XNAPUWVE.diagnosticHelper,
26
- findNamesInScope: () => import_chunk_XNAPUWVE.findNamesInScope,
27
- findUsingForNode: () => import_chunk_XNAPUWVE.findUsingForNode,
28
- formatAst: () => import_chunk_XNAPUWVE.formatAst,
29
- formatAstLongLines: () => import_chunk_XNAPUWVE.formatAstLongLines,
30
- formatScopedName: () => import_chunk_XNAPUWVE.formatScopedName,
31
- getApiFunctionInfo: () => import_chunk_XNAPUWVE.getApiFunctionInfo,
32
- getApiMapping: () => import_chunk_XNAPUWVE.getApiMapping,
33
- getSuperClasses: () => import_chunk_XNAPUWVE.getSuperClasses,
34
- handleImportUsing: () => import_chunk_XNAPUWVE.handleImportUsing,
21
+ checkCompilerVersion: () => import_chunk_7GXXJDR3.checkCompilerVersion,
22
+ collectNamespaces: () => import_chunk_7GXXJDR3.collectNamespaces,
23
+ createDocumentationMap: () => import_chunk_7GXXJDR3.createDocumentationMap,
24
+ diagnostic: () => import_chunk_7GXXJDR3.diagnostic,
25
+ diagnosticHelper: () => import_chunk_7GXXJDR3.diagnosticHelper,
26
+ findNamesInScope: () => import_chunk_7GXXJDR3.findNamesInScope,
27
+ findUsingForNode: () => import_chunk_7GXXJDR3.findUsingForNode,
28
+ formatAst: () => import_chunk_7GXXJDR3.formatAst,
29
+ formatAstLongLines: () => import_chunk_7GXXJDR3.formatAstLongLines,
30
+ formatScopedName: () => import_chunk_7GXXJDR3.formatScopedName,
31
+ getApiFunctionInfo: () => import_chunk_7GXXJDR3.getApiFunctionInfo,
32
+ getApiMapping: () => import_chunk_7GXXJDR3.getApiMapping,
33
+ getSuperClasses: () => import_chunk_7GXXJDR3.getSuperClasses,
34
+ handleImportUsing: () => import_chunk_7GXXJDR3.handleImportUsing,
35
35
  hasProperty: () => import_chunk_JDC43A3I.hasProperty,
36
- isClassVariable: () => import_chunk_XNAPUWVE.isClassVariable,
37
- isLocal: () => import_chunk_XNAPUWVE.isLocal,
38
- isLookupCandidate: () => import_chunk_XNAPUWVE.isLookupCandidate,
39
- isStateNode: () => import_chunk_XNAPUWVE.isStateNode,
40
- lookupByFullName: () => import_chunk_XNAPUWVE.lookupByFullName,
41
- lookupNext: () => import_chunk_XNAPUWVE.lookupNext,
42
- lookupResultContains: () => import_chunk_XNAPUWVE.lookupResultContains,
43
- lookupWithType: () => import_chunk_XNAPUWVE.lookupWithType,
44
- makeToyboxLink: () => import_chunk_XNAPUWVE.makeToyboxLink,
45
- mapVarDeclsByType: () => import_chunk_XNAPUWVE.mapVarDeclsByType,
46
- markInvokeClassMethod: () => import_chunk_XNAPUWVE.markInvokeClassMethod,
47
- parseSdkVersion: () => import_chunk_XNAPUWVE.parseSdkVersion,
48
- popRootNode: () => import_chunk_XNAPUWVE.popRootNode,
49
- pushRootNode: () => import_chunk_XNAPUWVE.pushRootNode,
50
- resolveDiagnostics: () => import_chunk_XNAPUWVE.resolveDiagnostics,
51
- resolveDiagnosticsMap: () => import_chunk_XNAPUWVE.resolveDiagnosticsMap,
52
- sameLookupResult: () => import_chunk_XNAPUWVE.sameLookupResult,
36
+ isClassVariable: () => import_chunk_7GXXJDR3.isClassVariable,
37
+ isLocal: () => import_chunk_7GXXJDR3.isLocal,
38
+ isLookupCandidate: () => import_chunk_7GXXJDR3.isLookupCandidate,
39
+ isStateNode: () => import_chunk_7GXXJDR3.isStateNode,
40
+ lookupByFullName: () => import_chunk_7GXXJDR3.lookupByFullName,
41
+ lookupNext: () => import_chunk_7GXXJDR3.lookupNext,
42
+ lookupResultContains: () => import_chunk_7GXXJDR3.lookupResultContains,
43
+ lookupWithType: () => import_chunk_7GXXJDR3.lookupWithType,
44
+ makeToyboxLink: () => import_chunk_7GXXJDR3.makeToyboxLink,
45
+ mapVarDeclsByType: () => import_chunk_7GXXJDR3.mapVarDeclsByType,
46
+ markInvokeClassMethod: () => import_chunk_7GXXJDR3.markInvokeClassMethod,
47
+ parseSdkVersion: () => import_chunk_7GXXJDR3.parseSdkVersion,
48
+ popRootNode: () => import_chunk_7GXXJDR3.popRootNode,
49
+ pushRootNode: () => import_chunk_7GXXJDR3.pushRootNode,
50
+ resolveDiagnostics: () => import_chunk_7GXXJDR3.resolveDiagnostics,
51
+ resolveDiagnosticsMap: () => import_chunk_7GXXJDR3.resolveDiagnosticsMap,
52
+ sameLookupResult: () => import_chunk_7GXXJDR3.sameLookupResult,
53
53
  traverseAst: () => import_chunk_JDC43A3I.traverseAst,
54
- variableDeclarationName: () => import_chunk_XNAPUWVE.variableDeclarationName,
55
- visitReferences: () => import_chunk_XNAPUWVE.visitReferences,
56
- visit_resources: () => import_chunk_XNAPUWVE.visit_resources,
57
- visitorNode: () => import_chunk_XNAPUWVE.visitorNode
54
+ variableDeclarationName: () => import_chunk_7GXXJDR3.variableDeclarationName,
55
+ visitReferences: () => import_chunk_7GXXJDR3.visitReferences,
56
+ visit_resources: () => import_chunk_7GXXJDR3.visit_resources,
57
+ visitorNode: () => import_chunk_7GXXJDR3.visitorNode
58
58
  });
59
59
  module.exports = __toCommonJS(api_exports);
60
- var import_chunk_XNAPUWVE = require("./chunk-XNAPUWVE.cjs");
60
+ var import_chunk_7GXXJDR3 = require("./chunk-7GXXJDR3.cjs");
61
61
  var import_chunk_NHZRKHZO = require("./chunk-NHZRKHZO.cjs");
62
62
  var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
63
63
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
64
- (0, import_chunk_XNAPUWVE.init_api)();
64
+ (0, import_chunk_7GXXJDR3.init_api)();
65
65
  // Annotate the CommonJS export names for ESM import in node:
66
66
  0 && (module.exports = {
67
67
  checkCompilerVersion,
@@ -26,8 +26,8 @@ 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_XNAPUWVE_exports = {};
30
- __export(chunk_XNAPUWVE_exports, {
29
+ var chunk_7GXXJDR3_exports = {};
30
+ __export(chunk_7GXXJDR3_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -138,7 +138,7 @@ __export(chunk_XNAPUWVE_exports, {
138
138
  visitorNode: () => visitorNode,
139
139
  xml_util_exports: () => xml_util_exports
140
140
  });
141
- module.exports = __toCommonJS(chunk_XNAPUWVE_exports);
141
+ module.exports = __toCommonJS(chunk_7GXXJDR3_exports);
142
142
  var import_chunk_NHZRKHZO = require("./chunk-NHZRKHZO.cjs");
143
143
  var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
144
144
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
@@ -8725,7 +8725,7 @@ function subtypeOfValue(pair) {
8725
8725
  case 8192: {
8726
8726
  const asd = pair.avalue;
8727
8727
  const bsd = pair.bvalue;
8728
- return (0, import_chunk_NHZRKHZO.some)(asd, (sna) => (0, import_chunk_NHZRKHZO.some)(bsd, (snb) => sna === snb));
8728
+ return (0, import_chunk_NHZRKHZO.every)(asd, (sna) => (0, import_chunk_NHZRKHZO.some)(bsd, (snb) => sna === snb));
8729
8729
  }
8730
8730
  case 16384: {
8731
8731
  const asd = pair.avalue;
@@ -10588,8 +10588,9 @@ function pushScopedNameType(istate, node, object) {
10588
10588
  if (istate.typeMap) {
10589
10589
  result = istate.typeMap.get(node);
10590
10590
  if (!result && object && node.type === "MemberExpression" && !node.computed) {
10591
- istate.typeMap.set(node.object, object.value);
10592
- const resolved = resolveDottedMember(istate, object.value, node);
10591
+ const objectType = deEnumerate(object.value);
10592
+ istate.typeMap.set(node.object, objectType);
10593
+ const resolved = resolveDottedMember(istate, objectType, node);
10593
10594
  if (resolved) {
10594
10595
  result = resolved.property;
10595
10596
  if (resolved.mayThrow) {
@@ -10944,7 +10945,7 @@ function evaluateNode(istate, node) {
10944
10945
  if (!isLookupCandidate(node)) {
10945
10946
  const property = popIstate(istate, node.property);
10946
10947
  const object = popIstate(istate, node.object);
10947
- const objectType = object.value;
10948
+ const objectType = deEnumerate(object.value);
10948
10949
  let byteArray = false;
10949
10950
  if (objectType.type & 32768 && objectType.value) {
10950
10951
  const odata = getObjectValue(objectType);
@@ -11115,29 +11116,26 @@ function evaluateNode(istate, node) {
11115
11116
  if (isExact(klass.value) && klass.value.type === 16384) {
11116
11117
  obj.value = { klass: klass.value };
11117
11118
  if (istate.checkTypes && klass.value.value) {
11118
- const results = lookupNext(
11119
- istate.state,
11120
- [
11121
- {
11122
- parent: null,
11123
- results: Array.isArray(klass.value.value) ? klass.value.value : [klass.value.value]
11124
- }
11125
- ],
11126
- "decls",
11127
- { type: "Identifier", name: "initialize" }
11119
+ const callees = (0, import_chunk_NHZRKHZO.map)(
11120
+ klass.value.value,
11121
+ (klass2) => klass2.decls?.initialize
11122
+ ).flat().filter(
11123
+ (result) => result?.type === "FunctionDeclaration"
11128
11124
  );
11129
- if (results) {
11130
- const callees = results.flatMap(
11131
- (lookupDef) => lookupDef.results.filter(
11132
- (result) => result.type === "FunctionDeclaration"
11133
- )
11134
- );
11125
+ if (callees.length) {
11135
11126
  checkCallArgs(
11136
11127
  istate,
11137
11128
  node,
11138
11129
  callees,
11139
11130
  args.map(({ value: value2 }) => value2)
11140
11131
  );
11132
+ } else if (args.length) {
11133
+ diagnostic(
11134
+ istate.state,
11135
+ node,
11136
+ `initialize method expected no args, but got ${args.length}`,
11137
+ istate.checkTypes
11138
+ );
11141
11139
  }
11142
11140
  }
11143
11141
  }
@@ -13572,11 +13570,23 @@ function propagateTypes(state, root, graph, optimizeEquivalencies, copyPropStore
13572
13570
  function getStateType(blockState, decl) {
13573
13571
  return getStateEntry(blockState, decl).curType;
13574
13572
  }
13575
- function getStateEntry(blockState, decl) {
13573
+ function getStateEntry(blockState, decl, node) {
13576
13574
  if (Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown") {
13577
13575
  let tsVal = blockState.map.get(decl);
13578
13576
  if (!tsVal) {
13579
- tsVal = { curType: typeConstraint(decl, blockState) };
13577
+ const t = typeConstraint(decl, blockState);
13578
+ if (node?.type === "MemberExpression" && !node.computed) {
13579
+ const baseType = typeMap.get(node.object);
13580
+ if (baseType) {
13581
+ const r = evaluate(istate, node).value;
13582
+ if (subtypeOf(r, t)) {
13583
+ tsVal = { curType: r };
13584
+ }
13585
+ }
13586
+ }
13587
+ if (!tsVal) {
13588
+ tsVal = { curType: t };
13589
+ }
13580
13590
  blockState.map.set(decl, tsVal);
13581
13591
  }
13582
13592
  return tsVal;
@@ -13989,7 +13999,7 @@ function propagateTypes(state, root, graph, optimizeEquivalencies, copyPropStore
13989
13999
  break;
13990
14000
  }
13991
14001
  case "ref": {
13992
- const curEntry = getStateEntry(curState, event.decl);
14002
+ const curEntry = getStateEntry(curState, event.decl, event.node);
13993
14003
  typeMap.set(event.node, curEntry.curType);
13994
14004
  nodeEquivs.delete(event.node);
13995
14005
  if (curEntry.equivSet) {
@@ -16923,8 +16933,10 @@ function collectClassInfo(state) {
16923
16933
  }
16924
16934
  function getFileSources(fnMap) {
16925
16935
  return Promise.all(
16926
- Object.entries(fnMap).map(([name, value2]) => {
16927
- return value2.monkeyCSource || fs.readFile(name).then(
16936
+ Object.values(fnMap).map((value2) => {
16937
+ if (value2.monkeyCSource)
16938
+ return value2.monkeyCSource;
16939
+ return fs.readFile(value2.name).then(
16928
16940
  (data) => value2.monkeyCSource = data.toString().replace(/\r\n/g, "\n")
16929
16941
  );
16930
16942
  })
@@ -16934,12 +16946,12 @@ function getFileSources(fnMap) {
16934
16946
  }
16935
16947
  function getFileASTs(fnMap) {
16936
16948
  return getFileSources(fnMap).then(
16937
- () => Object.entries(fnMap).reduce((ok, [name, value2]) => {
16949
+ () => Object.values(fnMap).reduce((ok, value2) => {
16938
16950
  if (!value2.ast && !value2.parserError) {
16939
16951
  const options = {
16940
- filepath: name
16952
+ filepath: value2.name
16941
16953
  };
16942
- if (/\.mss$/i.test(name)) {
16954
+ if (/\.mss$/i.test(value2.name)) {
16943
16955
  options.mss = value2.barrel;
16944
16956
  }
16945
16957
  try {
@@ -17026,12 +17038,12 @@ async function analyze(fnMap, resourcesMap, manifestXML, config, allowParseError
17026
17038
  markApi = false;
17027
17039
  const state = preState;
17028
17040
  await getFileASTs(fnMap);
17029
- Object.entries(fnMap).forEach(([name, value2]) => {
17041
+ Object.values(fnMap).forEach((value2) => {
17030
17042
  const { ast, parserError } = value2;
17031
17043
  if (!ast) {
17032
17044
  if (allowParseErrors)
17033
17045
  return;
17034
- throw parserError || new Error(`Failed to parse ${name}`);
17046
+ throw parserError || new Error(`Failed to parse ${value2.name}`);
17035
17047
  }
17036
17048
  hasTests = false;
17037
17049
  collectNamespaces(ast, state);
@@ -17732,8 +17744,8 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
17732
17744
  }
17733
17745
  const diagnostics = state.diagnostics && await resolveDiagnosticsMap(state.diagnostics);
17734
17746
  if (state.config?.checkBuildPragmas) {
17735
- Object.entries(fnMap).forEach(([name, f]) => {
17736
- pragmaChecker(state, f.ast, diagnostics?.[name]);
17747
+ Object.values(fnMap).forEach((f) => {
17748
+ pragmaChecker(state, f.ast, diagnostics?.[f.name]);
17737
17749
  });
17738
17750
  }
17739
17751
  return {
@@ -18263,7 +18275,7 @@ function visit_resource_refs(state, doc, e, barrelNames) {
18263
18275
  }
18264
18276
  }
18265
18277
  }
18266
- if ((0, import_chunk_JDC43A3I.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
18278
+ if (skip === true || (0, import_chunk_JDC43A3I.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
18267
18279
  return;
18268
18280
  }
18269
18281
  if (/^([-\w_$]+\s*\.\s*)*[-\w_$]+$/.test(name)) {
@@ -18357,6 +18369,13 @@ function visit_resource_refs(state, doc, e, barrelNames) {
18357
18369
  case "drawable":
18358
18370
  if (id === "class") {
18359
18371
  parseArg(dotted, l);
18372
+ } else if (id === "id" && !element.attr.class) {
18373
+ if (/^\w+$/.test(dotted)) {
18374
+ const base = (0, import_chunk_JDC43A3I.makeScopedName)(`Rez.Drawables`);
18375
+ const idLoc = (0, import_chunk_JDC43A3I.adjustLoc)(l, 0, 0);
18376
+ const id2 = (0, import_chunk_JDC43A3I.makeIdentifier)(dotted, idLoc);
18377
+ result.push((0, import_chunk_JDC43A3I.makeMemberExpression)((0, import_chunk_JDC43A3I.withLoc)(base, id2, false), id2));
18378
+ }
18360
18379
  }
18361
18380
  return;
18362
18381
  case "shape":
@@ -18615,7 +18634,8 @@ var init_resources = (0, import_chunk_ABYVSU2C.__esm)({
18615
18634
  foreground: {},
18616
18635
  background: {},
18617
18636
  font: {},
18618
- justification: {}
18637
+ justification: {},
18638
+ identifier: true
18619
18639
  };
18620
18640
  }
18621
18641
  });
@@ -18629,6 +18649,9 @@ function visitorNode(node) {
18629
18649
  if (node.type === "BinaryExpression" && node.operator === "has" && node.right.type === "UnaryExpression" && node.right.operator === ":") {
18630
18650
  return node.right.argument;
18631
18651
  }
18652
+ if (node.type === "NewExpression") {
18653
+ return visitorNode(node.callee);
18654
+ }
18632
18655
  return node;
18633
18656
  }
18634
18657
  function visitReferences(state, ast, name, defn, callback, includeDefs = false, filter = null, typeMap = null, findSingleDefinition = false) {
@@ -18716,6 +18739,42 @@ function visitReferences(state, ast, name, defn, callback, includeDefs = false,
18716
18739
  return ["arguments"];
18717
18740
  }
18718
18741
  break;
18742
+ case "NewExpression": {
18743
+ const [name2, results] = lookup2(node.callee, true);
18744
+ if (!results)
18745
+ break;
18746
+ const initializers = /* @__PURE__ */ new Map();
18747
+ results.forEach((result) => {
18748
+ result.results.forEach((klass) => {
18749
+ if (klass.type !== "ClassDeclaration")
18750
+ return;
18751
+ const inits = klass.decls?.["initialize"];
18752
+ inits?.forEach((init) => {
18753
+ if (init.type === "FunctionDeclaration") {
18754
+ const existing = initializers.get(klass);
18755
+ if (existing) {
18756
+ existing.push(init);
18757
+ } else {
18758
+ initializers.set(klass, [init]);
18759
+ }
18760
+ }
18761
+ });
18762
+ });
18763
+ });
18764
+ if (initializers.size) {
18765
+ checkResults(
18766
+ [
18767
+ name2,
18768
+ Array.from(initializers).map(([parent, results2]) => ({
18769
+ parent,
18770
+ results: results2
18771
+ }))
18772
+ ],
18773
+ node
18774
+ );
18775
+ }
18776
+ break;
18777
+ }
18719
18778
  case "Identifier":
18720
18779
  if (!name || node.name === name) {
18721
18780
  return checkResults(lookup2(node), node);
@@ -29969,7 +30028,7 @@ async function filesFromPaths(workspace, buildDir, inPaths, extension) {
29969
30028
  (pattern) => (0, import_chunk_NHZRKHZO.globa)(pattern, { cwd: workspace, mark: true }).then(
29970
30029
  (paths2) => paths2.map((p) => ({
29971
30030
  path: p,
29972
- filter: filter && /^\*\*[\\/]\*.mc$/i.test(path4.relative(workspace, pattern))
30031
+ filter: filter && /^\*\*[\\/]\*\.mc$/i.test(path4.relative(workspace, pattern))
29973
30032
  }))
29974
30033
  )
29975
30034
  ) || []
@@ -29987,11 +30046,12 @@ async function filesFromPaths(workspace, buildDir, inPaths, extension) {
29987
30046
  ) : result
29988
30047
  )
29989
30048
  );
30049
+ const buildDirNormalized = buildDir.replace(/\\/g, "/");
29990
30050
  return {
29991
30051
  files: files.flat().filter(
29992
- (file) => file.path.endsWith(extension) && (!file.filter || !file.path.startsWith(buildDir))
30052
+ (file) => file.path.endsWith(extension) && (!file.filter || !file.path.startsWith(buildDirNormalized))
29993
30053
  ).map(({ path: path7 }) => path7),
29994
- paths: paths.map(({ path: path7 }) => path7)
30054
+ paths: paths.filter(({ path: path7 }) => path7.endsWith("/")).map(({ path: path7 }) => path7)
29995
30055
  };
29996
30056
  }
29997
30057
  async function fileInfoFromConfig(workspace, buildDir, output, buildConfig, extraExcludes, barrel) {
@@ -30020,6 +30080,7 @@ async function fileInfoFromConfig(workspace, buildDir, output, buildConfig, extr
30020
30080
  ).concat(personalityFiles).map((file) => [
30021
30081
  file,
30022
30082
  {
30083
+ name: file,
30023
30084
  output: path4.join(
30024
30085
  output,
30025
30086
  relative_path_no_dotdot(path4.relative(workspace, file))
@@ -30093,7 +30154,9 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
30093
30154
  );
30094
30155
  barrelFnMaps.forEach(
30095
30156
  (barrelFnMap) => Object.entries(barrelFnMap).forEach(([key2, value2]) => {
30096
- if (!(0, import_chunk_JDC43A3I.hasProperty)(fnMap, key2)) {
30157
+ if (fnMap[key2]) {
30158
+ fnMap[key2 + "::" + value2.barrel] = value2;
30159
+ } else {
30097
30160
  fnMap[key2] = value2;
30098
30161
  }
30099
30162
  })
@@ -30121,7 +30184,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
30121
30184
  const opt_time = await (0, import_chunk_NHZRKHZO.first_modified)(
30122
30185
  Object.values(fnMap).map((v) => v.output)
30123
30186
  );
30124
- if (source_time < opt_time && 1722003035546 < opt_time) {
30187
+ if (source_time < opt_time && 1726412336564 < opt_time) {
30125
30188
  return {
30126
30189
  hasTests,
30127
30190
  diagnostics: prevDiagnostics,
@@ -30159,7 +30222,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
30159
30222
  hasTests: hasTests2,
30160
30223
  diagnostics,
30161
30224
  sdkVersion,
30162
- optimizerVersion: "1.1.73",
30225
+ optimizerVersion: "1.1.75",
30163
30226
  ...Object.fromEntries(
30164
30227
  configOptionsToCheck.map((option) => [option, config[option]])
30165
30228
  )
@@ -30224,9 +30287,13 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
30224
30287
  (results) => results.reduce((cur, result) => {
30225
30288
  if (!cur)
30226
30289
  return result;
30227
- Object.entries(result.fnMap).forEach(
30228
- ([key, value2]) => cur.fnMap[key] || (cur.fnMap[key] = value2)
30229
- );
30290
+ Object.entries(result.fnMap).forEach(([key, value2]) => {
30291
+ if (cur.fnMap[key]) {
30292
+ cur.fnMap[key + "::" + value2.barrel] = value2;
30293
+ } else {
30294
+ cur.fnMap[key] = value2;
30295
+ }
30296
+ });
30230
30297
  cur.paths.push(...result.paths);
30231
30298
  return cur;
30232
30299
  }, null)
@@ -30274,8 +30341,8 @@ async function getFnMapAnalysis(fnMap, resourcesMap, manifestXML, options) {
30274
30341
  const typeMap = await analyze_module_types(state);
30275
30342
  const diagnostics = state.diagnostics && await resolveDiagnosticsMap(state.diagnostics);
30276
30343
  if (state.config?.checkBuildPragmas) {
30277
- Object.entries(fnMap).forEach(
30278
- ([name, f]) => f.ast && pragmaChecker(state, f.ast, diagnostics?.[name])
30344
+ Object.values(fnMap).forEach(
30345
+ (f) => f.ast && pragmaChecker(state, f.ast, diagnostics?.[f.name])
30279
30346
  );
30280
30347
  }
30281
30348
  return { fnMap, state, typeMap };
@@ -18,30 +18,30 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var optimizer_exports = {};
20
20
  __export(optimizer_exports, {
21
- StateNodeAttributes: () => import_chunk_XNAPUWVE.StateNodeAttributes,
22
- buildConfigDescription: () => import_chunk_XNAPUWVE.buildConfigDescription,
23
- buildOptimizedProject: () => import_chunk_XNAPUWVE.buildOptimizedProject,
21
+ StateNodeAttributes: () => import_chunk_7GXXJDR3.StateNodeAttributes,
22
+ buildConfigDescription: () => import_chunk_7GXXJDR3.buildConfigDescription,
23
+ buildOptimizedProject: () => import_chunk_7GXXJDR3.buildOptimizedProject,
24
24
  copyRecursiveAsNeeded: () => import_chunk_NHZRKHZO.copyRecursiveAsNeeded,
25
- defaultConfig: () => import_chunk_XNAPUWVE.defaultConfig,
26
- display: () => import_chunk_XNAPUWVE.display,
27
- generateOneConfig: () => import_chunk_XNAPUWVE.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_XNAPUWVE.generateOptimizedProject,
29
- getConfig: () => import_chunk_XNAPUWVE.getConfig,
30
- getFnMapAnalysis: () => import_chunk_XNAPUWVE.getFnMapAnalysis,
31
- getProjectAnalysis: () => import_chunk_XNAPUWVE.getProjectAnalysis,
32
- get_jungle: () => import_chunk_XNAPUWVE.get_jungle,
33
- isErrorWithLocation: () => import_chunk_XNAPUWVE.isErrorWithLocation,
34
- launchSimulator: () => import_chunk_XNAPUWVE.launchSimulator,
35
- manifestProducts: () => import_chunk_XNAPUWVE.manifestProducts,
36
- mctree: () => import_chunk_XNAPUWVE.mctree,
37
- simulateProgram: () => import_chunk_XNAPUWVE.simulateProgram
25
+ defaultConfig: () => import_chunk_7GXXJDR3.defaultConfig,
26
+ display: () => import_chunk_7GXXJDR3.display,
27
+ generateOneConfig: () => import_chunk_7GXXJDR3.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_7GXXJDR3.generateOptimizedProject,
29
+ getConfig: () => import_chunk_7GXXJDR3.getConfig,
30
+ getFnMapAnalysis: () => import_chunk_7GXXJDR3.getFnMapAnalysis,
31
+ getProjectAnalysis: () => import_chunk_7GXXJDR3.getProjectAnalysis,
32
+ get_jungle: () => import_chunk_7GXXJDR3.get_jungle,
33
+ isErrorWithLocation: () => import_chunk_7GXXJDR3.isErrorWithLocation,
34
+ launchSimulator: () => import_chunk_7GXXJDR3.launchSimulator,
35
+ manifestProducts: () => import_chunk_7GXXJDR3.manifestProducts,
36
+ mctree: () => import_chunk_7GXXJDR3.mctree,
37
+ simulateProgram: () => import_chunk_7GXXJDR3.simulateProgram
38
38
  });
39
39
  module.exports = __toCommonJS(optimizer_exports);
40
- var import_chunk_XNAPUWVE = require("./chunk-XNAPUWVE.cjs");
40
+ var import_chunk_7GXXJDR3 = require("./chunk-7GXXJDR3.cjs");
41
41
  var import_chunk_NHZRKHZO = require("./chunk-NHZRKHZO.cjs");
42
42
  var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
43
43
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
44
- (0, import_chunk_XNAPUWVE.init_optimizer)();
44
+ (0, import_chunk_7GXXJDR3.init_optimizer)();
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
47
47
  StateNodeAttributes,
@@ -18,25 +18,25 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var sdk_util_exports = {};
20
20
  __export(sdk_util_exports, {
21
- SectionKinds: () => import_chunk_XNAPUWVE.SectionKinds,
22
- appSupport: () => import_chunk_XNAPUWVE.appSupport,
23
- connectiq: () => import_chunk_XNAPUWVE.connectiq,
24
- getDeviceInfo: () => import_chunk_XNAPUWVE.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_XNAPUWVE.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_XNAPUWVE.getLanguages,
27
- getSdkPath: () => import_chunk_XNAPUWVE.getSdkPath,
28
- isWin: () => import_chunk_XNAPUWVE.isWin,
29
- optimizeProgram: () => import_chunk_XNAPUWVE.optimizeProgram,
30
- readPrg: () => import_chunk_XNAPUWVE.readPrg,
31
- readPrgWithOffsets: () => import_chunk_XNAPUWVE.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_XNAPUWVE.xml_util_exports
21
+ SectionKinds: () => import_chunk_7GXXJDR3.SectionKinds,
22
+ appSupport: () => import_chunk_7GXXJDR3.appSupport,
23
+ connectiq: () => import_chunk_7GXXJDR3.connectiq,
24
+ getDeviceInfo: () => import_chunk_7GXXJDR3.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_7GXXJDR3.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_7GXXJDR3.getLanguages,
27
+ getSdkPath: () => import_chunk_7GXXJDR3.getSdkPath,
28
+ isWin: () => import_chunk_7GXXJDR3.isWin,
29
+ optimizeProgram: () => import_chunk_7GXXJDR3.optimizeProgram,
30
+ readPrg: () => import_chunk_7GXXJDR3.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_7GXXJDR3.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_7GXXJDR3.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_XNAPUWVE = require("./chunk-XNAPUWVE.cjs");
35
+ var import_chunk_7GXXJDR3 = require("./chunk-7GXXJDR3.cjs");
36
36
  var import_chunk_NHZRKHZO = require("./chunk-NHZRKHZO.cjs");
37
37
  var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
38
38
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
39
- (0, import_chunk_XNAPUWVE.init_sdk_util)();
39
+ (0, import_chunk_7GXXJDR3.init_sdk_util)();
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  SectionKinds,
@@ -197,6 +197,7 @@ export type ExcludeAnnotationsMap = {
197
197
  };
198
198
  export type FilesToOptimizeMap = {
199
199
  [key: string]: {
200
+ name: string;
200
201
  output: string;
201
202
  barrel: string;
202
203
  excludeAnnotations: ExcludeAnnotationsMap;
@@ -21,17 +21,17 @@ __export(worker_thread_exports, {
21
21
  default: () => worker_thread_default
22
22
  });
23
23
  module.exports = __toCommonJS(worker_thread_exports);
24
- var import_chunk_XNAPUWVE = require("./chunk-XNAPUWVE.cjs");
24
+ var import_chunk_7GXXJDR3 = require("./chunk-7GXXJDR3.cjs");
25
25
  var import_chunk_NHZRKHZO = require("./chunk-NHZRKHZO.cjs");
26
26
  var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
27
27
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
28
28
  var import_node_worker_threads = require("node:worker_threads");
29
29
  var require_worker_thread = (0, import_chunk_ABYVSU2C.__commonJS)({
30
30
  "src/worker-thread.ts"() {
31
- (0, import_chunk_XNAPUWVE.init_worker_task)();
31
+ (0, import_chunk_7GXXJDR3.init_worker_task)();
32
32
  if (import_node_worker_threads.parentPort) {
33
33
  import_node_worker_threads.parentPort.on("message", async (task) => {
34
- return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_XNAPUWVE.performTask)(task));
34
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_7GXXJDR3.performTask)(task));
35
35
  });
36
36
  }
37
37
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "commonjs",
4
- "version": "1.1.73",
4
+ "version": "1.1.75",
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",
@@ -35,7 +35,7 @@
35
35
  "test-post-only": "node test/test.js --showInfo --typeCheckLevel Strict --skipOptimization --postOptimize --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
36
36
  "test-garmin-opt": "node test/test.js --typeCheckLevel Strict --skipOptimization --garminOptLevel=2 --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
37
37
  "test-personality": "node test/test-personality.js",
38
- "test-analysis": "node test/test.js --showInfo --typeCheckLevel Strict --product=fr955 --sourceFile 'test/analysis/*.mc'",
38
+ "test-analysis": "node test/test.js --showInfo --typeCheckLevel Strict --product=fr955 --sourceFile \"test/analysis/*.mc\"",
39
39
  "test-tiny": "node test/test-tiny.js",
40
40
  "eslint": "npx eslint ."
41
41
  },