mlogjs 0.1.10 → 0.2.1

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 (245) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +68 -18
  3. package/build/Compiler.d.ts +18 -18
  4. package/build/Compiler.js +99 -92
  5. package/build/Compiler.js.map +1 -1
  6. package/build/Scope.d.ts +26 -26
  7. package/build/Scope.js +60 -60
  8. package/build/Scope.js.map +1 -1
  9. package/build/bin.d.ts +2 -2
  10. package/build/bin.js +59 -33
  11. package/build/bin.js.map +1 -1
  12. package/build/handlers/BlockStatement.d.ts +2 -2
  13. package/build/handlers/BlockStatement.js +13 -13
  14. package/build/handlers/BlockStatement.js.map +1 -1
  15. package/build/handlers/CallExpression.d.ts +3 -3
  16. package/build/handlers/CallExpression.js +19 -19
  17. package/build/handlers/CallExpression.js.map +1 -1
  18. package/build/handlers/ForStatement.d.ts +2 -2
  19. package/build/handlers/ForStatement.js +31 -31
  20. package/build/handlers/ForStatement.js.map +1 -1
  21. package/build/handlers/Function.d.ts +4 -4
  22. package/build/handlers/Function.js +35 -32
  23. package/build/handlers/Function.js.map +1 -1
  24. package/build/handlers/Identifier.d.ts +2 -2
  25. package/build/handlers/Identifier.js +7 -7
  26. package/build/handlers/Identifier.js.map +1 -1
  27. package/build/handlers/IfStatement.d.ts +2 -2
  28. package/build/handlers/IfStatement.js +24 -24
  29. package/build/handlers/IfStatement.js.map +1 -1
  30. package/build/handlers/Literal.d.ts +2 -2
  31. package/build/handlers/Literal.js +17 -15
  32. package/build/handlers/Literal.js.map +1 -1
  33. package/build/handlers/Object.d.ts +4 -4
  34. package/build/handlers/Object.js +43 -43
  35. package/build/handlers/Object.js.map +1 -1
  36. package/build/handlers/OperationExpressions.d.ts +7 -7
  37. package/build/handlers/OperationExpressions.js +32 -31
  38. package/build/handlers/OperationExpressions.js.map +1 -1
  39. package/build/handlers/Program.d.ts +2 -2
  40. package/build/handlers/Program.js +8 -8
  41. package/build/handlers/Program.js.map +1 -1
  42. package/build/handlers/Statements.d.ts +5 -5
  43. package/build/handlers/Statements.js +29 -27
  44. package/build/handlers/Statements.js.map +1 -1
  45. package/build/handlers/TemplateExpression.d.ts +2 -2
  46. package/build/handlers/TemplateExpression.js +17 -17
  47. package/build/handlers/TemplateExpression.js.map +1 -1
  48. package/build/handlers/VariableDeclaration.d.ts +3 -3
  49. package/build/handlers/VariableDeclaration.js +55 -31
  50. package/build/handlers/VariableDeclaration.js.map +1 -1
  51. package/build/handlers/WhileStatement.d.ts +2 -2
  52. package/build/handlers/WhileStatement.js +22 -22
  53. package/build/handlers/WhileStatement.js.map +1 -1
  54. package/build/handlers/index.d.ts +14 -14
  55. package/build/handlers/index.js +30 -26
  56. package/build/handlers/index.js.map +1 -1
  57. package/build/index.d.ts +1 -1
  58. package/build/index.js +7 -7
  59. package/build/index.js.map +1 -1
  60. package/build/initScope.d.ts +2 -0
  61. package/build/initScope.js +40 -0
  62. package/build/initScope.js.map +1 -0
  63. package/build/instructions/AddressResolver.d.ts +12 -12
  64. package/build/instructions/AddressResolver.js +30 -31
  65. package/build/instructions/AddressResolver.js.map +1 -1
  66. package/build/instructions/ControlInstructions.d.ts +11 -11
  67. package/build/instructions/ControlInstructions.js +22 -22
  68. package/build/instructions/ControlInstructions.js.map +1 -1
  69. package/build/instructions/EndInstruction.d.ts +4 -4
  70. package/build/instructions/EndInstruction.js +10 -10
  71. package/build/instructions/EndInstruction.js.map +1 -1
  72. package/build/instructions/InstructionBase.d.ts +10 -10
  73. package/build/instructions/InstructionBase.js +20 -20
  74. package/build/instructions/InstructionBase.js.map +1 -1
  75. package/build/instructions/JumpInstruction.d.ts +15 -15
  76. package/build/instructions/JumpInstruction.js +21 -21
  77. package/build/instructions/JumpInstruction.js.map +1 -1
  78. package/build/instructions/OperationInstruction.d.ts +5 -5
  79. package/build/instructions/OperationInstruction.js +10 -10
  80. package/build/instructions/OperationInstruction.js.map +1 -1
  81. package/build/instructions/SetCounterInstruction.d.ts +5 -5
  82. package/build/instructions/SetCounterInstruction.js +10 -10
  83. package/build/instructions/SetCounterInstruction.js.map +1 -1
  84. package/build/instructions/SetInstruction.d.ts +5 -5
  85. package/build/instructions/SetInstruction.js +10 -10
  86. package/build/instructions/SetInstruction.js.map +1 -1
  87. package/build/instructions/ZeroSpaceInstruction.d.ts +4 -4
  88. package/build/instructions/ZeroSpaceInstruction.js +10 -10
  89. package/build/instructions/ZeroSpaceInstruction.js.map +1 -1
  90. package/build/instructions/index.d.ts +9 -9
  91. package/build/instructions/index.js +25 -21
  92. package/build/instructions/index.js.map +1 -1
  93. package/build/macros/Building.d.ts +11 -0
  94. package/build/macros/Building.js +81 -0
  95. package/build/macros/Building.js.map +1 -0
  96. package/build/macros/Function.d.ts +12 -12
  97. package/build/macros/Function.js +19 -19
  98. package/build/macros/Function.js.map +1 -1
  99. package/build/macros/Math.d.ts +5 -5
  100. package/build/macros/Math.js +56 -56
  101. package/build/macros/Math.js.map +1 -1
  102. package/build/macros/{Blocks.d.ts → Memory.d.ts} +5 -5
  103. package/build/macros/Memory.js +61 -0
  104. package/build/macros/Memory.js.map +1 -0
  105. package/build/macros/Namespace.d.ts +21 -0
  106. package/build/macros/Namespace.js +98 -0
  107. package/build/macros/Namespace.js.map +1 -0
  108. package/build/macros/Other.d.ts +5 -8
  109. package/build/macros/Other.js +19 -28
  110. package/build/macros/Other.js.map +1 -1
  111. package/build/macros/{Draw.d.ts → RawValue.d.ts} +5 -5
  112. package/build/macros/RawValue.js +16 -0
  113. package/build/macros/RawValue.js.map +1 -0
  114. package/build/macros/commands/Control.d.ts +5 -0
  115. package/build/macros/commands/Control.js +25 -0
  116. package/build/macros/commands/Control.js.map +1 -0
  117. package/build/macros/commands/Draw.d.ts +5 -0
  118. package/build/macros/{Draw.js → commands/Draw.js} +38 -33
  119. package/build/macros/commands/Draw.js.map +1 -0
  120. package/build/macros/commands/DrawFlush.d.ts +5 -0
  121. package/build/macros/commands/DrawFlush.js +17 -0
  122. package/build/macros/commands/DrawFlush.js.map +1 -0
  123. package/build/macros/commands/GetLink.d.ts +5 -0
  124. package/build/macros/commands/GetLink.js +21 -0
  125. package/build/macros/commands/GetLink.js.map +1 -0
  126. package/build/macros/commands/Lookup.d.ts +5 -0
  127. package/build/macros/commands/Lookup.js +24 -0
  128. package/build/macros/commands/Lookup.js.map +1 -0
  129. package/build/macros/commands/Print.d.ts +5 -0
  130. package/build/macros/commands/Print.js +14 -0
  131. package/build/macros/commands/Print.js.map +1 -0
  132. package/build/macros/commands/PrintFlush.d.ts +5 -0
  133. package/build/macros/commands/PrintFlush.js +17 -0
  134. package/build/macros/commands/PrintFlush.js.map +1 -0
  135. package/build/macros/commands/Radar.d.ts +7 -0
  136. package/build/macros/commands/Radar.js +61 -0
  137. package/build/macros/commands/Radar.js.map +1 -0
  138. package/build/macros/commands/Sensor.d.ts +5 -0
  139. package/build/macros/commands/Sensor.js +20 -0
  140. package/build/macros/commands/Sensor.js.map +1 -0
  141. package/build/macros/commands/UnitBind.d.ts +5 -0
  142. package/build/macros/commands/UnitBind.js +17 -0
  143. package/build/macros/commands/UnitBind.js.map +1 -0
  144. package/build/macros/commands/UnitControl.d.ts +5 -0
  145. package/build/macros/commands/UnitControl.js +68 -0
  146. package/build/macros/commands/UnitControl.js.map +1 -0
  147. package/build/macros/commands/UnitLocate.d.ts +5 -0
  148. package/build/macros/commands/UnitLocate.js +55 -0
  149. package/build/macros/commands/UnitLocate.js.map +1 -0
  150. package/build/macros/commands/UnitRadar.d.ts +5 -0
  151. package/build/macros/commands/UnitRadar.js +41 -0
  152. package/build/macros/commands/UnitRadar.js.map +1 -0
  153. package/build/macros/commands/Wait.d.ts +5 -0
  154. package/build/macros/commands/Wait.js +18 -0
  155. package/build/macros/commands/Wait.js.map +1 -0
  156. package/build/macros/commands/index.d.ts +14 -0
  157. package/build/macros/commands/index.js +33 -0
  158. package/build/macros/commands/index.js.map +1 -0
  159. package/build/macros/index.d.ts +7 -5
  160. package/build/macros/index.js +39 -17
  161. package/build/macros/index.js.map +1 -1
  162. package/build/operators.d.ts +25 -22
  163. package/build/operators.js +101 -38
  164. package/build/operators.js.map +1 -1
  165. package/build/types.d.ts +49 -49
  166. package/build/types.js +27 -23
  167. package/build/types.js.map +1 -1
  168. package/build/utils.d.ts +3 -2
  169. package/build/utils.js +12 -8
  170. package/build/utils.js.map +1 -1
  171. package/build/values/BaseValue.d.ts +5 -5
  172. package/build/values/BaseValue.js +111 -101
  173. package/build/values/BaseValue.js.map +1 -1
  174. package/build/values/FunctionValue.d.ts +34 -34
  175. package/build/values/FunctionValue.js +103 -100
  176. package/build/values/FunctionValue.js.map +1 -1
  177. package/build/values/LiteralValue.d.ts +12 -12
  178. package/build/values/LiteralValue.js +87 -88
  179. package/build/values/LiteralValue.js.map +1 -1
  180. package/build/values/ObjectValue.d.ts +17 -17
  181. package/build/values/ObjectValue.js +49 -49
  182. package/build/values/ObjectValue.js.map +1 -1
  183. package/build/values/StoreValue.d.ts +11 -11
  184. package/build/values/StoreValue.js +30 -30
  185. package/build/values/StoreValue.js.map +1 -1
  186. package/build/values/TempValue.d.ts +12 -12
  187. package/build/values/TempValue.js +66 -52
  188. package/build/values/TempValue.js.map +1 -1
  189. package/build/values/VoidValue.d.ts +11 -11
  190. package/build/values/VoidValue.js +30 -30
  191. package/build/values/VoidValue.js.map +1 -1
  192. package/build/values/index.d.ts +6 -6
  193. package/build/values/index.js +22 -18
  194. package/build/values/index.js.map +1 -1
  195. package/dist/mlogjs.es.js +6366 -0
  196. package/dist/mlogjs.umd.js +8 -0
  197. package/lib/commands.d.ts +326 -0
  198. package/lib/eslib/index.d.ts +3 -0
  199. package/lib/eslib/lib.d.ts +9 -0
  200. package/lib/eslib/lib.es2015.collection.d.ts +89 -0
  201. package/lib/eslib/lib.es2015.core.d.ts +16 -0
  202. package/lib/eslib/lib.es2015.d.ts +30 -0
  203. package/lib/eslib/lib.es2015.generator.d.ts +79 -0
  204. package/lib/eslib/lib.es2015.iterable.d.ts +70 -0
  205. package/lib/eslib/lib.es5.d.ts +295 -0
  206. package/lib/eslib/lib.es6.d.ts +18 -0
  207. package/lib/globals.d.ts +328 -0
  208. package/lib/helpers.d.ts +23 -0
  209. package/lib/index.d.ts +7 -0
  210. package/lib/kinds.d.ts +36 -0
  211. package/lib/memory.d.ts +17 -0
  212. package/lib/traits.d.ts +121 -0
  213. package/lib/util.d.ts +32 -0
  214. package/package.json +73 -37
  215. package/.gitattributes +0 -2
  216. package/build/macros/Blocks.js +0 -134
  217. package/build/macros/Blocks.js.map +0 -1
  218. package/build/macros/Draw.js.map +0 -1
  219. package/build/macros/TypeFactory.d.ts +0 -8
  220. package/build/macros/TypeFactory.js +0 -22
  221. package/build/macros/TypeFactory.js.map +0 -1
  222. package/build/scopes/FunctionScope.d.ts +0 -5
  223. package/build/scopes/FunctionScope.js +0 -13
  224. package/build/scopes/FunctionScope.js.map +0 -1
  225. package/build/scopes/LoopScope.d.ts +0 -5
  226. package/build/scopes/LoopScope.js +0 -13
  227. package/build/scopes/LoopScope.js.map +0 -1
  228. package/build/scopes/Scope.d.ts +0 -36
  229. package/build/scopes/Scope.js +0 -93
  230. package/build/scopes/Scope.js.map +0 -1
  231. package/build/scopes/index.d.ts +0 -3
  232. package/build/scopes/index.js +0 -16
  233. package/build/scopes/index.js.map +0 -1
  234. package/dist/bundle.js +0 -553
  235. package/docs/.nojekyll +0 -0
  236. package/docs/README.md +0 -17
  237. package/docs/_coverpage.md +0 -8
  238. package/docs/_sidebar.md +0 -3
  239. package/docs/data-types.md +0 -56
  240. package/docs/getting-started.md +0 -19
  241. package/docs/index.html +0 -41
  242. package/docs/mlogjs.png +0 -0
  243. package/mlogjs.d.ts +0 -72
  244. package/tsconfig.json +0 -22
  245. package/webpack.config.js +0 -22
@@ -0,0 +1,17 @@
1
+ /// <reference path="./kinds.d.ts" />
2
+
3
+ type MemoryCapacity = 64 | 512;
4
+ /**
5
+ * A wrapper around memory cells/banks that is compatible with custom types.
6
+ */
7
+ declare class Memory<S extends MemoryCapacity = 64> {
8
+ constructor(cell: BasicBuilding, size?: S);
9
+
10
+ [Symbol.iterator](): IterableIterator<number>;
11
+ [index: number]: number;
12
+
13
+ /**
14
+ * The practical length of the memory view.
15
+ */
16
+ readonly length: S;
17
+ }
@@ -0,0 +1,121 @@
1
+ import "./globals";
2
+ import "./custom-lib";
3
+
4
+ type LogicSymbols = typeof Items & typeof Liquids & typeof LAccess;
5
+
6
+ type WithSymbols<T extends Record<string, unknown>> = T & {
7
+ readonly [K in keyof (LogicSymbols | T) as LogicSymbols[K]]: T[K];
8
+ };
9
+
10
+ declare global {
11
+ type LiquidHolder = WithSymbols<
12
+ {
13
+ readonly [L in keyof typeof Liquids]: number;
14
+ } & {
15
+ readonly totalLiquids: number;
16
+ readonly liquidCapacity: number;
17
+ }
18
+ >;
19
+
20
+ type ItemHolder = WithSymbols<
21
+ {
22
+ readonly [I in keyof typeof Items]: number;
23
+ } & {
24
+ readonly totalItems: number;
25
+ readonly firstItem: ItemSymbol | null;
26
+ readonly itemCapacity: number;
27
+ }
28
+ >;
29
+
30
+ type PowerHolder = WithSymbols<{
31
+ readonly totalPower: number;
32
+ readonly powerCapacity: number;
33
+ readonly powerNetStored: number;
34
+ readonly powerNetCapacity: number;
35
+ readonly powerNetIn: number;
36
+ readonly powerNetOut: number;
37
+ }>;
38
+
39
+ type Shooting = WithSymbols<{
40
+ readonly shootX: number;
41
+ readonly shootY: number;
42
+ readonly ammo: number;
43
+ readonly ammoCapacity: number;
44
+ }>;
45
+
46
+ type WithHealth = WithSymbols<{
47
+ readonly health: number;
48
+ readonly maxHealth: number;
49
+ readonly dead: boolean;
50
+ }>;
51
+
52
+ type Heatable = WithSymbols<{
53
+ readonly heat: number;
54
+ }>;
55
+
56
+ type WithEffiency = WithSymbols<{
57
+ readonly efficiency: number;
58
+ }>;
59
+
60
+ type WithProgress = WithSymbols<{
61
+ readonly progress: number;
62
+ }>;
63
+
64
+ type WithTimescale = WithSymbols<{
65
+ readonly timescale: number;
66
+ }>;
67
+
68
+ type Rotatable = WithSymbols<{
69
+ readonly rotation: number;
70
+ }>;
71
+
72
+ type Spaced = WithSymbols<{
73
+ readonly x: number;
74
+ readonly y: number;
75
+ readonly size: number;
76
+ }>;
77
+
78
+ type Ranged = WithSymbols<{
79
+ readonly range: number;
80
+ }>;
81
+
82
+ type Boosted = WithSymbols<{
83
+ readonly boosting: number;
84
+ }>;
85
+
86
+ type Mining = WithSymbols<{
87
+ readonly mineX: number;
88
+ readonly mineY: number;
89
+ readonly mining: number;
90
+ }>;
91
+
92
+ type Typed<T extends symbol = symbol> = WithSymbols<{
93
+ readonly type: T;
94
+ }>;
95
+ type Flagged = WithSymbols<{
96
+ readonly flag: number;
97
+ }>;
98
+
99
+ type Controllable = WithSymbols<{
100
+ readonly controlled: 0 | ControlKind;
101
+ readonly controller: AnyUnit | BasicBuilding;
102
+ }>;
103
+
104
+ type Nameable = WithSymbols<{
105
+ readonly name: string | null;
106
+ }>;
107
+
108
+ type PayloadHolder = WithSymbols<{
109
+ readonly payloadCount: number;
110
+ readonly payloadType: symbol | null;
111
+ }>;
112
+
113
+ type WithEnable = WithSymbols<{
114
+ enabled: boolean;
115
+ }>;
116
+
117
+ type WithConfig<T extends symbol | number | null = symbol | null> =
118
+ WithSymbols<{
119
+ readonly config: T;
120
+ }>;
121
+ }
package/lib/util.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export type TRadarFilter =
2
+ | "any"
3
+ | "enemy"
4
+ | "ally"
5
+ | "player"
6
+ | "attacker"
7
+ | "flying"
8
+ | "boss"
9
+ | "ground";
10
+
11
+ export type TRadarFilterArray =
12
+ | [TRadarFilter]
13
+ | [TRadarFilter, TRadarFilter]
14
+ | [TRadarFilter, TRadarFilter, TRadarFilter];
15
+
16
+ export type TRadarSort =
17
+ | "distance"
18
+ | "health"
19
+ | "shield"
20
+ | "armor"
21
+ | "maxHealth";
22
+
23
+ export type TUnitLocateBuildingGroup =
24
+ | "core"
25
+ | "storage"
26
+ | "generator"
27
+ | "turret"
28
+ | "factory"
29
+ | "repair"
30
+ | "rally"
31
+ | "battery"
32
+ | "reactor";
package/package.json CHANGED
@@ -1,37 +1,73 @@
1
- {
2
- "name": "mlogjs",
3
- "version": "0.1.10",
4
- "description": "Compiler that compiles Javascript to Mindustry Logic Code.",
5
- "main": "build/index.js",
6
- "bin": {
7
- "mlogjs": "./build/bin.js"
8
- },
9
- "scripts": {
10
- "build": "tsc && webpack",
11
- "start": "npm run build && npm i -g . && mlogjs"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/str1z/mlogjs.git"
16
- },
17
- "keywords": [],
18
- "author": "str1z",
19
- "license": "MIT",
20
- "bugs": {
21
- "url": "https://github.com/str1z/mlogjs/issues"
22
- },
23
- "homepage": "https://github.com/str1z/mlogjs#readme",
24
- "dependencies": {
25
- "esprima": "^4.0.1",
26
- "yargs": "^17.0.1"
27
- },
28
- "devDependencies": {
29
- "@types/esprima": "^4.0.2",
30
- "@types/node": "^15.3.0",
31
- "@types/yargs": "^16.0.1",
32
- "ts-loader": "^9.1.2",
33
- "typescript": "^4.2.4",
34
- "webpack": "^5.37.0",
35
- "webpack-cli": "^4.7.0"
36
- }
37
- }
1
+ {
2
+ "name": "mlogjs",
3
+ "version": "0.2.1",
4
+ "description": "Compiler that compiles Javascript to Mindustry Logic Code.",
5
+ "main": "build/index.js",
6
+ "bin": "./build/bin.js",
7
+ "scripts": {
8
+ "clean": "rm -rf docs dist build",
9
+ "build": "tsc && vite build",
10
+ "build:editor": "cd editor && vite build",
11
+ "dev": "ts-node src/bin",
12
+ "dev:editor": "cd editor && vite",
13
+ "test": "jest",
14
+ "coverage": "jest --coverage",
15
+ "docs:doc": "mkdir -p docs && cp -r doc/. docs",
16
+ "docs:lib": "typedoc --out docs/lib lib/*",
17
+ "docs:src": "typedoc --out docs/src src/index.ts",
18
+ "docs": "run-p docs:lib docs:src docs:doc",
19
+ "start": "npm run build && npm i -g . && mlogjs",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "exports": {
23
+ "require": "./build/index.js",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/weisrc/mlogjs.git"
29
+ },
30
+ "packageManager": "yarn@3.2.0",
31
+ "keywords": [],
32
+ "author": "str1z",
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/weisrc/mlogjs/issues"
36
+ },
37
+ "homepage": "https://github.com/weisrc/mlogjs#readme",
38
+ "dependencies": {
39
+ "acorn": "^8.7.0",
40
+ "cli-highlight": "^2.1.11",
41
+ "yargs": "^17.0.1"
42
+ },
43
+ "devDependencies": {
44
+ "@monaco-editor/react": "^4.3.1",
45
+ "@types/estree": "^0.0.51",
46
+ "@types/jest": "^27.4.1",
47
+ "@types/node": "^15.3.0",
48
+ "@types/react": "^17.0.39",
49
+ "@types/react-dom": "^17.0.13",
50
+ "@types/react-split-pane": "^0.1.67",
51
+ "@types/yargs": "^16.0.1",
52
+ "@vitejs/plugin-react": "^1.2.0",
53
+ "jest": "^27.5.1",
54
+ "monaco-editor": "^0.32.1",
55
+ "npm-run-all": "^4.1.5",
56
+ "prettier": "^2.5.1",
57
+ "react": "^17.0.2",
58
+ "react-dom": "^17.0.2",
59
+ "react-split-pane": "^0.1.92",
60
+ "ts-jest": "^27.1.3",
61
+ "ts-node": "^10.6.0",
62
+ "typedoc": "^0.22.12",
63
+ "typescript": "^4.6.2",
64
+ "vite": "^2.8.6"
65
+ },
66
+ "files": [
67
+ "build",
68
+ "dist",
69
+ "lib",
70
+ "LICENSE",
71
+ "README.md"
72
+ ]
73
+ }
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockBuilder = void 0;
4
- const instructions_1 = require("../instructions");
5
- const values_1 = require("../values");
6
- const Function_1 = require("./Function");
7
- class Block extends values_1.ObjectValue {
8
- constructor(scope, name) {
9
- super(scope, {
10
- $get: new Function_1.MacroFunction(scope, (prop) => {
11
- let obj;
12
- if (prop instanceof values_1.LiteralValue && typeof prop.data === "string") {
13
- obj = new values_1.ObjectValue(scope, {
14
- $eval: new Function_1.MacroFunction(scope, () => {
15
- return this.get(scope, new values_1.LiteralValue(scope, "sensor"))[0].call(scope, [prop]);
16
- }),
17
- "$=": new Function_1.MacroFunction(scope, (value) => {
18
- return this.get(scope, new values_1.LiteralValue(scope, "control"))[0].call(scope, [prop, value]);
19
- })
20
- });
21
- }
22
- else {
23
- obj = new values_1.ObjectValue(scope, {
24
- $eval: new Function_1.MacroFunction(scope, () => {
25
- return this.get(scope, new values_1.LiteralValue(scope, "read"))[0].call(scope, [prop]);
26
- }),
27
- "$=": new Function_1.MacroFunction(scope, (value) => {
28
- return this.get(scope, new values_1.LiteralValue(scope, "write"))[0].call(scope, [prop, value]);
29
- })
30
- });
31
- }
32
- return [obj, []];
33
- }),
34
- puts: new Function_1.MacroFunction(scope, (...args) => {
35
- return [
36
- null,
37
- [
38
- ...args.map((arg) => new instructions_1.InstructionBase("print", arg)),
39
- new instructions_1.InstructionBase("printflush", name),
40
- ],
41
- ];
42
- }),
43
- printFlush: new Function_1.MacroFunction(scope, () => {
44
- return [null, [new instructions_1.InstructionBase("printflush", name)]];
45
- }),
46
- drawFlush: new Function_1.MacroFunction(scope, () => {
47
- return [null, [new instructions_1.InstructionBase("drawflush", name)]];
48
- }),
49
- read: new Function_1.MacroFunction(scope, (i) => {
50
- if (!(i instanceof values_1.LiteralValue || i instanceof values_1.StoreValue))
51
- throw new Error("Cannot read at non-literal or non-store index.");
52
- const temp = new values_1.TempValue(scope);
53
- return [temp, [new instructions_1.InstructionBase("read", temp, name, i)]];
54
- }),
55
- write: new Function_1.MacroFunction(scope, (i, value) => {
56
- if (!(i instanceof values_1.LiteralValue || i instanceof values_1.StoreValue))
57
- throw new Error("Cannot write at non-literal or non-store index.");
58
- if (!(value instanceof values_1.LiteralValue || value instanceof values_1.StoreValue))
59
- throw new Error("Cannot write a non-literal or non-store value.");
60
- return [value, [new instructions_1.InstructionBase("write", value, name, i)]];
61
- }),
62
- // sensor result block1 @copper
63
- sensor: new Function_1.MacroFunction(scope, (attr) => {
64
- if (!(attr instanceof values_1.LiteralValue))
65
- throw new Error("Cannot use sensor with non-literal attribute.");
66
- if (typeof attr.data !== "string")
67
- throw new Error("Cannot use sensor with non-string attribute.");
68
- if (attr.data[0] === "@")
69
- throw new Error("The use of '@' is unnecessary beucase it is already done for you.");
70
- const temp = new values_1.TempValue(scope);
71
- return [temp, [new instructions_1.InstructionBase("sensor", temp, name, "@" + attr.data)]];
72
- }),
73
- //control enabled block1 0 0 0 0
74
- control: new Function_1.MacroFunction(scope, (attr, ...args) => {
75
- if (!(attr instanceof values_1.LiteralValue))
76
- throw new Error("Cannot use control with non-literal attribute.");
77
- if (["enabled", "shoot", "shootp", "configure", "color"].indexOf(attr.data) === -1)
78
- throw new Error("Control attribute must be valid.");
79
- for (const arg of args)
80
- if (!(arg instanceof values_1.LiteralValue || arg instanceof values_1.StoreValue))
81
- throw new Error("Arguments cannot be non-literal or non-store value.");
82
- return [null, [new instructions_1.InstructionBase("control", attr.data, name, ...args)]];
83
- }),
84
- // radar enemy any any distance turret1 1 result
85
- radar: new Function_1.MacroFunction(scope, (target0, target1, target2, sort, order) => {
86
- const targets = [target0, target1, target2];
87
- for (const target of targets) {
88
- if (!(target instanceof values_1.LiteralValue))
89
- throw new Error("Radar targets cannot be non-literal.");
90
- if ([
91
- "any",
92
- "enemy",
93
- "ally",
94
- "player",
95
- "attacker",
96
- "flying",
97
- "boss",
98
- "ground",
99
- ].indexOf(target.data) === -1)
100
- throw new Error("Radar target must be valid.");
101
- }
102
- if (!(sort instanceof values_1.LiteralValue))
103
- throw new Error("Radar sort cannot be non-literal.");
104
- if (["distance", "health", "shield", "armor", "maxHealth"].indexOf(sort.data) === -1)
105
- throw new Error("Radar sort must be valid");
106
- if (!(order instanceof values_1.LiteralValue || order instanceof values_1.StoreValue))
107
- throw new Error("Arguments cannot be non-literal or non-store value.");
108
- const temp = new values_1.TempValue(scope);
109
- return [
110
- temp,
111
- [
112
- new instructions_1.InstructionBase("radar", ...targets.map((v) => v.data), sort.data, name, order, temp),
113
- ],
114
- ];
115
- }),
116
- });
117
- this.name = name;
118
- }
119
- }
120
- class BlockBuilder extends values_1.ObjectValue {
121
- constructor(scope) {
122
- super(scope, {
123
- $call: new Function_1.MacroFunction(scope, (nameLit) => {
124
- if (!(nameLit instanceof values_1.LiteralValue))
125
- throw new Error("Block name must be a literal.");
126
- if (typeof nameLit.data !== "string")
127
- throw new Error("Block name must be a string.");
128
- return [new Block(scope, nameLit.data), []];
129
- }),
130
- });
131
- }
132
- }
133
- exports.BlockBuilder = BlockBuilder;
134
- //# sourceMappingURL=Blocks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Blocks.js","sourceRoot":"","sources":["../../src/macros/Blocks.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAElD,sCAA6E;AAC7E,yCAA2C;AAE3C,MAAM,KAAM,SAAQ,oBAAW;IAE9B,YAAY,KAAa,EAAE,IAAY;QACtC,KAAK,CAAC,KAAK,EAAE;YACH,IAAI,EAAE,IAAI,wBAAa,CAAC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC5C,IAAI,GAAgB,CAAA;gBACpB,IAAI,IAAI,YAAY,qBAAY,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;oBAC/D,GAAG,GAAG,IAAI,oBAAW,CAAC,KAAK,EAAE;wBACzB,KAAK,EAAE,IAAI,wBAAa,CAAC,KAAK,EAAE,GAAG,EAAE;4BACjC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,qBAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK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CAAC,CAAC,IAAI,YAAY,qBAAY,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACnF,IACC;gBACC,OAAO;gBACP,OAAO;gBACP,QAAQ;gBACR,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,UAAU;gBACV,UAAU;gBACV,OAAO;aACP,CAAC,OAAO,CAAC,IAAI,CAAC,IAAc,CAAC,KAAK,CAAC,CAAC;gBAErC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,8BAAe,CAAC,MAAM,EAAE,IAAI,CAAC,IAAc,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACnE,IAAI,CAAC,YAAY,qBAAY,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;4BAAE,OAAO,CAAC,CAAC,IAAI,CAAA;wBAC1E,OAAO,CAAC,CAAA;oBACZ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAzBD,oBAyBC"}
@@ -1,8 +0,0 @@
1
- import { IScope } from "../types";
2
- import { MacroFunction } from "./Function";
3
- export declare class StoreFactory extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
6
- export declare class TempFactory extends MacroFunction {
7
- constructor(scope: IScope);
8
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TempFactory = exports.StoreFactory = void 0;
4
- const values_1 = require("../values");
5
- const Function_1 = require("./Function");
6
- class StoreFactory extends Function_1.MacroFunction {
7
- constructor(scope) {
8
- super(scope, (value) => {
9
- if (value instanceof values_1.LiteralValue && typeof value.data === "string")
10
- return [new values_1.StoreValue(scope, value.data), []];
11
- throw new Error("Cannot create store value with name that is not a literal string");
12
- });
13
- }
14
- }
15
- exports.StoreFactory = StoreFactory;
16
- class TempFactory extends Function_1.MacroFunction {
17
- constructor(scope) {
18
- super(scope, () => [new values_1.TempValue(scope), []]);
19
- }
20
- }
21
- exports.TempFactory = TempFactory;
22
- //# sourceMappingURL=TypeFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeFactory.js","sourceRoot":"","sources":["../../src/macros/TypeFactory.ts"],"names":[],"mappings":";;;AACA,sCAAgE;AAChE,yCAA2C;AAE3C,MAAa,YAAa,SAAQ,wBAAa;IAC9C,YAAY,KAAa;QACxB,KAAK,CAAC,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE;YAC9B,IAAI,KAAK,YAAY,qBAAY,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAClE,OAAO,CAAC,IAAI,mBAAU,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AARD,oCAQC;AAED,MAAa,WAAY,SAAQ,wBAAa;IAC7C,YAAY,KAAa;QACxB,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,kBAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACD;AAJD,kCAIC"}
@@ -1,5 +0,0 @@
1
- import { IScope } from "../types";
2
- import { Scope } from ".";
3
- export declare class FunctionScope extends Scope {
4
- createScope(): IScope;
5
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionScope = void 0;
4
- const _1 = require(".");
5
- class FunctionScope extends _1.Scope {
6
- createScope() {
7
- const scope = super.createScope();
8
- scope.fnScope = this;
9
- return scope;
10
- }
11
- }
12
- exports.FunctionScope = FunctionScope;
13
- //# sourceMappingURL=FunctionScope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionScope.js","sourceRoot":"","sources":["../../src/scopes/FunctionScope.ts"],"names":[],"mappings":";;;AACA,wBAA0B;AAE1B,MAAa,aAAc,SAAQ,QAAK;IACpC,WAAW;QACP,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QACjC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAA;QACpB,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAND,sCAMC"}
@@ -1,5 +0,0 @@
1
- import { IScope } from "../types";
2
- import { Scope } from ".";
3
- export declare class LoopScope extends Scope {
4
- createScope(): IScope;
5
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoopScope = void 0;
4
- const _1 = require(".");
5
- class LoopScope extends _1.Scope {
6
- createScope() {
7
- const scope = super.createScope();
8
- scope.loopScope = this;
9
- return scope;
10
- }
11
- }
12
- exports.LoopScope = LoopScope;
13
- //# sourceMappingURL=LoopScope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoopScope.js","sourceRoot":"","sources":["../../src/scopes/LoopScope.ts"],"names":[],"mappings":";;;AACA,wBAA0B;AAE1B,MAAa,SAAU,SAAQ,QAAK;IAChC,WAAW;QACP,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QACjC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAA;QACtB,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAND,8BAMC"}
@@ -1,36 +0,0 @@
1
- import { AddressResolver } from "../instructions";
2
- import { IFunctionValue, IInstruction, IScope, IValue } from "../types";
3
- export declare class Scope implements IScope {
4
- fnScope: IScope;
5
- loopScope: IScope;
6
- private _fnEnded;
7
- private _loopEnded;
8
- parent: IScope;
9
- name: string;
10
- data: {
11
- [k: string]: IValue;
12
- };
13
- stacked: boolean;
14
- ntemp: number;
15
- inst: IInstruction[];
16
- break: AddressResolver;
17
- continue: AddressResolver;
18
- function: IFunctionValue;
19
- get fnEnded(): boolean;
20
- set fnEnded(value: boolean);
21
- get loopEnded(): boolean;
22
- set loopEnded(value: boolean);
23
- get ended(): boolean;
24
- constructor(values: {
25
- [k: string]: IValue;
26
- }, parent?: IScope, stacked?: boolean, ntemp?: number, name?: string, inst?: any[]);
27
- copy(): IScope;
28
- createScope(): IScope;
29
- createLoop(): IScope;
30
- createFunction(name: string, stacked?: boolean): IScope;
31
- has(name: string): boolean;
32
- get(name: string): IValue;
33
- set(name: string, value: IValue): IValue;
34
- hardSet(name: string, value: IValue): IValue;
35
- make(name: string, storeName: string): IValue;
36
- }
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Scope = void 0;
4
- const values_1 = require("../values");
5
- const _1 = require(".");
6
- class Scope {
7
- constructor(values, parent = null, stacked = false, ntemp = 0, name = "", inst = []) {
8
- this._fnEnded = false;
9
- this._loopEnded = false;
10
- this.stacked = false;
11
- this.ntemp = 0;
12
- this.data = values;
13
- this.parent = parent;
14
- this.stacked = stacked;
15
- this.ntemp = ntemp;
16
- this.name = name;
17
- this.inst = inst;
18
- }
19
- get fnEnded() {
20
- var _a, _b;
21
- return (_b = (_a = this.fnScope) === null || _a === void 0 ? void 0 : _a.fnEnded) !== null && _b !== void 0 ? _b : this._fnEnded;
22
- }
23
- set fnEnded(value) {
24
- if (this.fnScope)
25
- this.fnScope.fnEnded = value;
26
- else
27
- this._fnEnded = value;
28
- }
29
- get loopEnded() {
30
- var _a, _b;
31
- return (_b = (_a = this.loopScope) === null || _a === void 0 ? void 0 : _a.loopEnded) !== null && _b !== void 0 ? _b : this._loopEnded;
32
- }
33
- set loopEnded(value) {
34
- if (this.loopScope)
35
- this.loopScope.loopEnded = value;
36
- else
37
- this._loopEnded = value;
38
- }
39
- get ended() {
40
- console.log(this);
41
- return this.fnEnded || this.loopEnded;
42
- }
43
- copy() {
44
- const scope = new Scope(Object.assign({}, this.data), this.parent, this.stacked, this.ntemp, this.name, this.inst);
45
- scope.break = this.break;
46
- scope.continue = this.continue;
47
- scope.function = this.function;
48
- scope.fnScope = this.fnScope;
49
- scope.loopScope = this.loopScope;
50
- return scope;
51
- }
52
- createScope() {
53
- const scope = this.copy();
54
- scope.data = {};
55
- scope.parent = this;
56
- return scope;
57
- }
58
- createLoop() {
59
- return new _1.LoopScope({}, this, this.stacked, this.ntemp, this.name, this.inst);
60
- }
61
- createFunction(name, stacked) {
62
- return new _1.FunctionScope({}, this, stacked !== null && stacked !== void 0 ? stacked : this.stacked, 0, name, this.inst);
63
- }
64
- has(name) {
65
- if (name in this.data)
66
- return true;
67
- if (this.parent)
68
- return this.parent.has(name);
69
- return false;
70
- }
71
- get(name) {
72
- const value = this.data[name];
73
- if (value)
74
- return value;
75
- if (this.parent)
76
- return this.parent.get(name);
77
- throw Error(`${name} is not declared.`);
78
- }
79
- set(name, value) {
80
- if (name in this.data)
81
- throw Error(`${name} is already declared.`);
82
- return this.hardSet(name, value);
83
- }
84
- hardSet(name, value) {
85
- this.data[name] = value;
86
- return value;
87
- }
88
- make(name, storeName) {
89
- return this.set(name, this.stacked ? null : new values_1.StoreValue(this, storeName));
90
- }
91
- }
92
- exports.Scope = Scope;
93
- //# sourceMappingURL=Scope.js.map