mlogjs 0.4.0 → 0.4.2
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/Scope.d.ts +1 -0
- package/dist/handlers/Statements.d.ts +1 -0
- package/dist/index.cjs +500 -350
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +500 -350
- package/dist/index.mjs.map +1 -1
- package/dist/instructions/SetInstruction.d.ts +2 -0
- package/dist/macros/Asm.d.ts +1 -2
- package/dist/macros/Function.d.ts +4 -4
- package/dist/macros/GetGlobal.d.ts +2 -2
- package/dist/macros/Memory.d.ts +1 -2
- package/dist/macros/Namespace.d.ts +1 -1
- package/dist/macros/Other.d.ts +1 -2
- package/dist/macros/commands/ApplyStatus.d.ts +1 -2
- package/dist/macros/commands/Control.d.ts +1 -2
- package/dist/macros/commands/Cutscene.d.ts +1 -2
- package/dist/macros/commands/Draw.d.ts +1 -2
- package/dist/macros/commands/DrawFlush.d.ts +1 -2
- package/dist/macros/commands/End.d.ts +1 -2
- package/dist/macros/commands/Explosion.d.ts +1 -2
- package/dist/macros/commands/Fetch.d.ts +1 -2
- package/dist/macros/commands/FlushMessage.d.ts +1 -2
- package/dist/macros/commands/GetBlock.d.ts +1 -2
- package/dist/macros/commands/GetFlag.d.ts +1 -2
- package/dist/macros/commands/GetLink.d.ts +1 -2
- package/dist/macros/commands/Lookup.d.ts +1 -2
- package/dist/macros/commands/PackColor.d.ts +1 -2
- package/dist/macros/commands/Print.d.ts +1 -2
- package/dist/macros/commands/PrintFlush.d.ts +1 -2
- package/dist/macros/commands/Radar.d.ts +1 -2
- package/dist/macros/commands/Sensor.d.ts +1 -2
- package/dist/macros/commands/SetBlock.d.ts +1 -2
- package/dist/macros/commands/SetFlag.d.ts +1 -2
- package/dist/macros/commands/SetRate.d.ts +1 -2
- package/dist/macros/commands/SetRule.d.ts +1 -2
- package/dist/macros/commands/SpawnUnit.d.ts +1 -2
- package/dist/macros/commands/SpawnWave.d.ts +1 -2
- package/dist/macros/commands/Stop.d.ts +1 -2
- package/dist/macros/commands/UnitBind.d.ts +1 -2
- package/dist/macros/commands/UnitControl.d.ts +1 -2
- package/dist/macros/commands/UnitLocate.d.ts +1 -2
- package/dist/macros/commands/UnitRadar.d.ts +1 -2
- package/dist/macros/commands/Wait.d.ts +1 -2
- package/dist/macros/util.d.ts +2 -3
- package/dist/operators.d.ts +4 -4
- package/dist/types.d.ts +3 -1
- package/dist/values/BaseValue.d.ts +2 -2
- package/dist/values/DestructuringValue.d.ts +1 -1
- package/dist/values/FunctionValue.d.ts +3 -4
- package/dist/values/LiteralValue.d.ts +3 -2
- package/dist/values/ObjectValue.d.ts +3 -3
- package/dist/values/StoreValue.d.ts +4 -2
- package/dist/values/VoidValue.d.ts +0 -2
- package/lib/commands.d.ts +306 -40
- package/lib/eslib/lib.es5.d.ts +23 -0
- package/lib/globals.d.ts +2 -3
- package/lib/helpers.d.ts +2 -1
- package/lib/kinds.d.ts +5 -2
- package/lib/traits.d.ts +10 -6
- package/package.json +2 -7
- package/dist/types/Compiler.d.ts +0 -39
- package/dist/types/CompilerError.d.ts +0 -33
- package/dist/types/Scope.d.ts +0 -24
- package/dist/types/assertions.d.ts +0 -28
- package/dist/types/bin.d.ts +0 -1
- package/dist/types/handlers/BlockStatement.d.ts +0 -2
- package/dist/types/handlers/CallExpression.d.ts +0 -4
- package/dist/types/handlers/File.d.ts +0 -2
- package/dist/types/handlers/ForStatement.d.ts +0 -2
- package/dist/types/handlers/Function.d.ts +0 -5
- package/dist/types/handlers/Identifier.d.ts +0 -2
- package/dist/types/handlers/IfStatement.d.ts +0 -2
- package/dist/types/handlers/Literal.d.ts +0 -5
- package/dist/types/handlers/Object.d.ts +0 -6
- package/dist/types/handlers/OperationExpressions.d.ts +0 -8
- package/dist/types/handlers/Program.d.ts +0 -2
- package/dist/types/handlers/Statements.d.ts +0 -5
- package/dist/types/handlers/SwitchStatement.d.ts +0 -2
- package/dist/types/handlers/TemplateExpression.d.ts +0 -2
- package/dist/types/handlers/Typescript.d.ts +0 -7
- package/dist/types/handlers/VariableDeclaration.d.ts +0 -3
- package/dist/types/handlers/WhileStatement.d.ts +0 -3
- package/dist/types/handlers/index.d.ts +0 -17
- package/dist/types/index.d.ts +0 -3
- package/dist/types/initScope.d.ts +0 -5
- package/dist/types/instructions/AddressResolver.d.ts +0 -12
- package/dist/types/instructions/ControlInstructions.d.ts +0 -10
- package/dist/types/instructions/EndInstruction.d.ts +0 -4
- package/dist/types/instructions/InstructionBase.d.ts +0 -14
- package/dist/types/instructions/JumpInstruction.d.ts +0 -16
- package/dist/types/instructions/OperationInstruction.d.ts +0 -5
- package/dist/types/instructions/SetCounterInstruction.d.ts +0 -5
- package/dist/types/instructions/SetInstruction.d.ts +0 -6
- package/dist/types/instructions/ZeroSpaceInstruction.d.ts +0 -4
- package/dist/types/instructions/index.d.ts +0 -9
- package/dist/types/macros/Asm.d.ts +0 -5
- package/dist/types/macros/Function.d.ts +0 -13
- package/dist/types/macros/GetGlobal.d.ts +0 -5
- package/dist/types/macros/Math.d.ts +0 -5
- package/dist/types/macros/Memory.d.ts +0 -5
- package/dist/types/macros/Namespace.d.ts +0 -13
- package/dist/types/macros/Other.d.ts +0 -5
- package/dist/types/macros/commands/ApplyStatus.d.ts +0 -5
- package/dist/types/macros/commands/Control.d.ts +0 -5
- package/dist/types/macros/commands/Cutscene.d.ts +0 -5
- package/dist/types/macros/commands/Draw.d.ts +0 -5
- package/dist/types/macros/commands/DrawFlush.d.ts +0 -5
- package/dist/types/macros/commands/End.d.ts +0 -5
- package/dist/types/macros/commands/Explosion.d.ts +0 -5
- package/dist/types/macros/commands/Fetch.d.ts +0 -5
- package/dist/types/macros/commands/FlushMessage.d.ts +0 -5
- package/dist/types/macros/commands/GetBlock.d.ts +0 -5
- package/dist/types/macros/commands/GetFlag.d.ts +0 -5
- package/dist/types/macros/commands/GetLink.d.ts +0 -5
- package/dist/types/macros/commands/Lookup.d.ts +0 -5
- package/dist/types/macros/commands/PackColor.d.ts +0 -5
- package/dist/types/macros/commands/Print.d.ts +0 -5
- package/dist/types/macros/commands/PrintFlush.d.ts +0 -5
- package/dist/types/macros/commands/Radar.d.ts +0 -7
- package/dist/types/macros/commands/Sensor.d.ts +0 -5
- package/dist/types/macros/commands/SetBlock.d.ts +0 -5
- package/dist/types/macros/commands/SetFlag.d.ts +0 -5
- package/dist/types/macros/commands/SetRate.d.ts +0 -5
- package/dist/types/macros/commands/SetRule.d.ts +0 -5
- package/dist/types/macros/commands/SpawnUnit.d.ts +0 -5
- package/dist/types/macros/commands/SpawnWave.d.ts +0 -5
- package/dist/types/macros/commands/Stop.d.ts +0 -5
- package/dist/types/macros/commands/UnitBind.d.ts +0 -5
- package/dist/types/macros/commands/UnitControl.d.ts +0 -5
- package/dist/types/macros/commands/UnitLocate.d.ts +0 -5
- package/dist/types/macros/commands/UnitRadar.d.ts +0 -5
- package/dist/types/macros/commands/Wait.d.ts +0 -5
- package/dist/types/macros/commands/index.d.ts +0 -30
- package/dist/types/macros/index.d.ts +0 -6
- package/dist/types/macros/util.d.ts +0 -18
- package/dist/types/operators.d.ts +0 -25
- package/dist/types/types.d.ts +0 -238
- package/dist/types/utils.d.ts +0 -47
- package/dist/types/values/BaseValue.d.ts +0 -9
- package/dist/types/values/DestructuringValue.d.ts +0 -17
- package/dist/types/values/FunctionValue.d.ts +0 -47
- package/dist/types/values/LiteralValue.d.ts +0 -13
- package/dist/types/values/ObjectValue.d.ts +0 -23
- package/dist/types/values/SenseableValue.d.ts +0 -23
- package/dist/types/values/StoreValue.d.ts +0 -15
- package/dist/types/values/ValueOwner.d.ts +0 -27
- package/dist/types/values/VoidValue.d.ts +0 -16
- package/dist/types/values/index.d.ts +0 -7
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MacroFunction } from "..";
|
|
2
|
-
import { IScope } from "../../types";
|
|
3
2
|
export declare const validRadarFilters: readonly ["any", "enemy", "ally", "player", "attacker", "flying", "boss", "ground"];
|
|
4
3
|
export declare const validRadarSorts: readonly ["distance", "health", "shield", "armor", "maxHealth"];
|
|
5
4
|
export declare class Radar extends MacroFunction {
|
|
6
|
-
constructor(
|
|
5
|
+
constructor();
|
|
7
6
|
}
|
package/dist/macros/util.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { IParameterDescriptor } from "../assertions";
|
|
|
2
2
|
import { IScope, IValue, TValueInstructions } from "../types";
|
|
3
3
|
import { MacroFunction } from "./Function";
|
|
4
4
|
interface IOverloadNamespaceOptions<K extends string> {
|
|
5
|
-
scope: IScope;
|
|
6
5
|
overloads: Record<K, {
|
|
7
6
|
/**
|
|
8
7
|
* Pass the name of the options argument to tell if this overload uses
|
|
@@ -11,8 +10,8 @@ interface IOverloadNamespaceOptions<K extends string> {
|
|
|
11
10
|
named?: string;
|
|
12
11
|
args: (IParameterDescriptor | string)[];
|
|
13
12
|
}>;
|
|
14
|
-
handler(overload: K, ...args: (IValue | string)[]): TValueInstructions<IValue | null>;
|
|
13
|
+
handler(scope: IScope, overload: K, ...args: (IValue | string)[]): TValueInstructions<IValue | null>;
|
|
15
14
|
}
|
|
16
15
|
/** Used to create namespaces that contain multiple methods that map into instructions */
|
|
17
|
-
export declare function createOverloadNamespace<K extends string>({
|
|
16
|
+
export declare function createOverloadNamespace<K extends string>({ overloads, handler, }: IOverloadNamespaceOptions<K>): Record<string, MacroFunction<IValue | null>>;
|
|
18
17
|
export {};
|
package/dist/operators.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export declare type BinaryOperator = typeof binaryOperators[number];
|
|
|
6
6
|
export declare const logicalOperators: readonly ["&&", "??", "||"];
|
|
7
7
|
export declare type LogicalOperator = typeof logicalOperators[number];
|
|
8
8
|
export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
|
|
9
|
-
export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
|
|
9
|
+
export declare const logicalAssignmentOperators: readonly ["&&=", "||=", "??="];
|
|
10
10
|
export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
|
|
11
|
-
export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
11
|
+
export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "??=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
12
12
|
export declare type AssignementOperator = typeof assignmentOperators[number];
|
|
13
|
-
export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
13
|
+
export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "??=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
|
|
14
14
|
export declare type LeftRightOperator = typeof leftRightOperators[number];
|
|
15
15
|
export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
|
|
16
16
|
export declare type UnaryOperator = typeof unaryOperators[number];
|
|
@@ -18,7 +18,7 @@ export declare const updateOperators: readonly ["++", "--"];
|
|
|
18
18
|
export declare type UpdateOperator = typeof updateOperators[number];
|
|
19
19
|
export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
20
20
|
export declare type SingleOperator = typeof singleOperators[number];
|
|
21
|
-
export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
21
|
+
export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "??=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
22
22
|
export declare type Operator = typeof operators[number];
|
|
23
23
|
export declare const operatorMap: {
|
|
24
24
|
[k in Exclude<BinaryOperator, "instanceof" | "in"> | Exclude<LogicalOperator, "??">]: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface IScope {
|
|
|
38
38
|
* the instructions that make the body of a function
|
|
39
39
|
*/
|
|
40
40
|
inst: IInstruction[];
|
|
41
|
+
/** The label applied to this scope */
|
|
42
|
+
label?: string;
|
|
41
43
|
/** Where to jump to on a break statement */
|
|
42
44
|
break: AddressResolver;
|
|
43
45
|
/** Where to jump to on a continue statement */
|
|
@@ -174,6 +176,7 @@ export interface IValueOperators {
|
|
|
174
176
|
"/="(scope: IScope, value: IValue): TValueInstructions;
|
|
175
177
|
"&&="(scope: IScope, value: IValue): TValueInstructions;
|
|
176
178
|
"||="(scope: IScope, value: IValue): TValueInstructions;
|
|
179
|
+
"??="(scope: IScope, value: IValue): TValueInstructions;
|
|
177
180
|
"<<="(scope: IScope, value: IValue): TValueInstructions;
|
|
178
181
|
">>="(scope: IScope, value: IValue): TValueInstructions;
|
|
179
182
|
">>>="(scope: IScope, value: IValue): TValueInstructions;
|
|
@@ -198,7 +201,6 @@ export declare enum EMutability {
|
|
|
198
201
|
}
|
|
199
202
|
export interface IValue extends IValueOperators {
|
|
200
203
|
owner: IValueOwner | null;
|
|
201
|
-
scope: IScope;
|
|
202
204
|
mutability: EMutability;
|
|
203
205
|
macro: boolean;
|
|
204
206
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IScope, IValue, TValueInstructions } from "../types";
|
|
2
2
|
import { VoidValue } from ".";
|
|
3
3
|
export declare class BaseValue extends VoidValue implements IValue {
|
|
4
4
|
"u-"(scope: IScope): TValueInstructions;
|
|
5
5
|
"u+"(scope: IScope): TValueInstructions;
|
|
6
6
|
"!"(scope: IScope): TValueInstructions;
|
|
7
7
|
"~"(scope: IScope): TValueInstructions;
|
|
8
|
-
|
|
8
|
+
"??"(scope: IScope, other: IValue): TValueInstructions;
|
|
9
9
|
}
|
|
@@ -10,7 +10,7 @@ import { VoidValue } from "./VoidValue";
|
|
|
10
10
|
export declare class DestructuringValue extends VoidValue {
|
|
11
11
|
members: Map<IValue, IValue>;
|
|
12
12
|
macro: boolean;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(members: Map<IValue, IValue>);
|
|
14
14
|
"="(scope: IScope, right: IValue): TValueInstructions;
|
|
15
15
|
eval(_scope: IScope): TValueInstructions<IValue>;
|
|
16
16
|
consume(_scope: IScope): TValueInstructions<IValue>;
|
|
@@ -9,7 +9,7 @@ export declare type TFunctionValueInitParams = (childScope: IScope) => {
|
|
|
9
9
|
export declare class FunctionValue extends VoidValue implements IFunctionValue {
|
|
10
10
|
mutability: EMutability;
|
|
11
11
|
macro: boolean;
|
|
12
|
-
|
|
12
|
+
scope: IScope;
|
|
13
13
|
private childScope;
|
|
14
14
|
private params;
|
|
15
15
|
private paramOwners;
|
|
@@ -26,14 +26,13 @@ export declare class FunctionValue extends VoidValue implements IFunctionValue {
|
|
|
26
26
|
private inlineEnd?;
|
|
27
27
|
private bundled;
|
|
28
28
|
private initialized;
|
|
29
|
-
constructor({ scope, params, body, c,
|
|
29
|
+
constructor({ scope, params, body, c, }: {
|
|
30
30
|
scope: IScope;
|
|
31
31
|
body: es.BlockStatement;
|
|
32
32
|
c: Compiler;
|
|
33
|
-
node: es.Function;
|
|
34
33
|
params: es.Identifier[];
|
|
35
34
|
});
|
|
36
|
-
typeof(
|
|
35
|
+
typeof(): TValueInstructions;
|
|
37
36
|
private initScope;
|
|
38
37
|
private ensureInit;
|
|
39
38
|
private normalReturn;
|
|
@@ -3,11 +3,12 @@ import { BaseValue } from ".";
|
|
|
3
3
|
export declare class LiteralValue extends BaseValue implements IBindableValue {
|
|
4
4
|
data: TLiteral;
|
|
5
5
|
mutability: EMutability;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(data: TLiteral);
|
|
7
7
|
eval(_scope: IScope): TValueInstructions;
|
|
8
8
|
consume(_scope: IScope): TValueInstructions;
|
|
9
9
|
toString(): string;
|
|
10
10
|
get(scope: IScope, name: IValue): TValueInstructions;
|
|
11
11
|
get num(): number;
|
|
12
|
-
typeof(
|
|
12
|
+
typeof(): TValueInstructions;
|
|
13
|
+
ensureOwned(): void;
|
|
13
14
|
}
|
|
@@ -12,9 +12,9 @@ export declare class ObjectValue extends VoidValue {
|
|
|
12
12
|
mutability: EMutability;
|
|
13
13
|
macro: boolean;
|
|
14
14
|
data: IObjectValueData;
|
|
15
|
-
constructor(
|
|
16
|
-
static fromArray(
|
|
17
|
-
typeof(
|
|
15
|
+
constructor(data?: IObjectValueData);
|
|
16
|
+
static fromArray(items: IObjectValueData[keyof IObjectValueData][], intialData?: IObjectValueData): ObjectValue;
|
|
17
|
+
typeof(): TValueInstructions;
|
|
18
18
|
get(scope: IScope, key: LiteralValue): TValueInstructions;
|
|
19
19
|
eval(scope: IScope): TValueInstructions;
|
|
20
20
|
consume(scope: IScope): TValueInstructions;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { BaseValue } from ".";
|
|
2
|
-
import { EMutability, IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { EMutability, IOwnedValue, IScope, IValue, TValueInstructions } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* `StoreValue` represents values unknown at compile time,
|
|
5
5
|
* mostly used with mutable variables and temporary values
|
|
6
6
|
*/
|
|
7
7
|
export declare class StoreValue extends BaseValue implements IValue {
|
|
8
|
+
scope: IScope;
|
|
8
9
|
mutability: EMutability;
|
|
9
10
|
constructor(scope: IScope);
|
|
10
|
-
typeof(
|
|
11
|
+
typeof(): TValueInstructions;
|
|
11
12
|
"="(scope: IScope, value: IValue): TValueInstructions;
|
|
12
13
|
eval(_scope: IScope): TValueInstructions;
|
|
13
14
|
consume(_scope: IScope): TValueInstructions;
|
|
15
|
+
ensureOwned(): asserts this is IOwnedValue;
|
|
14
16
|
toString(): string;
|
|
15
17
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { EMutability, IScope, IValue, IValueOperators, IValueOwner, TValueInstructions } from "../types";
|
|
2
2
|
export declare class VoidValue implements IValue {
|
|
3
3
|
owner: IValueOwner | null;
|
|
4
|
-
scope: IScope;
|
|
5
4
|
mutability: EMutability;
|
|
6
5
|
macro: boolean;
|
|
7
|
-
constructor(scope: IScope);
|
|
8
6
|
eval(_scope: IScope): TValueInstructions;
|
|
9
7
|
consume(_scope: IScope): TValueInstructions<IValue>;
|
|
10
8
|
call(_scope: IScope, _args: IValue[]): TValueInstructions<IValue | null>;
|