mlogjs 0.2.1 → 0.2.2

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 (218) hide show
  1. package/build/bin.cjs +69 -0
  2. package/dist/bin.cjs +69 -0
  3. package/dist/index.cjs +1817 -0
  4. package/dist/index.mjs +1813 -0
  5. package/dist/types/Compiler.d.ts +18 -0
  6. package/{build → dist/types}/Scope.d.ts +23 -26
  7. package/dist/types/bin.d.ts +1 -0
  8. package/dist/types/handlers/BlockStatement.d.ts +2 -0
  9. package/dist/types/handlers/CallExpression.d.ts +3 -0
  10. package/dist/types/handlers/ForStatement.d.ts +2 -0
  11. package/{build → dist/types}/handlers/Function.d.ts +4 -4
  12. package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
  13. package/dist/types/handlers/IfStatement.d.ts +2 -0
  14. package/{build → dist/types}/handlers/Literal.d.ts +2 -2
  15. package/{build → dist/types}/handlers/Object.d.ts +4 -4
  16. package/{build → dist/types}/handlers/OperationExpressions.d.ts +7 -7
  17. package/dist/types/handlers/Program.d.ts +2 -0
  18. package/dist/types/handlers/Statements.d.ts +5 -0
  19. package/dist/types/handlers/TemplateExpression.d.ts +2 -0
  20. package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
  21. package/dist/types/handlers/WhileStatement.d.ts +2 -0
  22. package/{build → dist/types}/handlers/index.d.ts +14 -14
  23. package/dist/types/index.d.ts +1 -0
  24. package/{build → dist/types}/initScope.d.ts +2 -2
  25. package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
  26. package/{build → dist/types}/instructions/ControlInstructions.d.ts +11 -11
  27. package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
  28. package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
  29. package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
  30. package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
  31. package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
  32. package/{build → dist/types}/instructions/SetInstruction.d.ts +5 -5
  33. package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
  34. package/{build → dist/types}/instructions/index.d.ts +9 -9
  35. package/{build → dist/types}/macros/Building.d.ts +11 -11
  36. package/dist/types/macros/Function.d.ts +12 -0
  37. package/{build → dist/types}/macros/Math.d.ts +5 -5
  38. package/{build → dist/types}/macros/Memory.d.ts +5 -5
  39. package/{build → dist/types}/macros/Namespace.d.ts +21 -21
  40. package/{build → dist/types}/macros/Other.d.ts +5 -5
  41. package/{build → dist/types}/macros/RawValue.d.ts +5 -5
  42. package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
  43. package/{build → dist/types}/macros/commands/Draw.d.ts +5 -5
  44. package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
  45. package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
  46. package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
  47. package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
  48. package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
  49. package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
  50. package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
  51. package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
  52. package/dist/types/macros/commands/UnitControl.d.ts +5 -0
  53. package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
  54. package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
  55. package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
  56. package/{build → dist/types}/macros/commands/index.d.ts +14 -14
  57. package/{build → dist/types}/macros/index.d.ts +7 -7
  58. package/{build → dist/types}/operators.d.ts +25 -25
  59. package/dist/types/types.d.ts +100 -0
  60. package/{build → dist/types}/utils.d.ts +3 -3
  61. package/{build → dist/types}/values/BaseValue.d.ts +5 -5
  62. package/{build → dist/types}/values/FunctionValue.d.ts +34 -34
  63. package/{build → dist/types}/values/LiteralValue.d.ts +12 -12
  64. package/dist/types/values/ObjectValue.d.ts +19 -0
  65. package/{build → dist/types}/values/StoreValue.d.ts +11 -11
  66. package/{build → dist/types}/values/TempValue.d.ts +12 -12
  67. package/{build → dist/types}/values/VoidValue.d.ts +13 -11
  68. package/{build → dist/types}/values/index.d.ts +6 -6
  69. package/doc/README.md +9 -0
  70. package/lib/eslib/lib.es5.d.ts +1 -1
  71. package/lib/traits.d.ts +0 -1
  72. package/package.json +17 -27
  73. package/build/Compiler.d.ts +0 -18
  74. package/build/Compiler.js +0 -100
  75. package/build/Compiler.js.map +0 -1
  76. package/build/Scope.js +0 -61
  77. package/build/Scope.js.map +0 -1
  78. package/build/bin.d.ts +0 -2
  79. package/build/bin.js +0 -61
  80. package/build/bin.js.map +0 -1
  81. package/build/handlers/BlockStatement.d.ts +0 -2
  82. package/build/handlers/BlockStatement.js +0 -14
  83. package/build/handlers/BlockStatement.js.map +0 -1
  84. package/build/handlers/CallExpression.d.ts +0 -3
  85. package/build/handlers/CallExpression.js +0 -20
  86. package/build/handlers/CallExpression.js.map +0 -1
  87. package/build/handlers/ForStatement.d.ts +0 -2
  88. package/build/handlers/ForStatement.js +0 -32
  89. package/build/handlers/ForStatement.js.map +0 -1
  90. package/build/handlers/Function.js +0 -36
  91. package/build/handlers/Function.js.map +0 -1
  92. package/build/handlers/Identifier.js +0 -8
  93. package/build/handlers/Identifier.js.map +0 -1
  94. package/build/handlers/IfStatement.d.ts +0 -2
  95. package/build/handlers/IfStatement.js +0 -25
  96. package/build/handlers/IfStatement.js.map +0 -1
  97. package/build/handlers/Literal.js +0 -18
  98. package/build/handlers/Literal.js.map +0 -1
  99. package/build/handlers/Object.js +0 -44
  100. package/build/handlers/Object.js.map +0 -1
  101. package/build/handlers/OperationExpressions.js +0 -33
  102. package/build/handlers/OperationExpressions.js.map +0 -1
  103. package/build/handlers/Program.d.ts +0 -2
  104. package/build/handlers/Program.js +0 -9
  105. package/build/handlers/Program.js.map +0 -1
  106. package/build/handlers/Statements.d.ts +0 -5
  107. package/build/handlers/Statements.js +0 -30
  108. package/build/handlers/Statements.js.map +0 -1
  109. package/build/handlers/TemplateExpression.d.ts +0 -2
  110. package/build/handlers/TemplateExpression.js +0 -18
  111. package/build/handlers/TemplateExpression.js.map +0 -1
  112. package/build/handlers/VariableDeclaration.d.ts +0 -3
  113. package/build/handlers/VariableDeclaration.js +0 -56
  114. package/build/handlers/VariableDeclaration.js.map +0 -1
  115. package/build/handlers/WhileStatement.d.ts +0 -2
  116. package/build/handlers/WhileStatement.js +0 -23
  117. package/build/handlers/WhileStatement.js.map +0 -1
  118. package/build/handlers/index.js +0 -31
  119. package/build/handlers/index.js.map +0 -1
  120. package/build/index.d.ts +0 -1
  121. package/build/index.js +0 -8
  122. package/build/index.js.map +0 -1
  123. package/build/initScope.js +0 -40
  124. package/build/initScope.js.map +0 -1
  125. package/build/instructions/AddressResolver.js +0 -31
  126. package/build/instructions/AddressResolver.js.map +0 -1
  127. package/build/instructions/ControlInstructions.js +0 -23
  128. package/build/instructions/ControlInstructions.js.map +0 -1
  129. package/build/instructions/EndInstruction.js +0 -11
  130. package/build/instructions/EndInstruction.js.map +0 -1
  131. package/build/instructions/InstructionBase.js +0 -21
  132. package/build/instructions/InstructionBase.js.map +0 -1
  133. package/build/instructions/JumpInstruction.js +0 -22
  134. package/build/instructions/JumpInstruction.js.map +0 -1
  135. package/build/instructions/OperationInstruction.js +0 -11
  136. package/build/instructions/OperationInstruction.js.map +0 -1
  137. package/build/instructions/SetCounterInstruction.js +0 -11
  138. package/build/instructions/SetCounterInstruction.js.map +0 -1
  139. package/build/instructions/SetInstruction.js +0 -11
  140. package/build/instructions/SetInstruction.js.map +0 -1
  141. package/build/instructions/ZeroSpaceInstruction.js +0 -11
  142. package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
  143. package/build/instructions/index.js +0 -26
  144. package/build/instructions/index.js.map +0 -1
  145. package/build/macros/Building.js +0 -81
  146. package/build/macros/Building.js.map +0 -1
  147. package/build/macros/Function.d.ts +0 -12
  148. package/build/macros/Function.js +0 -20
  149. package/build/macros/Function.js.map +0 -1
  150. package/build/macros/Math.js +0 -57
  151. package/build/macros/Math.js.map +0 -1
  152. package/build/macros/Memory.js +0 -61
  153. package/build/macros/Memory.js.map +0 -1
  154. package/build/macros/Namespace.js +0 -98
  155. package/build/macros/Namespace.js.map +0 -1
  156. package/build/macros/Other.js +0 -20
  157. package/build/macros/Other.js.map +0 -1
  158. package/build/macros/RawValue.js +0 -16
  159. package/build/macros/RawValue.js.map +0 -1
  160. package/build/macros/commands/Control.js +0 -25
  161. package/build/macros/commands/Control.js.map +0 -1
  162. package/build/macros/commands/Draw.js +0 -39
  163. package/build/macros/commands/Draw.js.map +0 -1
  164. package/build/macros/commands/DrawFlush.js +0 -17
  165. package/build/macros/commands/DrawFlush.js.map +0 -1
  166. package/build/macros/commands/GetLink.js +0 -21
  167. package/build/macros/commands/GetLink.js.map +0 -1
  168. package/build/macros/commands/Lookup.js +0 -24
  169. package/build/macros/commands/Lookup.js.map +0 -1
  170. package/build/macros/commands/Print.js +0 -14
  171. package/build/macros/commands/Print.js.map +0 -1
  172. package/build/macros/commands/PrintFlush.js +0 -17
  173. package/build/macros/commands/PrintFlush.js.map +0 -1
  174. package/build/macros/commands/Radar.js +0 -61
  175. package/build/macros/commands/Radar.js.map +0 -1
  176. package/build/macros/commands/Sensor.js +0 -20
  177. package/build/macros/commands/Sensor.js.map +0 -1
  178. package/build/macros/commands/UnitBind.js +0 -17
  179. package/build/macros/commands/UnitBind.js.map +0 -1
  180. package/build/macros/commands/UnitControl.d.ts +0 -5
  181. package/build/macros/commands/UnitControl.js +0 -68
  182. package/build/macros/commands/UnitControl.js.map +0 -1
  183. package/build/macros/commands/UnitLocate.js +0 -55
  184. package/build/macros/commands/UnitLocate.js.map +0 -1
  185. package/build/macros/commands/UnitRadar.js +0 -41
  186. package/build/macros/commands/UnitRadar.js.map +0 -1
  187. package/build/macros/commands/Wait.js +0 -18
  188. package/build/macros/commands/Wait.js.map +0 -1
  189. package/build/macros/commands/index.js +0 -33
  190. package/build/macros/commands/index.js.map +0 -1
  191. package/build/macros/index.js +0 -40
  192. package/build/macros/index.js.map +0 -1
  193. package/build/operators.js +0 -102
  194. package/build/operators.js.map +0 -1
  195. package/build/types.d.ts +0 -49
  196. package/build/types.js +0 -28
  197. package/build/types.js.map +0 -1
  198. package/build/utils.js +0 -13
  199. package/build/utils.js.map +0 -1
  200. package/build/values/BaseValue.js +0 -112
  201. package/build/values/BaseValue.js.map +0 -1
  202. package/build/values/FunctionValue.js +0 -104
  203. package/build/values/FunctionValue.js.map +0 -1
  204. package/build/values/LiteralValue.js +0 -88
  205. package/build/values/LiteralValue.js.map +0 -1
  206. package/build/values/ObjectValue.d.ts +0 -17
  207. package/build/values/ObjectValue.js +0 -50
  208. package/build/values/ObjectValue.js.map +0 -1
  209. package/build/values/StoreValue.js +0 -31
  210. package/build/values/StoreValue.js.map +0 -1
  211. package/build/values/TempValue.js +0 -67
  212. package/build/values/TempValue.js.map +0 -1
  213. package/build/values/VoidValue.js +0 -31
  214. package/build/values/VoidValue.js.map +0 -1
  215. package/build/values/index.js +0 -23
  216. package/build/values/index.js.map +0 -1
  217. package/dist/mlogjs.es.js +0 -6366
  218. package/dist/mlogjs.umd.js +0 -8
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TemplateLiteral = void 0;
4
- const instructions_1 = require("../instructions");
5
- const TemplateLiteral = (c, scope, node) => {
6
- const args = [];
7
- const inst = [];
8
- node.expressions.forEach((expression, i) => {
9
- const [v, vi] = c.handleEval(scope, expression);
10
- inst.push(...vi);
11
- args.push(node.quasis[i].value.raw, v);
12
- });
13
- args.push(node.quasis.slice(-1)[0].value.raw);
14
- inst.push(new instructions_1.ZeroSpaceInstruction(...args));
15
- return [null, inst];
16
- };
17
- exports.TemplateLiteral = TemplateLiteral;
18
- //# sourceMappingURL=TemplateExpression.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateExpression.js","sourceRoot":"","sources":["../../src/handlers/TemplateExpression.ts"],"names":[],"mappings":";;;AAAA,kDAAuD;AAShD,MAAM,eAAe,GAAa,CACvC,CAAC,EACD,KAAK,EACL,IAAwB,EACxB,EAAE;IACF,MAAM,IAAI,GAAwB,EAAE,CAAC;IACrC,MAAM,IAAI,GAAmB,EAAE,CAAC;IAChC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,mCAAoB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,eAAe,mBAe1B"}
@@ -1,3 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const VariableDeclaration: THandler;
3
- export declare const VariableDeclarator: THandler;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VariableDeclarator = exports.VariableDeclaration = void 0;
4
- const utils_1 = require("../utils");
5
- const VariableDeclaration = (c, scope, node) => {
6
- return c.handleMany(scope, node.declarations, (scope, child) => (0, exports.VariableDeclarator)(c, scope, child, node.kind));
7
- };
8
- exports.VariableDeclaration = VariableDeclaration;
9
- const VariableDeclarator = (c, scope, node, kind = "let") => {
10
- let valinst = node.init
11
- ? c.handleEval(scope, node.init)
12
- : [null, []];
13
- switch (node.id.type) {
14
- case "Identifier": {
15
- const { name } = node.id;
16
- const [init] = valinst;
17
- if (kind === "const" && !init)
18
- throw Error("Cannot create constant with void value.");
19
- if (kind === "const" && init.constant) {
20
- scope.set(name, init);
21
- return valinst;
22
- }
23
- else {
24
- const value = scope.make(name, (0, utils_1.nodeName)(node));
25
- if (init) {
26
- if (init.macro)
27
- throw new Error("Macro value must be constant.");
28
- valinst[1].push(...value["="](scope, valinst[0])[1]);
29
- }
30
- if (kind === "const")
31
- value.constant = true;
32
- return valinst;
33
- }
34
- }
35
- case "ArrayPattern": {
36
- const { elements } = node.id;
37
- const [init] = valinst;
38
- if (!init)
39
- throw new Error("Cannot use array destructuring with constant with void value.");
40
- if (!init.macro)
41
- throw new Error("Cannot use array destructuring on non macro values");
42
- for (let i = 0; i < elements.length; i++) {
43
- const element = elements[i];
44
- if (!element)
45
- continue;
46
- const val = init.data[i];
47
- scope.set(element.name, val);
48
- }
49
- return valinst;
50
- }
51
- default:
52
- throw new Error("");
53
- }
54
- };
55
- exports.VariableDeclarator = VariableDeclarator;
56
- //# sourceMappingURL=VariableDeclaration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VariableDeclaration.js","sourceRoot":"","sources":["../../src/handlers/VariableDeclaration.ts"],"names":[],"mappings":";;;AAEA,oCAAoC;AAE7B,MAAM,mBAAmB,GAAa,CAC3C,CAAC,EACD,KAAK,EACL,IAA4B,EAC5B,EAAE;IACF,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC7D,IAAA,0BAAkB,EAAC,CAAC,EAAE,KAAK,EAAE,KAA8B,EAAE,IAAI,CAAC,IAAI,CAAC,CACxE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,OAAO,CAAC;aAChB;SACF;QACD,KAAK,cAAc,CAAC,CAAC;YACnB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,IAAI;gBACP,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,KAAK;gBACb,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;YAExE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAkB,CAAC;gBAE7C,IAAI,CAAC,OAAO;oBAAE,SAAS;gBACvB,MAAM,GAAG,GAAI,IAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAC1C,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aAC9B;YACD,OAAO,OAAO,CAAC;SAChB;QACD;YACE,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;KACvB;AACH,CAAC,CAAC;AAlDW,QAAA,kBAAkB,sBAkD7B"}
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const WhileStatement: THandler;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WhileStatement = void 0;
4
- const instructions_1 = require("../instructions");
5
- const values_1 = require("../values");
6
- const WhileStatement = (c, scope, node) => {
7
- const lines = [];
8
- const [test, testLines] = c.handleEval(scope, node.test);
9
- const startLoopAddr = new values_1.LiteralValue(scope, null);
10
- const endLoopAddr = new values_1.LiteralValue(scope, null);
11
- const startLoopLine = new instructions_1.AddressResolver(startLoopAddr).bindContinue(scope);
12
- const endLoopLine = new instructions_1.AddressResolver(endLoopAddr).bindBreak(scope);
13
- if (test instanceof values_1.LiteralValue) {
14
- if (test.data) {
15
- lines.push(startLoopLine, ...c.handle(scope, node.body)[1], new instructions_1.JumpInstruction(startLoopAddr, instructions_1.EJumpKind.Always), endLoopLine);
16
- }
17
- return [null, lines];
18
- }
19
- lines.push(startLoopLine, ...testLines, new instructions_1.JumpInstruction(endLoopAddr, instructions_1.EJumpKind.Equal, test, new values_1.LiteralValue(scope, 0)), ...c.handle(scope, node.body)[1], new instructions_1.JumpInstruction(startLoopAddr, instructions_1.EJumpKind.Always), endLoopLine);
20
- return [null, lines];
21
- };
22
- exports.WhileStatement = WhileStatement;
23
- //# sourceMappingURL=WhileStatement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WhileStatement.js","sourceRoot":"","sources":["../../src/handlers/WhileStatement.ts"],"names":[],"mappings":";;;AAAA,kDAA8E;AAE9E,sCAAyC;AAElC,MAAM,cAAc,GAAa,CAAC,CAAC,EAAE,KAAK,EAAE,IAAuB,EAAE,EAAE;IAC5E,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,IAAI,qBAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,IAAI,qBAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,8BAAe,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,WAAW,GAAG,IAAI,8BAAe,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEtE,IAAI,IAAI,YAAY,qBAAY,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,KAAK,CAAC,IAAI,CACR,aAAa,EACb,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,IAAI,8BAAe,CAAC,aAAa,EAAE,wBAAS,CAAC,MAAM,CAAC,EACpD,WAAW,CACZ,CAAC;SACH;QACD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACtB;IAED,KAAK,CAAC,IAAI,CACR,aAAa,EACb,GAAG,SAAS,EACZ,IAAI,8BAAe,CACjB,WAAW,EACX,wBAAS,CAAC,KAAK,EACf,IAAI,EACJ,IAAI,qBAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAC3B,EACD,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,IAAI,8BAAe,CAAC,aAAa,EAAE,wBAAS,CAAC,MAAM,CAAC,EACpD,WAAW,CACZ,CAAC;IACF,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAnCW,QAAA,cAAc,kBAmCzB"}
@@ -1,31 +0,0 @@
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("./Program"), exports);
18
- __exportStar(require("./VariableDeclaration"), exports);
19
- __exportStar(require("./Literal"), exports);
20
- __exportStar(require("./OperationExpressions"), exports);
21
- __exportStar(require("./Identifier"), exports);
22
- __exportStar(require("./Statements"), exports);
23
- __exportStar(require("./IfStatement"), exports);
24
- __exportStar(require("./WhileStatement"), exports);
25
- __exportStar(require("./ForStatement"), exports);
26
- __exportStar(require("./Function"), exports);
27
- __exportStar(require("./CallExpression"), exports);
28
- __exportStar(require("./Object"), exports);
29
- __exportStar(require("./TemplateExpression"), exports);
30
- __exportStar(require("./BlockStatement"), exports);
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,wDAAsC;AACtC,4CAA0B;AAC1B,yDAAuC;AACvC,+CAA6B;AAC7B,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,uDAAqC;AACrC,mDAAiC"}
package/build/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const compile: (script: string) => [string, Error, import("estree").Node[]];
package/build/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = void 0;
4
- const Compiler_1 = require("./Compiler");
5
- const compiler = new Compiler_1.Compiler();
6
- const compile = (script) => compiler.compile(script);
7
- exports.compile = compile;
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;AACzB,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAAvD,QAAA,OAAO,WAAgD"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initScope = void 0;
4
- const macros_1 = require("./macros");
5
- const Namespace_1 = require("./macros/Namespace");
6
- const RawValue_1 = require("./macros/RawValue");
7
- function initScope(scope) {
8
- // namespaces
9
- scope.hardSet("ControlKind", new macros_1.NamespaceMacro(scope));
10
- scope.hardSet("Vars", new macros_1.VarsNamespace(scope));
11
- scope.hardSet("Items", new macros_1.NamespaceMacro(scope, { changeCasing: true }));
12
- scope.hardSet("Liquids", new macros_1.NamespaceMacro(scope));
13
- scope.hardSet("Units", new macros_1.NamespaceMacro(scope));
14
- scope.hardSet("LAccess", new macros_1.NamespaceMacro(scope));
15
- scope.hardSet("UnitCommands", new Namespace_1.UCommandsNamespace(scope));
16
- scope.hardSet("Blocks", new macros_1.NamespaceMacro(scope, { changeCasing: true }));
17
- // helper methods
18
- scope.hardSet("getBuilding", new macros_1.BuildingBuilder(scope));
19
- scope.hardSet("getVar", new RawValue_1.RawValueMacro(scope));
20
- scope.hardSet("concat", new macros_1.Concat(scope));
21
- scope.hardSet("Math", new macros_1.MlogMath(scope));
22
- scope.hardSet("Memory", new macros_1.MemoryBuilder(scope));
23
- // commands
24
- scope.hardSet("draw", new macros_1.commands.Draw(scope));
25
- scope.hardSet("print", new macros_1.commands.Print(scope));
26
- scope.hardSet("printFlush", new macros_1.commands.PrintFlush(scope));
27
- scope.hardSet("drawFlush", new macros_1.commands.DrawFlush(scope));
28
- scope.hardSet("getLink", new macros_1.commands.GetLink(scope));
29
- scope.hardSet("control", new macros_1.commands.Control(scope));
30
- scope.hardSet("radar", new macros_1.commands.Radar(scope));
31
- scope.hardSet("sensor", new macros_1.commands.Sensor(scope));
32
- scope.hardSet("wait", new macros_1.commands.Wait(scope));
33
- scope.hardSet("lookup", new macros_1.commands.Lookup(scope));
34
- scope.hardSet("unitBind", new macros_1.commands.UnitBind(scope));
35
- scope.hardSet("unitControl", new macros_1.commands.UnitControl(scope));
36
- scope.hardSet("unitRadar", new macros_1.commands.UnitRadar(scope));
37
- scope.hardSet("unitLocate", new macros_1.commands.UnitLocate(scope));
38
- }
39
- exports.initScope = initScope;
40
- //# sourceMappingURL=initScope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initScope.js","sourceRoot":"","sources":["../src/initScope.ts"],"names":[],"mappings":";;;AAAA,qCAQkB;AAClB,kDAAwD;AACxD,gDAAkD;AAGlD,SAAgB,SAAS,CAAC,KAAY;IAEpC,aAAa;IACb,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,uBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,sBAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,uBAAc,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1E,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,uBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,uBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,uBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,8BAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,uBAAc,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAE3E,iBAAiB;IACjB,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,wBAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IACzD,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,wBAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,OAAO,C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CAAC;IACpD,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,iBAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,iBAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,iBAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,iBAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC;AAnCD,8BAmCC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddressResolver = void 0;
4
- const _1 = require(".");
5
- class AddressResolver extends _1.InstructionBase {
6
- constructor(...bonds) {
7
- super();
8
- this.bonds = bonds;
9
- }
10
- get hidden() {
11
- return true;
12
- }
13
- set hidden(value) { }
14
- resolve(i) {
15
- for (const literal of this.bonds)
16
- literal.data = i;
17
- }
18
- bind(bond) {
19
- this.bonds.push(bond);
20
- }
21
- bindBreak(scope) {
22
- scope.break = this;
23
- return this;
24
- }
25
- bindContinue(scope) {
26
- scope.continue = this;
27
- return this;
28
- }
29
- }
30
- exports.AddressResolver = AddressResolver;
31
- //# sourceMappingURL=AddressResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddressResolver.js","sourceRoot":"","sources":["../../src/instructions/AddressResolver.ts"],"names":[],"mappings":";;;AAAA,wBAAoC;AAGpC,MAAa,eAAgB,SAAQ,kBAAe;IAMlD,YAAY,GAAG,KAAuB;QACpC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IARD,IAAW,MAAM;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAW,MAAM,CAAC,KAAK,IAAG,CAAC;IAM3B,OAAO,CAAC,CAAS;QACf,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,CAAC,IAAoB;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,SAAS,CAAC,KAAa;QACrB,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,YAAY,CAAC,KAAa;QACxB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxBD,0CAwBC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReturnInstruction = exports.ContinueInstruction = exports.BreakInstruction = void 0;
4
- const JumpInstruction_1 = require("./JumpInstruction");
5
- class BreakInstruction extends JumpInstruction_1.JumpInstruction {
6
- constructor(address) {
7
- super(address, JumpInstruction_1.EJumpKind.Always);
8
- }
9
- }
10
- exports.BreakInstruction = BreakInstruction;
11
- class ContinueInstruction extends JumpInstruction_1.JumpInstruction {
12
- constructor(address) {
13
- super(address, JumpInstruction_1.EJumpKind.Always);
14
- }
15
- }
16
- exports.ContinueInstruction = ContinueInstruction;
17
- class ReturnInstruction extends JumpInstruction_1.JumpInstruction {
18
- constructor(address) {
19
- super(address, JumpInstruction_1.EJumpKind.Always);
20
- }
21
- }
22
- exports.ReturnInstruction = ReturnInstruction;
23
- //# sourceMappingURL=ControlInstructions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ControlInstructions.js","sourceRoot":"","sources":["../../src/instructions/ControlInstructions.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAE/D,MAAa,gBAAiB,SAAQ,iCAAe;IACnD,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,EAAE,2BAAS,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAJD,4CAIC;AAED,MAAa,mBAAoB,SAAQ,iCAAe;IACtD,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,EAAE,2BAAS,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,iBAAkB,SAAQ,iCAAe;IACpD,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,EAAE,2BAAS,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAJD,8CAIC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EndInstruction = void 0;
4
- const InstructionBase_1 = require("./InstructionBase");
5
- class EndInstruction extends InstructionBase_1.InstructionBase {
6
- constructor() {
7
- super("end");
8
- }
9
- }
10
- exports.EndInstruction = EndInstruction;
11
- //# sourceMappingURL=EndInstruction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndInstruction.js","sourceRoot":"","sources":["../../src/instructions/EndInstruction.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,MAAa,cAAe,SAAQ,iCAAe;IACjD;QACE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF;AAJD,wCAIC"}
@@ -1,21 +0,0 @@
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
- //# sourceMappingURL=InstructionBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InstructionBase.js","sourceRoot":"","sources":["../../src/instructions/InstructionBase.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAS1B,YAAY,GAAG,IAAyB;QARhC,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,CAAS,IAAG,CAAC;IACrB,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 +0,0 @@
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;
22
- //# sourceMappingURL=JumpInstruction.js.map
@@ -1 +0,0 @@
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,IAAa,EACb,KAAc;QAEd,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AATD,0CASC"}
@@ -1,11 +0,0 @@
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
- //# sourceMappingURL=OperationInstruction.js.map
@@ -1 +0,0 @@
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,KAAc;QAClE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;CACF;AAJD,oDAIC"}
@@ -1,11 +0,0 @@
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
- //# sourceMappingURL=SetCounterInstruction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SetCounterInstruction.js","sourceRoot":"","sources":["../../src/instructions/SetCounterInstruction.ts"],"names":[],"mappings":";;;AAAA,wBAAoC;AAGpC,MAAa,qBAAsB,SAAQ,kBAAe;IACxD,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;AAJD,sDAIC"}
@@ -1,11 +0,0 @@
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
- //# sourceMappingURL=SetInstruction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SetInstruction.js","sourceRoot":"","sources":["../../src/instructions/SetInstruction.ts"],"names":[],"mappings":";;;AAAA,wBAAoC;AAGpC,MAAa,cAAe,SAAQ,kBAAe;IACjD,YAAY,KAAa,EAAE,KAAa;QACtC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAJD,wCAIC"}
@@ -1,11 +0,0 @@
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
- //# sourceMappingURL=ZeroSpaceInstruction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ZeroSpaceInstruction.js","sourceRoot":"","sources":["../../src/instructions/ZeroSpaceInstruction.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,MAAa,oBAAqB,SAAQ,iCAAe;IACvD,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF;AAJD,oDAIC"}
@@ -1,26 +0,0 @@
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
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instructions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yDAAuC;AACvC,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,oDAAkC;AAClC,0DAAwC;AACxC,yDAAuC;AACvC,wDAAsC"}
@@ -1,81 +0,0 @@
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
- exports.itemNames = [
10
- "copper",
11
- "lead",
12
- "metaglass",
13
- "graphite",
14
- "sand",
15
- "coal",
16
- "titanium",
17
- "thorium",
18
- "scrap",
19
- "silicon",
20
- "plastanium",
21
- "phaseFabric",
22
- "surgeAlloy",
23
- "sporePod",
24
- "blastCompound",
25
- "pyratite",
26
- ];
27
- class Building extends values_1.ObjectValue {
28
- constructor(scope, name) {
29
- super(scope, {
30
- $get: new Function_1.MacroFunction(scope, (prop) => {
31
- if (prop instanceof values_1.LiteralValue && typeof prop.data === "string") {
32
- const name = exports.itemNames.includes(prop.data)
33
- ? (0, utils_1.camelToDashCase)(prop.data)
34
- : prop.data;
35
- const temp = new values_1.TempValue(scope);
36
- return [
37
- temp,
38
- [new instructions_1.InstructionBase("sensor", temp, this, `@${name}`)],
39
- ];
40
- }
41
- if (prop instanceof values_1.StoreValue) {
42
- const temp = new values_1.TempValue(scope);
43
- return [temp, [new instructions_1.InstructionBase("sensor", temp, this, prop)]];
44
- }
45
- throw new Error("Building property acessors must be string literals or stores");
46
- }),
47
- });
48
- this.name = name;
49
- }
50
- toString() {
51
- return this.name;
52
- }
53
- }
54
- exports.Building = Building;
55
- class BuildingBuilder extends values_1.ObjectValue {
56
- constructor(scope) {
57
- super(scope, {
58
- $call: new Function_1.MacroFunction(scope, (nameLit) => {
59
- if (!(nameLit instanceof values_1.LiteralValue))
60
- throw new Error("Block name must be a literal.");
61
- if (typeof nameLit.data !== "string")
62
- throw new Error("Block name must be a string.");
63
- return [new Building(scope, nameLit.data), []];
64
- }),
65
- });
66
- }
67
- }
68
- exports.BuildingBuilder = BuildingBuilder;
69
- for (const key in operators_1.operatorMap) {
70
- const kind = operators_1.operatorMap[key];
71
- Building.prototype[key] = function (scope, value) {
72
- const left = new values_1.StoreValue(scope, this.name);
73
- const [right, rightInst] = value.eval(scope);
74
- const temp = new values_1.TempValue(scope);
75
- return [
76
- temp,
77
- [...rightInst, new instructions_1.OperationInstruction(kind, temp, left, right)],
78
- ];
79
- };
80
- }
81
- //# sourceMappingURL=Building.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Building.js","sourceRoot":"","sources":["../../src/macros/Building.ts"],"names":[],"mappings":";;;AAAA,oCAA2C;AAC3C,kDAAwE;AAExE,sCAA6E;AAC7E,yCAA2C;AAC3C,4CAA2C;AAE9B,QAAA,SAAS,GAAG;IACvB,QAAQ;IACR,MAAM;IACN,WAAW;IACX,UAAU;IACV,MAAM;IACN,MAAM;IACN,UAAU;IACV,SAAS;IACT,OAAO;IACP,SAAS;IACT,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,UAAU;IACV,eAAe;IACf,UAAU;CACX,CAAC;AACF,MAAa,QAAS,SAAQ,oBAAW;IAKvC,YAAY,KAAa,EAAE,IAAY;QACrC,KAAK,CAAC,KAAK,EAAE;YACX,IAAI,EAAE,IAAI,wBAAa,CAAC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC9C,IAAI,IAAI,YAAY,qBAAY,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACjE,MAAM,IAAI,GAAG,iBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;wBACxC,CAAC,CAAC,IAAA,uBAAe,EAAC,IAAI,CAAC,IAAI,CAAC;wBAC5B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;oBACd,MAAM,IAAI,GAAG,IAAI,kBAAS,CAAC,KAAK,CAAC,CAAC;oBAClC,OAAO;wBACL,IAAI;wBACJ,CAAC,IAAI,8BAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;qBACxD,CAAC;iBACH;gBACD,IAAI,IAAI,YAAY,mBAAU,EAAE;oBAC9B,MAAM,IAAI,GAAG,IAAI,kBAAS,CAAC,KAAK,CAAC,CAAC;oBAClC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,8BAAe,CAA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QAClC,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"}
@@ -1,12 +0,0 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- import { VoidValue } from "../values";
3
- declare type TFunction = (...args: IValue[]) => TValueInstructions;
4
- export declare class MacroFunction extends VoidValue {
5
- macro: boolean;
6
- constant: boolean;
7
- fn: TFunction;
8
- constructor(scope: IScope, fn: TFunction);
9
- call(scope: IScope, args: IValue[]): TValueInstructions;
10
- eval(scope: IScope): TValueInstructions;
11
- }
12
- export {};
@@ -1,20 +0,0 @@
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
- //# sourceMappingURL=Function.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Function.js","sourceRoot":"","sources":["../../src/macros/Function.ts"],"names":[],"mappings":";;;AACA,sCAAsC;AAItC,MAAa,aAAc,SAAQ,kBAAS;IAI1C,YAAY,KAAa,EAAE,EAAa;QACtC,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,KAAa;QAChB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;CACF;AAdD,sCAcC"}