mlogjs 0.2.1 → 0.3.0
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/LICENSE +1 -1
- package/README.md +2 -2
- package/build/Compiler.js +104 -99
- package/build/Compiler.js.map +1 -1
- package/build/CompilerError.js +11 -0
- package/build/CompilerError.js.map +1 -0
- package/build/Scope.js +70 -60
- package/build/Scope.js.map +1 -1
- package/build/bin.js +74 -60
- package/build/bin.js.map +1 -1
- package/build/handlers/BlockStatement.js +13 -13
- package/build/handlers/BlockStatement.js.map +1 -1
- package/build/handlers/CallExpression.js +19 -19
- package/build/handlers/CallExpression.js.map +1 -1
- package/build/handlers/File.js +9 -0
- package/build/handlers/File.js.map +1 -0
- package/build/handlers/ForStatement.js +31 -31
- package/build/handlers/ForStatement.js.map +1 -1
- package/build/handlers/Function.js +46 -35
- package/build/handlers/Function.js.map +1 -1
- package/build/handlers/Identifier.js +7 -7
- package/build/handlers/IfStatement.js +24 -24
- package/build/handlers/IfStatement.js.map +1 -1
- package/build/handlers/Literal.js +14 -17
- package/build/handlers/Literal.js.map +1 -1
- package/build/handlers/Object.js +54 -43
- package/build/handlers/Object.js.map +1 -1
- package/build/handlers/OperationExpressions.js +37 -32
- package/build/handlers/OperationExpressions.js.map +1 -1
- package/build/handlers/Program.js +8 -8
- package/build/handlers/Program.js.map +1 -1
- package/build/handlers/Statements.js +29 -29
- package/build/handlers/Statements.js.map +1 -1
- package/build/handlers/TemplateExpression.js +17 -17
- package/build/handlers/TemplateExpression.js.map +1 -1
- package/build/handlers/VariableDeclaration.js +71 -55
- package/build/handlers/VariableDeclaration.js.map +1 -1
- package/build/handlers/WhileStatement.js +22 -22
- package/build/handlers/WhileStatement.js.map +1 -1
- package/build/handlers/index.js +31 -30
- package/build/handlers/index.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/initScope.js +39 -39
- package/build/instructions/AddressResolver.js +30 -30
- package/build/instructions/ControlInstructions.js +22 -22
- package/build/instructions/EndInstruction.js +10 -10
- package/build/instructions/InstructionBase.js +20 -20
- package/build/instructions/InstructionBase.js.map +1 -1
- package/build/instructions/JumpInstruction.js +21 -21
- package/build/instructions/JumpInstruction.js.map +1 -1
- package/build/instructions/OperationInstruction.js +10 -10
- package/build/instructions/OperationInstruction.js.map +1 -1
- package/build/instructions/SetCounterInstruction.js +10 -10
- package/build/instructions/SetInstruction.js +10 -10
- package/build/instructions/ZeroSpaceInstruction.js +10 -10
- package/build/instructions/index.js +25 -25
- package/build/macros/Building.js +88 -80
- package/build/macros/Building.js.map +1 -1
- package/build/macros/Function.js +19 -19
- package/build/macros/Function.js.map +1 -1
- package/build/macros/Math.js +61 -56
- package/build/macros/Math.js.map +1 -1
- package/build/macros/Memory.js +62 -60
- package/build/macros/Memory.js.map +1 -1
- package/build/macros/Namespace.js +110 -97
- package/build/macros/Namespace.js.map +1 -1
- package/build/macros/Other.js +20 -19
- package/build/macros/Other.js.map +1 -1
- package/build/macros/RawValue.js +16 -15
- package/build/macros/RawValue.js.map +1 -1
- package/build/macros/commands/Control.js +25 -24
- package/build/macros/commands/Control.js.map +1 -1
- package/build/macros/commands/Draw.js +39 -38
- package/build/macros/commands/Draw.js.map +1 -1
- package/build/macros/commands/DrawFlush.js +17 -16
- package/build/macros/commands/DrawFlush.js.map +1 -1
- package/build/macros/commands/GetLink.js +24 -20
- package/build/macros/commands/GetLink.js.map +1 -1
- package/build/macros/commands/Lookup.js +24 -23
- package/build/macros/commands/Lookup.js.map +1 -1
- package/build/macros/commands/Print.js +17 -13
- package/build/macros/commands/Print.js.map +1 -1
- package/build/macros/commands/PrintFlush.js +17 -16
- package/build/macros/commands/PrintFlush.js.map +1 -1
- package/build/macros/commands/Radar.js +64 -60
- package/build/macros/commands/Radar.js.map +1 -1
- package/build/macros/commands/Sensor.js +20 -19
- package/build/macros/commands/Sensor.js.map +1 -1
- package/build/macros/commands/UnitBind.js +17 -16
- package/build/macros/commands/UnitBind.js.map +1 -1
- package/build/macros/commands/UnitControl.js +72 -67
- package/build/macros/commands/UnitControl.js.map +1 -1
- package/build/macros/commands/UnitLocate.js +75 -54
- package/build/macros/commands/UnitLocate.js.map +1 -1
- package/build/macros/commands/UnitRadar.js +47 -40
- package/build/macros/commands/UnitRadar.js.map +1 -1
- package/build/macros/commands/Wait.js +18 -17
- package/build/macros/commands/Wait.js.map +1 -1
- package/build/macros/commands/index.js +32 -32
- package/build/macros/index.js +39 -39
- package/build/operators.js +101 -101
- package/build/operators.js.map +1 -1
- package/build/types.js +27 -27
- package/build/types.js.map +1 -1
- package/build/utils.js +17 -12
- package/build/utils.js.map +1 -1
- package/build/values/BaseValue.js +111 -111
- package/build/values/BaseValue.js.map +1 -1
- package/build/values/FunctionValue.js +115 -103
- package/build/values/FunctionValue.js.map +1 -1
- package/build/values/LiteralValue.js +88 -87
- package/build/values/LiteralValue.js.map +1 -1
- package/build/values/ObjectValue.js +54 -49
- package/build/values/ObjectValue.js.map +1 -1
- package/build/values/StoreValue.js +31 -30
- package/build/values/StoreValue.js.map +1 -1
- package/build/values/TempValue.js +77 -66
- package/build/values/TempValue.js.map +1 -1
- package/build/values/VoidValue.js +31 -30
- package/build/values/VoidValue.js.map +1 -1
- package/build/values/index.js +22 -22
- package/dist/bin.cjs +82 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/index.cjs +2220 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/Compiler.d.ts +26 -0
- package/dist/types/CompilerError.d.ts +9 -0
- package/dist/types/Scope.d.ts +24 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/handlers/BlockStatement.d.ts +2 -0
- package/dist/types/handlers/CallExpression.d.ts +3 -0
- package/dist/types/handlers/File.d.ts +2 -0
- package/dist/types/handlers/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +5 -4
- package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/dist/types/handlers/Literal.d.ts +5 -0
- package/{build → dist/types}/handlers/Object.d.ts +6 -4
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
- package/dist/types/handlers/Program.d.ts +2 -0
- package/dist/types/handlers/Statements.d.ts +5 -0
- package/dist/types/handlers/TemplateExpression.d.ts +2 -0
- package/dist/types/handlers/Typescript.d.ts +7 -0
- package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +3 -0
- package/{build → dist/types}/handlers/index.d.ts +16 -14
- package/dist/types/index.d.ts +2 -0
- package/{build → dist/types}/initScope.d.ts +5 -2
- package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
- package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/index.d.ts +9 -9
- package/{build → dist/types}/macros/Building.d.ts +10 -11
- package/dist/types/macros/Entities.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +13 -0
- package/dist/types/macros/GetGlobal.d.ts +5 -0
- package/{build → dist/types}/macros/Math.d.ts +5 -5
- package/{build → dist/types}/macros/Memory.d.ts +5 -5
- package/{build → dist/types}/macros/Namespace.d.ts +16 -21
- package/{build → dist/types}/macros/Other.d.ts +5 -5
- package/{build → dist/types}/macros/RawValue.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
- package/dist/types/macros/commands/Draw.d.ts +5 -0
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
- package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
- package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
- package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
- package/{build → dist/types}/macros/commands/index.d.ts +15 -14
- package/{build → dist/types}/macros/index.d.ts +6 -7
- package/{build → dist/types}/operators.d.ts +25 -25
- package/dist/types/types.d.ts +224 -0
- package/dist/types/utils.d.ts +30 -0
- package/dist/types/values/BaseValue.d.ts +7 -0
- package/dist/types/values/DestructuringValue.d.ts +17 -0
- package/dist/types/values/FunctionValue.d.ts +47 -0
- package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
- package/dist/types/values/ObjectValue.d.ts +23 -0
- package/dist/types/values/SenseableValue.d.ts +23 -0
- package/dist/types/values/StackValue.d.ts +16 -0
- package/dist/types/values/StoreValue.d.ts +15 -0
- package/{build → dist/types}/values/TempValue.d.ts +19 -12
- package/dist/types/values/ValueOwner.d.ts +27 -0
- package/dist/types/values/VoidValue.d.ts +16 -0
- package/{build → dist/types}/values/index.d.ts +7 -6
- package/lib/commands.d.ts +242 -36
- package/lib/eslib/lib.es5.d.ts +1 -1
- package/lib/globals.d.ts +172 -159
- package/lib/helpers.d.ts +2 -2
- package/lib/memory.d.ts +1 -1
- package/lib/traits.d.ts +130 -110
- package/package.json +33 -38
- package/build/Compiler.d.ts +0 -18
- package/build/Scope.d.ts +0 -26
- package/build/bin.d.ts +0 -2
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/IfStatement.d.ts +0 -2
- package/build/handlers/Literal.d.ts +0 -2
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/index.d.ts +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/commands/UnitControl.d.ts +0 -5
- package/build/types.d.ts +0 -49
- package/build/utils.d.ts +0 -3
- package/build/values/BaseValue.d.ts +0 -5
- package/build/values/FunctionValue.d.ts +0 -34
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/StoreValue.d.ts +0 -11
- package/build/values/VoidValue.d.ts +0 -11
- package/dist/mlogjs.es.js +0 -6366
- package/dist/mlogjs.umd.js +0 -8
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InstructionBase = void 0;
|
|
4
|
-
class InstructionBase {
|
|
5
|
-
constructor(...args) {
|
|
6
|
-
this._hidden = false;
|
|
7
|
-
this.args = args;
|
|
8
|
-
}
|
|
9
|
-
get hidden() {
|
|
10
|
-
return this._hidden;
|
|
11
|
-
}
|
|
12
|
-
set hidden(value) {
|
|
13
|
-
this._hidden = value;
|
|
14
|
-
}
|
|
15
|
-
resolve(
|
|
16
|
-
toString() {
|
|
17
|
-
return this.args.filter(arg => arg).join(" ");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.InstructionBase = InstructionBase;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstructionBase = void 0;
|
|
4
|
+
class InstructionBase {
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
this._hidden = false;
|
|
7
|
+
this.args = args;
|
|
8
|
+
}
|
|
9
|
+
get hidden() {
|
|
10
|
+
return this._hidden;
|
|
11
|
+
}
|
|
12
|
+
set hidden(value) {
|
|
13
|
+
this._hidden = value;
|
|
14
|
+
}
|
|
15
|
+
resolve(_i) { }
|
|
16
|
+
toString() {
|
|
17
|
+
return this.args.filter(arg => arg).join(" ");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.InstructionBase = InstructionBase;
|
|
21
21
|
//# sourceMappingURL=InstructionBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionBase.js","sourceRoot":"","sources":["../../src/instructions/InstructionBase.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAS1B,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"InstructionBase.js","sourceRoot":"","sources":["../../src/instructions/InstructionBase.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAS1B,YAAY,GAAG,IAAgC;QARvC,YAAO,GAAG,KAAK,CAAC;QAStB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IATD,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAW,MAAM,CAAC,KAAK;QACrB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAKD,OAAO,CAAC,EAAU,IAAG,CAAC;IACtB,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;CACF;AAhBD,0CAgBC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JumpInstruction = exports.EJumpKind = void 0;
|
|
4
|
-
const InstructionBase_1 = require("./InstructionBase");
|
|
5
|
-
var EJumpKind;
|
|
6
|
-
(function (EJumpKind) {
|
|
7
|
-
EJumpKind["Equal"] = "equal";
|
|
8
|
-
EJumpKind["NotEqual"] = "notEqual";
|
|
9
|
-
EJumpKind["LessThan"] = "lessThan";
|
|
10
|
-
EJumpKind["LessThanEq"] = "lessThanEq";
|
|
11
|
-
EJumpKind["GreaterThan"] = "greaterThan";
|
|
12
|
-
EJumpKind["GreaterThanEq"] = "greaterThanEq";
|
|
13
|
-
EJumpKind["StrictEqual"] = "strictEqual";
|
|
14
|
-
EJumpKind["Always"] = "always";
|
|
15
|
-
})(EJumpKind = exports.EJumpKind || (exports.EJumpKind = {}));
|
|
16
|
-
class JumpInstruction extends InstructionBase_1.InstructionBase {
|
|
17
|
-
constructor(address, kind, left, right) {
|
|
18
|
-
super("jump", address, kind, left, right);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.JumpInstruction = JumpInstruction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JumpInstruction = exports.EJumpKind = void 0;
|
|
4
|
+
const InstructionBase_1 = require("./InstructionBase");
|
|
5
|
+
var EJumpKind;
|
|
6
|
+
(function (EJumpKind) {
|
|
7
|
+
EJumpKind["Equal"] = "equal";
|
|
8
|
+
EJumpKind["NotEqual"] = "notEqual";
|
|
9
|
+
EJumpKind["LessThan"] = "lessThan";
|
|
10
|
+
EJumpKind["LessThanEq"] = "lessThanEq";
|
|
11
|
+
EJumpKind["GreaterThan"] = "greaterThan";
|
|
12
|
+
EJumpKind["GreaterThanEq"] = "greaterThanEq";
|
|
13
|
+
EJumpKind["StrictEqual"] = "strictEqual";
|
|
14
|
+
EJumpKind["Always"] = "always";
|
|
15
|
+
})(EJumpKind = exports.EJumpKind || (exports.EJumpKind = {}));
|
|
16
|
+
class JumpInstruction extends InstructionBase_1.InstructionBase {
|
|
17
|
+
constructor(address, kind, left = null, right = null) {
|
|
18
|
+
super("jump", address, kind, left, right);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.JumpInstruction = JumpInstruction;
|
|
22
22
|
//# sourceMappingURL=JumpInstruction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JumpInstruction.js","sourceRoot":"","sources":["../../src/instructions/JumpInstruction.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,IAAY,SASX;AATD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,kCAAqB,CAAA;IACrB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,4CAA+B,CAAA;IAC/B,wCAA2B,CAAA;IAC3B,8BAAiB,CAAA;AACnB,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED,MAAa,eAAgB,SAAQ,iCAAe;IAClD,YACE,OAAuB,EACvB,IAAe,EACf,
|
|
1
|
+
{"version":3,"file":"JumpInstruction.js","sourceRoot":"","sources":["../../src/instructions/JumpInstruction.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,IAAY,SASX;AATD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,kCAAqB,CAAA;IACrB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,4CAA+B,CAAA;IAC/B,wCAA2B,CAAA;IAC3B,8BAAiB,CAAA;AACnB,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED,MAAa,eAAgB,SAAQ,iCAAe;IAClD,YACE,OAAuB,EACvB,IAAe,EACf,OAAsB,IAAI,EAC1B,QAAuB,IAAI;QAE3B,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AATD,0CASC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OperationInstruction = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
class OperationInstruction extends _1.InstructionBase {
|
|
6
|
-
constructor(kind, temp, left, right) {
|
|
7
|
-
super("op", kind, temp, left, right);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.OperationInstruction = OperationInstruction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationInstruction = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class OperationInstruction extends _1.InstructionBase {
|
|
6
|
+
constructor(kind, temp, left, right) {
|
|
7
|
+
super("op", kind, temp, left, right);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.OperationInstruction = OperationInstruction;
|
|
11
11
|
//# sourceMappingURL=OperationInstruction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationInstruction.js","sourceRoot":"","sources":["../../src/instructions/OperationInstruction.ts"],"names":[],"mappings":";;;AAAA,wBAAoC;AAGpC,MAAa,oBAAqB,SAAQ,kBAAe;IACvD,YAAY,IAAY,EAAE,IAAY,EAAE,IAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"OperationInstruction.js","sourceRoot":"","sources":["../../src/instructions/OperationInstruction.ts"],"names":[],"mappings":";;;AAAA,wBAAoC;AAGpC,MAAa,oBAAqB,SAAQ,kBAAe;IACvD,YAAY,IAAY,EAAE,IAAY,EAAE,IAAY,EAAE,KAAoB;QACxE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;CACF;AAJD,oDAIC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetCounterInstruction = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
class SetCounterInstruction extends _1.InstructionBase {
|
|
6
|
-
constructor(value) {
|
|
7
|
-
super("set", "@counter", value);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.SetCounterInstruction = SetCounterInstruction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetCounterInstruction = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class SetCounterInstruction extends _1.InstructionBase {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super("set", "@counter", value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SetCounterInstruction = SetCounterInstruction;
|
|
11
11
|
//# sourceMappingURL=SetCounterInstruction.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetInstruction = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
class SetInstruction extends _1.InstructionBase {
|
|
6
|
-
constructor(store, value) {
|
|
7
|
-
super("set", store, value);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.SetInstruction = SetInstruction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetInstruction = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class SetInstruction extends _1.InstructionBase {
|
|
6
|
+
constructor(store, value) {
|
|
7
|
+
super("set", store, value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SetInstruction = SetInstruction;
|
|
11
11
|
//# sourceMappingURL=SetInstruction.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZeroSpaceInstruction = void 0;
|
|
4
|
-
const InstructionBase_1 = require("./InstructionBase");
|
|
5
|
-
class ZeroSpaceInstruction extends InstructionBase_1.InstructionBase {
|
|
6
|
-
toString() {
|
|
7
|
-
return this.args.join("");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ZeroSpaceInstruction = ZeroSpaceInstruction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZeroSpaceInstruction = void 0;
|
|
4
|
+
const InstructionBase_1 = require("./InstructionBase");
|
|
5
|
+
class ZeroSpaceInstruction extends InstructionBase_1.InstructionBase {
|
|
6
|
+
toString() {
|
|
7
|
+
return this.args.join("");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ZeroSpaceInstruction = ZeroSpaceInstruction;
|
|
11
11
|
//# sourceMappingURL=ZeroSpaceInstruction.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./InstructionBase"), exports);
|
|
18
|
-
__exportStar(require("./OperationInstruction"), exports);
|
|
19
|
-
__exportStar(require("./SetInstruction"), exports);
|
|
20
|
-
__exportStar(require("./EndInstruction"), exports);
|
|
21
|
-
__exportStar(require("./AddressResolver"), exports);
|
|
22
|
-
__exportStar(require("./JumpInstruction"), exports);
|
|
23
|
-
__exportStar(require("./SetCounterInstruction"), exports);
|
|
24
|
-
__exportStar(require("./ZeroSpaceInstruction"), exports);
|
|
25
|
-
__exportStar(require("./ControlInstructions"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./InstructionBase"), exports);
|
|
18
|
+
__exportStar(require("./OperationInstruction"), exports);
|
|
19
|
+
__exportStar(require("./SetInstruction"), exports);
|
|
20
|
+
__exportStar(require("./EndInstruction"), exports);
|
|
21
|
+
__exportStar(require("./AddressResolver"), exports);
|
|
22
|
+
__exportStar(require("./JumpInstruction"), exports);
|
|
23
|
+
__exportStar(require("./SetCounterInstruction"), exports);
|
|
24
|
+
__exportStar(require("./ZeroSpaceInstruction"), exports);
|
|
25
|
+
__exportStar(require("./ControlInstructions"), exports);
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
package/build/macros/Building.js
CHANGED
|
@@ -1,81 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuildingBuilder = exports.Building = exports.itemNames = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const instructions_1 = require("../instructions");
|
|
6
|
-
const values_1 = require("../values");
|
|
7
|
-
const Function_1 = require("./Function");
|
|
8
|
-
const operators_1 = require("../operators");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildingBuilder = exports.Building = exports.itemNames = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const instructions_1 = require("../instructions");
|
|
6
|
+
const values_1 = require("../values");
|
|
7
|
+
const Function_1 = require("./Function");
|
|
8
|
+
const operators_1 = require("../operators");
|
|
9
|
+
const CompilerError_1 = require("../CompilerError");
|
|
10
|
+
exports.itemNames = [
|
|
11
|
+
"copper",
|
|
12
|
+
"lead",
|
|
13
|
+
"metaglass",
|
|
14
|
+
"graphite",
|
|
15
|
+
"sand",
|
|
16
|
+
"coal",
|
|
17
|
+
"titanium",
|
|
18
|
+
"thorium",
|
|
19
|
+
"scrap",
|
|
20
|
+
"silicon",
|
|
21
|
+
"plastanium",
|
|
22
|
+
"phaseFabric",
|
|
23
|
+
"surgeAlloy",
|
|
24
|
+
"sporePod",
|
|
25
|
+
"blastCompound",
|
|
26
|
+
"pyratite",
|
|
27
|
+
];
|
|
28
|
+
class Building extends values_1.ObjectValue {
|
|
29
|
+
constructor({ scope, name, renameable, }) {
|
|
30
|
+
super(scope, {
|
|
31
|
+
$get: new Function_1.MacroFunction(scope, (prop) => {
|
|
32
|
+
if (prop instanceof values_1.LiteralValue && typeof prop.data === "string") {
|
|
33
|
+
const name = exports.itemNames.includes(prop.data)
|
|
34
|
+
? (0, utils_1.camelToDashCase)(prop.data)
|
|
35
|
+
: prop.data;
|
|
36
|
+
const temp = new values_1.TempValue({ scope });
|
|
37
|
+
return [
|
|
38
|
+
temp,
|
|
39
|
+
[new instructions_1.InstructionBase("sensor", temp, this, `@${name}`)],
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
if (prop instanceof values_1.StoreValue) {
|
|
43
|
+
const temp = new values_1.TempValue({ scope });
|
|
44
|
+
return [temp, [new instructions_1.InstructionBase("sensor", temp, this, prop)]];
|
|
45
|
+
}
|
|
46
|
+
throw new CompilerError_1.CompilerError("Building property acessors must be string literals or stores");
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
this.name = name;
|
|
50
|
+
this.renameable = !!renameable;
|
|
51
|
+
}
|
|
52
|
+
toString() {
|
|
53
|
+
return this.name;
|
|
54
|
+
}
|
|
55
|
+
rename(name) {
|
|
56
|
+
if (!this.renameable)
|
|
57
|
+
return;
|
|
58
|
+
this.name = name;
|
|
59
|
+
this.renameable = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Building = Building;
|
|
63
|
+
class BuildingBuilder extends values_1.ObjectValue {
|
|
64
|
+
constructor(scope) {
|
|
65
|
+
super(scope, {
|
|
66
|
+
$call: new Function_1.MacroFunction(scope, (nameLit) => {
|
|
67
|
+
if (!(nameLit instanceof values_1.LiteralValue))
|
|
68
|
+
throw new CompilerError_1.CompilerError("Block name must be a literal.");
|
|
69
|
+
if (typeof nameLit.data !== "string")
|
|
70
|
+
throw new CompilerError_1.CompilerError("Block name must be a string.");
|
|
71
|
+
return [new Building({ scope, name: nameLit.data }), []];
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.BuildingBuilder = BuildingBuilder;
|
|
77
|
+
for (const key in operators_1.operatorMap) {
|
|
78
|
+
const kind = operators_1.operatorMap[key];
|
|
79
|
+
Building.prototype[key] = function (scope, value) {
|
|
80
|
+
const left = new values_1.StoreValue(scope, this.name);
|
|
81
|
+
const [right, rightInst] = value.eval(scope);
|
|
82
|
+
const temp = new values_1.TempValue({ scope });
|
|
83
|
+
return [
|
|
84
|
+
temp,
|
|
85
|
+
[...rightInst, new instructions_1.OperationInstruction(kind, temp, left, right)],
|
|
86
|
+
];
|
|
87
|
+
};
|
|
88
|
+
}
|
|
81
89
|
//# sourceMappingURL=Building.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Building.js","sourceRoot":"","sources":["../../src/macros/Building.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C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Q,CAAC,SAAS,CAAC,GAAQ,CAAC,GAAG,UAE7B,KAAa,EACb,KAAa;QAEb,MAAM,IAAI,GAAG,IAAI,mBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,kBAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACtC,OAAO;YACL,IAAI;YACJ,CAAC,GAAG,SAAS,EAAE,IAAI,mCAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SAClE,CAAC;IACJ,CAAC,CAAC;CACH"}
|
package/build/macros/Function.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MacroFunction = void 0;
|
|
4
|
-
const values_1 = require("../values");
|
|
5
|
-
class MacroFunction extends values_1.VoidValue {
|
|
6
|
-
constructor(scope, fn) {
|
|
7
|
-
super(scope);
|
|
8
|
-
this.macro = true;
|
|
9
|
-
this.constant = true;
|
|
10
|
-
this.fn = fn;
|
|
11
|
-
}
|
|
12
|
-
call(scope, args) {
|
|
13
|
-
return this.fn.apply(this, args);
|
|
14
|
-
}
|
|
15
|
-
eval(
|
|
16
|
-
return [this, []];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.MacroFunction = MacroFunction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MacroFunction = void 0;
|
|
4
|
+
const values_1 = require("../values");
|
|
5
|
+
class MacroFunction extends values_1.VoidValue {
|
|
6
|
+
constructor(scope, fn) {
|
|
7
|
+
super(scope);
|
|
8
|
+
this.macro = true;
|
|
9
|
+
this.constant = true;
|
|
10
|
+
this.fn = fn;
|
|
11
|
+
}
|
|
12
|
+
call(scope, args) {
|
|
13
|
+
return this.fn.apply(this, args);
|
|
14
|
+
}
|
|
15
|
+
eval(_scope) {
|
|
16
|
+
return [this, []];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.MacroFunction = MacroFunction;
|
|
20
20
|
//# sourceMappingURL=Function.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Function.js","sourceRoot":"","sources":["../../src/macros/Function.ts"],"names":[],"mappings":";;;AACA,sCAAsC;
|
|
1
|
+
{"version":3,"file":"Function.js","sourceRoot":"","sources":["../../src/macros/Function.ts"],"names":[],"mappings":";;;AACA,sCAAsC;AAMtC,MAAa,aAEX,SAAQ,kBAAS;IAIjB,YAAY,KAAa,EAAE,EAAiB;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC;QAJf,UAAK,GAAG,IAAI,CAAC;QACb,aAAQ,GAAG,IAAI,CAAC;QAId,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC,KAAa,EAAE,IAAc;QAChC,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,MAAc;QACjB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;CACF;AAhBD,sCAgBC"}
|
package/build/macros/Math.js
CHANGED
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MlogMath = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return [new
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MlogMath = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
5
|
+
const CompilerError_1 = require("../CompilerError");
|
|
6
|
+
const instructions_1 = require("../instructions");
|
|
7
|
+
const values_1 = require("../values");
|
|
8
|
+
const Function_1 = require("./Function");
|
|
9
|
+
const mathOperations = {
|
|
10
|
+
max: (a, b) => Math.max(a, b),
|
|
11
|
+
min: (a, b) => Math.min(a, b),
|
|
12
|
+
angle: (x, y) => {
|
|
13
|
+
const angle = (Math.atan2(y, x) * 180) / Math.PI;
|
|
14
|
+
return angle < 0 ? angle + 360 : angle;
|
|
15
|
+
},
|
|
16
|
+
len: (a, b) => Math.sqrt(a ** 2 + b ** 2),
|
|
17
|
+
noise: null,
|
|
18
|
+
abs: a => Math.abs(a),
|
|
19
|
+
log: a => Math.log(a),
|
|
20
|
+
log10: a => Math.log10(a),
|
|
21
|
+
sin: a => Math.sin(a),
|
|
22
|
+
cos: a => Math.cos(a),
|
|
23
|
+
tan: a => Math.tan(a),
|
|
24
|
+
floor: a => Math.floor(a),
|
|
25
|
+
ceil: a => Math.ceil(a),
|
|
26
|
+
sqrt: a => Math.sqrt(a),
|
|
27
|
+
rand: null,
|
|
28
|
+
};
|
|
29
|
+
function createMacroMathOperations(scope) {
|
|
30
|
+
const macroMathOperations = {};
|
|
31
|
+
for (const key in mathOperations) {
|
|
32
|
+
const fn = mathOperations[key];
|
|
33
|
+
macroMathOperations[key] = new Function_1.MacroFunction(scope, (a, b) => {
|
|
34
|
+
if (b) {
|
|
35
|
+
if (fn && a instanceof values_1.LiteralValue && b instanceof values_1.LiteralValue) {
|
|
36
|
+
if (typeof a.data !== "number" || typeof b.data !== "number")
|
|
37
|
+
throw new CompilerError_1.CompilerError("Cannot do math operation with non-numerical literals.");
|
|
38
|
+
return [new values_1.LiteralValue(scope, fn(a.num, b.num)), []];
|
|
39
|
+
}
|
|
40
|
+
const temp = new values_1.TempValue({ scope });
|
|
41
|
+
return [temp, [new instructions_1.OperationInstruction(key, temp, a, b)]];
|
|
42
|
+
}
|
|
43
|
+
if (fn && a instanceof values_1.LiteralValue) {
|
|
44
|
+
if (typeof a.data !== "number")
|
|
45
|
+
throw new CompilerError_1.CompilerError("Cannot do math operation with non-numerical literal.");
|
|
46
|
+
return [new values_1.LiteralValue(scope, fn(a.num)), []];
|
|
47
|
+
}
|
|
48
|
+
const temp = new values_1.TempValue({ scope });
|
|
49
|
+
return [temp, [new instructions_1.OperationInstruction(key, temp, a, b)]];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return macroMathOperations;
|
|
53
|
+
}
|
|
54
|
+
class MlogMath extends values_1.ObjectValue {
|
|
55
|
+
constructor(scope) {
|
|
56
|
+
super(scope, createMacroMathOperations(scope));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.MlogMath = MlogMath;
|
|
60
|
+
// op angle result a b
|
|
61
|
+
// op len result a b
|
|
57
62
|
//# sourceMappingURL=Math.js.map
|
package/build/macros/Math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Math.js","sourceRoot":"","sources":["../../src/macros/Math.ts"],"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