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
package/build/macros/Memory.js
CHANGED
|
@@ -1,61 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryBuilder = void 0;
|
|
4
|
-
const operators_1 = require("../operators");
|
|
5
|
-
const instructions_1 = require("../instructions");
|
|
6
|
-
const values_1 = require("../values");
|
|
7
|
-
const Function_1 = require("./Function");
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!(
|
|
54
|
-
throw new
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryBuilder = void 0;
|
|
4
|
+
const operators_1 = require("../operators");
|
|
5
|
+
const instructions_1 = require("../instructions");
|
|
6
|
+
const values_1 = require("../values");
|
|
7
|
+
const Function_1 = require("./Function");
|
|
8
|
+
const CompilerError_1 = require("../CompilerError");
|
|
9
|
+
class MemoryEntry extends values_1.ObjectValue {
|
|
10
|
+
constructor(scope, mem, prop) {
|
|
11
|
+
super(scope, {
|
|
12
|
+
$eval: new Function_1.MacroFunction(scope, () => {
|
|
13
|
+
const temp = new values_1.TempValue({ scope });
|
|
14
|
+
return [temp, [new instructions_1.InstructionBase("read", temp, mem.cell, prop)]];
|
|
15
|
+
}),
|
|
16
|
+
"$=": new Function_1.MacroFunction(scope, value => {
|
|
17
|
+
return [value, [new instructions_1.InstructionBase("write", value, mem.cell, prop)]];
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (const operator of operators_1.operators) {
|
|
23
|
+
if (operator === "=")
|
|
24
|
+
continue;
|
|
25
|
+
MemoryEntry.prototype[operator] = function (...args) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return
|
|
27
|
+
return values_1.BaseValue.prototype[operator].apply(this, args);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
class MemoryMacro extends values_1.ObjectValue {
|
|
31
|
+
constructor(scope, cell, size) {
|
|
32
|
+
super(scope, {
|
|
33
|
+
$get: new Function_1.MacroFunction(scope, (prop) => {
|
|
34
|
+
if (prop instanceof values_1.LiteralValue && typeof prop.data !== "number")
|
|
35
|
+
throw new CompilerError_1.CompilerError(`Invalid memory object property: "${prop.data}"`);
|
|
36
|
+
const obj = new MemoryEntry(scope, this, prop);
|
|
37
|
+
return [obj, []];
|
|
38
|
+
}),
|
|
39
|
+
length: size,
|
|
40
|
+
size,
|
|
41
|
+
});
|
|
42
|
+
this.cell = cell;
|
|
43
|
+
this.name = cell.toString();
|
|
44
|
+
}
|
|
45
|
+
toString() {
|
|
46
|
+
return this.name;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class MemoryBuilder extends values_1.ObjectValue {
|
|
50
|
+
constructor(scope) {
|
|
51
|
+
super(scope, {
|
|
52
|
+
$call: new Function_1.MacroFunction(scope, (cell, size = new values_1.LiteralValue(scope, 64)) => {
|
|
53
|
+
if (!(cell instanceof values_1.ObjectValue))
|
|
54
|
+
throw new CompilerError_1.CompilerError("Memory cell must be a building object.");
|
|
55
|
+
if (!(size instanceof values_1.LiteralValue && typeof size.data === "number"))
|
|
56
|
+
throw new CompilerError_1.CompilerError("The memory size must be a number literal.");
|
|
57
|
+
return [new MemoryMacro(scope, cell, size), []];
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.MemoryBuilder = MemoryBuilder;
|
|
61
63
|
//# sourceMappingURL=Memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.js","sourceRoot":"","sources":["../../src/macros/Memory.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"Memory.js","sourceRoot":"","sources":["../../src/macros/Memory.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,kDAAkD;AAElD,sCAA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oBAC/D,MAAM,IAAI,6BAAa,CACrB,oCAAoC,IAAI,CAAC,IAAI,GAAG,CACjD,CAAC;gBACJ,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC/C,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACnB,CAAC,CAAC;YACF,MAAM,EAAE,IAAI;YACZ,IAAI;SACL,CAAC,CAAC;QAZ6B,SAAI,GAAJ,IAAI,CAAa;QAcjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAlBD,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CAiBF;AAED,MAAa,aAAc,SAAQ,oBAAW;IAC5C,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE;YACX,KAAK,EAAE,IAAI,wBAAa,CACtB,KAAK,EACL,CAAC,IAAY,EAAE,OAAe,IAAI,qBAAY,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;gBAC3D,IAAI,CAAC,CAAC,IAAI,YAAY,oBAAW,CAAC;oBAChC,MAAM,IAAI,6BAAa,CAAC,wCAAwC,CAAC,CAAC;gBAEpE,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAY,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;oBAClE,MAAM,IAAI,6BAAa,CACrB,2CAA2C,CAC5C,CAAC;gBAEJ,OAAO,CAAC,IAAI,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YAClD,CAAC,CACF;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,sCAmBC"}
|
|
@@ -1,98 +1,111 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unit = exports.UCommandsNamespace = exports.VarsNamespace = exports.NamespaceMacro = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const values_1 = require("../values");
|
|
7
|
-
const Building_1 = require("./Building");
|
|
8
|
-
const instructions_1 = require("../instructions");
|
|
9
|
-
const operators_1 = require("../operators");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.data.$get
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.data.$get = new _1.MacroFunction(scope, prop => {
|
|
47
|
-
if (!(prop instanceof values_1.LiteralValue) || typeof prop.data !== "string")
|
|
48
|
-
throw new
|
|
49
|
-
const symbolName = prop.data[0].toUpperCase() + prop.data.slice(1);
|
|
50
|
-
return [new values_1.StoreValue(scope, `@command${symbolName}`), []];
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.UCommandsNamespace = UCommandsNamespace;
|
|
55
|
-
// TODO: repeated logic between UnitMacro and Building
|
|
56
|
-
class Unit extends values_1.ObjectValue {
|
|
57
|
-
constructor(scope, name) {
|
|
58
|
-
super(scope, {
|
|
59
|
-
$get: new _1.MacroFunction(scope, prop => {
|
|
60
|
-
if (prop instanceof values_1.LiteralValue && typeof prop.data === "string") {
|
|
61
|
-
const name = Building_1.itemNames.includes(prop.data)
|
|
62
|
-
? (0, utils_1.camelToDashCase)(prop.data)
|
|
63
|
-
: prop.data;
|
|
64
|
-
const temp = new values_1.TempValue(scope);
|
|
65
|
-
// special case, should return another unit or building
|
|
66
|
-
const result = prop.data === "controller"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Unit = exports.UCommandsNamespace = exports.VarsNamespace = exports.NamespaceMacro = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const values_1 = require("../values");
|
|
7
|
+
const Building_1 = require("./Building");
|
|
8
|
+
const instructions_1 = require("../instructions");
|
|
9
|
+
const operators_1 = require("../operators");
|
|
10
|
+
const CompilerError_1 = require("../CompilerError");
|
|
11
|
+
class NamespaceMacro extends values_1.ObjectValue {
|
|
12
|
+
constructor(scope, { changeCasing = false } = {}) {
|
|
13
|
+
super(scope, {
|
|
14
|
+
$get: new _1.MacroFunction(scope, prop => {
|
|
15
|
+
if (!(prop instanceof values_1.LiteralValue) || typeof prop.data !== "string")
|
|
16
|
+
throw new CompilerError_1.CompilerError("Cannot use dynamic properties on object macros");
|
|
17
|
+
const symbolName = this.changeCasing
|
|
18
|
+
? (0, utils_1.camelToDashCase)(prop.data)
|
|
19
|
+
: prop.data;
|
|
20
|
+
return [new values_1.StoreValue(scope, `@${symbolName}`), []];
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
this.changeCasing = changeCasing;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NamespaceMacro = NamespaceMacro;
|
|
27
|
+
class VarsNamespace extends NamespaceMacro {
|
|
28
|
+
constructor(scope) {
|
|
29
|
+
super(scope);
|
|
30
|
+
const $get = this.data.$get;
|
|
31
|
+
this.data.$get = new _1.MacroFunction(scope, prop => {
|
|
32
|
+
if (prop instanceof values_1.LiteralValue) {
|
|
33
|
+
if (prop.data === "unit")
|
|
34
|
+
return [new Unit({ scope, name: "@unit" }), []];
|
|
35
|
+
if (prop.data === "this")
|
|
36
|
+
return [new Building_1.Building({ scope, name: "@this" }), []];
|
|
37
|
+
}
|
|
38
|
+
return $get.call(scope, [prop]);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.VarsNamespace = VarsNamespace;
|
|
43
|
+
class UCommandsNamespace extends NamespaceMacro {
|
|
44
|
+
constructor(scope) {
|
|
45
|
+
super(scope);
|
|
46
|
+
this.data.$get = new _1.MacroFunction(scope, prop => {
|
|
47
|
+
if (!(prop instanceof values_1.LiteralValue) || typeof prop.data !== "string")
|
|
48
|
+
throw new CompilerError_1.CompilerError("Cannot use dynamic properties on object macros");
|
|
49
|
+
const symbolName = prop.data[0].toUpperCase() + prop.data.slice(1);
|
|
50
|
+
return [new values_1.StoreValue(scope, `@command${symbolName}`), []];
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.UCommandsNamespace = UCommandsNamespace;
|
|
55
|
+
// TODO: repeated logic between UnitMacro and Building
|
|
56
|
+
class Unit extends values_1.ObjectValue {
|
|
57
|
+
constructor({ scope, name, renameable, }) {
|
|
58
|
+
super(scope, {
|
|
59
|
+
$get: new _1.MacroFunction(scope, prop => {
|
|
60
|
+
if (prop instanceof values_1.LiteralValue && typeof prop.data === "string") {
|
|
61
|
+
const name = Building_1.itemNames.includes(prop.data)
|
|
62
|
+
? (0, utils_1.camelToDashCase)(prop.data)
|
|
63
|
+
: prop.data;
|
|
64
|
+
const temp = new values_1.TempValue({ scope });
|
|
65
|
+
// special case, should return another unit or building
|
|
66
|
+
const result = prop.data === "controller"
|
|
67
|
+
? new Unit({
|
|
68
|
+
scope,
|
|
69
|
+
name: scope.makeTempName(),
|
|
70
|
+
renameable: true,
|
|
71
|
+
})
|
|
72
|
+
: temp;
|
|
73
|
+
return [
|
|
74
|
+
result,
|
|
75
|
+
[new instructions_1.InstructionBase("sensor", result, this, `@${name}`)],
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
if (prop instanceof values_1.StoreValue) {
|
|
79
|
+
const temp = new values_1.TempValue({ scope });
|
|
80
|
+
return [temp, [new instructions_1.InstructionBase("sensor", temp, this, prop)]];
|
|
81
|
+
}
|
|
82
|
+
throw new CompilerError_1.CompilerError("Building property acessors must be string literals or stores");
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
this.name = name;
|
|
86
|
+
this.renameable = !!renameable;
|
|
87
|
+
}
|
|
88
|
+
toString() {
|
|
89
|
+
return this.name;
|
|
90
|
+
}
|
|
91
|
+
rename(name) {
|
|
92
|
+
if (!this.renameable)
|
|
93
|
+
return;
|
|
94
|
+
this.name = name;
|
|
95
|
+
this.renameable = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.Unit = Unit;
|
|
99
|
+
for (const key in operators_1.operatorMap) {
|
|
100
|
+
const kind = operators_1.operatorMap[key];
|
|
101
|
+
Unit.prototype[key] = function (scope, value) {
|
|
102
|
+
const left = new values_1.StoreValue(scope, this.name);
|
|
103
|
+
const [right, rightInst] = value.eval(scope);
|
|
104
|
+
const temp = new values_1.TempValue({ scope });
|
|
105
|
+
return [
|
|
106
|
+
temp,
|
|
107
|
+
[...rightInst, new instructions_1.OperationInstruction(kind, temp, left, right)],
|
|
108
|
+
];
|
|
109
|
+
};
|
|
110
|
+
}
|
|
98
111
|
//# sourceMappingURL=Namespace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Namespace.js","sourceRoot":"","sources":["../../src/macros/Namespace.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C,wBAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"Namespace.js","sourceRoot":"","sources":["../../src/macros/Namespace.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C,wBAAkC;AAElC,sCAA6E;AAC7E,yCAAiD;AACjD,kDAAwE;AACxE,4CAA2C;AAC3C,oDAAiD;AAKjD,MAAa,cAAe,SAAQ,oBAAW;IAE7C,YACE,KAAa,EACb,EAAE,YAAY,GAAG,KAAK,KAA4B,EAAE;QAEpD,KAAK,CAAC,KAAK,EAAE;YACX,IAAI,EAAE,IAAI,gBAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;gBACpC,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAY,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;oBAClE,MAAM,IAAI,6BAAa,CACrB,gDAAgD,CACjD,CAAC;gBACJ,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY;oBAClC,CAAC,CAAC,IAAA,uBAAe,EAAC,IAAI,CAAC,IAAI,CAAC;oBAC5B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBACd,OAAO,CAAC,IAAI,mBAAU,CAAC,KAAK,EAAE,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACvD,CAAC,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AApBD,wCAoBC;AAED,MAAa,aAAc,SAAQ,cAAc;IAC/C,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAqB,CAAC;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,gBAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EA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AAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;CACF;AAvDD,oBAuDC;AAED,KAAK,MAAM,GAAG,IAAI,uBAAW,EAAE;IAE7B,MAAM,IAAI,GAAG,uBAAW,CAAC,GAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,SAAS,CAAC,GAAQ,CAAC,GAAG,UAEzB,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/Other.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Concat = void 0;
|
|
4
|
-
const values_1 = require("../values");
|
|
5
|
-
const Function_1 = require("./Function");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Concat = void 0;
|
|
4
|
+
const values_1 = require("../values");
|
|
5
|
+
const Function_1 = require("./Function");
|
|
6
|
+
const CompilerError_1 = require("../CompilerError");
|
|
7
|
+
class Concat extends Function_1.MacroFunction {
|
|
8
|
+
constructor(scope) {
|
|
9
|
+
super(scope, (...values) => {
|
|
10
|
+
for (const value of values)
|
|
11
|
+
if (!(value instanceof values_1.LiteralValue))
|
|
12
|
+
throw new CompilerError_1.CompilerError("Concat arguments must all be literal values.");
|
|
13
|
+
return [
|
|
14
|
+
new values_1.LiteralValue(scope, values.map(v => v.data).join("")),
|
|
15
|
+
[],
|
|
16
|
+
];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Concat = Concat;
|
|
20
21
|
//# sourceMappingURL=Other.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Other.js","sourceRoot":"","sources":["../../src/macros/Other.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAEzC,yCAA2C;
|
|
1
|
+
{"version":3,"file":"Other.js","sourceRoot":"","sources":["../../src/macros/Other.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAEzC,yCAA2C;AAC3C,oDAAiD;AAEjD,MAAa,MAAO,SAAQ,wBAAa;IACvC,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,MAAgB,EAAE,EAAE;YACnC,KAAK,MAAM,KAAK,IAAI,MAAM;gBACxB,IAAI,CAAC,CAAC,KAAK,YAAY,qBAAY,CAAC;oBAClC,MAAM,IAAI,6BAAa,CACrB,8CAA8C,CAC/C,CAAC;YACN,OAAO;gBACL,IAAI,qBAAY,CACd,KAAK,EACL,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACnD;gBACD,EAAE;aACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,wBAiBC"}
|
package/build/macros/RawValue.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RawValueMacro = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawValueMacro = void 0;
|
|
4
|
+
const CompilerError_1 = require("../CompilerError");
|
|
5
|
+
const values_1 = require("../values");
|
|
6
|
+
const Function_1 = require("./Function");
|
|
7
|
+
class RawValueMacro extends Function_1.MacroFunction {
|
|
8
|
+
constructor(scope) {
|
|
9
|
+
super(scope, (name) => {
|
|
10
|
+
if (!(name instanceof values_1.LiteralValue) || typeof name.data !== "string")
|
|
11
|
+
throw new CompilerError_1.CompilerError("The name of the building must be a string literal.");
|
|
12
|
+
return [new values_1.StoreValue(scope, name.data), []];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RawValueMacro = RawValueMacro;
|
|
16
17
|
//# sourceMappingURL=RawValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RawValue.js","sourceRoot":"","sources":["../../src/macros/RawValue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RawValue.js","sourceRoot":"","sources":["../../src/macros/RawValue.ts"],"names":[],"mappings":";;;AAAA,oDAAiD;AAEjD,sCAAqD;AACrD,yCAA2C;AAE3C,MAAa,aAAc,SAAQ,wBAAa;IAC9C,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;YAC5B,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAY,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAClE,MAAM,IAAI,6BAAa,CACrB,oDAAoD,CACrD,CAAC;YAEJ,OAAO,CAAC,IAAI,mBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAXD,sCAWC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Control = void 0;
|
|
4
|
-
const instructions_1 = require("../../instructions");
|
|
5
|
-
const __1 = require("..");
|
|
6
|
-
const values_1 = require("../../values");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Control = void 0;
|
|
4
|
+
const instructions_1 = require("../../instructions");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const values_1 = require("../../values");
|
|
7
|
+
const CompilerError_1 = require("../../CompilerError");
|
|
8
|
+
const validKinds = ["enabled", "shoot", "shootp", "config", "color"];
|
|
9
|
+
class Control extends __1.MacroFunction {
|
|
10
|
+
constructor(scope) {
|
|
11
|
+
super(scope, (kind, building, ...args) => {
|
|
12
|
+
if (!(kind instanceof values_1.LiteralValue) || typeof kind.data !== "string")
|
|
13
|
+
throw new CompilerError_1.CompilerError("The control kind must be a string literal");
|
|
14
|
+
if (!validKinds.includes(kind.data))
|
|
15
|
+
throw new CompilerError_1.CompilerError("Invalid control kind");
|
|
16
|
+
if (!(building instanceof values_1.ObjectValue))
|
|
17
|
+
throw new CompilerError_1.CompilerError("The building must be an object value");
|
|
18
|
+
return [
|
|
19
|
+
null,
|
|
20
|
+
[new instructions_1.InstructionBase("control", kind.data, building, ...args)],
|
|
21
|
+
];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Control = Control;
|
|
25
26
|
//# sourceMappingURL=Control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../src/macros/commands/Control.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,0BAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../src/macros/commands/Control.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,0BAAmC;AAEnC,yCAAyD;AACzD,uDAAoD;AAEpD,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACrE,MAAa,OAAQ,SAAQ,iBAAmB;IAC9C,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE;YACvC,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAY,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAClE,MAAM,IAAI,6BAAa,CAAC,2CAA2C,CAAC,CAAC;YAEvE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;gBACjC,MAAM,IAAI,6BAAa,CAAC,sBAAsB,CAAC,CAAC;YAElD,IAAI,CAAC,CAAC,QAAQ,YAAY,oBAAW,CAAC;gBACpC,MAAM,IAAI,6BAAa,CAAC,sCAAsC,CAAC,CAAC;YAElE,OAAO;gBACL,IAAI;gBACJ,CAAC,IAAI,8BAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;aAC/D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlBD,0BAkBC"}
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Draw = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Draw = void 0;
|
|
4
|
+
const CompilerError_1 = require("../../CompilerError");
|
|
5
|
+
const instructions_1 = require("../../instructions");
|
|
6
|
+
const values_1 = require("../../values");
|
|
7
|
+
const Function_1 = require("../Function");
|
|
8
|
+
class Draw extends Function_1.MacroFunction {
|
|
9
|
+
constructor(scope) {
|
|
10
|
+
super(scope, (kind, ...args) => {
|
|
11
|
+
if (!(kind instanceof values_1.LiteralValue && typeof kind.data === "string"))
|
|
12
|
+
throw new CompilerError_1.CompilerError("Draw kind must be literal.");
|
|
13
|
+
if ([
|
|
14
|
+
"clear",
|
|
15
|
+
"color",
|
|
16
|
+
"stroke",
|
|
17
|
+
"line",
|
|
18
|
+
"rect",
|
|
19
|
+
"lineRect",
|
|
20
|
+
"poly",
|
|
21
|
+
"linePoly",
|
|
22
|
+
"triangle",
|
|
23
|
+
"image",
|
|
24
|
+
].indexOf(kind.data) === -1)
|
|
25
|
+
throw new CompilerError_1.CompilerError("Draw kind must be valid");
|
|
26
|
+
return [
|
|
27
|
+
null,
|
|
28
|
+
[
|
|
29
|
+
new instructions_1.InstructionBase("draw", kind.data, ...args.map(v => {
|
|
30
|
+
if (v instanceof values_1.LiteralValue && typeof v.data === "string")
|
|
31
|
+
return v.data;
|
|
32
|
+
return v;
|
|
33
|
+
})),
|
|
34
|
+
],
|
|
35
|
+
];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Draw = Draw;
|
|
39
40
|
//# sourceMappingURL=Draw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Draw.js","sourceRoot":"","sources":["../../../src/macros/commands/Draw.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AAErD,yCAA4C;AAC5C,0CAA4C;AAE5C,MAAa,IAAK,SAAQ,
|
|
1
|
+
{"version":3,"file":"Draw.js","sourceRoot":"","sources":["../../../src/macros/commands/Draw.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,qDAAqD;AAErD,yCAA4C;AAC5C,0CAA4C;AAE5C,MAAa,IAAK,SAAQ,wBAAmB;IAC3C,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,CAAC,IAAY,EAAE,GAAG,IAAc,EAAE,EAAE;YAC/C,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAY,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;gBAClE,MAAM,IAAI,6BAAa,CAAC,4BAA4B,CAAC,CAAC;YACxD,IACE;gBACE,OAAO;gBACP,OAAO;gBACP,QAAQ;gBACR,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,UAAU;gBACV,UAAU;gBACV,OAAO;aACR,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAE3B,MAAM,IAAI,6BAAa,CAAC,yBAAyB,CAAC,CAAC;YACrD,OAAO;gBACL,IAAI;gBACJ;oBACE,IAAI,8BAAe,CACjB,MAAM,EACN,IAAI,CAAC,IAAI,EACT,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACd,IAAI,CAAC,YAAY,qBAAY,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;4BACzD,OAAO,CAAC,CAAC,IAAI,CAAC;wBAChB,OAAO,CAAC,CAAC;oBACX,CAAC,CAAC,CACH;iBACF;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApCD,oBAoCC"}
|