mlogjs 0.4.3 → 0.4.5
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/dist/bin.cjs +4 -9
- package/dist/bin.cjs.map +1 -1
- package/dist/index.cjs +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +35 -3
- package/dist/index.mjs.map +1 -1
- package/dist/macros/DynamicArray.d.ts +15 -2
- package/dist/values/LazyValue.d.ts +9 -0
- package/lib/globals.d.ts +1 -0
- package/lib/kinds.d.ts +1 -0
- package/lib/traits.d.ts +5 -0
- package/package.json +7 -8
package/dist/index.mjs
CHANGED
|
@@ -574,6 +574,12 @@ const itemNames = [
|
|
|
574
574
|
"sporePod",
|
|
575
575
|
"blastCompound",
|
|
576
576
|
"pyratite",
|
|
577
|
+
"beryllium",
|
|
578
|
+
"tungsten",
|
|
579
|
+
"oxide",
|
|
580
|
+
"carbide",
|
|
581
|
+
"fissileMatter",
|
|
582
|
+
"dormantCyst",
|
|
577
583
|
];
|
|
578
584
|
/**
|
|
579
585
|
* A more type safe version of `Object.assign`
|
|
@@ -1277,11 +1283,14 @@ const ForStatement = (c, parentScope, node) => {
|
|
|
1277
1283
|
: [new LiteralValue(1), []];
|
|
1278
1284
|
const updateLines = node.update ? c.handle(scope, node.update)[1] : [];
|
|
1279
1285
|
const startLoopAddr = new LiteralValue(null);
|
|
1286
|
+
// continue statements jump here to run the loop update lines
|
|
1287
|
+
const beforeEndAddr = new LiteralValue(null);
|
|
1280
1288
|
const endLoopAddr = new LiteralValue(null);
|
|
1281
|
-
const startLoopLine = new AddressResolver(startLoopAddr)
|
|
1289
|
+
const startLoopLine = new AddressResolver(startLoopAddr);
|
|
1282
1290
|
const endLoopLine = new AddressResolver(endLoopAddr).bindBreak(scope);
|
|
1291
|
+
const beforeEndLine = new AddressResolver(beforeEndAddr).bindContinue(scope);
|
|
1283
1292
|
if (parentScope.label) {
|
|
1284
|
-
|
|
1293
|
+
beforeEndLine.bindContinue(parentScope);
|
|
1285
1294
|
}
|
|
1286
1295
|
return [
|
|
1287
1296
|
null,
|
|
@@ -1291,6 +1300,7 @@ const ForStatement = (c, parentScope, node) => {
|
|
|
1291
1300
|
...testLines,
|
|
1292
1301
|
new JumpInstruction(endLoopAddr, EJumpKind.Equal, test, new LiteralValue(0)),
|
|
1293
1302
|
...withAlwaysRuns(c.handle(scope, node.body), false)[1],
|
|
1303
|
+
beforeEndLine,
|
|
1294
1304
|
...updateLines,
|
|
1295
1305
|
new JumpInstruction(startLoopAddr, EJumpKind.Always),
|
|
1296
1306
|
endLoopLine,
|
|
@@ -1453,6 +1463,14 @@ class FunctionValue extends VoidValue {
|
|
|
1453
1463
|
function endsWithReturn(inst) {
|
|
1454
1464
|
for (let i = inst.length - 1; i >= 0; i--) {
|
|
1455
1465
|
const instruction = inst[i];
|
|
1466
|
+
// this means that there is an instruction trying to reference
|
|
1467
|
+
// the final function `set @counter` instruction
|
|
1468
|
+
// of course this generates an unecessary
|
|
1469
|
+
// `set @counter` in cases where a control flow
|
|
1470
|
+
// structure contains a fallback return statement
|
|
1471
|
+
// TODO: fix this with static analysis
|
|
1472
|
+
if (instruction instanceof AddressResolver)
|
|
1473
|
+
return false;
|
|
1456
1474
|
if (instruction.hidden)
|
|
1457
1475
|
continue;
|
|
1458
1476
|
return instruction instanceof SetCounterInstruction;
|
|
@@ -2070,7 +2088,21 @@ class Control extends ObjectValue {
|
|
|
2070
2088
|
color: { args: ["building", "r", "g", "b"] },
|
|
2071
2089
|
},
|
|
2072
2090
|
handler(scope, overload, ...args) {
|
|
2073
|
-
|
|
2091
|
+
if (overload !== "color")
|
|
2092
|
+
return [null, [new InstructionBase("control", overload, ...args)]];
|
|
2093
|
+
const temp = new StoreValue(scope);
|
|
2094
|
+
temp.ensureOwned();
|
|
2095
|
+
// this "patch" is here for compatibility reasons
|
|
2096
|
+
// I don't want to add another breaking change
|
|
2097
|
+
// TODO: figure out if this patch should be removed later
|
|
2098
|
+
const [building, ...colors] = args;
|
|
2099
|
+
return [
|
|
2100
|
+
null,
|
|
2101
|
+
[
|
|
2102
|
+
new InstructionBase("packcolor", temp, ...colors),
|
|
2103
|
+
new InstructionBase("control", overload, building, temp),
|
|
2104
|
+
],
|
|
2105
|
+
];
|
|
2074
2106
|
},
|
|
2075
2107
|
}));
|
|
2076
2108
|
}
|