overpy 9.5.5 → 9.5.6

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 (2) hide show
  1. package/overpy.js +55 -41
  2. package/package.json +1 -1
package/overpy.js CHANGED
@@ -45328,10 +45328,9 @@ astParsingFunctions.__raiseToPower__ = function(content) {
45328
45328
  astParsingFunctions.__rule__ = function(content) {
45329
45329
  var isRelativeGotoEncountered = false;
45330
45330
  var isGotoEncountered = false;
45331
- var hasMeaningfulInstructionBeenEncountered = false;
45332
45331
  var declaredLabels = [];
45333
45332
  function iterateOnRuleActions(children) {
45334
- for (var i2 = 0; i2 < children.length; i2++) {
45333
+ for (let i2 = 0; i2 < children.length; i2++) {
45335
45334
  setFileStack(content.fileStack);
45336
45335
  if (children[i2].name === "__skip__" && children[i2].args[0].name !== "__distanceTo__" || children[i2].name === "__skipIf__" && children[i2].args[1].name !== "__distanceTo__") {
45337
45336
  isRelativeGotoEncountered = true;
@@ -45345,39 +45344,6 @@ astParsingFunctions.__rule__ = function(content) {
45345
45344
  }
45346
45345
  declaredLabels.push(content.name);
45347
45346
  }
45348
- if (!hasMeaningfulInstructionBeenEncountered && ![
45349
- "__abortIf__",
45350
- "__abortIfConditionIsFalse__",
45351
- "__abortIfConditionIsTrue__",
45352
- "break",
45353
- "continue",
45354
- "__disableOptimizations__",
45355
- "__disableOptimizeForSize__",
45356
- "__disableOptimizeStrict__",
45357
- "__enableOptimizations__",
45358
- "__enableOptimizeForSize__",
45359
- "__enableOptimizeStrict__",
45360
- "__else__",
45361
- "__elif__",
45362
- "__end__",
45363
- //"__for__", //meaningful because it modifies the loop variable
45364
- //"__forGlobalVariable__",
45365
- //"__forPlayerVariable__",
45366
- "__if__",
45367
- "loop",
45368
- "__loopIf__",
45369
- "__loopIfConditionIsFalse__",
45370
- "__loopIfConditionIsTrue__",
45371
- "pass",
45372
- "return",
45373
- "__skip__",
45374
- "__skipIf__",
45375
- //"wait",
45376
- "__while__"
45377
- ].includes(children[i2].name) && children[i2].type !== "Label" && !(children[i2].name === "wait" && content.ruleAttributes.event !== "__subroutine__")) {
45378
- debug("meaningful instruction :" + children[i2].name);
45379
- hasMeaningfulInstructionBeenEncountered = true;
45380
- }
45381
45347
  iterateOnRuleActions(children[i2].children);
45382
45348
  if (!isRelativeGotoEncountered) {
45383
45349
  if (children[i2].name === "pass") {
@@ -45397,7 +45363,14 @@ astParsingFunctions.__rule__ = function(content) {
45397
45363
  }
45398
45364
  }
45399
45365
  if (isDefinitelyFalsy(children[i2].args[0]) && (children[i2].children.length === 0 || !isGotoEncountered)) {
45400
- if (children[i2 + 1].name === "__else__") {
45366
+ if (i2 === children.length - 1 || children[i2 + 1].name === "__end__") {
45367
+ children.splice(i2, 1);
45368
+ if (i2 < children.length && children[i2].name === "__end__") {
45369
+ children.splice(i2, 1);
45370
+ }
45371
+ i2--;
45372
+ continue;
45373
+ } else if (children[i2 + 1].name === "__else__") {
45401
45374
  children[i2 + 1].name = "__if__";
45402
45375
  children[i2 + 1].args = [getAstForTrue()];
45403
45376
  children.splice(i2, 1);
@@ -45446,10 +45419,51 @@ astParsingFunctions.__rule__ = function(content) {
45446
45419
  }
45447
45420
  }
45448
45421
  }
45422
+ function checkForMeaningfulInstructions(instructions) {
45423
+ for (let instruction of instructions) {
45424
+ if (![
45425
+ "__abortIf__",
45426
+ "__abortIfConditionIsFalse__",
45427
+ "__abortIfConditionIsTrue__",
45428
+ "break",
45429
+ "continue",
45430
+ "__disableOptimizations__",
45431
+ "__disableOptimizeForSize__",
45432
+ "__disableOptimizeStrict__",
45433
+ "__enableOptimizations__",
45434
+ "__enableOptimizeForSize__",
45435
+ "__enableOptimizeStrict__",
45436
+ "__else__",
45437
+ "__elif__",
45438
+ "__end__",
45439
+ //"__for__", //meaningful because it modifies the loop variable
45440
+ //"__forGlobalVariable__",
45441
+ //"__forPlayerVariable__",
45442
+ "__if__",
45443
+ "loop",
45444
+ "__loopIf__",
45445
+ "__loopIfConditionIsFalse__",
45446
+ "__loopIfConditionIsTrue__",
45447
+ "pass",
45448
+ "return",
45449
+ "__skip__",
45450
+ "__skipIf__",
45451
+ //"wait",
45452
+ "__while__"
45453
+ ].includes(instruction.name) && instruction.type !== "Label" && !(instruction.name === "wait" && content.ruleAttributes.event !== "__subroutine__")) {
45454
+ debug("meaningful instruction :" + instruction.name);
45455
+ return true;
45456
+ }
45457
+ if (checkForMeaningfulInstructions(instruction.children)) {
45458
+ return true;
45459
+ }
45460
+ }
45461
+ return false;
45462
+ }
45449
45463
  if (enableOptimization) {
45450
45464
  iterateOnRuleActions(content.children);
45451
45465
  }
45452
- if (enableOptimization && !hasMeaningfulInstructionBeenEncountered && !content.ruleAttributes.isDelimiter) {
45466
+ if (enableOptimization && !checkForMeaningfulInstructions(content.children) && !content.ruleAttributes.isDelimiter) {
45453
45467
  return getAstForUselessInstruction();
45454
45468
  }
45455
45469
  function resolveDistanceTo(content2) {
@@ -65313,7 +65327,7 @@ rule "Disable inspector":
65313
65327
  }
65314
65328
  if (DEBUG_MODE) {
65315
65329
  for (var elem of astRules) {
65316
- console.log(astToString2(elem));
65330
+ console.log(astToString3(elem));
65317
65331
  }
65318
65332
  console.log(astRules);
65319
65333
  }
@@ -67736,7 +67750,7 @@ function nthOfNumber(nb) {
67736
67750
  return nb + "th";
67737
67751
  }
67738
67752
  }
67739
- function astToString2(ast, nbTabs2 = 0) {
67753
+ function astToString3(ast, nbTabs2 = 0) {
67740
67754
  var result = "";
67741
67755
  if (ast === void 0) {
67742
67756
  return "__undefined__";
@@ -67745,14 +67759,14 @@ function astToString2(ast, nbTabs2 = 0) {
67745
67759
  if (ast.args === void 0) {
67746
67760
  result += "(__undefined__)";
67747
67761
  } else if (ast.args.length > 0) {
67748
- result += "(" + ast.args.map((x) => astToString2(x)).join(", ") + ")";
67762
+ result += "(" + ast.args.map((x) => astToString3(x)).join(", ") + ")";
67749
67763
  }
67750
67764
  if (ast.children === void 0) {
67751
67765
  result += ":__undefined__";
67752
67766
  } else if (ast.children.length > 0) {
67753
67767
  result += ":\n";
67754
67768
  for (var child of ast.children) {
67755
- result += tabLevel(nbTabs2 + 1) + astToString2(child, nbTabs2 + 1) + "\n";
67769
+ result += tabLevel(nbTabs2 + 1) + astToString3(child, nbTabs2 + 1) + "\n";
67756
67770
  }
67757
67771
  }
67758
67772
  return result;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/Zezombye/overpy"
8
8
  },
9
9
  "description": "High-level language for the Overwatch Workshop, with decompilation and compilation.",
10
- "version": "9.5.5",
10
+ "version": "9.5.6",
11
11
  "readme": "README.md",
12
12
  "keywords": [
13
13
  "overpy",