mlogjs 0.2.1 → 0.3.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 +1 -1
- package/README.md +2 -2
- package/build/Compiler.js +104 -99
- package/build/Compiler.js.map +1 -1
- package/build/CompilerError.js +11 -0
- package/build/CompilerError.js.map +1 -0
- package/build/Scope.js +70 -60
- package/build/Scope.js.map +1 -1
- package/build/bin.js +74 -60
- package/build/bin.js.map +1 -1
- package/build/handlers/BlockStatement.js +13 -13
- package/build/handlers/BlockStatement.js.map +1 -1
- package/build/handlers/CallExpression.js +19 -19
- 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 +31 -31
- package/build/handlers/ForStatement.js.map +1 -1
- package/build/handlers/Function.js +46 -35
- package/build/handlers/Function.js.map +1 -1
- package/build/handlers/Identifier.js +7 -7
- package/build/handlers/IfStatement.js +24 -24
- package/build/handlers/IfStatement.js.map +1 -1
- package/build/handlers/Literal.js +14 -17
- package/build/handlers/Literal.js.map +1 -1
- package/build/handlers/Object.js +54 -43
- package/build/handlers/Object.js.map +1 -1
- package/build/handlers/OperationExpressions.js +37 -32
- package/build/handlers/OperationExpressions.js.map +1 -1
- package/build/handlers/Program.js +8 -8
- package/build/handlers/Program.js.map +1 -1
- package/build/handlers/Statements.js +29 -29
- package/build/handlers/Statements.js.map +1 -1
- package/build/handlers/TemplateExpression.js +17 -17
- package/build/handlers/TemplateExpression.js.map +1 -1
- package/build/handlers/VariableDeclaration.js +71 -55
- package/build/handlers/VariableDeclaration.js.map +1 -1
- package/build/handlers/WhileStatement.js +22 -22
- package/build/handlers/WhileStatement.js.map +1 -1
- package/build/handlers/index.js +31 -30
- package/build/handlers/index.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/initScope.js +39 -39
- package/build/instructions/AddressResolver.js +30 -30
- package/build/instructions/ControlInstructions.js +22 -22
- package/build/instructions/EndInstruction.js +10 -10
- package/build/instructions/InstructionBase.js +20 -20
- package/build/instructions/InstructionBase.js.map +1 -1
- package/build/instructions/JumpInstruction.js +21 -21
- package/build/instructions/JumpInstruction.js.map +1 -1
- package/build/instructions/OperationInstruction.js +10 -10
- package/build/instructions/OperationInstruction.js.map +1 -1
- package/build/instructions/SetCounterInstruction.js +10 -10
- package/build/instructions/SetInstruction.js +10 -10
- package/build/instructions/ZeroSpaceInstruction.js +10 -10
- package/build/instructions/index.js +25 -25
- package/build/macros/Building.js +88 -80
- package/build/macros/Building.js.map +1 -1
- package/build/macros/Function.js +19 -19
- package/build/macros/Function.js.map +1 -1
- package/build/macros/Math.js +61 -56
- package/build/macros/Math.js.map +1 -1
- package/build/macros/Memory.js +62 -60
- package/build/macros/Memory.js.map +1 -1
- package/build/macros/Namespace.js +110 -97
- package/build/macros/Namespace.js.map +1 -1
- package/build/macros/Other.js +20 -19
- package/build/macros/Other.js.map +1 -1
- package/build/macros/RawValue.js +16 -15
- package/build/macros/RawValue.js.map +1 -1
- package/build/macros/commands/Control.js +25 -24
- package/build/macros/commands/Control.js.map +1 -1
- package/build/macros/commands/Draw.js +39 -38
- package/build/macros/commands/Draw.js.map +1 -1
- package/build/macros/commands/DrawFlush.js +17 -16
- package/build/macros/commands/DrawFlush.js.map +1 -1
- package/build/macros/commands/GetLink.js +24 -20
- package/build/macros/commands/GetLink.js.map +1 -1
- package/build/macros/commands/Lookup.js +24 -23
- package/build/macros/commands/Lookup.js.map +1 -1
- package/build/macros/commands/Print.js +17 -13
- package/build/macros/commands/Print.js.map +1 -1
- package/build/macros/commands/PrintFlush.js +17 -16
- package/build/macros/commands/PrintFlush.js.map +1 -1
- package/build/macros/commands/Radar.js +64 -60
- package/build/macros/commands/Radar.js.map +1 -1
- package/build/macros/commands/Sensor.js +20 -19
- package/build/macros/commands/Sensor.js.map +1 -1
- package/build/macros/commands/UnitBind.js +17 -16
- package/build/macros/commands/UnitBind.js.map +1 -1
- package/build/macros/commands/UnitControl.js +72 -67
- package/build/macros/commands/UnitControl.js.map +1 -1
- package/build/macros/commands/UnitLocate.js +75 -54
- package/build/macros/commands/UnitLocate.js.map +1 -1
- package/build/macros/commands/UnitRadar.js +47 -40
- package/build/macros/commands/UnitRadar.js.map +1 -1
- package/build/macros/commands/Wait.js +18 -17
- package/build/macros/commands/Wait.js.map +1 -1
- package/build/macros/commands/index.js +32 -32
- package/build/macros/index.js +39 -39
- package/build/operators.js +101 -101
- package/build/operators.js.map +1 -1
- package/build/types.js +27 -27
- package/build/types.js.map +1 -1
- package/build/utils.js +17 -12
- package/build/utils.js.map +1 -1
- package/build/values/BaseValue.js +111 -111
- package/build/values/BaseValue.js.map +1 -1
- package/build/values/FunctionValue.js +115 -103
- package/build/values/FunctionValue.js.map +1 -1
- package/build/values/LiteralValue.js +88 -87
- package/build/values/LiteralValue.js.map +1 -1
- package/build/values/ObjectValue.js +54 -49
- package/build/values/ObjectValue.js.map +1 -1
- package/build/values/StoreValue.js +31 -30
- package/build/values/StoreValue.js.map +1 -1
- package/build/values/TempValue.js +77 -66
- package/build/values/TempValue.js.map +1 -1
- package/build/values/VoidValue.js +31 -30
- package/build/values/VoidValue.js.map +1 -1
- package/build/values/index.js +22 -22
- package/dist/bin.cjs +82 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/index.cjs +2220 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2195 -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 +5 -4
- package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
- 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 +6 -4
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
- 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 +16 -14
- package/dist/types/index.d.ts +2 -0
- package/{build → dist/types}/initScope.d.ts +5 -2
- package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
- package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/index.d.ts +9 -9
- package/{build → dist/types}/macros/Building.d.ts +10 -11
- package/dist/types/macros/Entities.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +13 -0
- package/dist/types/macros/GetGlobal.d.ts +5 -0
- package/{build → dist/types}/macros/Math.d.ts +5 -5
- package/{build → dist/types}/macros/Memory.d.ts +5 -5
- package/{build → dist/types}/macros/Namespace.d.ts +16 -21
- package/{build → dist/types}/macros/Other.d.ts +5 -5
- package/{build → dist/types}/macros/RawValue.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
- package/dist/types/macros/commands/Draw.d.ts +5 -0
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
- package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
- package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
- package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
- package/{build → dist/types}/macros/commands/index.d.ts +15 -14
- package/{build → dist/types}/macros/index.d.ts +6 -7
- package/{build → dist/types}/operators.d.ts +25 -25
- package/dist/types/types.d.ts +224 -0
- package/dist/types/utils.d.ts +30 -0
- package/dist/types/values/BaseValue.d.ts +7 -0
- package/dist/types/values/DestructuringValue.d.ts +17 -0
- package/dist/types/values/FunctionValue.d.ts +47 -0
- package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
- 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/dist/types/values/StoreValue.d.ts +15 -0
- package/{build → dist/types}/values/TempValue.d.ts +19 -12
- 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 +7 -6
- package/lib/commands.d.ts +242 -36
- package/lib/eslib/lib.es5.d.ts +1 -1
- package/lib/globals.d.ts +172 -159
- package/lib/helpers.d.ts +2 -2
- package/lib/memory.d.ts +1 -1
- package/lib/traits.d.ts +130 -110
- package/package.json +33 -38
- 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/Function.d.ts +0 -12
- package/build/macros/commands/UnitControl.d.ts +0 -5
- 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/FunctionValue.d.ts +0 -34
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/StoreValue.d.ts +0 -11
- package/build/values/VoidValue.d.ts +0 -11
- package/dist/mlogjs.es.js +0 -6366
- package/dist/mlogjs.umd.js +0 -8
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { es } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The prefix for internal variables inside the compiler output
|
|
4
|
+
*/
|
|
5
|
+
export declare const internalPrefix = "&";
|
|
6
|
+
export declare const discardedName: string;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a string that has the format: [line]:[column].
|
|
9
|
+
*
|
|
10
|
+
* If `name` is provided, and it is a string, the resulting string will
|
|
11
|
+
* have the format: [name]:[line]:[column].
|
|
12
|
+
*/
|
|
13
|
+
export declare function nodeName(node: es.Node, name?: false | string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a camel case string into a dash case one.
|
|
16
|
+
*
|
|
17
|
+
* As an example `camelCase` becomes `camel-case`
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* camelToDashCase("camelCase") // returns "camel-case"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function camelToDashCase(name: string): string;
|
|
24
|
+
export declare const itemNames: string[];
|
|
25
|
+
/**
|
|
26
|
+
* A more type safe version of `Object.assign`
|
|
27
|
+
*/
|
|
28
|
+
export declare function assign<T>(obj: T, props: {
|
|
29
|
+
[K in keyof T as T[K] extends Function ? never : K]?: T[K];
|
|
30
|
+
}): T;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IOwnedValue, IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { VoidValue } from ".";
|
|
3
|
+
export declare class BaseValue extends VoidValue implements IValue {
|
|
4
|
+
"u-"(scope: IScope): TValueInstructions;
|
|
5
|
+
"u+"(scope: IScope): TValueInstructions;
|
|
6
|
+
ensureOwned(): asserts this is IOwnedValue;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { VoidValue } from "./VoidValue";
|
|
3
|
+
/**
|
|
4
|
+
* Specific case class, required on the ArrayPattern and ObjectPattern handlers
|
|
5
|
+
* in order to keep the separation of concerns and make the code more modular.
|
|
6
|
+
*
|
|
7
|
+
* When it is assign a value, it will get it's own properties and recursively assign
|
|
8
|
+
* each of them to their counterparts on the right hand value.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DestructuringValue extends VoidValue {
|
|
11
|
+
members: Map<IValue, IValue>;
|
|
12
|
+
macro: boolean;
|
|
13
|
+
constructor(scope: IScope, members: Map<IValue, IValue>);
|
|
14
|
+
"="(scope: IScope, right: IValue): TValueInstructions;
|
|
15
|
+
eval(_scope: IScope): TValueInstructions<IValue>;
|
|
16
|
+
consume(_scope: IScope): TValueInstructions<IValue>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Compiler } from "../Compiler";
|
|
2
|
+
import { EMutability, es, IFunctionValue, IScope, IValue, TValueInstructions } from "../types";
|
|
3
|
+
import { StoreValue } from "./StoreValue";
|
|
4
|
+
import { VoidValue } from "./VoidValue";
|
|
5
|
+
export declare type TFunctionValueInitParams = (childScope: IScope) => {
|
|
6
|
+
paramStores: StoreValue[];
|
|
7
|
+
paramNames: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare class FunctionValue extends VoidValue implements IFunctionValue {
|
|
10
|
+
mutability: EMutability;
|
|
11
|
+
macro: boolean;
|
|
12
|
+
private node;
|
|
13
|
+
private childScope;
|
|
14
|
+
private params;
|
|
15
|
+
private paramOwners;
|
|
16
|
+
private inst;
|
|
17
|
+
private addr;
|
|
18
|
+
private temp;
|
|
19
|
+
private ret;
|
|
20
|
+
private inline;
|
|
21
|
+
private tryingInline;
|
|
22
|
+
private body;
|
|
23
|
+
private c;
|
|
24
|
+
private callSize;
|
|
25
|
+
private inlineTemp;
|
|
26
|
+
private inlineEnd;
|
|
27
|
+
private bundled;
|
|
28
|
+
private initialized;
|
|
29
|
+
constructor({ scope, params, body, c, node, }: {
|
|
30
|
+
scope: IScope;
|
|
31
|
+
body: es.BlockStatement;
|
|
32
|
+
c: Compiler;
|
|
33
|
+
node: es.Function;
|
|
34
|
+
params: es.Identifier[];
|
|
35
|
+
});
|
|
36
|
+
typeof(scope: IScope): TValueInstructions;
|
|
37
|
+
private initScope;
|
|
38
|
+
private ensureInit;
|
|
39
|
+
private normalReturn;
|
|
40
|
+
private normalCall;
|
|
41
|
+
private inlineReturn;
|
|
42
|
+
private inlineCall;
|
|
43
|
+
call(scope: IScope, args: IValue[]): TValueInstructions;
|
|
44
|
+
return(scope: IScope, arg: IValue | null): TValueInstructions<IValue | null>;
|
|
45
|
+
eval(_scope: IScope): TValueInstructions;
|
|
46
|
+
consume(_scope: IScope): TValueInstructions;
|
|
47
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue } from "../types";
|
|
2
|
-
import { BaseValue } from ".";
|
|
3
|
-
export declare class LiteralValue extends BaseValue implements IBindableValue {
|
|
4
|
-
data: TLiteral;
|
|
5
|
-
|
|
6
|
-
constructor(scope: IScope, data: TLiteral);
|
|
7
|
-
eval(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
get
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue, EMutability } from "../types";
|
|
2
|
+
import { BaseValue } from ".";
|
|
3
|
+
export declare class LiteralValue extends BaseValue implements IBindableValue {
|
|
4
|
+
data: TLiteral;
|
|
5
|
+
mutability: EMutability;
|
|
6
|
+
constructor(scope: IScope, data: TLiteral);
|
|
7
|
+
eval(_scope: IScope): TValueInstructions;
|
|
8
|
+
consume(_scope: IScope): TValueInstructions;
|
|
9
|
+
toString(): string;
|
|
10
|
+
get(scope: IScope, name: IValue): TValueInstructions;
|
|
11
|
+
get num(): number;
|
|
12
|
+
typeof(scope: IScope): TValueInstructions;
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MacroFunction } from "../macros";
|
|
2
|
+
import { EMutability, IOwnedValue, 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
|
+
$consume?: MacroFunction<IValue>;
|
|
10
|
+
}
|
|
11
|
+
export declare class ObjectValue extends VoidValue {
|
|
12
|
+
mutability: EMutability;
|
|
13
|
+
macro: boolean;
|
|
14
|
+
data: IObjectValueData;
|
|
15
|
+
constructor(scope: IScope, data?: IObjectValueData);
|
|
16
|
+
static fromArray(scope: IScope, items: IObjectValueData[keyof IObjectValueData][]): ObjectValue;
|
|
17
|
+
typeof(scope: IScope): TValueInstructions;
|
|
18
|
+
get(scope: IScope, key: LiteralValue): TValueInstructions;
|
|
19
|
+
eval(scope: IScope): TValueInstructions;
|
|
20
|
+
consume(scope: IScope): TValueInstructions;
|
|
21
|
+
call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
|
|
22
|
+
ensureOwned(): asserts this is IOwnedValue;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EMutability, IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { StoreValue } from "./StoreValue";
|
|
3
|
+
/**
|
|
4
|
+
* Senseable values are "objects" in the mlog runtime that
|
|
5
|
+
* have special properties that can be accessed
|
|
6
|
+
* via the `sense` instruction.
|
|
7
|
+
*
|
|
8
|
+
* This class extends `StoreValue` to allow dynamic behavior
|
|
9
|
+
* that is not possible with object macros.
|
|
10
|
+
*
|
|
11
|
+
* Note that these values are constant by default, so make sure
|
|
12
|
+
* to set that field to `false` if you want them to be assignable. Example:
|
|
13
|
+
* ```
|
|
14
|
+
* const value = assign(new SenseableValue(scope), {
|
|
15
|
+
* mutability: EMutability.mutable
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class SenseableValue extends StoreValue {
|
|
20
|
+
mutability: EMutability;
|
|
21
|
+
constructor(scope: IScope);
|
|
22
|
+
get(scope: IScope, prop: IValue): TValueInstructions<IValue>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseValue } from ".";
|
|
2
|
+
import { IScope, IValue, TValueInstructions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* `StackValue` represents values unknown at compile time inside a stack memory,
|
|
5
|
+
* mostly used with mutable variables and temporary values
|
|
6
|
+
*/
|
|
7
|
+
export declare class StackValue extends BaseValue implements IValue {
|
|
8
|
+
constant: boolean;
|
|
9
|
+
offset: number;
|
|
10
|
+
constructor(scope: IScope);
|
|
11
|
+
typeof(scope: IScope): TValueInstructions;
|
|
12
|
+
"="(scope: IScope, value: IValue): TValueInstructions;
|
|
13
|
+
eval(scope: IScope): TValueInstructions;
|
|
14
|
+
consume(_scope: IScope): TValueInstructions;
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseValue } from ".";
|
|
2
|
+
import { EMutability, IScope, IValue, TValueInstructions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* `StoreValue` represents values unknown at compile time,
|
|
5
|
+
* mostly used with mutable variables and temporary values
|
|
6
|
+
*/
|
|
7
|
+
export declare class StoreValue extends BaseValue implements IValue {
|
|
8
|
+
mutability: EMutability;
|
|
9
|
+
constructor(scope: IScope);
|
|
10
|
+
typeof(scope: IScope): TValueInstructions;
|
|
11
|
+
"="(scope: IScope, value: IValue): TValueInstructions;
|
|
12
|
+
eval(_scope: IScope): TValueInstructions;
|
|
13
|
+
consume(_scope: IScope): TValueInstructions;
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { IInstruction, IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
-
import { StoreValue } from "./";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { IInstruction, IScope, IValue, TValueInstructions } from "../types";
|
|
2
|
+
import { StoreValue } from "./";
|
|
3
|
+
export interface TempValueOptions {
|
|
4
|
+
scope: IScope;
|
|
5
|
+
name?: string;
|
|
6
|
+
renameable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class TempValue extends StoreValue implements IValue {
|
|
9
|
+
proxied: IValue;
|
|
10
|
+
canProxy: boolean;
|
|
11
|
+
setInst: IInstruction;
|
|
12
|
+
renameable: boolean;
|
|
13
|
+
constructor({ scope, name, renameable }: TempValueOptions);
|
|
14
|
+
eval(scope: IScope): TValueInstructions;
|
|
15
|
+
"="(scope: IScope, value: IValue): TValueInstructions;
|
|
16
|
+
proxy(value: IValue): TValueInstructions;
|
|
17
|
+
noProxy(): void;
|
|
18
|
+
rename(name: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IScope, IValue, IValueOwner } from "../types";
|
|
2
|
+
export interface IValueOwnerParams<T extends IValue> {
|
|
3
|
+
scope: IScope;
|
|
4
|
+
constant?: boolean;
|
|
5
|
+
value: T;
|
|
6
|
+
/** The identifier of the variable that `this` represents */
|
|
7
|
+
identifier?: string;
|
|
8
|
+
/** The name that the variable will have during transpilation to mlog */
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ValueOwner<T extends IValue = IValue> implements IValueOwner<T> {
|
|
12
|
+
scope: IScope;
|
|
13
|
+
constant: boolean;
|
|
14
|
+
value: T;
|
|
15
|
+
owned: Set<T>;
|
|
16
|
+
identifier?: string;
|
|
17
|
+
name: string;
|
|
18
|
+
persistent: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new `ValueOwner`, if `value` is already owned,
|
|
21
|
+
* `this` will be aliased to `value`, else `this` will own `value`
|
|
22
|
+
*/
|
|
23
|
+
constructor({ scope, constant, value, identifier, name, }: IValueOwnerParams<T>);
|
|
24
|
+
own(target: T): void;
|
|
25
|
+
replace(target: T): void;
|
|
26
|
+
moveInto(owner: IValueOwner<T>): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EMutability, IScope, IValue, IValueOperators, IValueOwner, TValueInstructions } from "../types";
|
|
2
|
+
export declare class VoidValue implements IValue {
|
|
3
|
+
owner: IValueOwner | null;
|
|
4
|
+
scope: IScope;
|
|
5
|
+
mutability: EMutability;
|
|
6
|
+
macro: boolean;
|
|
7
|
+
constructor(scope: IScope);
|
|
8
|
+
eval(_scope: IScope): TValueInstructions;
|
|
9
|
+
consume(_scope: IScope): TValueInstructions<IValue>;
|
|
10
|
+
call(_scope: IScope, _args: IValue[]): TValueInstructions<IValue | null>;
|
|
11
|
+
get(_scope: IScope, _name: IValue): TValueInstructions;
|
|
12
|
+
ensureOwned(): void;
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
export interface VoidValue extends IValueOperators {
|
|
16
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from "./VoidValue";
|
|
2
|
-
export * from "./BaseValue";
|
|
3
|
-
export * from "./LiteralValue";
|
|
4
|
-
export * from "./StoreValue";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
1
|
+
export * from "./VoidValue";
|
|
2
|
+
export * from "./BaseValue";
|
|
3
|
+
export * from "./LiteralValue";
|
|
4
|
+
export * from "./StoreValue";
|
|
5
|
+
export * from "./ObjectValue";
|
|
6
|
+
export * from "./SenseableValue";
|
|
7
|
+
export * from "./DestructuringValue";
|