mlogjs 0.1.11 → 0.2.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 (206) hide show
  1. package/build/Compiler.js +39 -12
  2. package/build/Compiler.js.map +1 -1
  3. package/build/Scope.js.map +1 -1
  4. package/build/bin.js +17 -10
  5. package/build/bin.js.map +1 -1
  6. package/build/handlers/BlockStatement.js.map +1 -1
  7. package/build/handlers/CallExpression.js.map +1 -1
  8. package/build/handlers/ForStatement.js.map +1 -1
  9. package/build/handlers/Function.js +6 -3
  10. package/build/handlers/Function.js.map +1 -1
  11. package/build/handlers/Identifier.js.map +1 -1
  12. package/build/handlers/IfStatement.js.map +1 -1
  13. package/build/handlers/Literal.js +3 -1
  14. package/build/handlers/Literal.js.map +1 -1
  15. package/build/handlers/Object.js +1 -1
  16. package/build/handlers/Object.js.map +1 -1
  17. package/build/handlers/OperationExpressions.js +2 -1
  18. package/build/handlers/OperationExpressions.js.map +1 -1
  19. package/build/handlers/Program.js.map +1 -1
  20. package/build/handlers/Statements.js +3 -1
  21. package/build/handlers/Statements.js.map +1 -1
  22. package/build/handlers/TemplateExpression.js.map +1 -1
  23. package/build/handlers/VariableDeclaration.js +43 -19
  24. package/build/handlers/VariableDeclaration.js.map +1 -1
  25. package/build/handlers/WhileStatement.js.map +1 -1
  26. package/build/handlers/index.js +5 -1
  27. package/build/handlers/index.js.map +1 -1
  28. package/build/index.js.map +1 -1
  29. package/build/instructions/AddressResolver.js +1 -2
  30. package/build/instructions/AddressResolver.js.map +1 -1
  31. package/build/instructions/ControlInstructions.js.map +1 -1
  32. package/build/instructions/EndInstruction.js.map +1 -1
  33. package/build/instructions/InstructionBase.js.map +1 -1
  34. package/build/instructions/JumpInstruction.js.map +1 -1
  35. package/build/instructions/OperationInstruction.js.map +1 -1
  36. package/build/instructions/SetCounterInstruction.js.map +1 -1
  37. package/build/instructions/SetInstruction.js.map +1 -1
  38. package/build/instructions/ZeroSpaceInstruction.js.map +1 -1
  39. package/build/instructions/index.js +5 -1
  40. package/build/instructions/index.js.map +1 -1
  41. package/build/macros/Blocks.js +12 -6
  42. package/build/macros/Blocks.js.map +1 -1
  43. package/build/macros/Building.d.ts +11 -0
  44. package/build/macros/Building.js +81 -0
  45. package/build/macros/Building.js.map +1 -0
  46. package/build/macros/Draw.js +7 -2
  47. package/build/macros/Draw.js.map +1 -1
  48. package/build/macros/Function.js.map +1 -1
  49. package/build/macros/Items.d.ts +5 -0
  50. package/build/macros/Items.js +20 -0
  51. package/build/macros/Items.js.map +1 -0
  52. package/build/macros/Liquids.d.ts +5 -0
  53. package/build/macros/Liquids.js +18 -0
  54. package/build/macros/Liquids.js.map +1 -0
  55. package/build/macros/Math.js +9 -9
  56. package/build/macros/Math.js.map +1 -1
  57. package/build/macros/Memory.d.ts +5 -0
  58. package/build/macros/Memory.js +61 -0
  59. package/build/macros/Memory.js.map +1 -0
  60. package/build/macros/Namespace.d.ts +21 -0
  61. package/build/macros/Namespace.js +98 -0
  62. package/build/macros/Namespace.js.map +1 -0
  63. package/build/macros/Other.d.ts +0 -3
  64. package/build/macros/Other.js +2 -11
  65. package/build/macros/Other.js.map +1 -1
  66. package/build/macros/RawValue.d.ts +5 -0
  67. package/build/macros/RawValue.js +16 -0
  68. package/build/macros/RawValue.js.map +1 -0
  69. package/{docs/.nojekyll → build/macros/Symbol.d.ts} +0 -0
  70. package/build/macros/Symbol.js +1 -0
  71. package/build/macros/Symbol.js.map +1 -0
  72. package/build/macros/SymbolNamespace.d.ts +0 -0
  73. package/build/macros/SymbolNamespace.js +1 -0
  74. package/build/macros/SymbolNamespace.js.map +1 -0
  75. package/build/macros/TypeFactory.js.map +1 -1
  76. package/build/macros/Units.d.ts +5 -0
  77. package/build/macros/Units.js +18 -0
  78. package/build/macros/Units.js.map +1 -0
  79. package/build/macros/Vars.d.ts +5 -0
  80. package/build/macros/Vars.js +18 -0
  81. package/build/macros/Vars.js.map +1 -0
  82. package/build/macros/commands/Asm.d.ts +5 -0
  83. package/build/macros/commands/Asm.js +21 -0
  84. package/build/macros/commands/Asm.js.map +1 -0
  85. package/build/macros/commands/Draw.d.ts +5 -0
  86. package/build/macros/commands/Draw.js +39 -0
  87. package/build/macros/commands/Draw.js.map +1 -0
  88. package/build/macros/commands/DrawFlush.d.ts +5 -0
  89. package/build/macros/commands/DrawFlush.js +17 -0
  90. package/build/macros/commands/DrawFlush.js.map +1 -0
  91. package/build/macros/commands/GetLink.d.ts +5 -0
  92. package/build/macros/commands/GetLink.js +21 -0
  93. package/build/macros/commands/GetLink.js.map +1 -0
  94. package/build/macros/commands/Lookup.d.ts +5 -0
  95. package/build/macros/commands/Lookup.js +24 -0
  96. package/build/macros/commands/Lookup.js.map +1 -0
  97. package/build/macros/commands/Print.d.ts +5 -0
  98. package/build/macros/commands/Print.js +14 -0
  99. package/build/macros/commands/Print.js.map +1 -0
  100. package/build/macros/commands/PrintFlush.d.ts +5 -0
  101. package/build/macros/commands/PrintFlush.js +17 -0
  102. package/build/macros/commands/PrintFlush.js.map +1 -0
  103. package/build/macros/commands/Radar.d.ts +7 -0
  104. package/build/macros/commands/Radar.js +61 -0
  105. package/build/macros/commands/Radar.js.map +1 -0
  106. package/build/macros/commands/Sensor.d.ts +5 -0
  107. package/build/macros/commands/Sensor.js +20 -0
  108. package/build/macros/commands/Sensor.js.map +1 -0
  109. package/build/macros/commands/UnitBind.d.ts +5 -0
  110. package/build/macros/commands/UnitBind.js +17 -0
  111. package/build/macros/commands/UnitBind.js.map +1 -0
  112. package/build/macros/commands/UnitControl.d.ts +5 -0
  113. package/build/macros/commands/UnitControl.js +68 -0
  114. package/build/macros/commands/UnitControl.js.map +1 -0
  115. package/build/macros/commands/UnitLocate.d.ts +5 -0
  116. package/build/macros/commands/UnitLocate.js +55 -0
  117. package/build/macros/commands/UnitLocate.js.map +1 -0
  118. package/build/macros/commands/UnitRadar.d.ts +5 -0
  119. package/build/macros/commands/UnitRadar.js +41 -0
  120. package/build/macros/commands/UnitRadar.js.map +1 -0
  121. package/build/macros/commands/Wait.d.ts +5 -0
  122. package/build/macros/commands/Wait.js +18 -0
  123. package/build/macros/commands/Wait.js.map +1 -0
  124. package/build/macros/commands/control.d.ts +5 -0
  125. package/build/macros/commands/control.js +25 -0
  126. package/build/macros/commands/control.js.map +1 -0
  127. package/build/macros/commands/index.d.ts +14 -0
  128. package/build/macros/commands/index.js +33 -0
  129. package/build/macros/commands/index.js.map +1 -0
  130. package/build/macros/commands/io.d.ts +8 -0
  131. package/build/macros/commands/io.js +47 -0
  132. package/build/macros/commands/io.js.map +1 -0
  133. package/build/macros/helpers/GetBuilding.d.ts +5 -0
  134. package/build/macros/helpers/GetBuilding.js +16 -0
  135. package/build/macros/helpers/GetBuilding.js.map +1 -0
  136. package/build/macros/helpers/GetVar.d.ts +5 -0
  137. package/build/macros/helpers/GetVar.js +16 -0
  138. package/build/macros/helpers/GetVar.js.map +1 -0
  139. package/build/macros/helpers/index.d.ts +2 -0
  140. package/build/{scopes → macros/helpers}/index.js +2 -3
  141. package/build/macros/helpers/index.js.map +1 -0
  142. package/build/macros/index.d.ts +4 -2
  143. package/build/macros/index.js +25 -3
  144. package/build/macros/index.js.map +1 -1
  145. package/build/operators.d.ts +3 -0
  146. package/build/operators.js +79 -16
  147. package/build/operators.js.map +1 -1
  148. package/build/types.js +5 -1
  149. package/build/types.js.map +1 -1
  150. package/build/utils.d.ts +1 -0
  151. package/build/utils.js +5 -1
  152. package/build/utils.js.map +1 -1
  153. package/build/values/BaseValue.js +13 -3
  154. package/build/values/BaseValue.js.map +1 -1
  155. package/build/values/FunctionValue.js +5 -2
  156. package/build/values/FunctionValue.js.map +1 -1
  157. package/build/values/LiteralValue.js +4 -5
  158. package/build/values/LiteralValue.js.map +1 -1
  159. package/build/values/ObjectValue.js.map +1 -1
  160. package/build/values/StoreValue.js.map +1 -1
  161. package/build/values/TempValue.js +16 -2
  162. package/build/values/TempValue.js.map +1 -1
  163. package/build/values/VoidValue.js.map +1 -1
  164. package/build/values/index.js +5 -1
  165. package/build/values/index.js.map +1 -1
  166. package/dist/bundle.js +1 -553
  167. package/lib/commands.d.ts +326 -0
  168. package/lib/eslib/index.d.ts +3 -0
  169. package/lib/eslib/lib.d.ts +9 -0
  170. package/lib/eslib/lib.es2015.collection.d.ts +89 -0
  171. package/lib/eslib/lib.es2015.core.d.ts +16 -0
  172. package/lib/eslib/lib.es2015.d.ts +30 -0
  173. package/lib/eslib/lib.es2015.generator.d.ts +79 -0
  174. package/lib/eslib/lib.es2015.iterable.d.ts +70 -0
  175. package/lib/eslib/lib.es5.d.ts +295 -0
  176. package/lib/eslib/lib.es6.d.ts +18 -0
  177. package/lib/globals.d.ts +328 -0
  178. package/lib/helpers.d.ts +23 -0
  179. package/lib/index.d.ts +7 -0
  180. package/lib/kinds.d.ts +36 -0
  181. package/lib/memory.d.ts +17 -0
  182. package/lib/traits.d.ts +121 -0
  183. package/lib/util.d.ts +32 -0
  184. package/package.json +18 -7
  185. package/.gitattributes +0 -2
  186. package/build/scopes/FunctionScope.d.ts +0 -5
  187. package/build/scopes/FunctionScope.js +0 -13
  188. package/build/scopes/FunctionScope.js.map +0 -1
  189. package/build/scopes/LoopScope.d.ts +0 -5
  190. package/build/scopes/LoopScope.js +0 -13
  191. package/build/scopes/LoopScope.js.map +0 -1
  192. package/build/scopes/Scope.d.ts +0 -36
  193. package/build/scopes/Scope.js +0 -93
  194. package/build/scopes/Scope.js.map +0 -1
  195. package/build/scopes/index.d.ts +0 -3
  196. package/build/scopes/index.js.map +0 -1
  197. package/docs/README.md +0 -17
  198. package/docs/_coverpage.md +0 -8
  199. package/docs/_sidebar.md +0 -3
  200. package/docs/data-types.md +0 -56
  201. package/docs/getting-started.md +0 -19
  202. package/docs/index.html +0 -41
  203. package/docs/mlogjs.png +0 -0
  204. package/mlogjs.d.ts +0 -72
  205. package/tsconfig.json +0 -22
  206. 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,19 +1,19 @@
1
1
  {
2
2
  "name": "mlogjs",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "description": "Compiler that compiles Javascript to Mindustry Logic Code.",
5
5
  "main": "build/index.js",
6
- "bin": {
7
- "mlogjs": "./build/bin.js"
8
- },
6
+ "bin": "./build/bin.js",
9
7
  "scripts": {
10
8
  "build": "tsc && webpack",
11
- "start": "npm run build && npm i -g . && mlogjs"
9
+ "start": "npm run build && npm i -g . && mlogjs",
10
+ "prepublishOnly": "npm run build"
12
11
  },
13
12
  "repository": {
14
13
  "type": "git",
15
14
  "url": "git+https://github.com/weisrc/mlogjs.git"
16
15
  },
16
+ "packageManager": "yarn@3.2.0",
17
17
  "keywords": [],
18
18
  "author": "str1z",
19
19
  "license": "MIT",
@@ -27,11 +27,22 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/esprima": "^4.0.2",
30
+ "@types/jest": "^27.4.1",
30
31
  "@types/node": "^15.3.0",
31
32
  "@types/yargs": "^16.0.1",
33
+ "jest": "^27.5.1",
34
+ "prettier": "^2.5.1",
35
+ "ts-jest": "^27.1.3",
32
36
  "ts-loader": "^9.1.2",
33
- "typescript": "^4.2.4",
37
+ "typescript": "^4.6.2",
34
38
  "webpack": "^5.37.0",
35
39
  "webpack-cli": "^4.7.0"
36
- }
40
+ },
41
+ "files": [
42
+ "build",
43
+ "dist",
44
+ "lib",
45
+ "LICENSE",
46
+ "README.md"
47
+ ]
37
48
  }
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"Scope.js","sourceRoot":"","sources":["../../src/scopes/Scope.ts"],"names":[],"mappings":";;;AAAA,sCAAuC;AAGvC,wBAA4C;AAE5C,MAAa,KAAK;IAoCjB,Y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AAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,IAAY;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,GAAG,CAAC,IAAY,EAAE,KAAa;QAC9B,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI;YAAE,MAAM,KAAK,CAAC,GAAG,IAAI,uBAAuB,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,CAAC,IAAY,EAAE,KAAa;QAClC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,CAAC,IAAY,EAAE,SAAiB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,mBAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9E,CAAC;CACD;AAvGD,sBAuGC"}
@@ -1,3 +0,0 @@
1
- export * from "./Scope";
2
- export * from "./FunctionScope";
3
- export * from "./LoopScope";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scopes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAuB;AACvB,kDAA+B;AAC/B,8CAA2B"}
package/docs/README.md DELETED
@@ -1,17 +0,0 @@
1
- # MlogJS
2
-
3
- MlogJS is a compiler that allows users to compile complex JavaScript programs into Mindustry Logic Code.
4
-
5
- ## Discord
6
-
7
- You can join the Discord server for more information and for help.
8
-
9
- <iframe src="https://discord.com/widget?id=841105039211888710&theme=dark" width="350" height="300" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>
10
-
11
- ## Getting started!
12
-
13
- ```
14
- npm i mlogjs -g
15
- ```
16
-
17
- After installing the package from NPM, read the [docs](https://str1z.github.io/mlogjs).
@@ -1,8 +0,0 @@
1
- # MlogJS <small>0.1.1</small>
2
-
3
- > Effortless JavaScript to Mindustry Logic Code compiler.
4
-
5
- ![](mlogjs.png)
6
-
7
- [GitHub](https://github.com/str1z/mlogcc)
8
- [Get Started](#getting-started)
package/docs/_sidebar.md DELETED
@@ -1,3 +0,0 @@
1
- - [MlogJS](/)
2
- - [Getting Started](/getting-started)
3
- - [Data Types](/data-types)
@@ -1,56 +0,0 @@
1
- # Data Types
2
-
3
- There are a total of four different data types:
4
-
5
- - Literal
6
- - Stora
7
- - Function
8
- - Object
9
-
10
- ## Literal
11
-
12
- Literal values are the raw values that you write directly. They are constant strings or numbers.
13
-
14
- ```js
15
- 123 // is a literal
16
- const a = 123 // is a literal as well
17
- const b = "some string" // string literal
18
- typeof a === "literal" // true
19
- ```
20
-
21
- ## Store
22
-
23
- Store values are the registers in the game inside a processor. They are mutable.
24
-
25
- ```js
26
- let a = 123 // is a store number
27
- let b = "string" // is a store string
28
- typeof b === "store" // true
29
- ```
30
-
31
- ## Function
32
-
33
- Function values are constants.
34
-
35
- ```js
36
- function add(a,b) {
37
- return a + b
38
- }
39
- typeof add === "function" // true
40
- ```
41
-
42
- ## Object
43
-
44
- Object values are constants and support operator overriding.
45
-
46
- ```js
47
- const obj = {
48
- a: 1,
49
- b: (a,b) => a + b,
50
- $call: (a,b) => a * b,
51
- }
52
- obj.a // 1
53
- obj.b(1,2) // 3
54
- obj(2,2) // 4
55
- typeof obj === "object" // true
56
- ```
@@ -1,19 +0,0 @@
1
- # Getting started.
2
-
3
- ## How to use it?
4
-
5
- You can use it through the online version, the Discord bot, or the command-line interface tool.
6
-
7
- ## CLI installation
8
-
9
- ```
10
- npm i -g mlogjs
11
- ```
12
-
13
- ## Web version
14
-
15
- https://weisrc.github.io/mlogjs-web-editor/
16
-
17
- ## Discord bot
18
-
19
- Coming soon!
package/docs/index.html DELETED
@@ -1,41 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <title>Document</title>
7
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
8
- <meta name="description" content="Description" />
9
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
10
- <link rel="stylesheet"
11
- href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css" />
12
-
13
-
14
- </head>
15
-
16
- <body>
17
- <div id="app"></div>
18
- <script src="//cdn.jsdelivr.net/npm/docsify-edit-on-github"></script>
19
-
20
- <script>
21
- window.$docsify = {
22
- plugins: [EditOnGithubPlugin.create("https://github.com/str1z/mlogcc/tree/main/docs/")],
23
- name: "MlogJS",
24
- repo: "https://github.com/str1z/mlogcc",
25
- coverpage: true,
26
- loadSidebar: true,
27
- subMaxLevel: 3,
28
- copyCode: {
29
- buttonText: "Copy",
30
- errorText: "Error",
31
- successText: "Copied",
32
- },
33
- };
34
- </script>
35
- <!-- Docsify v4 -->
36
- <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
37
- <script src="https://unpkg.com/docsify-copy-code@2"></script>
38
- <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
39
- </body>
40
-
41
- </html>
package/docs/mlogjs.png DELETED
Binary file
package/mlogjs.d.ts DELETED
@@ -1,72 +0,0 @@
1
- declare type TTarget =
2
- | "any"
3
- | "enemy"
4
- | "ally"
5
- | "player"
6
- | "attacker"
7
- | "flying"
8
- | "boss"
9
- | "ground";
10
-
11
- declare class Block {
12
- constructor(name: string);
13
- write(i: number, value: number): number;
14
- read(i: number): number;
15
- printFlush(): void;
16
- drawFlush(): void;
17
- puts(...values: (number | string)[]): void;
18
- sensor(attr: string): number | boolean;
19
- control(attr: "enabled" | "shoot" | "shootp" | "configure" | "color", ...args: number[]): void;
20
- radar(
21
- target0: TTarget,
22
- target1: TTarget,
23
- target2: TTarget,
24
- sort: "distance" | "health" | "shield" | "armor" | "maxHealth",
25
- distance: number
26
- ): any;
27
- }
28
-
29
- declare class Store {
30
- constructor(name: string);
31
- }
32
-
33
- declare class Temp {}
34
-
35
- // @ts-ignore
36
- declare const Math = {
37
- max: (a: number, b: number) => Math.max(a, b),
38
- min: (a: number, b: number) => Math.min(a, b),
39
- angle: (a: number, b: number) => Math.atan2(a, b),
40
- len: (a: number, b: number) => Math.sqrt(a ** 2 + b ** 2),
41
- noise: (x: any, y: any) => x + y,
42
- abs: (a: number) => Math.abs(a),
43
- log: (a: number) => Math.log(a),
44
- log10: (a: number) => Math.log(a) / Math.log(10),
45
- sin: (a: number) => Math.sin(a),
46
- cos: (a: number) => Math.cos(a),
47
- tan: (a: number) => Math.tan(a),
48
- floor: (a: number) => Math.floor(a),
49
- ceil: (a: number) => Math.ceil(a),
50
- sqrt: (a: number) => Math.ceil(a),
51
- rand: (range: number) => Math.random() * range,
52
- };
53
-
54
- declare function draw(
55
- kind:
56
- | "clear"
57
- | "color"
58
- | "stroke"
59
- | "line"
60
- | "rect"
61
- | "lineRect"
62
- | "poly"
63
- | "linePoly"
64
- | "triangle"
65
- | "image",
66
- ...args: any
67
- ): void;
68
-
69
- declare function print(...values: any): void;
70
- declare function concat(...values: string[]): string;
71
-
72
- declare class Entity extends Block {}
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "esModuleInterop": true,
6
- "allowSyntheticDefaultImports": true,
7
- "target": "es6",
8
- "moduleResolution": "node",
9
- "sourceMap": true,
10
- "outDir": "build",
11
- "baseUrl": ".",
12
- "paths": {
13
- "*": [
14
- "node_modules/*",
15
- "src/types/*"
16
- ]
17
- }
18
- },
19
- "include": [
20
- "src/**/*"
21
- ]
22
- }