mlogjs 0.1.11 → 0.2.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/LICENSE +21 -21
- package/README.md +68 -18
- package/build/bin.cjs +69 -0
- package/dist/bin.cjs +69 -0
- package/dist/index.cjs +1817 -0
- package/dist/index.mjs +1813 -0
- package/dist/types/Compiler.d.ts +18 -0
- package/{build → dist/types}/Scope.d.ts +8 -11
- 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/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +0 -0
- package/{build → dist/types}/handlers/Identifier.d.ts +0 -0
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Literal.d.ts +0 -0
- package/{build → dist/types}/handlers/Object.d.ts +0 -0
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +0 -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/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/index.d.ts +0 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/initScope.d.ts +2 -0
- package/{build → dist/types}/instructions/AddressResolver.d.ts +1 -1
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +0 -0
- package/{build → dist/types}/instructions/EndInstruction.d.ts +0 -0
- package/{build → dist/types}/instructions/InstructionBase.d.ts +2 -2
- 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 +0 -0
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +0 -0
- package/{build → dist/types}/instructions/index.d.ts +0 -0
- package/dist/types/macros/Building.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +12 -0
- package/{build → dist/types}/macros/Math.d.ts +0 -0
- package/{build/macros/Blocks.d.ts → dist/types/macros/Memory.d.ts} +1 -1
- package/dist/types/macros/Namespace.d.ts +21 -0
- package/{build/macros/Draw.d.ts → dist/types/macros/Other.d.ts} +1 -1
- package/dist/types/macros/RawValue.d.ts +5 -0
- package/dist/types/macros/commands/Control.d.ts +5 -0
- package/dist/types/macros/commands/Draw.d.ts +5 -0
- package/dist/types/macros/commands/DrawFlush.d.ts +5 -0
- package/dist/types/macros/commands/GetLink.d.ts +5 -0
- package/dist/types/macros/commands/Lookup.d.ts +5 -0
- package/dist/types/macros/commands/Print.d.ts +5 -0
- package/dist/types/macros/commands/PrintFlush.d.ts +5 -0
- package/dist/types/macros/commands/Radar.d.ts +7 -0
- package/dist/types/macros/commands/Sensor.d.ts +5 -0
- package/dist/types/macros/commands/UnitBind.d.ts +5 -0
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/dist/types/macros/commands/UnitLocate.d.ts +5 -0
- package/dist/types/macros/commands/UnitRadar.d.ts +5 -0
- package/dist/types/macros/commands/Wait.d.ts +5 -0
- package/dist/types/macros/commands/index.d.ts +14 -0
- package/dist/types/macros/index.d.ts +7 -0
- package/{build → dist/types}/operators.d.ts +3 -0
- package/dist/types/types.d.ts +100 -0
- package/{build → dist/types}/utils.d.ts +1 -0
- package/{build → dist/types}/values/BaseValue.d.ts +0 -0
- package/{build → dist/types}/values/FunctionValue.d.ts +1 -1
- package/{build → dist/types}/values/LiteralValue.d.ts +0 -0
- package/dist/types/values/ObjectValue.d.ts +19 -0
- package/{build → dist/types}/values/StoreValue.d.ts +0 -0
- package/{build → dist/types}/values/TempValue.d.ts +0 -0
- package/{build → dist/types}/values/VoidValue.d.ts +3 -1
- package/{build → dist/types}/values/index.d.ts +0 -0
- package/{docs → doc}/README.md +9 -17
- package/lib/commands.d.ts +326 -0
- package/lib/eslib/index.d.ts +3 -0
- package/lib/eslib/lib.d.ts +9 -0
- package/lib/eslib/lib.es2015.collection.d.ts +89 -0
- package/lib/eslib/lib.es2015.core.d.ts +16 -0
- package/lib/eslib/lib.es2015.d.ts +30 -0
- package/lib/eslib/lib.es2015.generator.d.ts +79 -0
- package/lib/eslib/lib.es2015.iterable.d.ts +70 -0
- package/lib/eslib/lib.es5.d.ts +295 -0
- package/lib/eslib/lib.es6.d.ts +18 -0
- package/lib/globals.d.ts +328 -0
- package/lib/helpers.d.ts +23 -0
- package/lib/index.d.ts +7 -0
- package/lib/kinds.d.ts +36 -0
- package/lib/memory.d.ts +17 -0
- package/lib/traits.d.ts +120 -0
- package/lib/util.d.ts +32 -0
- package/package.json +63 -37
- package/.gitattributes +0 -2
- package/build/Compiler.d.ts +0 -18
- package/build/Compiler.js +0 -93
- package/build/Compiler.js.map +0 -1
- package/build/Scope.js +0 -61
- package/build/Scope.js.map +0 -1
- package/build/bin.d.ts +0 -2
- package/build/bin.js +0 -35
- package/build/bin.js.map +0 -1
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/BlockStatement.js +0 -14
- package/build/handlers/BlockStatement.js.map +0 -1
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/CallExpression.js +0 -20
- package/build/handlers/CallExpression.js.map +0 -1
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/ForStatement.js +0 -32
- package/build/handlers/ForStatement.js.map +0 -1
- package/build/handlers/Function.js +0 -33
- 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.d.ts +0 -2
- package/build/handlers/IfStatement.js +0 -25
- package/build/handlers/IfStatement.js.map +0 -1
- package/build/handlers/Literal.js +0 -16
- package/build/handlers/Literal.js.map +0 -1
- package/build/handlers/Object.js +0 -44
- package/build/handlers/Object.js.map +0 -1
- package/build/handlers/OperationExpressions.js +0 -32
- package/build/handlers/OperationExpressions.js.map +0 -1
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Program.js +0 -9
- package/build/handlers/Program.js.map +0 -1
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/Statements.js +0 -28
- package/build/handlers/Statements.js.map +0 -1
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/TemplateExpression.js +0 -18
- package/build/handlers/TemplateExpression.js.map +0 -1
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/VariableDeclaration.js +0 -32
- package/build/handlers/VariableDeclaration.js.map +0 -1
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/handlers/WhileStatement.js +0 -23
- package/build/handlers/WhileStatement.js.map +0 -1
- package/build/handlers/index.js +0 -27
- package/build/handlers/index.js.map +0 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -8
- package/build/index.js.map +0 -1
- package/build/instructions/AddressResolver.js +0 -32
- 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 -22
- package/build/instructions/index.js.map +0 -1
- package/build/macros/Blocks.js +0 -137
- package/build/macros/Blocks.js.map +0 -1
- package/build/macros/Draw.js +0 -34
- package/build/macros/Draw.js.map +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/Function.js +0 -20
- package/build/macros/Function.js.map +0 -1
- package/build/macros/Math.js +0 -57
- package/build/macros/Math.js.map +0 -1
- package/build/macros/Other.d.ts +0 -8
- package/build/macros/Other.js +0 -29
- package/build/macros/Other.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/index.d.ts +0 -5
- package/build/macros/index.js +0 -18
- package/build/macros/index.js.map +0 -1
- package/build/operators.js +0 -39
- package/build/operators.js.map +0 -1
- package/build/scopes/FunctionScope.d.ts +0 -5
- package/build/scopes/FunctionScope.js +0 -13
- package/build/scopes/FunctionScope.js.map +0 -1
- package/build/scopes/LoopScope.d.ts +0 -5
- package/build/scopes/LoopScope.js +0 -13
- package/build/scopes/LoopScope.js.map +0 -1
- package/build/scopes/Scope.d.ts +0 -36
- package/build/scopes/Scope.js +0 -93
- package/build/scopes/Scope.js.map +0 -1
- package/build/scopes/index.d.ts +0 -3
- package/build/scopes/index.js +0 -16
- package/build/scopes/index.js.map +0 -1
- package/build/types.d.ts +0 -49
- package/build/types.js +0 -24
- package/build/types.js.map +0 -1
- package/build/utils.js +0 -9
- package/build/utils.js.map +0 -1
- package/build/values/BaseValue.js +0 -102
- package/build/values/BaseValue.js.map +0 -1
- package/build/values/FunctionValue.js +0 -101
- 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.d.ts +0 -17
- package/build/values/ObjectValue.js +0 -50
- package/build/values/ObjectValue.js.map +0 -1
- package/build/values/StoreValue.js +0 -31
- package/build/values/StoreValue.js.map +0 -1
- package/build/values/TempValue.js +0 -53
- package/build/values/TempValue.js.map +0 -1
- package/build/values/VoidValue.js +0 -31
- package/build/values/VoidValue.js.map +0 -1
- package/build/values/index.js +0 -19
- package/build/values/index.js.map +0 -1
- package/dist/bundle.js +0 -553
- package/docs/.nojekyll +0 -0
- package/docs/_coverpage.md +0 -8
- package/docs/_sidebar.md +0 -3
- package/docs/data-types.md +0 -56
- package/docs/getting-started.md +0 -19
- package/docs/index.html +0 -41
- package/docs/mlogjs.png +0 -0
- package/mlogjs.d.ts +0 -72
- package/tsconfig.json +0 -22
- package/webpack.config.js +0 -22
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { es, IScope, IValue, THandler, TValueInstructions } from "./types";
|
|
2
|
+
declare type THandlerMap = {
|
|
3
|
+
[k in es.Node["type"]]?: THandler<IValue | null>;
|
|
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, null, es.Node[]] | [null, Error, es.Node[]];
|
|
11
|
+
protected resolve(valueInst: TValueInstructions<IValue | null>): void;
|
|
12
|
+
protected serialize(resLines: TValueInstructions<IValue | null>): string;
|
|
13
|
+
protected parse(script: string): es.Node;
|
|
14
|
+
handle(scope: IScope, node: es.Node): TValueInstructions<IValue | null>;
|
|
15
|
+
handleEval(scope: IScope, node: es.Node): TValueInstructions;
|
|
16
|
+
handleMany<T extends es.Node>(scope: IScope, nodes: T[], handler?: (scope: IScope, node: T) => TValueInstructions<IValue | null>): TValueInstructions<null>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
+
import { StoreValue } from "./values";
|
|
1
2
|
import { AddressResolver } from "./instructions";
|
|
2
3
|
import { IFunctionValue, IInstruction, IScope, IValue } from "./types";
|
|
3
4
|
export declare class Scope implements IScope {
|
|
4
|
-
parent: IScope;
|
|
5
|
-
name: string;
|
|
6
|
-
data: {
|
|
7
|
-
[k: string]: IValue;
|
|
8
|
-
};
|
|
5
|
+
parent: IScope | null;
|
|
9
6
|
stacked: boolean;
|
|
10
7
|
ntemp: number;
|
|
8
|
+
name: string;
|
|
11
9
|
inst: IInstruction[];
|
|
10
|
+
data: Record<string, IValue | null>;
|
|
12
11
|
break: AddressResolver;
|
|
13
12
|
continue: AddressResolver;
|
|
14
13
|
function: IFunctionValue;
|
|
15
|
-
constructor(values:
|
|
16
|
-
[k: string]: IValue;
|
|
17
|
-
}, parent?: IScope, stacked?: boolean, ntemp?: number, name?: string, inst?: any[]);
|
|
14
|
+
constructor(values: Record<string, IValue | null>, parent?: IScope | null, stacked?: boolean, ntemp?: number, name?: string, inst?: IInstruction[]);
|
|
18
15
|
copy(): IScope;
|
|
19
16
|
createScope(): IScope;
|
|
20
17
|
createFunction(name: string, stacked?: boolean): IScope;
|
|
21
18
|
has(name: string): boolean;
|
|
22
19
|
get(name: string): IValue;
|
|
23
|
-
set(name: string, value:
|
|
24
|
-
hardSet(name: string, value:
|
|
25
|
-
make(name: string, storeName: string):
|
|
20
|
+
set<T extends IValue>(name: string, value: T): T;
|
|
21
|
+
hardSet<T extends IValue>(name: string, value: T): T;
|
|
22
|
+
make(name: string, storeName: string): StoreValue;
|
|
26
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IValue, THandler } from "../types";
|
|
2
|
+
export declare const ExpressionStatement: THandler<IValue | null>;
|
|
3
|
+
export declare const BreakStatement: THandler<null>;
|
|
4
|
+
export declare const ContinueStatement: THandler<null>;
|
|
5
|
+
export declare const ReturnStatement: THandler<IValue | null>;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const compile: (script: string) => [string, null, import("estree").Node[]] | [null, Error, import("estree").Node[]];
|
|
File without changes
|
|
File without changes
|
|
@@ -3,8 +3,8 @@ export declare class InstructionBase implements IInstruction {
|
|
|
3
3
|
private _hidden;
|
|
4
4
|
get hidden(): boolean;
|
|
5
5
|
set hidden(value: boolean);
|
|
6
|
-
args: (string | IValue)[];
|
|
7
|
-
constructor(...args: (string | IValue)[]);
|
|
6
|
+
args: (string | IValue | null)[];
|
|
7
|
+
constructor(...args: (string | IValue | null)[]);
|
|
8
8
|
resolve(i: number): void;
|
|
9
9
|
toString(): string;
|
|
10
10
|
}
|
|
@@ -11,5 +11,5 @@ export declare enum EJumpKind {
|
|
|
11
11
|
Always = "always"
|
|
12
12
|
}
|
|
13
13
|
export declare class JumpInstruction extends InstructionBase {
|
|
14
|
-
constructor(address: IBindableValue, kind: EJumpKind, left?: IValue, right?: IValue);
|
|
14
|
+
constructor(address: IBindableValue, kind: EJumpKind, left?: IValue | null, right?: IValue | null);
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstructionBase } from ".";
|
|
2
2
|
import { IValue } from "../types";
|
|
3
3
|
export declare class OperationInstruction extends InstructionBase {
|
|
4
|
-
constructor(kind: string, temp: IValue, left: IValue, right
|
|
4
|
+
constructor(kind: string, temp: IValue, left: IValue, right: IValue | null);
|
|
5
5
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IScope } from "../types";
|
|
2
|
+
import { ObjectValue } from "../values";
|
|
3
|
+
export declare const itemNames: string[];
|
|
4
|
+
export declare class Building extends ObjectValue {
|
|
5
|
+
name: string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
constructor(scope: IScope, name: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class BuildingBuilder extends ObjectValue {
|
|
10
|
+
constructor(scope: IScope);
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { VoidValue } from "../values";
|
|
3
|
+
declare type TFunction<T extends IValue | null> = (...args: IValue[]) => TValueInstructions<T>;
|
|
4
|
+
export declare class MacroFunction<RT extends IValue | null = IValue> extends VoidValue {
|
|
5
|
+
macro: boolean;
|
|
6
|
+
constant: boolean;
|
|
7
|
+
fn: TFunction<RT>;
|
|
8
|
+
constructor(scope: IScope, fn: TFunction<RT>);
|
|
9
|
+
call(scope: IScope, args: IValue[]): TValueInstructions<RT>;
|
|
10
|
+
eval(scope: IScope): TValueInstructions;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
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 declare class UCommandsNamespace extends NamespaceMacro {
|
|
14
|
+
constructor(scope: IScope);
|
|
15
|
+
}
|
|
16
|
+
export declare class Unit extends ObjectValue {
|
|
17
|
+
name: string;
|
|
18
|
+
constructor(scope: IScope, name: string);
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./Draw";
|
|
2
|
+
export * from "./Print";
|
|
3
|
+
export * from "./PrintFlush";
|
|
4
|
+
export * from "./DrawFlush";
|
|
5
|
+
export * from "./GetLink";
|
|
6
|
+
export * from "./Control";
|
|
7
|
+
export { Radar } from "./Radar";
|
|
8
|
+
export * from "./Sensor";
|
|
9
|
+
export * from "./Wait";
|
|
10
|
+
export * from "./Lookup";
|
|
11
|
+
export * from "./UnitBind";
|
|
12
|
+
export * from "./UnitControl";
|
|
13
|
+
export * from "./UnitRadar";
|
|
14
|
+
export * from "./UnitLocate";
|
|
@@ -20,3 +20,6 @@ export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "type
|
|
|
20
20
|
export declare type SingleOperator = typeof singleOperators[number];
|
|
21
21
|
export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
|
|
22
22
|
export declare type Operator = typeof operators[number];
|
|
23
|
+
export declare const operatorMap: {
|
|
24
|
+
[k in Exclude<BinaryOperator, "instanceof" | "in"> | Extract<LogicalOperator, "&&" | "||">]: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export * as es from "estree";
|
|
2
|
+
import { Compiler } from "./Compiler";
|
|
3
|
+
import { AddressResolver } from "./instructions";
|
|
4
|
+
import { MacroFunction } from "./macros";
|
|
5
|
+
import { LeftRightOperator, UnaryOperator, UpdateOperator } from "./operators";
|
|
6
|
+
import { StoreValue } from "./values";
|
|
7
|
+
export interface IInstruction {
|
|
8
|
+
hidden: boolean;
|
|
9
|
+
resolve(i: number): void;
|
|
10
|
+
}
|
|
11
|
+
export declare type THandler<T extends IValue | null = IValue> = (compiler: Compiler, scope: IScope, node: any, arg: any) => TValueInstructions<T>;
|
|
12
|
+
export interface IScope {
|
|
13
|
+
parent: IScope | null;
|
|
14
|
+
data: {};
|
|
15
|
+
name: string;
|
|
16
|
+
inst: IInstruction[];
|
|
17
|
+
break: AddressResolver;
|
|
18
|
+
continue: AddressResolver;
|
|
19
|
+
function: IFunctionValue;
|
|
20
|
+
ntemp: number;
|
|
21
|
+
createScope(): IScope;
|
|
22
|
+
createFunction(name: string, stacked?: boolean): IScope;
|
|
23
|
+
has(name: string): boolean;
|
|
24
|
+
get(name: string): IValue;
|
|
25
|
+
set<T extends IValue>(name: string, value: T): T;
|
|
26
|
+
hardSet<T extends IValue>(name: string, value: T): T;
|
|
27
|
+
make(name: string, storeName: string): StoreValue;
|
|
28
|
+
copy(): IScope;
|
|
29
|
+
}
|
|
30
|
+
export interface IValue {
|
|
31
|
+
scope: IScope;
|
|
32
|
+
constant: boolean;
|
|
33
|
+
macro: boolean;
|
|
34
|
+
eval(scope: IScope): TValueInstructions;
|
|
35
|
+
call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
|
|
36
|
+
get(scope: IScope, name: IValue): TValueInstructions;
|
|
37
|
+
"!"(scope: IScope): TValueInstructions;
|
|
38
|
+
"u+"(scope: IScope): TValueInstructions;
|
|
39
|
+
"u-"(scope: IScope): TValueInstructions;
|
|
40
|
+
"delete"(scope: IScope): TValueInstructions;
|
|
41
|
+
"typeof"(scope: IScope): TValueInstructions;
|
|
42
|
+
"void"(scope: IScope): TValueInstructions;
|
|
43
|
+
"~"(scope: IScope): TValueInstructions;
|
|
44
|
+
"++"(scope: IScope, prefix: boolean): TValueInstructions;
|
|
45
|
+
"--"(scope: IScope, prefix: boolean): TValueInstructions;
|
|
46
|
+
"*"(scope: IScope, value: IValue): TValueInstructions;
|
|
47
|
+
"**"(scope: IScope, value: IValue): TValueInstructions;
|
|
48
|
+
"+"(scope: IScope, value: IValue): TValueInstructions;
|
|
49
|
+
"-"(scope: IScope, value: IValue): TValueInstructions;
|
|
50
|
+
"/"(scope: IScope, value: IValue): TValueInstructions;
|
|
51
|
+
"%"(scope: IScope, value: IValue): TValueInstructions;
|
|
52
|
+
"!="(scope: IScope, value: IValue): TValueInstructions;
|
|
53
|
+
"!=="(scope: IScope, value: IValue): TValueInstructions;
|
|
54
|
+
"<"(scope: IScope, value: IValue): TValueInstructions;
|
|
55
|
+
"<="(scope: IScope, value: IValue): TValueInstructions;
|
|
56
|
+
"=="(scope: IScope, value: IValue): TValueInstructions;
|
|
57
|
+
"==="(scope: IScope, value: IValue): TValueInstructions;
|
|
58
|
+
">"(scope: IScope, value: IValue): TValueInstructions;
|
|
59
|
+
">="(scope: IScope, value: IValue): TValueInstructions;
|
|
60
|
+
"&"(scope: IScope, value: IValue): TValueInstructions;
|
|
61
|
+
"<<"(scope: IScope, value: IValue): TValueInstructions;
|
|
62
|
+
">>"(scope: IScope, value: IValue): TValueInstructions;
|
|
63
|
+
">>>"(scope: IScope, value: IValue): TValueInstructions;
|
|
64
|
+
"^"(scope: IScope, value: IValue): TValueInstructions;
|
|
65
|
+
"|"(scope: IScope, value: IValue): TValueInstructions;
|
|
66
|
+
instanceof(scope: IScope, value: IValue): TValueInstructions;
|
|
67
|
+
in(scope: IScope, value: IValue): TValueInstructions;
|
|
68
|
+
"&&"(scope: IScope, value: IValue): TValueInstructions;
|
|
69
|
+
"??"(scope: IScope, value: IValue): TValueInstructions;
|
|
70
|
+
"||"(scope: IScope, value: IValue): TValueInstructions;
|
|
71
|
+
"%="(scope: IScope, value: IValue): TValueInstructions;
|
|
72
|
+
"&="(scope: IScope, value: IValue): TValueInstructions;
|
|
73
|
+
"*="(scope: IScope, value: IValue): TValueInstructions;
|
|
74
|
+
"**="(scope: IScope, value: IValue): TValueInstructions;
|
|
75
|
+
"+="(scope: IScope, value: IValue): TValueInstructions;
|
|
76
|
+
"-="(scope: IScope, value: IValue): TValueInstructions;
|
|
77
|
+
"/="(scope: IScope, value: IValue): TValueInstructions;
|
|
78
|
+
"&&="(scope: IScope, value: IValue): TValueInstructions;
|
|
79
|
+
"||="(scope: IScope, value: IValue): TValueInstructions;
|
|
80
|
+
"<<="(scope: IScope, value: IValue): TValueInstructions;
|
|
81
|
+
">>="(scope: IScope, value: IValue): TValueInstructions;
|
|
82
|
+
">>>="(scope: IScope, value: IValue): TValueInstructions;
|
|
83
|
+
"^="(scope: IScope, value: IValue): TValueInstructions;
|
|
84
|
+
"|="(scope: IScope, value: IValue): TValueInstructions;
|
|
85
|
+
"="(scope: IScope, value: IValue): TValueInstructions;
|
|
86
|
+
}
|
|
87
|
+
export declare type TLiteral = string | number;
|
|
88
|
+
export interface IBindableValue extends IValue {
|
|
89
|
+
data: TLiteral;
|
|
90
|
+
}
|
|
91
|
+
export interface IFunctionValue extends IValue {
|
|
92
|
+
return(scope: IScope, argument: IValue): TValueInstructions<IValue | null>;
|
|
93
|
+
}
|
|
94
|
+
export declare type TValueInstructions<Content extends IValue | null = IValue> = [
|
|
95
|
+
Content,
|
|
96
|
+
IInstruction[]
|
|
97
|
+
];
|
|
98
|
+
export declare type TOperatorMacroMap = {
|
|
99
|
+
[K in UnaryOperator | UpdateOperator | LeftRightOperator as `$${K}`]?: MacroFunction;
|
|
100
|
+
};
|
|
File without changes
|
|
@@ -29,6 +29,6 @@ export declare class FunctionValue extends VoidValue implements IFunctionValue {
|
|
|
29
29
|
private inlineReturn;
|
|
30
30
|
private inlineCall;
|
|
31
31
|
call(scope: IScope, args: IValue[]): TValueInstructions;
|
|
32
|
-
return(scope: IScope, arg: IValue): TValueInstructions
|
|
32
|
+
return(scope: IScope, arg: IValue): TValueInstructions<IValue | null>;
|
|
33
33
|
eval(scope: IScope): TValueInstructions;
|
|
34
34
|
}
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MacroFunction } from "../macros";
|
|
2
|
+
import { IScope, IValue, TOperatorMacroMap, TValueInstructions } from "../types";
|
|
3
|
+
import { LiteralValue } from "./LiteralValue";
|
|
4
|
+
import { VoidValue } from "./VoidValue";
|
|
5
|
+
export interface IObjectValueData extends TOperatorMacroMap {
|
|
6
|
+
[k: string]: IValue | undefined;
|
|
7
|
+
$get?: MacroFunction<IValue>;
|
|
8
|
+
$eval?: MacroFunction<IValue>;
|
|
9
|
+
}
|
|
10
|
+
export declare class ObjectValue extends VoidValue {
|
|
11
|
+
constant: boolean;
|
|
12
|
+
macro: boolean;
|
|
13
|
+
data: IObjectValueData;
|
|
14
|
+
constructor(scope: IScope, data?: IObjectValueData);
|
|
15
|
+
typeof(scope: IScope): TValueInstructions;
|
|
16
|
+
get(scope: IScope, key: LiteralValue): TValueInstructions;
|
|
17
|
+
eval(scope: IScope): TValueInstructions;
|
|
18
|
+
call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
|
|
19
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,9 @@ export declare class VoidValue implements IValue {
|
|
|
5
5
|
macro: boolean;
|
|
6
6
|
constructor(scope: IScope);
|
|
7
7
|
eval(scope: IScope): TValueInstructions;
|
|
8
|
-
call(scope: IScope, args: IValue[]): TValueInstructions
|
|
8
|
+
call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
|
|
9
9
|
get(scope: IScope, name: IValue): TValueInstructions;
|
|
10
10
|
toString(): string;
|
|
11
11
|
}
|
|
12
|
+
export interface VoidValue extends IValue {
|
|
13
|
+
}
|
|
File without changes
|
package/{docs → doc}/README.md
RENAMED
|
@@ -1,17 +1,9 @@
|
|
|
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
|
+
# 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>
|