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.
Files changed (234) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/build/Compiler.js +104 -99
  4. package/build/Compiler.js.map +1 -1
  5. package/build/CompilerError.js +11 -0
  6. package/build/CompilerError.js.map +1 -0
  7. package/build/Scope.js +70 -60
  8. package/build/Scope.js.map +1 -1
  9. package/build/bin.js +74 -60
  10. package/build/bin.js.map +1 -1
  11. package/build/handlers/BlockStatement.js +13 -13
  12. package/build/handlers/BlockStatement.js.map +1 -1
  13. package/build/handlers/CallExpression.js +19 -19
  14. package/build/handlers/CallExpression.js.map +1 -1
  15. package/build/handlers/File.js +9 -0
  16. package/build/handlers/File.js.map +1 -0
  17. package/build/handlers/ForStatement.js +31 -31
  18. package/build/handlers/ForStatement.js.map +1 -1
  19. package/build/handlers/Function.js +46 -35
  20. package/build/handlers/Function.js.map +1 -1
  21. package/build/handlers/Identifier.js +7 -7
  22. package/build/handlers/IfStatement.js +24 -24
  23. package/build/handlers/IfStatement.js.map +1 -1
  24. package/build/handlers/Literal.js +14 -17
  25. package/build/handlers/Literal.js.map +1 -1
  26. package/build/handlers/Object.js +54 -43
  27. package/build/handlers/Object.js.map +1 -1
  28. package/build/handlers/OperationExpressions.js +37 -32
  29. package/build/handlers/OperationExpressions.js.map +1 -1
  30. package/build/handlers/Program.js +8 -8
  31. package/build/handlers/Program.js.map +1 -1
  32. package/build/handlers/Statements.js +29 -29
  33. package/build/handlers/Statements.js.map +1 -1
  34. package/build/handlers/TemplateExpression.js +17 -17
  35. package/build/handlers/TemplateExpression.js.map +1 -1
  36. package/build/handlers/VariableDeclaration.js +71 -55
  37. package/build/handlers/VariableDeclaration.js.map +1 -1
  38. package/build/handlers/WhileStatement.js +22 -22
  39. package/build/handlers/WhileStatement.js.map +1 -1
  40. package/build/handlers/index.js +31 -30
  41. package/build/handlers/index.js.map +1 -1
  42. package/build/index.js +7 -7
  43. package/build/index.js.map +1 -1
  44. package/build/initScope.js +39 -39
  45. package/build/instructions/AddressResolver.js +30 -30
  46. package/build/instructions/ControlInstructions.js +22 -22
  47. package/build/instructions/EndInstruction.js +10 -10
  48. package/build/instructions/InstructionBase.js +20 -20
  49. package/build/instructions/InstructionBase.js.map +1 -1
  50. package/build/instructions/JumpInstruction.js +21 -21
  51. package/build/instructions/JumpInstruction.js.map +1 -1
  52. package/build/instructions/OperationInstruction.js +10 -10
  53. package/build/instructions/OperationInstruction.js.map +1 -1
  54. package/build/instructions/SetCounterInstruction.js +10 -10
  55. package/build/instructions/SetInstruction.js +10 -10
  56. package/build/instructions/ZeroSpaceInstruction.js +10 -10
  57. package/build/instructions/index.js +25 -25
  58. package/build/macros/Building.js +88 -80
  59. package/build/macros/Building.js.map +1 -1
  60. package/build/macros/Function.js +19 -19
  61. package/build/macros/Function.js.map +1 -1
  62. package/build/macros/Math.js +61 -56
  63. package/build/macros/Math.js.map +1 -1
  64. package/build/macros/Memory.js +62 -60
  65. package/build/macros/Memory.js.map +1 -1
  66. package/build/macros/Namespace.js +110 -97
  67. package/build/macros/Namespace.js.map +1 -1
  68. package/build/macros/Other.js +20 -19
  69. package/build/macros/Other.js.map +1 -1
  70. package/build/macros/RawValue.js +16 -15
  71. package/build/macros/RawValue.js.map +1 -1
  72. package/build/macros/commands/Control.js +25 -24
  73. package/build/macros/commands/Control.js.map +1 -1
  74. package/build/macros/commands/Draw.js +39 -38
  75. package/build/macros/commands/Draw.js.map +1 -1
  76. package/build/macros/commands/DrawFlush.js +17 -16
  77. package/build/macros/commands/DrawFlush.js.map +1 -1
  78. package/build/macros/commands/GetLink.js +24 -20
  79. package/build/macros/commands/GetLink.js.map +1 -1
  80. package/build/macros/commands/Lookup.js +24 -23
  81. package/build/macros/commands/Lookup.js.map +1 -1
  82. package/build/macros/commands/Print.js +17 -13
  83. package/build/macros/commands/Print.js.map +1 -1
  84. package/build/macros/commands/PrintFlush.js +17 -16
  85. package/build/macros/commands/PrintFlush.js.map +1 -1
  86. package/build/macros/commands/Radar.js +64 -60
  87. package/build/macros/commands/Radar.js.map +1 -1
  88. package/build/macros/commands/Sensor.js +20 -19
  89. package/build/macros/commands/Sensor.js.map +1 -1
  90. package/build/macros/commands/UnitBind.js +17 -16
  91. package/build/macros/commands/UnitBind.js.map +1 -1
  92. package/build/macros/commands/UnitControl.js +72 -67
  93. package/build/macros/commands/UnitControl.js.map +1 -1
  94. package/build/macros/commands/UnitLocate.js +75 -54
  95. package/build/macros/commands/UnitLocate.js.map +1 -1
  96. package/build/macros/commands/UnitRadar.js +47 -40
  97. package/build/macros/commands/UnitRadar.js.map +1 -1
  98. package/build/macros/commands/Wait.js +18 -17
  99. package/build/macros/commands/Wait.js.map +1 -1
  100. package/build/macros/commands/index.js +32 -32
  101. package/build/macros/index.js +39 -39
  102. package/build/operators.js +101 -101
  103. package/build/operators.js.map +1 -1
  104. package/build/types.js +27 -27
  105. package/build/types.js.map +1 -1
  106. package/build/utils.js +17 -12
  107. package/build/utils.js.map +1 -1
  108. package/build/values/BaseValue.js +111 -111
  109. package/build/values/BaseValue.js.map +1 -1
  110. package/build/values/FunctionValue.js +115 -103
  111. package/build/values/FunctionValue.js.map +1 -1
  112. package/build/values/LiteralValue.js +88 -87
  113. package/build/values/LiteralValue.js.map +1 -1
  114. package/build/values/ObjectValue.js +54 -49
  115. package/build/values/ObjectValue.js.map +1 -1
  116. package/build/values/StoreValue.js +31 -30
  117. package/build/values/StoreValue.js.map +1 -1
  118. package/build/values/TempValue.js +77 -66
  119. package/build/values/TempValue.js.map +1 -1
  120. package/build/values/VoidValue.js +31 -30
  121. package/build/values/VoidValue.js.map +1 -1
  122. package/build/values/index.js +22 -22
  123. package/dist/bin.cjs +82 -0
  124. package/dist/bin.cjs.map +1 -0
  125. package/dist/index.cjs +2220 -0
  126. package/dist/index.cjs.map +1 -0
  127. package/dist/index.mjs +2195 -0
  128. package/dist/index.mjs.map +1 -0
  129. package/dist/types/Compiler.d.ts +26 -0
  130. package/dist/types/CompilerError.d.ts +9 -0
  131. package/dist/types/Scope.d.ts +24 -0
  132. package/dist/types/bin.d.ts +1 -0
  133. package/dist/types/handlers/BlockStatement.d.ts +2 -0
  134. package/dist/types/handlers/CallExpression.d.ts +3 -0
  135. package/dist/types/handlers/File.d.ts +2 -0
  136. package/dist/types/handlers/ForStatement.d.ts +2 -0
  137. package/{build → dist/types}/handlers/Function.d.ts +5 -4
  138. package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
  139. package/dist/types/handlers/IfStatement.d.ts +2 -0
  140. package/dist/types/handlers/Literal.d.ts +5 -0
  141. package/{build → dist/types}/handlers/Object.d.ts +6 -4
  142. package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
  143. package/dist/types/handlers/Program.d.ts +2 -0
  144. package/dist/types/handlers/Statements.d.ts +5 -0
  145. package/dist/types/handlers/TemplateExpression.d.ts +2 -0
  146. package/dist/types/handlers/Typescript.d.ts +7 -0
  147. package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
  148. package/dist/types/handlers/WhileStatement.d.ts +3 -0
  149. package/{build → dist/types}/handlers/index.d.ts +16 -14
  150. package/dist/types/index.d.ts +2 -0
  151. package/{build → dist/types}/initScope.d.ts +5 -2
  152. package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
  153. package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
  154. package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
  155. package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
  156. package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
  157. package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
  158. package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
  159. package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
  160. package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
  161. package/{build → dist/types}/instructions/index.d.ts +9 -9
  162. package/{build → dist/types}/macros/Building.d.ts +10 -11
  163. package/dist/types/macros/Entities.d.ts +11 -0
  164. package/dist/types/macros/Function.d.ts +13 -0
  165. package/dist/types/macros/GetGlobal.d.ts +5 -0
  166. package/{build → dist/types}/macros/Math.d.ts +5 -5
  167. package/{build → dist/types}/macros/Memory.d.ts +5 -5
  168. package/{build → dist/types}/macros/Namespace.d.ts +16 -21
  169. package/{build → dist/types}/macros/Other.d.ts +5 -5
  170. package/{build → dist/types}/macros/RawValue.d.ts +5 -5
  171. package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
  172. package/dist/types/macros/commands/Draw.d.ts +5 -0
  173. package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
  174. package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
  175. package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
  176. package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
  177. package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
  178. package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
  179. package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
  180. package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
  181. package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
  182. package/dist/types/macros/commands/UnitControl.d.ts +5 -0
  183. package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
  184. package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
  185. package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
  186. package/{build → dist/types}/macros/commands/index.d.ts +15 -14
  187. package/{build → dist/types}/macros/index.d.ts +6 -7
  188. package/{build → dist/types}/operators.d.ts +25 -25
  189. package/dist/types/types.d.ts +224 -0
  190. package/dist/types/utils.d.ts +30 -0
  191. package/dist/types/values/BaseValue.d.ts +7 -0
  192. package/dist/types/values/DestructuringValue.d.ts +17 -0
  193. package/dist/types/values/FunctionValue.d.ts +47 -0
  194. package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
  195. package/dist/types/values/ObjectValue.d.ts +23 -0
  196. package/dist/types/values/SenseableValue.d.ts +23 -0
  197. package/dist/types/values/StackValue.d.ts +16 -0
  198. package/dist/types/values/StoreValue.d.ts +15 -0
  199. package/{build → dist/types}/values/TempValue.d.ts +19 -12
  200. package/dist/types/values/ValueOwner.d.ts +27 -0
  201. package/dist/types/values/VoidValue.d.ts +16 -0
  202. package/{build → dist/types}/values/index.d.ts +7 -6
  203. package/lib/commands.d.ts +242 -36
  204. package/lib/eslib/lib.es5.d.ts +1 -1
  205. package/lib/globals.d.ts +172 -159
  206. package/lib/helpers.d.ts +2 -2
  207. package/lib/memory.d.ts +1 -1
  208. package/lib/traits.d.ts +130 -110
  209. package/package.json +33 -38
  210. package/build/Compiler.d.ts +0 -18
  211. package/build/Scope.d.ts +0 -26
  212. package/build/bin.d.ts +0 -2
  213. package/build/handlers/BlockStatement.d.ts +0 -2
  214. package/build/handlers/CallExpression.d.ts +0 -3
  215. package/build/handlers/ForStatement.d.ts +0 -2
  216. package/build/handlers/IfStatement.d.ts +0 -2
  217. package/build/handlers/Literal.d.ts +0 -2
  218. package/build/handlers/Program.d.ts +0 -2
  219. package/build/handlers/Statements.d.ts +0 -5
  220. package/build/handlers/TemplateExpression.d.ts +0 -2
  221. package/build/handlers/VariableDeclaration.d.ts +0 -3
  222. package/build/handlers/WhileStatement.d.ts +0 -2
  223. package/build/index.d.ts +0 -1
  224. package/build/macros/Function.d.ts +0 -12
  225. package/build/macros/commands/UnitControl.d.ts +0 -5
  226. package/build/types.d.ts +0 -49
  227. package/build/utils.d.ts +0 -3
  228. package/build/values/BaseValue.d.ts +0 -5
  229. package/build/values/FunctionValue.d.ts +0 -34
  230. package/build/values/ObjectValue.d.ts +0 -17
  231. package/build/values/StoreValue.d.ts +0 -11
  232. package/build/values/VoidValue.d.ts +0 -11
  233. package/dist/mlogjs.es.js +0 -6366
  234. package/dist/mlogjs.umd.js +0 -8
@@ -0,0 +1,11 @@
1
+ import { IScope, IValue } from "../types";
2
+ import { ObjectValue } from "../values";
3
+ export declare const itemNames: string[];
4
+ export declare class Building extends ObjectValue {
5
+ toString(): string;
6
+ constructor(scope: IScope);
7
+ }
8
+ export declare class Unit extends ObjectValue implements IValue {
9
+ constructor(scope: IScope);
10
+ toString(): string;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { IScope, IValue, TValueInstructions } from "../types";
2
+ import { VoidValue } from "../values";
3
+ declare type TFunction<T extends IValue | null> = (...args: IValue[]) => TValueInstructions<T>;
4
+ export declare class MacroFunction<RT extends IValue | null = IValue> extends VoidValue {
5
+ macro: boolean;
6
+ constant: boolean;
7
+ fn: TFunction<RT>;
8
+ constructor(scope: IScope, fn: TFunction<RT>);
9
+ call(scope: IScope, args: IValue[]): TValueInstructions<RT>;
10
+ eval(_scope: IScope): TValueInstructions;
11
+ consume(_scope: IScope): TValueInstructions;
12
+ }
13
+ export {};
@@ -0,0 +1,5 @@
1
+ import { EMutability, IScope } from "../types";
2
+ import { MacroFunction } from "./Function";
3
+ export declare class GetGlobal extends MacroFunction {
4
+ constructor(scope: IScope, mutability: EMutability);
5
+ }
@@ -1,5 +1,5 @@
1
- import { IScope } from "../types";
2
- import { ObjectValue } from "../values";
3
- export declare class MlogMath extends ObjectValue {
4
- constructor(scope: IScope);
5
- }
1
+ import { IScope } from "../types";
2
+ import { ObjectValue } from "../values";
3
+ export declare class MlogMath extends ObjectValue {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { IScope } from "../types";
2
- import { ObjectValue } from "../values";
3
- export declare class MemoryBuilder extends ObjectValue {
4
- constructor(scope: IScope);
5
- }
1
+ import { IScope } from "../types";
2
+ import { ObjectValue } from "../values";
3
+ export declare class MemoryBuilder extends ObjectValue {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,21 +1,16 @@
1
- import { IScope } from "../types";
2
- import { ObjectValue } from "../values";
3
- interface NamespaceMacroOptions {
4
- changeCasing?: boolean;
5
- }
6
- export declare class NamespaceMacro extends ObjectValue {
7
- changeCasing: boolean;
8
- constructor(scope: IScope, { changeCasing }?: NamespaceMacroOptions);
9
- }
10
- export declare class VarsNamespace extends NamespaceMacro {
11
- constructor(scope: IScope);
12
- }
13
- export declare class UCommandsNamespace extends NamespaceMacro {
14
- constructor(scope: IScope);
15
- }
16
- export declare class Unit extends ObjectValue {
17
- name: string;
18
- constructor(scope: IScope, name: string);
19
- toString(): string;
20
- }
21
- export {};
1
+ import { IScope } from "../types";
2
+ import { ObjectValue } from "../values";
3
+ interface NamespaceMacroOptions {
4
+ changeCasing?: boolean;
5
+ }
6
+ export declare class NamespaceMacro extends ObjectValue {
7
+ changeCasing: boolean;
8
+ constructor(scope: IScope, { changeCasing }?: NamespaceMacroOptions);
9
+ }
10
+ export declare class VarsNamespace extends NamespaceMacro {
11
+ constructor(scope: IScope);
12
+ }
13
+ export declare class UCommandsNamespace extends NamespaceMacro {
14
+ constructor(scope: IScope);
15
+ }
16
+ export {};
@@ -1,5 +1,5 @@
1
- import { IScope } from "../types";
2
- import { MacroFunction } from "./Function";
3
- export declare class Concat extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { IScope } from "../types";
2
+ import { MacroFunction } from "./Function";
3
+ export declare class Concat extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { IScope } from "../types";
2
- import { MacroFunction } from "./Function";
3
- export declare class RawValueMacro extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { IScope } from "../types";
2
+ import { MacroFunction } from "./Function";
3
+ export declare class RawValueMacro extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Control extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Control extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { IScope } from "../../types";
2
+ import { MacroFunction } from "../Function";
3
+ export declare class Draw extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class DrawFlush extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class DrawFlush extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { IScope } from "../../types";
2
- import { MacroFunction } from "../Function";
3
- export declare class Draw extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { IScope } from "../../types";
2
+ import { MacroFunction } from "../Function";
3
+ export declare class End extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class GetLink extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class GetLink extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Lookup extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Lookup extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Print extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Print extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class PrintFlush extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class PrintFlush extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,7 +1,7 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare const validRadarFilters: string[];
4
- export declare const validRadarSorts: string[];
5
- export declare class Radar extends MacroFunction {
6
- constructor(scope: IScope);
7
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare const validRadarFilters: string[];
4
+ export declare const validRadarSorts: string[];
5
+ export declare class Radar extends MacroFunction {
6
+ constructor(scope: IScope);
7
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Sensor extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Sensor extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitBind extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitBind extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { MacroFunction } from "..";
2
+ import { IScope, IValue } from "../../types";
3
+ export declare class UnitControl extends MacroFunction<IValue | null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitLocate extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitLocate extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitRadar extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitRadar extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Wait extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Wait extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,14 +1,15 @@
1
- export * from "./Draw";
2
- export * from "./Print";
3
- export * from "./PrintFlush";
4
- export * from "./DrawFlush";
5
- export * from "./GetLink";
6
- export * from "./Control";
7
- export { Radar } from "./Radar";
8
- export * from "./Sensor";
9
- export * from "./Wait";
10
- export * from "./Lookup";
11
- export * from "./UnitBind";
12
- export * from "./UnitControl";
13
- export * from "./UnitRadar";
14
- export * from "./UnitLocate";
1
+ export * from "./Draw";
2
+ export * from "./Print";
3
+ export * from "./PrintFlush";
4
+ export * from "./DrawFlush";
5
+ export * from "./GetLink";
6
+ export * from "./Control";
7
+ export { Radar } from "./Radar";
8
+ export * from "./Sensor";
9
+ export * from "./Wait";
10
+ export * from "./Lookup";
11
+ export * from "./End";
12
+ export * from "./UnitBind";
13
+ export * from "./UnitControl";
14
+ export * from "./UnitRadar";
15
+ export * from "./UnitLocate";
@@ -1,7 +1,6 @@
1
- export * from "./Function";
2
- export * from "./Math";
3
- export * from "./Other";
4
- export * as commands from "./commands";
5
- export * from "./Memory";
6
- export { BuildingBuilder } from "./Building";
7
- export { NamespaceMacro, VarsNamespace } from "./Namespace";
1
+ export * from "./Function";
2
+ export * from "./Math";
3
+ export * from "./Other";
4
+ export * as commands from "./commands";
5
+ export * from "./Memory";
6
+ export { NamespaceMacro, VarsNamespace } from "./Namespace";
@@ -1,25 +1,25 @@
1
- export declare const arithmeticBinaryOperators: readonly ["*", "**", "+", "-", "/", "%"];
2
- export declare const comparisonBinaryOperators: readonly ["!=", "!==", "<", "<=", "==", "===", ">", ">="];
3
- export declare const bitwiseBinaryOperators: readonly ["&", "<<", ">>", ">>>", "^", "|"];
4
- export declare const binaryOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in"];
5
- export declare type BinaryOperator = typeof binaryOperators[number];
6
- export declare const logicalOperators: readonly ["&&", "??", "||"];
7
- export declare type LogicalOperator = typeof logicalOperators[number];
8
- export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
9
- export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
10
- export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
11
- export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
12
- export declare type AssignementOperator = typeof assignmentOperators[number];
13
- export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
14
- export declare type LeftRightOperator = typeof leftRightOperators[number];
15
- export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
16
- export declare type UnaryOperator = typeof unaryOperators[number];
17
- export declare const updateOperators: readonly ["++", "--"];
18
- export declare type UpdateOperator = typeof updateOperators[number];
19
- export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
20
- export declare type SingleOperator = typeof singleOperators[number];
21
- export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
22
- export declare type Operator = typeof operators[number];
23
- export declare const operatorMap: {
24
- [k in BinaryOperator | LogicalOperator]?: string;
25
- };
1
+ export declare const arithmeticBinaryOperators: readonly ["*", "**", "+", "-", "/", "%"];
2
+ export declare const comparisonBinaryOperators: readonly ["!=", "!==", "<", "<=", "==", "===", ">", ">="];
3
+ export declare const bitwiseBinaryOperators: readonly ["&", "<<", ">>", ">>>", "^", "|"];
4
+ export declare const binaryOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in"];
5
+ export declare type BinaryOperator = typeof binaryOperators[number];
6
+ export declare const logicalOperators: readonly ["&&", "??", "||"];
7
+ export declare type LogicalOperator = typeof logicalOperators[number];
8
+ export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
9
+ export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
10
+ export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
11
+ export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
12
+ export declare type AssignementOperator = typeof assignmentOperators[number];
13
+ export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
14
+ export declare type LeftRightOperator = typeof leftRightOperators[number];
15
+ export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
16
+ export declare type UnaryOperator = typeof unaryOperators[number];
17
+ export declare const updateOperators: readonly ["++", "--"];
18
+ export declare type UpdateOperator = typeof updateOperators[number];
19
+ export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
20
+ export declare type SingleOperator = typeof singleOperators[number];
21
+ export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
22
+ export declare type Operator = typeof operators[number];
23
+ export declare const operatorMap: {
24
+ [k in Exclude<BinaryOperator, "instanceof" | "in"> | Exclude<LogicalOperator, "??">]: string;
25
+ };
@@ -0,0 +1,224 @@
1
+ export * as es from "@babel/types";
2
+ import { Compiler } from "./Compiler";
3
+ import { AddressResolver } from "./instructions";
4
+ import { MacroFunction } from "./macros";
5
+ import { LeftRightOperator, UnaryOperator, UpdateOperator } from "./operators";
6
+ export interface IInstruction {
7
+ hidden: boolean;
8
+ resolve(i: number): void;
9
+ }
10
+ export declare type THandler<T extends IValue | null = IValue> = (compiler: Compiler, scope: IScope, node: any, arg: any) => TValueInstructions<T>;
11
+ /**
12
+ * The scope manages the source code generated variables and their owners,
13
+ * as well as break and continue statements and they also work as function
14
+ * bodies.
15
+ */
16
+ export interface IScope {
17
+ /** Every scope except the top level one has a parent */
18
+ parent: IScope | null;
19
+ /** The registry of variables contained by this scope */
20
+ data: Record<string, IValueOwner | null>;
21
+ name: string;
22
+ /**
23
+ * Additional instructions required by this scope, such as
24
+ * the instructions that make the body of a function
25
+ */
26
+ inst: IInstruction[];
27
+ /** Where to jump to on a break statement */
28
+ break: AddressResolver;
29
+ /** Where to jump to on a continue statement */
30
+ continue: AddressResolver;
31
+ /** The function linked to `this`, is `null` when the scope is not inside a function. */
32
+ function: IFunctionValue;
33
+ /** Counts the number of temp variables generated during compilaton */
34
+ ntemp: number;
35
+ /**
36
+ * Creates a new scope that has `this` as it's parent.
37
+ */
38
+ createScope(): IScope;
39
+ /**
40
+ * Creates a new scope to be used by a function value, the scope has the following properties:
41
+ * - uses `name` as it's primary name, it changes how variable names are formatted.
42
+ * - it has `this` as it's parent
43
+ * - independent variable registry
44
+ * @param name The name of the scope
45
+ * @param stacked
46
+ */
47
+ createFunction(name: string, stacked?: boolean): IScope;
48
+ /** Checks if there is an owner registered with the specified identifier */
49
+ has(identifier: string): boolean;
50
+ /** Gets a value by their owner's identifier */
51
+ get(identifier: string): IOwnedValue;
52
+ /**
53
+ * Registers `value` with an owner that uses `name` as both it's name and identifier,
54
+ * throws an error if there already is an owner with the same identitifer.
55
+ * @param name
56
+ * @param value
57
+ */
58
+ set<T extends IValue>(name: string, value: T): T;
59
+ /**
60
+ * Registers `owner` and it's inner value, throws an error
61
+ * if there already is an owner with the same identifier.
62
+ */
63
+ set<T extends IValue>(owner: IValueOwner<T>): T;
64
+ /**
65
+ * Registers `value` with an owner that uses `name` as both it's name and identifier,
66
+ * overriding any preexisting variables with the same identifier.
67
+ * @param name
68
+ * @param value
69
+ */
70
+ hardSet<T extends IValue>(name: string, value: T): T;
71
+ /**
72
+ * Registers `owner` and it's inner value, overriding
73
+ * any preexisting variables with the same identifier.
74
+ * @param owner
75
+ */
76
+ hardSet<T extends IValue>(owner: IValueOwner<T>): T;
77
+ /**
78
+ * Creates an owned store and registers it to this scope.
79
+ * @param identifier The name of the variable that will hold the store
80
+ * @param name The mlog name that the owner will have
81
+ */
82
+ make(identifier: string, name: string): IValue;
83
+ /**
84
+ * Creates a shallow copy of this scope.
85
+ *
86
+ * Be aware that since the copy is shallow, changes on object fields (except `data`)
87
+ * reflect on the original scope. Note that changes to the children of data also follow this rule.
88
+ */
89
+ copy(): IScope;
90
+ /** Creates a temporary mlog variable name */
91
+ makeTempName(): string;
92
+ }
93
+ /**
94
+ * Owners track how variables will behave when it comes to their usage.
95
+ *
96
+ * As an example, Stores use their owners to determine what to do during
97
+ * assignments, like making a compile time alias, moving the values or generating
98
+ * a `set` instruction.
99
+ */
100
+ export interface IValueOwner<T extends IValue = IValue> {
101
+ scope: IScope;
102
+ constant: boolean;
103
+ value: T;
104
+ /** The name of the variable on the source code that generated this value owner */
105
+ identifier?: string;
106
+ /** The name this owner has in it's mlog representation */
107
+ name: string;
108
+ /** Whether this owner is temporary or persistent */
109
+ persistent: boolean;
110
+ /** Set of values owned by this, can be used to get the owned value count */
111
+ owned: Set<T>;
112
+ /** Adds `target` to the {@link owned set of owned values} and sets its owner to `this` */
113
+ own(target: T): void;
114
+ /** Replaces the currently held value by `target` */
115
+ replace(target: T): void;
116
+ /** Moves all values owned by `this` into `owner` */
117
+ moveInto(owner: IValueOwner<T>): void;
118
+ }
119
+ export interface IValueOperators {
120
+ "!"(scope: IScope): TValueInstructions;
121
+ "u+"(scope: IScope): TValueInstructions;
122
+ "u-"(scope: IScope): TValueInstructions;
123
+ "delete"(scope: IScope): TValueInstructions;
124
+ "typeof"(scope: IScope): TValueInstructions;
125
+ "void"(scope: IScope): TValueInstructions;
126
+ "~"(scope: IScope): TValueInstructions;
127
+ "++"(scope: IScope, prefix: boolean): TValueInstructions;
128
+ "--"(scope: IScope, prefix: boolean): TValueInstructions;
129
+ "*"(scope: IScope, value: IValue): TValueInstructions;
130
+ "**"(scope: IScope, value: IValue): TValueInstructions;
131
+ "+"(scope: IScope, value: IValue): TValueInstructions;
132
+ "-"(scope: IScope, value: IValue): TValueInstructions;
133
+ "/"(scope: IScope, value: IValue): TValueInstructions;
134
+ "%"(scope: IScope, value: IValue): TValueInstructions;
135
+ "!="(scope: IScope, value: IValue): TValueInstructions;
136
+ "!=="(scope: IScope, value: IValue): TValueInstructions;
137
+ "<"(scope: IScope, value: IValue): TValueInstructions;
138
+ "<="(scope: IScope, value: IValue): TValueInstructions;
139
+ "=="(scope: IScope, value: IValue): TValueInstructions;
140
+ "==="(scope: IScope, value: IValue): TValueInstructions;
141
+ ">"(scope: IScope, value: IValue): TValueInstructions;
142
+ ">="(scope: IScope, value: IValue): TValueInstructions;
143
+ "&"(scope: IScope, value: IValue): TValueInstructions;
144
+ "<<"(scope: IScope, value: IValue): TValueInstructions;
145
+ ">>"(scope: IScope, value: IValue): TValueInstructions;
146
+ ">>>"(scope: IScope, value: IValue): TValueInstructions;
147
+ "^"(scope: IScope, value: IValue): TValueInstructions;
148
+ "|"(scope: IScope, value: IValue): TValueInstructions;
149
+ instanceof(scope: IScope, value: IValue): TValueInstructions;
150
+ in(scope: IScope, value: IValue): TValueInstructions;
151
+ "&&"(scope: IScope, value: IValue): TValueInstructions;
152
+ "??"(scope: IScope, value: IValue): TValueInstructions;
153
+ "||"(scope: IScope, value: IValue): TValueInstructions;
154
+ "%="(scope: IScope, value: IValue): TValueInstructions;
155
+ "&="(scope: IScope, value: IValue): TValueInstructions;
156
+ "*="(scope: IScope, value: IValue): TValueInstructions;
157
+ "**="(scope: IScope, value: IValue): TValueInstructions;
158
+ "+="(scope: IScope, value: IValue): TValueInstructions;
159
+ "-="(scope: IScope, value: IValue): TValueInstructions;
160
+ "/="(scope: IScope, value: IValue): TValueInstructions;
161
+ "&&="(scope: IScope, value: IValue): TValueInstructions;
162
+ "||="(scope: IScope, value: IValue): TValueInstructions;
163
+ "<<="(scope: IScope, value: IValue): TValueInstructions;
164
+ ">>="(scope: IScope, value: IValue): TValueInstructions;
165
+ ">>>="(scope: IScope, value: IValue): TValueInstructions;
166
+ "^="(scope: IScope, value: IValue): TValueInstructions;
167
+ "|="(scope: IScope, value: IValue): TValueInstructions;
168
+ "="(scope: IScope, value: IValue): TValueInstructions;
169
+ }
170
+ /** Defines the possible types of mutability of a value */
171
+ export declare enum EMutability {
172
+ /**
173
+ * The value can be changed by the user's code,
174
+ * by the mlog runtime, or us
175
+ */
176
+ mutable = 0,
177
+ /**
178
+ * The value cannot be directly assigned,
179
+ * but it's still not safe from mutations coming from the runtime.
180
+ */
181
+ readonly = 1,
182
+ /** Constant values, won't change during execution */
183
+ constant = 2
184
+ }
185
+ export interface IValue extends IValueOperators {
186
+ owner: IValueOwner | null;
187
+ scope: IScope;
188
+ mutability: EMutability;
189
+ macro: boolean;
190
+ /**
191
+ * Evaluates `this`, returning it's representation in a more basic
192
+ * value like `StoreValue` with the instructions required to compute that value
193
+ */
194
+ eval(scope: IScope): TValueInstructions;
195
+ /**
196
+ * Does the same thing as {@link IValue.eval eval}, but ensures that the resulting value has an owner.
197
+ *
198
+ * This behaviour is required when dealing with temporary values inside expressions like comparations.
199
+ */
200
+ consume(scope: IScope): TValueInstructions;
201
+ call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
202
+ get(scope: IScope, name: IValue): TValueInstructions;
203
+ ensureOwned(): asserts this is IOwnedValue;
204
+ }
205
+ /** Helper type that is used in some typescript assertions */
206
+ export interface IOwnedValue extends IValue {
207
+ owner: Exclude<IValue["owner"], null>;
208
+ }
209
+ export declare type TLiteral = string | number;
210
+ export interface IBindableValue extends IValue {
211
+ data: TLiteral;
212
+ }
213
+ export interface IFunctionValue extends IValue {
214
+ return(scope: IScope, argument: IValue | null): TValueInstructions<IValue | null>;
215
+ }
216
+ /** Contains a value and the instructions required to compute it */
217
+ export declare type TValueInstructions<Content extends IValue | null = IValue> = [
218
+ Content,
219
+ IInstruction[]
220
+ ];
221
+ /** Map of overridable operators in object macros */
222
+ export declare type TOperatorMacroMap = {
223
+ [K in UnaryOperator | UpdateOperator | LeftRightOperator as `$${K}`]?: MacroFunction;
224
+ };