mlogjs 0.2.0 → 0.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +68 -18
- package/build/Compiler.js +32 -47
- package/build/Compiler.js.map +1 -1
- package/build/CompilerError.js +11 -0
- package/build/CompilerError.js.map +1 -0
- package/build/Scope.js +17 -7
- package/build/Scope.js.map +1 -1
- package/build/bin.js +45 -12
- package/build/bin.js.map +1 -1
- package/build/handlers/BlockStatement.js.map +1 -1
- package/build/handlers/CallExpression.js.map +1 -1
- package/build/handlers/File.js +9 -0
- package/build/handlers/File.js.map +1 -0
- package/build/handlers/ForStatement.js.map +1 -1
- package/build/handlers/Function.js +20 -9
- package/build/handlers/Function.js.map +1 -1
- package/build/handlers/IfStatement.js.map +1 -1
- package/build/handlers/Literal.js +11 -14
- package/build/handlers/Literal.js.map +1 -1
- package/build/handlers/Object.js +16 -5
- package/build/handlers/Object.js.map +1 -1
- package/build/handlers/OperationExpressions.js +6 -1
- package/build/handlers/OperationExpressions.js.map +1 -1
- package/build/handlers/Program.js +1 -1
- package/build/handlers/Program.js.map +1 -1
- package/build/handlers/Statements.js.map +1 -1
- package/build/handlers/TemplateExpression.js.map +1 -1
- package/build/handlers/VariableDeclaration.js +25 -9
- package/build/handlers/VariableDeclaration.js.map +1 -1
- package/build/handlers/WhileStatement.js.map +1 -1
- package/build/handlers/index.js +1 -0
- package/build/handlers/index.js.map +1 -1
- package/build/index.js +5 -5
- package/build/index.js.map +1 -1
- package/build/initScope.js +40 -0
- package/build/initScope.js.map +1 -0
- package/build/instructions/InstructionBase.js +1 -1
- package/build/instructions/InstructionBase.js.map +1 -1
- package/build/instructions/JumpInstruction.js +1 -1
- package/build/instructions/JumpInstruction.js.map +1 -1
- package/build/instructions/OperationInstruction.js.map +1 -1
- package/build/macros/Building.js +16 -8
- package/build/macros/Building.js.map +1 -1
- package/build/macros/Function.js +1 -1
- package/build/macros/Function.js.map +1 -1
- package/build/macros/Math.js +13 -8
- package/build/macros/Math.js.map +1 -1
- package/build/macros/Memory.js +7 -5
- package/build/macros/Memory.js.map +1 -1
- package/build/macros/Namespace.js +24 -11
- package/build/macros/Namespace.js.map +1 -1
- package/build/macros/Other.js +2 -1
- package/build/macros/Other.js.map +1 -1
- package/build/macros/RawValue.js +2 -1
- package/build/macros/RawValue.js.map +1 -1
- package/build/macros/commands/{control.js → Control.js} +4 -3
- package/build/macros/commands/Control.js.map +1 -0
- package/build/macros/commands/Draw.js +4 -3
- package/build/macros/commands/Draw.js.map +1 -1
- package/build/macros/commands/DrawFlush.js +2 -1
- package/build/macros/commands/DrawFlush.js.map +1 -1
- package/build/macros/commands/GetLink.js +8 -4
- package/build/macros/commands/GetLink.js.map +1 -1
- package/build/macros/commands/Lookup.js +5 -4
- package/build/macros/commands/Lookup.js.map +1 -1
- package/build/macros/commands/Print.js +5 -1
- package/build/macros/commands/Print.js.map +1 -1
- package/build/macros/commands/PrintFlush.js +2 -1
- package/build/macros/commands/PrintFlush.js.map +1 -1
- package/build/macros/commands/Radar.js +16 -12
- package/build/macros/commands/Radar.js.map +1 -1
- package/build/macros/commands/Sensor.js +4 -3
- package/build/macros/commands/Sensor.js.map +1 -1
- package/build/macros/commands/UnitBind.js +2 -1
- package/build/macros/commands/UnitBind.js.map +1 -1
- package/build/macros/commands/UnitControl.js +13 -8
- package/build/macros/commands/UnitControl.js.map +1 -1
- package/build/macros/commands/UnitLocate.js +29 -8
- package/build/macros/commands/UnitLocate.js.map +1 -1
- package/build/macros/commands/UnitRadar.js +17 -10
- package/build/macros/commands/UnitRadar.js.map +1 -1
- package/build/macros/commands/Wait.js +2 -1
- package/build/macros/commands/Wait.js.map +1 -1
- package/build/operators.js.map +1 -1
- package/build/types.js +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js +7 -2
- package/build/utils.js.map +1 -1
- package/build/values/BaseValue.js +5 -5
- package/build/values/BaseValue.js.map +1 -1
- package/build/values/FunctionValue.js +25 -13
- package/build/values/FunctionValue.js.map +1 -1
- package/build/values/LiteralValue.js +5 -4
- package/build/values/LiteralValue.js.map +1 -1
- package/build/values/ObjectValue.js +11 -6
- package/build/values/ObjectValue.js.map +1 -1
- package/build/values/StoreValue.js +3 -2
- package/build/values/StoreValue.js.map +1 -1
- package/build/values/TempValue.js +18 -7
- package/build/values/TempValue.js.map +1 -1
- package/build/values/VoidValue.js +8 -7
- package/build/values/VoidValue.js.map +1 -1
- package/dist/bin.cjs +82 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/index.cjs +2187 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2162 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/Compiler.d.ts +26 -0
- package/dist/types/CompilerError.d.ts +9 -0
- package/dist/types/Scope.d.ts +24 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/handlers/BlockStatement.d.ts +2 -0
- package/dist/types/handlers/CallExpression.d.ts +3 -0
- package/dist/types/handlers/File.d.ts +2 -0
- package/dist/types/handlers/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +1 -0
- package/{build → dist/types}/handlers/Identifier.d.ts +0 -0
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/dist/types/handlers/Literal.d.ts +5 -0
- package/{build → dist/types}/handlers/Object.d.ts +2 -0
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +1 -0
- package/dist/types/handlers/Program.d.ts +2 -0
- package/dist/types/handlers/Statements.d.ts +5 -0
- package/dist/types/handlers/TemplateExpression.d.ts +2 -0
- package/dist/types/handlers/Typescript.d.ts +7 -0
- package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +3 -0
- package/{build → dist/types}/handlers/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/initScope.d.ts +5 -0
- package/{build → dist/types}/instructions/AddressResolver.d.ts +1 -1
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +0 -3
- package/{build → dist/types}/instructions/EndInstruction.d.ts +0 -0
- package/{build → dist/types}/instructions/InstructionBase.d.ts +4 -4
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +1 -1
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +1 -1
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +0 -0
- package/{build → dist/types}/instructions/SetInstruction.d.ts +1 -0
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +0 -0
- package/{build → dist/types}/instructions/index.d.ts +0 -0
- package/{build → dist/types}/macros/Building.d.ts +1 -2
- package/dist/types/macros/Entities.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +13 -0
- package/{build/macros/Draw.d.ts → dist/types/macros/GetGlobal.d.ts} +1 -1
- package/{build → dist/types}/macros/Math.d.ts +0 -0
- package/{build → dist/types}/macros/Memory.d.ts +0 -0
- package/{build → dist/types}/macros/Namespace.d.ts +0 -5
- package/{build → dist/types}/macros/Other.d.ts +0 -0
- package/{build → dist/types}/macros/RawValue.d.ts +0 -0
- package/{build/macros/commands/Asm.d.ts → dist/types/macros/commands/Control.d.ts} +1 -1
- package/{build/macros/helpers/GetVar.d.ts → dist/types/macros/commands/Draw.d.ts} +1 -1
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +1 -1
- package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +1 -1
- package/{build → dist/types}/macros/commands/GetLink.d.ts +0 -0
- package/{build → dist/types}/macros/commands/Lookup.d.ts +0 -0
- package/{build → dist/types}/macros/commands/Print.d.ts +1 -1
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +1 -1
- package/{build → dist/types}/macros/commands/Radar.d.ts +0 -0
- package/{build → dist/types}/macros/commands/Sensor.d.ts +0 -0
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +1 -1
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +0 -0
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +0 -0
- package/{build → dist/types}/macros/commands/Wait.d.ts +1 -1
- package/{build → dist/types}/macros/commands/index.d.ts +1 -0
- package/{build → dist/types}/macros/index.d.ts +0 -1
- package/{build → dist/types}/operators.d.ts +1 -1
- package/dist/types/types.d.ts +209 -0
- package/dist/types/utils.d.ts +24 -0
- package/dist/types/values/BaseValue.d.ts +7 -0
- package/dist/types/values/DestructuringValue.d.ts +17 -0
- package/{build → dist/types}/values/FunctionValue.d.ts +21 -8
- package/{build → dist/types}/values/LiteralValue.d.ts +2 -1
- package/dist/types/values/ObjectValue.d.ts +23 -0
- package/dist/types/values/SenseableValue.d.ts +23 -0
- package/dist/types/values/StackValue.d.ts +16 -0
- package/{build → dist/types}/values/StoreValue.d.ts +7 -3
- package/{build → dist/types}/values/TempValue.d.ts +9 -2
- package/dist/types/values/ValueOwner.d.ts +27 -0
- package/dist/types/values/VoidValue.d.ts +16 -0
- package/{build → dist/types}/values/index.d.ts +2 -1
- package/lib/commands.d.ts +532 -326
- package/lib/eslib/index.d.ts +3 -3
- package/lib/eslib/lib.d.ts +9 -9
- package/lib/eslib/lib.es2015.collection.d.ts +89 -89
- package/lib/eslib/lib.es2015.core.d.ts +16 -16
- package/lib/eslib/lib.es2015.d.ts +30 -30
- package/lib/eslib/lib.es2015.generator.d.ts +79 -79
- package/lib/eslib/lib.es2015.iterable.d.ts +70 -70
- package/lib/eslib/lib.es5.d.ts +295 -295
- package/lib/eslib/lib.es6.d.ts +18 -18
- package/lib/globals.d.ts +341 -328
- package/lib/helpers.d.ts +23 -23
- package/lib/index.d.ts +7 -7
- package/lib/kinds.d.ts +36 -36
- package/lib/memory.d.ts +17 -17
- package/lib/traits.d.ts +141 -121
- package/lib/util.d.ts +32 -32
- package/package.json +68 -48
- package/build/Compiler.d.ts +0 -18
- package/build/Scope.d.ts +0 -26
- package/build/bin.d.ts +0 -2
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/IfStatement.d.ts +0 -2
- package/build/handlers/Literal.d.ts +0 -2
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/index.d.ts +0 -1
- package/build/macros/Blocks.d.ts +0 -5
- package/build/macros/Blocks.js +0 -143
- package/build/macros/Blocks.js.map +0 -1
- package/build/macros/Draw.js +0 -39
- package/build/macros/Draw.js.map +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/Items.d.ts +0 -5
- package/build/macros/Items.js +0 -20
- package/build/macros/Items.js.map +0 -1
- package/build/macros/Liquids.d.ts +0 -5
- package/build/macros/Liquids.js +0 -18
- package/build/macros/Liquids.js.map +0 -1
- package/build/macros/Symbol.d.ts +0 -0
- package/build/macros/Symbol.js +0 -1
- package/build/macros/Symbol.js.map +0 -1
- package/build/macros/SymbolNamespace.d.ts +0 -0
- package/build/macros/SymbolNamespace.js +0 -1
- package/build/macros/SymbolNamespace.js.map +0 -1
- package/build/macros/TypeFactory.d.ts +0 -8
- package/build/macros/TypeFactory.js +0 -22
- package/build/macros/TypeFactory.js.map +0 -1
- package/build/macros/Units.d.ts +0 -5
- package/build/macros/Units.js +0 -18
- package/build/macros/Units.js.map +0 -1
- package/build/macros/Vars.d.ts +0 -5
- package/build/macros/Vars.js +0 -18
- package/build/macros/Vars.js.map +0 -1
- package/build/macros/commands/Asm.js +0 -21
- package/build/macros/commands/Asm.js.map +0 -1
- package/build/macros/commands/UnitControl.d.ts +0 -5
- package/build/macros/commands/control.d.ts +0 -5
- package/build/macros/commands/control.js.map +0 -1
- package/build/macros/commands/io.d.ts +0 -8
- package/build/macros/commands/io.js +0 -47
- package/build/macros/commands/io.js.map +0 -1
- package/build/macros/helpers/GetBuilding.d.ts +0 -5
- package/build/macros/helpers/GetBuilding.js +0 -16
- package/build/macros/helpers/GetBuilding.js.map +0 -1
- package/build/macros/helpers/GetVar.js +0 -16
- package/build/macros/helpers/GetVar.js.map +0 -1
- package/build/macros/helpers/index.d.ts +0 -2
- package/build/macros/helpers/index.js +0 -15
- package/build/macros/helpers/index.js.map +0 -1
- package/build/types.d.ts +0 -49
- package/build/utils.d.ts +0 -3
- package/build/values/BaseValue.d.ts +0 -5
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/VoidValue.d.ts +0 -11
- package/dist/bundle.js +0 -1
package/lib/helpers.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/// <reference path="./kinds.d.ts" />
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Allows getting unlisted processor variables or symbols.
|
|
5
|
-
*
|
|
6
|
-
* Using this method is discouraged because most values are
|
|
7
|
-
* already accessible under the namespaces `Units`, `Blocks`,
|
|
8
|
-
* `Items`, `Liquids`, `ControlKind`, `Vars` and `UnitCommands`.
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
11
|
-
*/
|
|
12
|
-
declare function getVar<T>(
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gets a building linked to the processor by its name.
|
|
16
|
-
*
|
|
17
|
-
* @param name
|
|
18
|
-
*/
|
|
19
|
-
declare function getBuilding<T extends BasicBuilding = AnyBuilding>(
|
|
20
|
-
name: string
|
|
21
|
-
): T;
|
|
22
|
-
|
|
23
|
-
declare function concat(...strings: string[]): string;
|
|
1
|
+
/// <reference path="./kinds.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Allows getting unlisted processor variables or symbols.
|
|
5
|
+
*
|
|
6
|
+
* Using this method is discouraged because most values are
|
|
7
|
+
* already accessible under the namespaces `Units`, `Blocks`,
|
|
8
|
+
* `Items`, `Liquids`, `ControlKind`, `Vars` and `UnitCommands`.
|
|
9
|
+
*
|
|
10
|
+
* @param name The identifier of the value
|
|
11
|
+
*/
|
|
12
|
+
declare function getVar<T>(name: string): T;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets a building linked to the processor by its name.
|
|
16
|
+
*
|
|
17
|
+
* @param name
|
|
18
|
+
*/
|
|
19
|
+
declare function getBuilding<T extends BasicBuilding = AnyBuilding>(
|
|
20
|
+
name: string
|
|
21
|
+
): T;
|
|
22
|
+
|
|
23
|
+
declare function concat(...strings: string[]): string;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference path="./eslib/index.d.ts" />
|
|
2
|
-
/// <reference path="./commands.d.ts" />
|
|
3
|
-
/// <reference path="./globals.d.ts" />
|
|
4
|
-
/// <reference path="./helpers.d.ts" />
|
|
5
|
-
/// <reference path="./kinds.d.ts" />
|
|
6
|
-
/// <reference path="./memory.d.ts" />
|
|
7
|
-
/// <reference path="./traits.d.ts" />
|
|
1
|
+
/// <reference path="./eslib/index.d.ts" />
|
|
2
|
+
/// <reference path="./commands.d.ts" />
|
|
3
|
+
/// <reference path="./globals.d.ts" />
|
|
4
|
+
/// <reference path="./helpers.d.ts" />
|
|
5
|
+
/// <reference path="./kinds.d.ts" />
|
|
6
|
+
/// <reference path="./memory.d.ts" />
|
|
7
|
+
/// <reference path="./traits.d.ts" />
|
package/lib/kinds.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/// <reference path="./traits.d.ts" />
|
|
2
|
-
|
|
3
|
-
interface BasicUnit
|
|
4
|
-
extends ItemHolder,
|
|
5
|
-
Shooting,
|
|
6
|
-
WithHealth,
|
|
7
|
-
Rotatable,
|
|
8
|
-
Spaced,
|
|
9
|
-
Ranged,
|
|
10
|
-
Typed<UnitSymbol>,
|
|
11
|
-
Flagged,
|
|
12
|
-
Controllable,
|
|
13
|
-
Nameable {}
|
|
14
|
-
|
|
15
|
-
interface AnyUnit extends BasicUnit, Boosted {}
|
|
16
|
-
|
|
17
|
-
interface BasicBuilding
|
|
18
|
-
extends LiquidHolder,
|
|
19
|
-
ItemHolder,
|
|
20
|
-
PowerHolder,
|
|
21
|
-
WithHealth,
|
|
22
|
-
WithEffiency,
|
|
23
|
-
WithTimescale,
|
|
24
|
-
Rotatable,
|
|
25
|
-
Spaced,
|
|
26
|
-
Ranged,
|
|
27
|
-
Typed<BlockSymbol>,
|
|
28
|
-
WithEnable,
|
|
29
|
-
WithConfig {}
|
|
30
|
-
|
|
31
|
-
interface BasicTurret extends BasicBuilding, Shooting, WithProgress {}
|
|
32
|
-
|
|
33
|
-
// just to make this future proof
|
|
34
|
-
interface AnyTurret extends BasicTurret {}
|
|
35
|
-
|
|
36
|
-
interface AnyBuilding extends AnyTurret, Heatable {}
|
|
1
|
+
/// <reference path="./traits.d.ts" />
|
|
2
|
+
|
|
3
|
+
interface BasicUnit
|
|
4
|
+
extends ItemHolder,
|
|
5
|
+
Shooting,
|
|
6
|
+
WithHealth,
|
|
7
|
+
Rotatable,
|
|
8
|
+
Spaced,
|
|
9
|
+
Ranged,
|
|
10
|
+
Typed<UnitSymbol>,
|
|
11
|
+
Flagged,
|
|
12
|
+
Controllable,
|
|
13
|
+
Nameable {}
|
|
14
|
+
|
|
15
|
+
interface AnyUnit extends BasicUnit, Boosted {}
|
|
16
|
+
|
|
17
|
+
interface BasicBuilding
|
|
18
|
+
extends LiquidHolder,
|
|
19
|
+
ItemHolder,
|
|
20
|
+
PowerHolder,
|
|
21
|
+
WithHealth,
|
|
22
|
+
WithEffiency,
|
|
23
|
+
WithTimescale,
|
|
24
|
+
Rotatable,
|
|
25
|
+
Spaced,
|
|
26
|
+
Ranged,
|
|
27
|
+
Typed<BlockSymbol>,
|
|
28
|
+
WithEnable,
|
|
29
|
+
WithConfig {}
|
|
30
|
+
|
|
31
|
+
interface BasicTurret extends BasicBuilding, Shooting, WithProgress {}
|
|
32
|
+
|
|
33
|
+
// just to make this future proof
|
|
34
|
+
interface AnyTurret extends BasicTurret {}
|
|
35
|
+
|
|
36
|
+
interface AnyBuilding extends AnyTurret, Heatable {}
|
package/lib/memory.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/// <reference path="./kinds.d.ts" />
|
|
2
|
-
|
|
3
|
-
type MemoryCapacity = 64 | 512;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
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
|
-
}
|
|
1
|
+
/// <reference path="./kinds.d.ts" />
|
|
2
|
+
|
|
3
|
+
type MemoryCapacity = 64 | 512;
|
|
4
|
+
/**
|
|
5
|
+
* Allows you to view and modify the data of memory cells and memory banks.
|
|
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
|
+
}
|
package/lib/traits.d.ts
CHANGED
|
@@ -1,121 +1,141 @@
|
|
|
1
|
-
import "./globals";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
import "./globals";
|
|
2
|
+
|
|
3
|
+
type LogicSymbols = typeof Items & typeof Liquids & typeof LAccess;
|
|
4
|
+
|
|
5
|
+
type WithSymbols<T extends Record<string, unknown>> = T & {
|
|
6
|
+
readonly [K in keyof (LogicSymbols | T) as LogicSymbols[K]]: T[K];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
interface LiquidHolder
|
|
11
|
+
extends WithSymbols<
|
|
12
|
+
{
|
|
13
|
+
readonly [L in keyof typeof Liquids]: number;
|
|
14
|
+
} & {
|
|
15
|
+
readonly totalLiquids: number;
|
|
16
|
+
readonly liquidCapacity: number;
|
|
17
|
+
}
|
|
18
|
+
> {}
|
|
19
|
+
|
|
20
|
+
interface ItemHolder
|
|
21
|
+
extends WithSymbols<
|
|
22
|
+
{
|
|
23
|
+
readonly [I in keyof typeof Items]: number;
|
|
24
|
+
} & {
|
|
25
|
+
readonly totalItems: number;
|
|
26
|
+
readonly firstItem: ItemSymbol | null;
|
|
27
|
+
readonly itemCapacity: number;
|
|
28
|
+
}
|
|
29
|
+
> {}
|
|
30
|
+
|
|
31
|
+
interface PowerHolder
|
|
32
|
+
extends WithSymbols<{
|
|
33
|
+
readonly totalPower: number;
|
|
34
|
+
readonly powerCapacity: number;
|
|
35
|
+
readonly powerNetStored: number;
|
|
36
|
+
readonly powerNetCapacity: number;
|
|
37
|
+
readonly powerNetIn: number;
|
|
38
|
+
readonly powerNetOut: number;
|
|
39
|
+
}> {}
|
|
40
|
+
|
|
41
|
+
interface Shooting
|
|
42
|
+
extends WithSymbols<{
|
|
43
|
+
readonly shootX: number;
|
|
44
|
+
readonly shootY: number;
|
|
45
|
+
readonly ammo: number;
|
|
46
|
+
readonly ammoCapacity: number;
|
|
47
|
+
}> {}
|
|
48
|
+
|
|
49
|
+
interface WithHealth
|
|
50
|
+
extends WithSymbols<{
|
|
51
|
+
readonly health: number;
|
|
52
|
+
readonly maxHealth: number;
|
|
53
|
+
readonly dead: boolean;
|
|
54
|
+
}> {}
|
|
55
|
+
|
|
56
|
+
interface Heatable
|
|
57
|
+
extends WithSymbols<{
|
|
58
|
+
readonly heat: number;
|
|
59
|
+
}> {}
|
|
60
|
+
|
|
61
|
+
interface WithEffiency
|
|
62
|
+
extends WithSymbols<{
|
|
63
|
+
readonly efficiency: number;
|
|
64
|
+
}> {}
|
|
65
|
+
|
|
66
|
+
interface WithProgress
|
|
67
|
+
extends WithSymbols<{
|
|
68
|
+
readonly progress: number;
|
|
69
|
+
}> {}
|
|
70
|
+
|
|
71
|
+
interface WithTimescale
|
|
72
|
+
extends WithSymbols<{
|
|
73
|
+
readonly timescale: number;
|
|
74
|
+
}> {}
|
|
75
|
+
|
|
76
|
+
interface Rotatable
|
|
77
|
+
extends WithSymbols<{
|
|
78
|
+
readonly rotation: number;
|
|
79
|
+
}> {}
|
|
80
|
+
|
|
81
|
+
interface Spaced
|
|
82
|
+
extends WithSymbols<{
|
|
83
|
+
readonly x: number;
|
|
84
|
+
readonly y: number;
|
|
85
|
+
readonly size: number;
|
|
86
|
+
}> {}
|
|
87
|
+
|
|
88
|
+
interface Ranged
|
|
89
|
+
extends WithSymbols<{
|
|
90
|
+
readonly range: number;
|
|
91
|
+
}> {}
|
|
92
|
+
|
|
93
|
+
interface Boosted
|
|
94
|
+
extends WithSymbols<{
|
|
95
|
+
readonly boosting: number;
|
|
96
|
+
}> {}
|
|
97
|
+
|
|
98
|
+
interface Mining
|
|
99
|
+
extends WithSymbols<{
|
|
100
|
+
readonly mineX: number;
|
|
101
|
+
readonly mineY: number;
|
|
102
|
+
readonly mining: number;
|
|
103
|
+
}> {}
|
|
104
|
+
|
|
105
|
+
interface Typed<T extends symbol = symbol>
|
|
106
|
+
extends WithSymbols<{
|
|
107
|
+
readonly type: T;
|
|
108
|
+
}> {}
|
|
109
|
+
interface Flagged
|
|
110
|
+
extends WithSymbols<{
|
|
111
|
+
readonly flag: number;
|
|
112
|
+
}> {}
|
|
113
|
+
|
|
114
|
+
interface Controllable
|
|
115
|
+
extends WithSymbols<{
|
|
116
|
+
readonly controlled: 0 | ControlKind;
|
|
117
|
+
readonly controller: AnyUnit | BasicBuilding;
|
|
118
|
+
}> {}
|
|
119
|
+
|
|
120
|
+
interface Nameable
|
|
121
|
+
extends WithSymbols<{
|
|
122
|
+
readonly name: string | null;
|
|
123
|
+
}> {}
|
|
124
|
+
|
|
125
|
+
interface PayloadHolder
|
|
126
|
+
extends WithSymbols<{
|
|
127
|
+
readonly payloadCount: number;
|
|
128
|
+
readonly payloadType: symbol | null;
|
|
129
|
+
}> {}
|
|
130
|
+
|
|
131
|
+
interface WithEnable
|
|
132
|
+
extends WithSymbols<{
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
}> {}
|
|
135
|
+
|
|
136
|
+
interface WithConfig<
|
|
137
|
+
T extends symbol | number | null = symbol | null
|
|
138
|
+
> extends WithSymbols<{
|
|
139
|
+
readonly config: T;
|
|
140
|
+
}> {}
|
|
141
|
+
}
|
package/lib/util.d.ts
CHANGED
|
@@ -1,32 +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";
|
|
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,48 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mlogjs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Compiler that compiles Javascript to Mindustry Logic Code.",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@types/
|
|
32
|
-
"@types/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "mlogjs",
|
|
3
|
+
"version": "0.3.0-beta.0",
|
|
4
|
+
"description": "Compiler that compiles Javascript to Mindustry Logic Code.",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"bin": "./dist/bin.cjs",
|
|
8
|
+
"types": "./dist/types",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/weisrc/mlogjs.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "str1z",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/weisrc/mlogjs/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/weisrc/mlogjs#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@babel/parser": "^7.17.7",
|
|
22
|
+
"chalk": "^4.1.2",
|
|
23
|
+
"cli-highlight": "^2.1.11",
|
|
24
|
+
"yargs": "^17.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/types": "^7.17.0",
|
|
28
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
29
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
30
|
+
"@rollup/plugin-typescript": "^8.3.1",
|
|
31
|
+
"@types/estree": "^0.0.51",
|
|
32
|
+
"@types/jest": "^27.4.1",
|
|
33
|
+
"@types/node": "^15.3.0",
|
|
34
|
+
"@types/yargs": "^16.0.1",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
36
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
37
|
+
"eslint": "^8.11.0",
|
|
38
|
+
"jest": "^27.5.1",
|
|
39
|
+
"npm-run-all": "^4.1.5",
|
|
40
|
+
"rollup": "^2.70.1",
|
|
41
|
+
"ts-jest": "^27.1.3",
|
|
42
|
+
"ts-node": "^10.6.0",
|
|
43
|
+
"tslib": "^2.3.1",
|
|
44
|
+
"typedoc": "^0.22.12",
|
|
45
|
+
"typescript": "*"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"build",
|
|
49
|
+
"dist",
|
|
50
|
+
"lib",
|
|
51
|
+
"LICENSE",
|
|
52
|
+
"README.md"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"clean": "rm -rf ../docs dist build",
|
|
56
|
+
"build": "rollup -c",
|
|
57
|
+
"build:dev": "rollup -c --environment DEV",
|
|
58
|
+
"dev": "ts-node src/bin",
|
|
59
|
+
"test": "jest",
|
|
60
|
+
"lint": "eslint src/**/*.ts",
|
|
61
|
+
"coverage": "jest --coverage",
|
|
62
|
+
"docs:doc": "mkdir -p ../docs && cp -r doc/. ../docs",
|
|
63
|
+
"docs:lib": "typedoc --out ../docs/lib lib/*",
|
|
64
|
+
"docs:src": "typedoc --out ../docs/src src/index.ts",
|
|
65
|
+
"docs": "run-p docs:lib docs:src docs:doc",
|
|
66
|
+
"start": "npm run build && npm i -g . && mlogjs"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/build/Compiler.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { es, IScope, THandler, TValueInstructions } from "./types";
|
|
2
|
-
declare type THandlerMap = {
|
|
3
|
-
[k in es.Node["type"]]?: THandler;
|
|
4
|
-
};
|
|
5
|
-
export declare class Compiler {
|
|
6
|
-
protected stackName?: string;
|
|
7
|
-
protected usingStack: boolean;
|
|
8
|
-
protected handlers: THandlerMap;
|
|
9
|
-
constructor(stackName?: string);
|
|
10
|
-
compile(script: string): string;
|
|
11
|
-
protected resolve(valueInst: TValueInstructions): void;
|
|
12
|
-
protected serialize(resLines: TValueInstructions): string;
|
|
13
|
-
protected parse(script: string): import("esprima").Program;
|
|
14
|
-
handle(scope: IScope, node: es.Node): TValueInstructions;
|
|
15
|
-
handleEval(scope: IScope, node: es.Node): TValueInstructions;
|
|
16
|
-
handleMany(scope: IScope, nodes: es.Node[], handler?: typeof Compiler.prototype.handle): TValueInstructions;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
package/build/Scope.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AddressResolver } from "./instructions";
|
|
2
|
-
import { IFunctionValue, IInstruction, IScope, IValue } from "./types";
|
|
3
|
-
export declare class Scope implements IScope {
|
|
4
|
-
parent: IScope;
|
|
5
|
-
name: string;
|
|
6
|
-
data: {
|
|
7
|
-
[k: string]: IValue;
|
|
8
|
-
};
|
|
9
|
-
stacked: boolean;
|
|
10
|
-
ntemp: number;
|
|
11
|
-
inst: IInstruction[];
|
|
12
|
-
break: AddressResolver;
|
|
13
|
-
continue: AddressResolver;
|
|
14
|
-
function: IFunctionValue;
|
|
15
|
-
constructor(values: {
|
|
16
|
-
[k: string]: IValue;
|
|
17
|
-
}, parent?: IScope, stacked?: boolean, ntemp?: number, name?: string, inst?: any[]);
|
|
18
|
-
copy(): IScope;
|
|
19
|
-
createScope(): IScope;
|
|
20
|
-
createFunction(name: string, stacked?: boolean): IScope;
|
|
21
|
-
has(name: string): boolean;
|
|
22
|
-
get(name: string): IValue;
|
|
23
|
-
set(name: string, value: IValue): IValue;
|
|
24
|
-
hardSet(name: string, value: IValue): IValue;
|
|
25
|
-
make(name: string, storeName: string): IValue;
|
|
26
|
-
}
|