mlogjs 0.3.0 → 0.4.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/dist/Compiler.d.ts +39 -0
- package/dist/CompilerError.d.ts +33 -0
- package/dist/Scope.d.ts +24 -0
- package/dist/assertions.d.ts +28 -0
- package/dist/bin.cjs +7 -14
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/handlers/BlockStatement.d.ts +2 -0
- package/dist/handlers/CallExpression.d.ts +4 -0
- package/dist/handlers/File.d.ts +2 -0
- package/dist/handlers/ForStatement.d.ts +2 -0
- package/dist/handlers/Function.d.ts +5 -0
- package/dist/handlers/Identifier.d.ts +2 -0
- package/dist/handlers/IfStatement.d.ts +2 -0
- package/dist/handlers/Literal.d.ts +5 -0
- package/dist/handlers/Object.d.ts +6 -0
- package/dist/handlers/OperationExpressions.d.ts +8 -0
- package/dist/handlers/Program.d.ts +2 -0
- package/dist/handlers/Statements.d.ts +5 -0
- package/dist/handlers/SwitchStatement.d.ts +2 -0
- package/dist/handlers/TemplateExpression.d.ts +2 -0
- package/dist/handlers/Typescript.d.ts +7 -0
- package/dist/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/handlers/WhileStatement.d.ts +3 -0
- package/dist/handlers/index.d.ts +17 -0
- package/dist/index.cjs +1037 -315
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1037 -315
- package/dist/index.mjs.map +1 -1
- package/dist/initScope.d.ts +5 -0
- package/dist/instructions/AddressResolver.d.ts +12 -0
- package/dist/instructions/ControlInstructions.d.ts +10 -0
- package/dist/instructions/EndInstruction.d.ts +4 -0
- package/dist/instructions/InstructionBase.d.ts +14 -0
- package/dist/instructions/JumpInstruction.d.ts +16 -0
- package/dist/instructions/OperationInstruction.d.ts +5 -0
- package/dist/instructions/SetCounterInstruction.d.ts +5 -0
- package/dist/instructions/SetInstruction.d.ts +6 -0
- package/dist/instructions/ZeroSpaceInstruction.d.ts +4 -0
- package/dist/instructions/index.d.ts +9 -0
- package/dist/{types/macros/RawValue.d.ts → macros/Asm.d.ts} +1 -1
- package/dist/macros/Function.d.ts +13 -0
- package/dist/macros/GetGlobal.d.ts +5 -0
- package/dist/macros/Math.d.ts +5 -0
- package/dist/macros/Memory.d.ts +5 -0
- package/dist/macros/Namespace.d.ts +13 -0
- package/dist/macros/Other.d.ts +5 -0
- package/dist/macros/commands/ApplyStatus.d.ts +5 -0
- package/dist/macros/commands/Control.d.ts +5 -0
- package/dist/macros/commands/Cutscene.d.ts +5 -0
- package/dist/macros/commands/Draw.d.ts +5 -0
- package/dist/macros/commands/DrawFlush.d.ts +5 -0
- package/dist/macros/commands/End.d.ts +5 -0
- package/dist/macros/commands/Explosion.d.ts +5 -0
- package/dist/macros/commands/Fetch.d.ts +5 -0
- package/dist/macros/commands/FlushMessage.d.ts +5 -0
- package/dist/macros/commands/GetBlock.d.ts +5 -0
- package/dist/macros/commands/GetFlag.d.ts +5 -0
- package/dist/macros/commands/GetLink.d.ts +5 -0
- package/dist/macros/commands/Lookup.d.ts +5 -0
- package/dist/macros/commands/PackColor.d.ts +5 -0
- package/dist/macros/commands/Print.d.ts +5 -0
- package/dist/macros/commands/PrintFlush.d.ts +5 -0
- package/dist/macros/commands/Radar.d.ts +7 -0
- package/dist/macros/commands/Sensor.d.ts +5 -0
- package/dist/macros/commands/SetBlock.d.ts +5 -0
- package/dist/macros/commands/SetFlag.d.ts +5 -0
- package/dist/macros/commands/SetRate.d.ts +5 -0
- package/dist/macros/commands/SetRule.d.ts +5 -0
- package/dist/macros/commands/SpawnUnit.d.ts +5 -0
- package/dist/macros/commands/SpawnWave.d.ts +5 -0
- package/dist/macros/commands/Stop.d.ts +5 -0
- package/dist/macros/commands/UnitBind.d.ts +5 -0
- package/dist/macros/commands/UnitControl.d.ts +5 -0
- package/dist/macros/commands/UnitLocate.d.ts +5 -0
- package/dist/macros/commands/UnitRadar.d.ts +5 -0
- package/dist/macros/commands/Wait.d.ts +5 -0
- package/dist/macros/commands/index.d.ts +30 -0
- package/dist/macros/index.d.ts +6 -0
- package/dist/macros/util.d.ts +18 -0
- package/dist/operators.d.ts +25 -0
- package/dist/types/Compiler.d.ts +17 -4
- package/dist/types/CompilerError.d.ts +28 -4
- package/dist/types/assertions.d.ts +28 -0
- package/dist/types/handlers/CallExpression.d.ts +1 -0
- package/dist/types/handlers/SwitchStatement.d.ts +2 -0
- package/dist/types/handlers/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/instructions/ControlInstructions.d.ts +3 -1
- package/dist/types/instructions/InstructionBase.d.ts +5 -1
- package/dist/types/instructions/JumpInstruction.d.ts +1 -0
- package/dist/types/macros/Asm.d.ts +5 -0
- package/dist/types/macros/Namespace.d.ts +0 -3
- package/dist/types/macros/commands/ApplyStatus.d.ts +5 -0
- package/dist/types/macros/commands/Control.d.ts +2 -2
- package/dist/types/macros/commands/Cutscene.d.ts +5 -0
- package/dist/types/macros/commands/Draw.d.ts +2 -2
- package/dist/types/macros/commands/Explosion.d.ts +5 -0
- package/dist/types/macros/commands/Fetch.d.ts +5 -0
- package/dist/types/macros/commands/FlushMessage.d.ts +5 -0
- package/dist/types/macros/commands/GetBlock.d.ts +5 -0
- package/dist/types/macros/commands/GetFlag.d.ts +5 -0
- package/dist/types/macros/commands/Lookup.d.ts +2 -2
- package/dist/types/macros/commands/PackColor.d.ts +5 -0
- package/dist/types/macros/commands/Radar.d.ts +2 -2
- package/dist/types/macros/commands/SetBlock.d.ts +5 -0
- package/dist/types/macros/commands/SetFlag.d.ts +5 -0
- package/dist/types/macros/commands/SetRate.d.ts +5 -0
- package/dist/types/macros/commands/SetRule.d.ts +5 -0
- package/dist/types/macros/commands/SpawnUnit.d.ts +5 -0
- package/dist/types/macros/commands/SpawnWave.d.ts +5 -0
- package/dist/types/macros/commands/Stop.d.ts +5 -0
- package/dist/types/macros/commands/UnitControl.d.ts +3 -3
- package/dist/types/macros/commands/UnitLocate.d.ts +2 -2
- package/dist/types/macros/commands/index.d.ts +15 -0
- package/dist/types/macros/util.d.ts +18 -0
- package/dist/types/types.d.ts +14 -0
- package/dist/types/utils.d.ts +19 -2
- package/dist/types/values/BaseValue.d.ts +2 -0
- package/dist/types/values/FunctionValue.d.ts +1 -1
- package/dist/types/values/ObjectValue.d.ts +1 -1
- package/dist/types.d.ts +238 -0
- package/dist/utils.d.ts +47 -0
- package/dist/values/BaseValue.d.ts +9 -0
- package/dist/values/DestructuringValue.d.ts +17 -0
- package/dist/values/FunctionValue.d.ts +47 -0
- package/dist/values/LiteralValue.d.ts +13 -0
- package/dist/values/ObjectValue.d.ts +23 -0
- package/dist/values/SenseableValue.d.ts +23 -0
- package/dist/{types/values/StackValue.d.ts → values/StoreValue.d.ts} +5 -6
- package/dist/values/ValueOwner.d.ts +27 -0
- package/dist/values/VoidValue.d.ts +16 -0
- package/dist/values/index.d.ts +7 -0
- package/lib/commands.d.ts +849 -418
- package/lib/eslib/lib.es2015.core.d.ts +3 -0
- package/lib/globals.d.ts +331 -19
- package/lib/helpers.d.ts +14 -0
- package/lib/kinds.d.ts +3 -2
- package/lib/memory.d.ts +1 -1
- package/lib/traits.d.ts +6 -0
- package/lib/util.d.ts +16 -0
- package/package.json +15 -16
- package/build/Compiler.js +0 -105
- package/build/Compiler.js.map +0 -1
- package/build/CompilerError.js +0 -11
- package/build/CompilerError.js.map +0 -1
- package/build/Scope.js +0 -71
- package/build/Scope.js.map +0 -1
- package/build/bin.js +0 -75
- package/build/bin.js.map +0 -1
- package/build/handlers/BlockStatement.js +0 -14
- package/build/handlers/BlockStatement.js.map +0 -1
- package/build/handlers/CallExpression.js +0 -20
- package/build/handlers/CallExpression.js.map +0 -1
- package/build/handlers/File.js +0 -9
- package/build/handlers/File.js.map +0 -1
- package/build/handlers/ForStatement.js +0 -32
- package/build/handlers/ForStatement.js.map +0 -1
- package/build/handlers/Function.js +0 -47
- package/build/handlers/Function.js.map +0 -1
- package/build/handlers/Identifier.js +0 -8
- package/build/handlers/Identifier.js.map +0 -1
- package/build/handlers/IfStatement.js +0 -25
- package/build/handlers/IfStatement.js.map +0 -1
- package/build/handlers/Literal.js +0 -15
- package/build/handlers/Literal.js.map +0 -1
- package/build/handlers/Object.js +0 -55
- package/build/handlers/Object.js.map +0 -1
- package/build/handlers/OperationExpressions.js +0 -38
- package/build/handlers/OperationExpressions.js.map +0 -1
- package/build/handlers/Program.js +0 -9
- package/build/handlers/Program.js.map +0 -1
- package/build/handlers/Statements.js +0 -30
- package/build/handlers/Statements.js.map +0 -1
- package/build/handlers/TemplateExpression.js +0 -18
- package/build/handlers/TemplateExpression.js.map +0 -1
- package/build/handlers/VariableDeclaration.js +0 -72
- package/build/handlers/VariableDeclaration.js.map +0 -1
- package/build/handlers/WhileStatement.js +0 -23
- package/build/handlers/WhileStatement.js.map +0 -1
- package/build/handlers/index.js +0 -32
- package/build/handlers/index.js.map +0 -1
- package/build/index.js +0 -8
- package/build/index.js.map +0 -1
- package/build/initScope.js +0 -40
- package/build/initScope.js.map +0 -1
- package/build/instructions/AddressResolver.js +0 -31
- package/build/instructions/AddressResolver.js.map +0 -1
- package/build/instructions/ControlInstructions.js +0 -23
- package/build/instructions/ControlInstructions.js.map +0 -1
- package/build/instructions/EndInstruction.js +0 -11
- package/build/instructions/EndInstruction.js.map +0 -1
- package/build/instructions/InstructionBase.js +0 -21
- package/build/instructions/InstructionBase.js.map +0 -1
- package/build/instructions/JumpInstruction.js +0 -22
- package/build/instructions/JumpInstruction.js.map +0 -1
- package/build/instructions/OperationInstruction.js +0 -11
- package/build/instructions/OperationInstruction.js.map +0 -1
- package/build/instructions/SetCounterInstruction.js +0 -11
- package/build/instructions/SetCounterInstruction.js.map +0 -1
- package/build/instructions/SetInstruction.js +0 -11
- package/build/instructions/SetInstruction.js.map +0 -1
- package/build/instructions/ZeroSpaceInstruction.js +0 -11
- package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
- package/build/instructions/index.js +0 -26
- package/build/instructions/index.js.map +0 -1
- package/build/macros/Building.js +0 -89
- package/build/macros/Building.js.map +0 -1
- package/build/macros/Function.js +0 -20
- package/build/macros/Function.js.map +0 -1
- package/build/macros/Math.js +0 -62
- package/build/macros/Math.js.map +0 -1
- package/build/macros/Memory.js +0 -63
- package/build/macros/Memory.js.map +0 -1
- package/build/macros/Namespace.js +0 -111
- package/build/macros/Namespace.js.map +0 -1
- package/build/macros/Other.js +0 -21
- package/build/macros/Other.js.map +0 -1
- package/build/macros/RawValue.js +0 -17
- package/build/macros/RawValue.js.map +0 -1
- package/build/macros/commands/Control.js +0 -26
- package/build/macros/commands/Control.js.map +0 -1
- package/build/macros/commands/Draw.js +0 -40
- package/build/macros/commands/Draw.js.map +0 -1
- package/build/macros/commands/DrawFlush.js +0 -18
- package/build/macros/commands/DrawFlush.js.map +0 -1
- package/build/macros/commands/GetLink.js +0 -25
- package/build/macros/commands/GetLink.js.map +0 -1
- package/build/macros/commands/Lookup.js +0 -25
- package/build/macros/commands/Lookup.js.map +0 -1
- package/build/macros/commands/Print.js +0 -18
- package/build/macros/commands/Print.js.map +0 -1
- package/build/macros/commands/PrintFlush.js +0 -18
- package/build/macros/commands/PrintFlush.js.map +0 -1
- package/build/macros/commands/Radar.js +0 -65
- package/build/macros/commands/Radar.js.map +0 -1
- package/build/macros/commands/Sensor.js +0 -21
- package/build/macros/commands/Sensor.js.map +0 -1
- package/build/macros/commands/UnitBind.js +0 -18
- package/build/macros/commands/UnitBind.js.map +0 -1
- package/build/macros/commands/UnitControl.js +0 -73
- package/build/macros/commands/UnitControl.js.map +0 -1
- package/build/macros/commands/UnitLocate.js +0 -76
- package/build/macros/commands/UnitLocate.js.map +0 -1
- package/build/macros/commands/UnitRadar.js +0 -48
- package/build/macros/commands/UnitRadar.js.map +0 -1
- package/build/macros/commands/Wait.js +0 -19
- package/build/macros/commands/Wait.js.map +0 -1
- package/build/macros/commands/index.js +0 -33
- package/build/macros/commands/index.js.map +0 -1
- package/build/macros/index.js +0 -40
- package/build/macros/index.js.map +0 -1
- package/build/operators.js +0 -102
- package/build/operators.js.map +0 -1
- package/build/types.js +0 -28
- package/build/types.js.map +0 -1
- package/build/utils.js +0 -18
- package/build/utils.js.map +0 -1
- package/build/values/BaseValue.js +0 -112
- package/build/values/BaseValue.js.map +0 -1
- package/build/values/FunctionValue.js +0 -116
- package/build/values/FunctionValue.js.map +0 -1
- package/build/values/LiteralValue.js +0 -89
- package/build/values/LiteralValue.js.map +0 -1
- package/build/values/ObjectValue.js +0 -55
- package/build/values/ObjectValue.js.map +0 -1
- package/build/values/StoreValue.js +0 -32
- package/build/values/StoreValue.js.map +0 -1
- package/build/values/TempValue.js +0 -78
- package/build/values/TempValue.js.map +0 -1
- package/build/values/VoidValue.js +0 -32
- package/build/values/VoidValue.js.map +0 -1
- package/build/values/index.js +0 -23
- package/build/values/index.js.map +0 -1
- package/dist/types/macros/Building.d.ts +0 -10
- package/dist/types/macros/Entities.d.ts +0 -11
- package/dist/types/values/TempValue.d.ts +0 -19
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IScope } from "../types";
|
|
2
|
+
import { ObjectValue } from "../values";
|
|
3
|
+
interface NamespaceMacroOptions {
|
|
4
|
+
changeCasing?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class NamespaceMacro extends ObjectValue {
|
|
7
|
+
changeCasing: boolean;
|
|
8
|
+
constructor(scope: IScope, { changeCasing }?: NamespaceMacroOptions);
|
|
9
|
+
}
|
|
10
|
+
export declare class VarsNamespace extends NamespaceMacro {
|
|
11
|
+
constructor(scope: IScope);
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MacroFunction } from "..";
|
|
2
|
+
import { IScope } from "../../types";
|
|
3
|
+
export declare const validRadarFilters: readonly ["any", "enemy", "ally", "player", "attacker", "flying", "boss", "ground"];
|
|
4
|
+
export declare const validRadarSorts: readonly ["distance", "health", "shield", "armor", "maxHealth"];
|
|
5
|
+
export declare class Radar extends MacroFunction {
|
|
6
|
+
constructor(scope: IScope);
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from "./Draw";
|
|
2
|
+
export * from "./Print";
|
|
3
|
+
export * from "./PrintFlush";
|
|
4
|
+
export * from "./DrawFlush";
|
|
5
|
+
export * from "./GetBlock";
|
|
6
|
+
export * from "./GetLink";
|
|
7
|
+
export * from "./Control";
|
|
8
|
+
export { Radar } from "./Radar";
|
|
9
|
+
export * from "./Sensor";
|
|
10
|
+
export * from "./Wait";
|
|
11
|
+
export * from "./Lookup";
|
|
12
|
+
export * from "./PackColor";
|
|
13
|
+
export * from "./End";
|
|
14
|
+
export * from "./SetBlock";
|
|
15
|
+
export * from "./SpawnUnit";
|
|
16
|
+
export * from "./Stop";
|
|
17
|
+
export * from "./UnitBind";
|
|
18
|
+
export * from "./UnitControl";
|
|
19
|
+
export * from "./UnitRadar";
|
|
20
|
+
export * from "./UnitLocate";
|
|
21
|
+
export * from "./ApplyStatus";
|
|
22
|
+
export * from "./SpawnWave";
|
|
23
|
+
export * from "./SetRule";
|
|
24
|
+
export * from "./FlushMessage";
|
|
25
|
+
export * from "./Cutscene";
|
|
26
|
+
export * from "./Explosion";
|
|
27
|
+
export * from "./SetRate";
|
|
28
|
+
export * from "./Fetch";
|
|
29
|
+
export * from "./GetFlag";
|
|
30
|
+
export * from "./SetFlag";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IParameterDescriptor } from "../assertions";
|
|
2
|
+
import { IScope, IValue, TValueInstructions } from "../types";
|
|
3
|
+
import { MacroFunction } from "./Function";
|
|
4
|
+
interface IOverloadNamespaceOptions<K extends string> {
|
|
5
|
+
scope: IScope;
|
|
6
|
+
overloads: Record<K, {
|
|
7
|
+
/**
|
|
8
|
+
* Pass the name of the options argument to tell if this overload uses
|
|
9
|
+
* named parameters.
|
|
10
|
+
*/
|
|
11
|
+
named?: string;
|
|
12
|
+
args: (IParameterDescriptor | string)[];
|
|
13
|
+
}>;
|
|
14
|
+
handler(overload: K, ...args: (IValue | string)[]): TValueInstructions<IValue | null>;
|
|
15
|
+
}
|
|
16
|
+
/** Used to create namespaces that contain multiple methods that map into instructions */
|
|
17
|
+
export declare function createOverloadNamespace<K extends string>({ scope, overloads, handler, }: IOverloadNamespaceOptions<K>): Record<string, MacroFunction<IValue | null>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const arithmeticBinaryOperators: readonly ["*", "**", "+", "-", "/", "%"];
|
|
2
|
+
export declare const comparisonBinaryOperators: readonly ["!=", "!==", "<", "<=", "==", "===", ">", ">="];
|
|
3
|
+
export declare const bitwiseBinaryOperators: readonly ["&", "<<", ">>", ">>>", "^", "|"];
|
|
4
|
+
export declare const binaryOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in"];
|
|
5
|
+
export declare type BinaryOperator = typeof binaryOperators[number];
|
|
6
|
+
export declare const logicalOperators: readonly ["&&", "??", "||"];
|
|
7
|
+
export declare type LogicalOperator = typeof logicalOperators[number];
|
|
8
|
+
export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
|
|
9
|
+
export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
|
|
10
|
+
export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
|
|
11
|
+
export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
12
|
+
export declare type AssignementOperator = typeof assignmentOperators[number];
|
|
13
|
+
export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
14
|
+
export declare type LeftRightOperator = typeof leftRightOperators[number];
|
|
15
|
+
export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
|
|
16
|
+
export declare type UnaryOperator = typeof unaryOperators[number];
|
|
17
|
+
export declare const updateOperators: readonly ["++", "--"];
|
|
18
|
+
export declare type UpdateOperator = typeof updateOperators[number];
|
|
19
|
+
export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
20
|
+
export declare type SingleOperator = typeof singleOperators[number];
|
|
21
|
+
export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
22
|
+
export declare type Operator = typeof operators[number];
|
|
23
|
+
export declare const operatorMap: {
|
|
24
|
+
[k in Exclude<BinaryOperator, "instanceof" | "in"> | Exclude<LogicalOperator, "??">]: string;
|
|
25
|
+
};
|
package/dist/types/Compiler.d.ts
CHANGED
|
@@ -7,20 +7,33 @@ export interface CompilerOptions {
|
|
|
7
7
|
stackName?: string;
|
|
8
8
|
/** Wether the compiler should preserve or compact variable and function names*/
|
|
9
9
|
compactNames?: boolean;
|
|
10
|
+
sourcemap?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare class Compiler {
|
|
12
13
|
protected stackName?: string;
|
|
13
14
|
protected usingStack: boolean;
|
|
14
15
|
protected handlers: THandlerMap;
|
|
15
16
|
readonly compactNames: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
readonly sourcemap: boolean;
|
|
18
|
+
constructor({ stackName, compactNames, sourcemap, }?: CompilerOptions);
|
|
19
|
+
compile(script: string): [string, null, es.SourceLocation[] | undefined] | [null, CompilerError];
|
|
18
20
|
protected resolve(valueInst: TValueInstructions<IValue | null>): void;
|
|
19
21
|
protected serialize(resLines: TValueInstructions<IValue | null>): string;
|
|
20
22
|
protected parse(script: string): import("@babel/parser").ParseResult<es.File>;
|
|
21
|
-
|
|
23
|
+
protected mapSources(valueInst: TValueInstructions<IValue | null>): es.SourceLocation[];
|
|
24
|
+
handle(scope: IScope, node: es.Node, handler?: THandler<IValue | null> | undefined): TValueInstructions<IValue | null>;
|
|
22
25
|
handleEval(scope: IScope, node: es.Node): TValueInstructions;
|
|
23
26
|
handleConsume(scope: IScope, node: es.Node): TValueInstructions;
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Handles many nodes in order.
|
|
29
|
+
*
|
|
30
|
+
* The usage of this method over a regular loop over an array of nodes
|
|
31
|
+
* is only required if the code inside the loop generates
|
|
32
|
+
* instructions that are not tracked by the compiler
|
|
33
|
+
* handler methods ({@link handle}, {@link handleEval}, {@link handleConsume}
|
|
34
|
+
* and {@link handleMany})
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
handleMany<T extends es.Node>(scope: IScope, nodes: T[], handler?: (node: T) => TValueInstructions<IValue | null>): TValueInstructions<null>;
|
|
25
38
|
}
|
|
26
39
|
export {};
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { es } from "./types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown by the babel parser.
|
|
4
|
+
*
|
|
5
|
+
* It doesn't export the type so we are writing it ourselves
|
|
6
|
+
*/
|
|
7
|
+
export interface ParsingError extends Error {
|
|
8
|
+
code: string;
|
|
9
|
+
reasonCode: string;
|
|
10
|
+
loc: {
|
|
5
11
|
line: number;
|
|
6
12
|
column: number;
|
|
7
13
|
};
|
|
8
|
-
constructor(message: string, nodeStack?: es.Node[]);
|
|
9
14
|
}
|
|
15
|
+
declare type CompilerErrorSource = es.Node | es.SourceLocation | {
|
|
16
|
+
line: number;
|
|
17
|
+
column: number;
|
|
18
|
+
};
|
|
19
|
+
export declare class CompilerError extends Error {
|
|
20
|
+
protected _loc?: es.SourceLocation;
|
|
21
|
+
/**
|
|
22
|
+
* The error that preceded this `CompilerError`.
|
|
23
|
+
*
|
|
24
|
+
* If it's not `undefined` it means that `this` is just wrapping the error to
|
|
25
|
+
* append extra data like the node stack
|
|
26
|
+
* */
|
|
27
|
+
inner?: unknown;
|
|
28
|
+
constructor(message: string, source?: CompilerErrorSource);
|
|
29
|
+
get loc(): es.SourceLocation | undefined;
|
|
30
|
+
set loc(value: CompilerErrorSource | undefined);
|
|
31
|
+
static from(error: unknown, source?: CompilerErrorSource): CompilerError;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IValue } from "./types";
|
|
2
|
+
import { LiteralValue, ObjectValue, StoreValue } from "./values";
|
|
3
|
+
/** Asserts that `value` is a `LiteralValue` that contains a string */
|
|
4
|
+
export declare function assertStringLiteral(value: IValue | undefined, name: string): asserts value is LiteralValue & {
|
|
5
|
+
data: string;
|
|
6
|
+
};
|
|
7
|
+
/** Asserts that `value` is a string literal that is part of a given set of `members`*/
|
|
8
|
+
export declare function assertLiteralOneOf<T extends readonly string[]>(value: IValue | undefined, members: T, name: string): asserts value is LiteralValue & {
|
|
9
|
+
data: T[number];
|
|
10
|
+
};
|
|
11
|
+
/** Asserts that `value` is either a store or a literal */
|
|
12
|
+
export declare function assertIsRuntimeValue(value: IValue | undefined, name: string): asserts value is LiteralValue | StoreValue;
|
|
13
|
+
/** Asserts that `value` is an `ObjectValue` */
|
|
14
|
+
export declare function assertIsObjectMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
|
|
15
|
+
/** Asserts that `value` is an `ObjectValue` that has a length property */
|
|
16
|
+
export declare function assertIsArrayMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
|
|
17
|
+
/** Helper type used to describe the overloads of a macro function. See {@link assertObjectFields} */
|
|
18
|
+
export declare type TOverloadDescriptor<K extends string> = Record<K, (string | IParameterDescriptor)[]>;
|
|
19
|
+
/** Describes an object destructuring paremeter. Generally used with `assertObjectFields` */
|
|
20
|
+
export interface IParameterDescriptor {
|
|
21
|
+
key: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
default?: string;
|
|
24
|
+
/** Throw an error on invalid values */
|
|
25
|
+
validate?(value: IValue): void;
|
|
26
|
+
}
|
|
27
|
+
/** Asserts that all of the fields described are present on `value`*/
|
|
28
|
+
export declare function assertObjectFields(value: ObjectValue, fields: (string | IParameterDescriptor)[]): (IValue | string)[];
|
|
@@ -5,6 +5,7 @@ export * from "./OperationExpressions";
|
|
|
5
5
|
export * from "./Identifier";
|
|
6
6
|
export * from "./Statements";
|
|
7
7
|
export * from "./IfStatement";
|
|
8
|
+
export * from "./SwitchStatement";
|
|
8
9
|
export * from "./WhileStatement";
|
|
9
10
|
export * from "./ForStatement";
|
|
10
11
|
export * from "./Function";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { IBindableValue } from "../types";
|
|
1
|
+
import { EInstIntent, IBindableValue } from "../types";
|
|
2
2
|
import { JumpInstruction } from "./JumpInstruction";
|
|
3
3
|
export declare class BreakInstruction extends JumpInstruction {
|
|
4
|
+
intent: EInstIntent;
|
|
4
5
|
constructor(address: IBindableValue);
|
|
5
6
|
}
|
|
6
7
|
export declare class ContinueInstruction extends JumpInstruction {
|
|
8
|
+
intent: EInstIntent;
|
|
7
9
|
constructor(address: IBindableValue);
|
|
8
10
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SourceLocation } from "@babel/types";
|
|
2
|
+
import { EInstIntent, IInstruction, IValue } from "../types";
|
|
2
3
|
export declare class InstructionBase implements IInstruction {
|
|
4
|
+
intent: EInstIntent;
|
|
5
|
+
alwaysRuns: boolean;
|
|
3
6
|
protected _hidden: boolean;
|
|
4
7
|
get hidden(): boolean;
|
|
5
8
|
set hidden(value: boolean);
|
|
6
9
|
args: (string | IValue | null)[];
|
|
10
|
+
source?: SourceLocation;
|
|
7
11
|
constructor(...args: (string | IValue | null)[]);
|
|
8
12
|
resolve(_i: number): void;
|
|
9
13
|
toString(): string;
|
|
@@ -10,7 +10,4 @@ export declare class NamespaceMacro extends ObjectValue {
|
|
|
10
10
|
export declare class VarsNamespace extends NamespaceMacro {
|
|
11
11
|
constructor(scope: IScope);
|
|
12
12
|
}
|
|
13
|
-
export declare class UCommandsNamespace extends NamespaceMacro {
|
|
14
|
-
constructor(scope: IScope);
|
|
15
|
-
}
|
|
16
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MacroFunction } from "..";
|
|
2
1
|
import { IScope } from "../../types";
|
|
3
|
-
|
|
2
|
+
import { ObjectValue } from "../../values";
|
|
3
|
+
export declare class Control extends ObjectValue {
|
|
4
4
|
constructor(scope: IScope);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IScope } from "../../types";
|
|
2
|
-
import {
|
|
3
|
-
export declare class Draw extends
|
|
2
|
+
import { ObjectValue } from "../../values";
|
|
3
|
+
export declare class Draw extends ObjectValue {
|
|
4
4
|
constructor(scope: IScope);
|
|
5
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MacroFunction } from "..";
|
|
2
2
|
import { IScope } from "../../types";
|
|
3
|
-
export declare const validRadarFilters:
|
|
4
|
-
export declare const validRadarSorts:
|
|
3
|
+
export declare const validRadarFilters: readonly ["any", "enemy", "ally", "player", "attacker", "flying", "boss", "ground"];
|
|
4
|
+
export declare const validRadarSorts: readonly ["distance", "health", "shield", "armor", "maxHealth"];
|
|
5
5
|
export declare class Radar extends MacroFunction {
|
|
6
6
|
constructor(scope: IScope);
|
|
7
7
|
}
|