mlogjs 0.5.2 → 0.6.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/README.md +2 -2
- package/dist/{index.cjs → Compiler-7GMG4MDr.js} +1746 -452
- package/dist/Compiler.d.ts +8 -12
- package/dist/CompilerError.d.ts +13 -3
- package/dist/Scope.d.ts +8 -8
- package/dist/bin/files.d.ts +18 -0
- package/dist/bin.mjs +170 -0
- package/dist/handlers/Import.d.ts +5 -0
- package/dist/handlers/Literal.d.ts +2 -2
- package/dist/handlers/Typescript.d.ts +2 -2
- package/dist/handlers/index.d.ts +1 -0
- package/dist/index.mjs +3 -4267
- package/dist/instructions/AddressResolver.d.ts +4 -4
- package/dist/instructions/ControlInstructions.d.ts +3 -3
- package/dist/instructions/InstructionBase.d.ts +1 -0
- package/dist/instructions/JumpInstruction.d.ts +5 -5
- package/dist/instructions/index.d.ts +0 -1
- package/dist/macros/DynamicArray.d.ts +4 -4
- package/dist/macros/Function.d.ts +2 -2
- package/dist/macros/GetBuildings.d.ts +4 -0
- package/dist/macros/GetColor.d.ts +4 -0
- package/dist/macros/Marker.d.ts +4 -0
- package/dist/macros/Namespace.d.ts +16 -0
- package/dist/macros/Queries.d.ts +10 -0
- package/dist/macros/StringView.d.ts +4 -0
- package/dist/macros/commands/Effect.d.ts +4 -0
- package/dist/macros/commands/Format.d.ts +4 -0
- package/dist/macros/commands/LocalePrint.d.ts +4 -0
- package/dist/macros/commands/PlayMusic.d.ts +4 -0
- package/dist/macros/commands/PlaySound.d.ts +4 -0
- package/dist/macros/commands/PrintChar.d.ts +4 -0
- package/dist/macros/commands/Query.d.ts +4 -0
- package/dist/macros/commands/SetProp.d.ts +4 -0
- package/dist/macros/commands/SpawnBullet.d.ts +4 -0
- package/dist/macros/commands/Sync.d.ts +6 -0
- package/dist/macros/commands/UnpackColor.d.ts +4 -0
- package/dist/macros/commands/WeatherSense.d.ts +4 -0
- package/dist/macros/commands/WeatherSet.d.ts +4 -0
- package/dist/macros/commands/index.d.ts +13 -0
- package/dist/macros/index.d.ts +7 -1
- package/dist/macros/util.d.ts +5 -2
- package/dist/modules.d.ts +8 -0
- package/dist/operators.d.ts +1 -1
- package/dist/types.d.ts +84 -59
- package/dist/utils/constants.d.ts +9 -4
- package/dist/utils/general.d.ts +8 -9
- package/dist/utils/instruction.d.ts +5 -1
- package/dist/utils/value.d.ts +14 -5
- package/dist/values/AssignmentValue.d.ts +1 -1
- package/dist/values/BaseValue.d.ts +4 -2
- package/dist/values/DestructuringValue.d.ts +5 -7
- package/dist/values/FunctionValue.d.ts +8 -6
- package/dist/values/JumpOutValue.d.ts +4 -4
- package/dist/values/LazyValue.d.ts +3 -3
- package/dist/values/LiteralValue.d.ts +2 -3
- package/dist/values/ObjectValue.d.ts +6 -11
- package/dist/values/StoreValue.d.ts +10 -5
- package/dist/values/VoidValue.d.ts +2 -1
- package/dist/values/index.d.ts +0 -1
- package/lib/commands.d.ts +776 -730
- package/lib/eslib/lib.es2015.collection.d.ts +50 -39
- package/lib/eslib/lib.es2015.core.d.ts +59 -0
- package/lib/eslib/lib.es2015.d.ts +0 -3
- package/lib/eslib/lib.es2015.generator.d.ts +54 -53
- package/lib/eslib/lib.es2015.iterable.d.ts +9 -6
- package/lib/eslib/lib.es5.d.ts +53 -6
- package/lib/globals.d.ts +309 -18
- package/lib/helpers.d.ts +86 -52
- package/lib/kinds.d.ts +42 -7
- package/lib/macros.d.ts +53 -18
- package/lib/traits.d.ts +308 -146
- package/lib/util.d.ts +144 -48
- package/lib/world.d.ts +1197 -0
- package/package.json +27 -35
- package/dist/bin.cjs +0 -111
- package/dist/initScope.d.ts +0 -5
- package/dist/instructions/ZeroSpaceInstruction.d.ts +0 -4
- package/dist/values/SenseableValue.d.ts +0 -24
- /package/dist/{bin.d.ts → bin/index.d.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { InstructionBase } from ".";
|
|
2
|
-
import {
|
|
2
|
+
import { IScope, TLineRef } from "../types";
|
|
3
3
|
export declare class AddressResolver extends InstructionBase {
|
|
4
4
|
get hidden(): boolean;
|
|
5
5
|
set hidden(value: boolean);
|
|
6
|
-
bonds:
|
|
7
|
-
constructor(...bonds:
|
|
6
|
+
bonds: TLineRef[];
|
|
7
|
+
constructor(...bonds: TLineRef[]);
|
|
8
8
|
resolve(i: number): void;
|
|
9
|
-
bind(bond:
|
|
9
|
+
bind(bond: TLineRef): void;
|
|
10
10
|
bindBreak(scope: IScope): this;
|
|
11
11
|
bindContinue(scope: IScope): this;
|
|
12
12
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EInstIntent,
|
|
1
|
+
import { EInstIntent, TLineRef } from "../types";
|
|
2
2
|
import { JumpInstruction } from "./JumpInstruction";
|
|
3
3
|
export declare class BreakInstruction extends JumpInstruction {
|
|
4
4
|
intent: EInstIntent;
|
|
5
|
-
constructor(address:
|
|
5
|
+
constructor(address: TLineRef);
|
|
6
6
|
}
|
|
7
7
|
export declare class ContinueInstruction extends JumpInstruction {
|
|
8
8
|
intent: EInstIntent;
|
|
9
|
-
constructor(address:
|
|
9
|
+
constructor(address: TLineRef);
|
|
10
10
|
}
|
|
@@ -7,6 +7,7 @@ export declare class InstructionBase implements IInstruction {
|
|
|
7
7
|
protected _hidden: boolean;
|
|
8
8
|
get hidden(): boolean;
|
|
9
9
|
set hidden(value: boolean);
|
|
10
|
+
ignoredByParser: boolean;
|
|
10
11
|
args: (string | IValue | null)[];
|
|
11
12
|
source?: SourceLocation;
|
|
12
13
|
constructor(...args: (string | IValue | null)[]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IValue, TLineRef } from "../types";
|
|
2
2
|
import { JumpOutValue } from "../values/JumpOutValue";
|
|
3
3
|
import { InstructionBase } from "./InstructionBase";
|
|
4
4
|
export declare enum EJumpKind {
|
|
@@ -12,11 +12,11 @@ export declare enum EJumpKind {
|
|
|
12
12
|
Always = "always"
|
|
13
13
|
}
|
|
14
14
|
export declare class JumpInstruction extends InstructionBase {
|
|
15
|
-
address:
|
|
16
|
-
constructor(address:
|
|
15
|
+
address: TLineRef;
|
|
16
|
+
constructor(address: TLineRef, kind: EJumpKind, left?: IValue | null, right?: IValue | null);
|
|
17
17
|
/**
|
|
18
|
-
* Works with the `JumpOutValue` class to determine
|
|
19
|
-
*
|
|
18
|
+
* Works with the `JumpOutValue` class to determine whether a jump should be
|
|
19
|
+
* added if the expression wasn't jump compressed.
|
|
20
20
|
*/
|
|
21
21
|
static or(test: IValue, out: JumpOutValue): JumpInstruction[];
|
|
22
22
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
|
|
2
|
-
import { LiteralValue, ObjectValue,
|
|
2
|
+
import { LiteralValue, ObjectValue, StoreValue } from "../values";
|
|
3
3
|
import { MacroFunction } from "./Function";
|
|
4
4
|
export declare class DynamicArray extends ObjectValue {
|
|
5
5
|
scope: IScope;
|
|
6
6
|
name: string;
|
|
7
7
|
values: IValue[];
|
|
8
8
|
dynamic: boolean;
|
|
9
|
-
getterTemp:
|
|
10
|
-
setterTemp:
|
|
9
|
+
getterTemp: StoreValue;
|
|
10
|
+
setterTemp: StoreValue;
|
|
11
11
|
returnTemp: StoreValue;
|
|
12
12
|
getterAddr: LiteralValue<number | null>;
|
|
13
13
|
setterAddr: LiteralValue<number | null>;
|
|
@@ -26,7 +26,7 @@ export declare class DynamicArray extends ObjectValue {
|
|
|
26
26
|
initRemoveAt(): void;
|
|
27
27
|
initFill(): void;
|
|
28
28
|
debugString(): string;
|
|
29
|
-
|
|
29
|
+
toMlogString(): string;
|
|
30
30
|
}
|
|
31
31
|
export declare class DynamicArrayConstructor extends MacroFunction {
|
|
32
32
|
constructor(dynamic: boolean);
|
|
@@ -9,8 +9,8 @@ export declare class MacroFunction<RT extends IValue | null = IValue> extends Vo
|
|
|
9
9
|
constructor(fn: TFunction<RT>, paramOuts?: TEOutput[] | undefined);
|
|
10
10
|
call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions<RT>;
|
|
11
11
|
eval(_scope: IScope): TValueInstructions;
|
|
12
|
-
preCall(_scope: IScope, _out?: TEOutput
|
|
12
|
+
preCall(_scope: IScope, _out?: TEOutput): readonly TEOutput[] | undefined;
|
|
13
13
|
debugString(): string;
|
|
14
|
-
|
|
14
|
+
toMlogString(): string;
|
|
15
15
|
}
|
|
16
16
|
export {};
|
|
@@ -12,4 +12,20 @@ export declare class NamespaceMacro extends ObjectValue {
|
|
|
12
12
|
export declare class VarsNamespace extends NamespaceMacro {
|
|
13
13
|
constructor();
|
|
14
14
|
}
|
|
15
|
+
export declare class ColorsNamespace extends NamespaceMacro {
|
|
16
|
+
constructor();
|
|
17
|
+
get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions<IValue>;
|
|
18
|
+
}
|
|
19
|
+
export declare class SoundsNamespace extends NamespaceMacro {
|
|
20
|
+
constructor();
|
|
21
|
+
get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions<IValue>;
|
|
22
|
+
}
|
|
23
|
+
export declare class StatusEffectsNamespace extends NamespaceMacro {
|
|
24
|
+
constructor();
|
|
25
|
+
get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions<IValue>;
|
|
26
|
+
}
|
|
27
|
+
export declare class PVarsNamespace extends NamespaceMacro {
|
|
28
|
+
constructor();
|
|
29
|
+
get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions<IValue>;
|
|
30
|
+
}
|
|
15
31
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
|
|
2
|
+
import { ObjectValue, StoreValue } from "../values";
|
|
3
|
+
export declare class QueriesMacro extends ObjectValue {
|
|
4
|
+
queriesStore: StoreValue;
|
|
5
|
+
constructor();
|
|
6
|
+
get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions<IValue>;
|
|
7
|
+
hasProperty(scope: IScope, prop: IValue): boolean;
|
|
8
|
+
debugString(): string;
|
|
9
|
+
toMlogString(): string;
|
|
10
|
+
}
|
|
@@ -28,3 +28,16 @@ export * from "./SetRate";
|
|
|
28
28
|
export * from "./Fetch";
|
|
29
29
|
export * from "./GetFlag";
|
|
30
30
|
export * from "./SetFlag";
|
|
31
|
+
export * from "./SetProp";
|
|
32
|
+
export * from "./Sync";
|
|
33
|
+
export * from "./Effect";
|
|
34
|
+
export * from "./LocalePrint";
|
|
35
|
+
export * from "./WeatherSense";
|
|
36
|
+
export * from "./WeatherSet";
|
|
37
|
+
export * from "./PlaySound";
|
|
38
|
+
export * from "./PrintChar";
|
|
39
|
+
export * from "./UnpackColor";
|
|
40
|
+
export * from "./Format";
|
|
41
|
+
export * from "./Query";
|
|
42
|
+
export * from "./SpawnBullet";
|
|
43
|
+
export * from "./PlayMusic";
|
package/dist/macros/index.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ export * from "./Math";
|
|
|
3
3
|
export * from "./Other";
|
|
4
4
|
export * as commands from "./commands";
|
|
5
5
|
export * from "./Memory";
|
|
6
|
-
export { NamespaceMacro, VarsNamespace } from "./Namespace";
|
|
6
|
+
export { NamespaceMacro, VarsNamespace, StatusEffectsNamespace, PVarsNamespace, } from "./Namespace";
|
|
7
|
+
export * from "./Queries";
|
|
7
8
|
export * from "./DynamicArray";
|
|
8
9
|
export * from "./Unchecked";
|
|
10
|
+
export * from "./GetBuildings";
|
|
11
|
+
export * from "./GetGlobal";
|
|
12
|
+
export * from "./GetColor";
|
|
13
|
+
export * from "./Marker";
|
|
14
|
+
export * from "./StringView";
|
package/dist/macros/util.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ interface IOverloadNamespaceOptions<K extends string> {
|
|
|
10
10
|
named?: string;
|
|
11
11
|
args: (IParameterDescriptor | string)[];
|
|
12
12
|
}>;
|
|
13
|
-
handler(scope: IScope, overload: K, out: TEOutput | undefined, ...args: (IValue | string)[]): TValueInstructions<IValue | null>;
|
|
13
|
+
handler(this: void, scope: IScope, overload: K, out: TEOutput | undefined, ...args: (IValue | string)[]): TValueInstructions<IValue | null>;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Used to create namespaces that contain multiple methods that map into
|
|
17
|
+
* instructions
|
|
18
|
+
*/
|
|
16
19
|
export declare function createOverloadNamespace<K extends string>({ overloads, handler, }: IOverloadNamespaceOptions<K>): Record<string, MacroFunction<IValue | null>>;
|
|
17
20
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IScope } from "./types";
|
|
2
|
+
import { ObjectValue } from "./values";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the global scope of the user's script, contains all built-ins that
|
|
5
|
+
* are not privileged
|
|
6
|
+
*/
|
|
7
|
+
export declare function createGlobalScope(): IScope;
|
|
8
|
+
export declare function createWordModule(): ObjectValue;
|
package/dist/operators.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -2,32 +2,35 @@ export * as es from "@babel/types";
|
|
|
2
2
|
import * as es from "@babel/types";
|
|
3
3
|
import { Compiler } from "./Compiler";
|
|
4
4
|
import { AddressResolver } from "./instructions";
|
|
5
|
-
import { MacroFunction } from "./macros";
|
|
6
|
-
import { LeftRightOperator, UnaryOperator, UpdateOperator } from "./operators";
|
|
7
5
|
export declare enum EInstIntent {
|
|
8
6
|
none = 0,
|
|
9
7
|
break = 1,
|
|
10
8
|
continue = 2,
|
|
11
9
|
return = 3,
|
|
12
10
|
/**
|
|
13
|
-
* This is used by the `end` and `stop` instructions.
|
|
14
|
-
*
|
|
11
|
+
* This is used by the `end` and `stop` instructions. Means that the processor
|
|
12
|
+
* will restart or shutdown.
|
|
15
13
|
*/
|
|
16
14
|
exit = 4
|
|
17
15
|
}
|
|
18
16
|
export interface IInstruction {
|
|
19
17
|
intent: EInstIntent;
|
|
20
18
|
/**
|
|
21
|
-
* Used by function values to check if a return instruction
|
|
22
|
-
*
|
|
19
|
+
* Used by function values to check if a return instruction originates from
|
|
20
|
+
* them or other function.
|
|
23
21
|
*/
|
|
24
22
|
intentSource?: IValue;
|
|
25
23
|
hidden: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Used to identify pseudo instructions like single line comments and label
|
|
26
|
+
* declarations created in asm calls.
|
|
27
|
+
*/
|
|
28
|
+
ignoredByParser: boolean;
|
|
26
29
|
resolve(i: number): void;
|
|
27
30
|
source?: es.SourceLocation;
|
|
28
31
|
/**
|
|
29
|
-
* Helps analyzing control flow, handlers should
|
|
30
|
-
*
|
|
32
|
+
* Helps analyzing control flow, handlers should indicate which instructions
|
|
33
|
+
* returned are guaranteed to run
|
|
31
34
|
*/
|
|
32
35
|
alwaysRuns: boolean;
|
|
33
36
|
}
|
|
@@ -38,14 +41,14 @@ export interface IInstruction {
|
|
|
38
41
|
*
|
|
39
42
|
* A string means that the handler should create a value with the given name.
|
|
40
43
|
*
|
|
41
|
-
* An IValue means that the handler should try to use `this` as the output
|
|
44
|
+
* An IValue means that the handler should try to use `this` as the output
|
|
45
|
+
* value.
|
|
42
46
|
*/
|
|
43
47
|
export type TEOutput = IValue | string;
|
|
44
48
|
export type THandler<T extends IValue | null = IValue> = (compiler: Compiler, scope: IScope, node: any, out: TEOutput | undefined, arg: any) => TValueInstructions<T>;
|
|
45
49
|
/**
|
|
46
|
-
* The scope manages the source code generated variables and their owners,
|
|
47
|
-
*
|
|
48
|
-
* bodies.
|
|
50
|
+
* The scope manages the source code generated variables and their owners, as
|
|
51
|
+
* well as break and continue statements and they also work as function bodies.
|
|
49
52
|
*/
|
|
50
53
|
export interface IScope {
|
|
51
54
|
/** Every scope except the top level one has a parent */
|
|
@@ -54,8 +57,8 @@ export interface IScope {
|
|
|
54
57
|
data: Record<string, IValue | null>;
|
|
55
58
|
name: string;
|
|
56
59
|
/**
|
|
57
|
-
* Additional instructions required by this scope, such as
|
|
58
|
-
*
|
|
60
|
+
* Additional instructions required by this scope, such as the instructions
|
|
61
|
+
* that make the body of a function
|
|
59
62
|
*/
|
|
60
63
|
inst: IInstruction[];
|
|
61
64
|
/** The label applied to this scope */
|
|
@@ -64,31 +67,44 @@ export interface IScope {
|
|
|
64
67
|
break: AddressResolver;
|
|
65
68
|
/** Where to jump to on a continue statement */
|
|
66
69
|
continue: AddressResolver;
|
|
67
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The function linked to `this`, is `null` when the scope is not inside a
|
|
72
|
+
* function.
|
|
73
|
+
*/
|
|
68
74
|
function: IFunctionValue;
|
|
69
75
|
/** Counts the number of temp variables generated during compilaton */
|
|
70
76
|
ntemp: number;
|
|
71
77
|
/**
|
|
72
|
-
* A record of the cached value operations, maps the id
|
|
73
|
-
*
|
|
78
|
+
* A record of the cached value operations, maps the id of an operation to a
|
|
79
|
+
* previously computed value.
|
|
74
80
|
*/
|
|
75
81
|
operationCache: Record<string, IValue>;
|
|
76
82
|
/** Tracks the dependency relation beteween values and cached operations */
|
|
77
83
|
cacheDependencies: Record<string, string[]>;
|
|
78
84
|
/**
|
|
79
|
-
* Tells array macros whether to check index access performed.
|
|
80
|
-
*
|
|
85
|
+
* Tells array macros whether to check index access performed. This field is
|
|
86
|
+
* mutable.
|
|
81
87
|
*/
|
|
82
88
|
checkIndexes: boolean;
|
|
83
89
|
/**
|
|
84
|
-
*
|
|
90
|
+
* Maps mlogjs' built-in modules, such as `"mlogjs:world"`.
|
|
91
|
+
*
|
|
92
|
+
* This was put here because only the compiler object and scope are accessible
|
|
93
|
+
* to the ast node handlers, and it is more appropriate to put this in the
|
|
94
|
+
* scope rather than the compiler object.
|
|
85
95
|
*/
|
|
96
|
+
builtInModules: Record<string, IValue>;
|
|
97
|
+
/** Creates a new scope that has `this` as it's parent. */
|
|
86
98
|
createScope(): IScope;
|
|
87
99
|
/**
|
|
88
|
-
* Creates a new scope to be used by a function value, the scope has the
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* -
|
|
100
|
+
* Creates a new scope to be used by a function value, the scope has the
|
|
101
|
+
* following properties:
|
|
102
|
+
*
|
|
103
|
+
* - Uses `name` as it's primary name, it changes how variable names are
|
|
104
|
+
* formatted.
|
|
105
|
+
* - It has `this` as it's parent
|
|
106
|
+
* - Independent variable registry
|
|
107
|
+
*
|
|
92
108
|
* @param name The name of the scope
|
|
93
109
|
* @param stacked
|
|
94
110
|
*/
|
|
@@ -98,21 +114,25 @@ export interface IScope {
|
|
|
98
114
|
/** Gets a value by their owner's identifier */
|
|
99
115
|
get(identifier: string): INamedValue;
|
|
100
116
|
/**
|
|
101
|
-
* Registers `value` with an owner that uses `name` as both it's name and
|
|
102
|
-
* throws an error if there already is an owner with the same
|
|
117
|
+
* Registers `value` with an owner that uses `name` as both it's name and
|
|
118
|
+
* identifier, throws an error if there already is an owner with the same
|
|
119
|
+
* identitifer.
|
|
120
|
+
*
|
|
103
121
|
* @param name
|
|
104
122
|
* @param value
|
|
105
123
|
*/
|
|
106
124
|
set<T extends IValue>(name: string, value: T): T;
|
|
107
125
|
/**
|
|
108
|
-
* Registers `value` with an owner that uses `name` as both it's name and
|
|
109
|
-
* overriding any preexisting variables with the same identifier.
|
|
126
|
+
* Registers `value` with an owner that uses `name` as both it's name and
|
|
127
|
+
* identifier, overriding any preexisting variables with the same identifier.
|
|
128
|
+
*
|
|
110
129
|
* @param name
|
|
111
130
|
* @param value
|
|
112
131
|
*/
|
|
113
132
|
hardSet<T extends IValue>(name: string, value: T): T;
|
|
114
133
|
/**
|
|
115
134
|
* Creates an owned store and registers it to this scope.
|
|
135
|
+
*
|
|
116
136
|
* @param identifier The name of the variable that will hold the store
|
|
117
137
|
* @param name The mlog name that the owner will have
|
|
118
138
|
*/
|
|
@@ -120,8 +140,9 @@ export interface IScope {
|
|
|
120
140
|
/**
|
|
121
141
|
* Creates a shallow copy of this scope.
|
|
122
142
|
*
|
|
123
|
-
* Be aware that since the copy is shallow, changes on object fields (except
|
|
124
|
-
* reflect on the original scope. Note that changes to the children of
|
|
143
|
+
* Be aware that since the copy is shallow, changes on object fields (except
|
|
144
|
+
* `data`) reflect on the original scope. Note that changes to the children of
|
|
145
|
+
* data also follow this rule.
|
|
125
146
|
*/
|
|
126
147
|
copy(): IScope;
|
|
127
148
|
/** Creates a temporary mlog variable name */
|
|
@@ -141,9 +162,9 @@ export interface IValueOperators {
|
|
|
141
162
|
"!"(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
142
163
|
"u+"(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
143
164
|
"u-"(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
165
|
+
delete(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
166
|
+
typeof(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
167
|
+
void(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
147
168
|
"~"(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
148
169
|
"++"(scope: IScope, prefix: boolean, out?: TEOutput): TValueInstructions;
|
|
149
170
|
"--"(scope: IScope, prefix: boolean, out?: TEOutput): TValueInstructions;
|
|
@@ -169,9 +190,9 @@ export interface IValueOperators {
|
|
|
169
190
|
"|"(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
170
191
|
instanceof(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
171
192
|
in(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
172
|
-
"&&"(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
173
|
-
"??"(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
174
|
-
"||"(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
193
|
+
"&&"(scope: IScope, value: IValue, out?: TEOutput, endAddress?: TLineRef): TValueInstructions;
|
|
194
|
+
"??"(scope: IScope, value: IValue, out?: TEOutput, endAddress?: TLineRef): TValueInstructions;
|
|
195
|
+
"||"(scope: IScope, value: IValue, out?: TEOutput, endAddress?: TLineRef): TValueInstructions;
|
|
175
196
|
"%="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
176
197
|
"&="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
177
198
|
"*="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
|
|
@@ -191,54 +212,56 @@ export interface IValueOperators {
|
|
|
191
212
|
}
|
|
192
213
|
/** Defines the possible types of mutability of a value */
|
|
193
214
|
export declare enum EMutability {
|
|
194
|
-
/**
|
|
195
|
-
* The value can be changed by the user's code,
|
|
196
|
-
* by the mlog runtime, or us
|
|
197
|
-
*/
|
|
215
|
+
/** The value can be changed by the user's code, by the mlog runtime, or us */
|
|
198
216
|
mutable = 0,
|
|
199
217
|
/**
|
|
200
|
-
* The value cannot be directly assigned,
|
|
201
|
-
*
|
|
218
|
+
* The value cannot be directly assigned, but it's still not safe from
|
|
219
|
+
* mutations coming from the runtime.
|
|
202
220
|
*/
|
|
203
221
|
readonly = 1,
|
|
204
|
-
/**
|
|
222
|
+
/** Compile-time constants. */
|
|
205
223
|
constant = 2,
|
|
206
224
|
/** An immutable value that hasn't been initialized yet */
|
|
207
|
-
init = 3
|
|
225
|
+
init = 3,
|
|
226
|
+
/** A value unknown at compile-time that will not change after initialization */
|
|
227
|
+
immutable = 4
|
|
208
228
|
}
|
|
209
229
|
export interface IValue extends IValueOperators {
|
|
210
230
|
/** The name is used by values that exist on some form in the runtime */
|
|
211
231
|
name?: string;
|
|
212
232
|
mutability: EMutability;
|
|
213
233
|
macro: boolean;
|
|
234
|
+
/** Used by the operation cache to know if an operation can be safely cached. */
|
|
235
|
+
volatile: boolean;
|
|
214
236
|
/**
|
|
215
|
-
* Evaluates `this`, returning it's representation in a more basic
|
|
216
|
-
*
|
|
237
|
+
* Evaluates `this`, returning it's representation in a more basic value like
|
|
238
|
+
* `StoreValue` with the instructions required to compute that value
|
|
217
239
|
*/
|
|
218
240
|
eval(scope: IScope, out?: TEOutput): TValueInstructions;
|
|
219
241
|
call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions<IValue | null>;
|
|
220
242
|
get(scope: IScope, name: IValue, out?: TEOutput): TValueInstructions;
|
|
221
243
|
/**
|
|
222
|
-
* Wether `this` has a given property.
|
|
223
|
-
*
|
|
224
|
-
* field of an object without errors.
|
|
244
|
+
* Wether `this` has a given property. This method is used to know if it's
|
|
245
|
+
* safe to get a field of an object without errors.
|
|
225
246
|
*/
|
|
226
247
|
hasProperty(scope: IScope, prop: IValue): boolean;
|
|
227
248
|
/**
|
|
228
|
-
* A hook that the CallExpression and related handlers call
|
|
229
|
-
*
|
|
249
|
+
* A hook that the CallExpression and related handlers call before evaluating
|
|
250
|
+
* the function parameters.
|
|
230
251
|
*/
|
|
231
252
|
preCall(scope: IScope, out?: TEOutput): readonly TEOutput[] | undefined;
|
|
232
253
|
/**
|
|
233
|
-
* A hook that the CallExpression and related handlers call
|
|
234
|
-
*
|
|
254
|
+
* A hook that the CallExpression and related handlers call after the call has
|
|
255
|
+
* been evaluated.
|
|
235
256
|
*/
|
|
236
257
|
postCall(scope: IScope): void;
|
|
237
258
|
/** The string representation of `this` in error messages. */
|
|
238
259
|
debugString(): string;
|
|
260
|
+
/** The string representation of `this` in the generated mlog code. */
|
|
261
|
+
toMlogString(): string;
|
|
239
262
|
/**
|
|
240
|
-
* Allows some values to choose alternative representations
|
|
241
|
-
*
|
|
263
|
+
* Allows some values to choose alternative representations when they are used
|
|
264
|
+
* as operation outputs.
|
|
242
265
|
*/
|
|
243
266
|
toOut(): IValue;
|
|
244
267
|
}
|
|
@@ -250,6 +273,12 @@ export type TLiteral = string | number;
|
|
|
250
273
|
export interface IBindableValue<T extends TLiteral | null = TLiteral> extends IValue {
|
|
251
274
|
data: T;
|
|
252
275
|
}
|
|
276
|
+
export type TLineRef = IBindableValue<number | null>;
|
|
277
|
+
export declare enum EInlineType {
|
|
278
|
+
auto = 0,
|
|
279
|
+
always = 1,
|
|
280
|
+
never = 2
|
|
281
|
+
}
|
|
253
282
|
export interface IFunctionValue extends IValue {
|
|
254
283
|
return(scope: IScope, argument: IValue | null, out?: TEOutput): TValueInstructions<IValue | null>;
|
|
255
284
|
}
|
|
@@ -258,7 +287,3 @@ export type TValueInstructions<Content extends IValue | null = IValue> = [
|
|
|
258
287
|
Content,
|
|
259
288
|
IInstruction[]
|
|
260
289
|
];
|
|
261
|
-
/** Map of overridable operators in object macros */
|
|
262
|
-
export type TOperatorMacroMap = {
|
|
263
|
-
[K in UnaryOperator | UpdateOperator | LeftRightOperator as `$${K}`]?: MacroFunction;
|
|
264
|
-
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The prefix for internal variables inside the compiler output
|
|
3
|
-
*/
|
|
1
|
+
/** The prefix for internal variables inside the compiler output */
|
|
4
2
|
export declare const internalPrefix = "&";
|
|
5
|
-
export declare const discardedName
|
|
3
|
+
export declare const discardedName = "&_";
|
|
6
4
|
export declare const itemNames: string[];
|
|
7
5
|
/** The name of a special processor variable, controls the instruction pointer */
|
|
8
6
|
export declare const counterName = "@counter";
|
|
7
|
+
export declare const worldModuleName = "mlogjs:world";
|
|
8
|
+
export declare const mathConstants: {
|
|
9
|
+
E: number;
|
|
10
|
+
PI: number;
|
|
11
|
+
radToDeg: number;
|
|
12
|
+
degToRad: number;
|
|
13
|
+
};
|