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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/{index.cjs → Compiler-7GMG4MDr.js} +1746 -452
  3. package/dist/Compiler.d.ts +8 -12
  4. package/dist/CompilerError.d.ts +13 -3
  5. package/dist/Scope.d.ts +8 -8
  6. package/dist/bin/files.d.ts +18 -0
  7. package/dist/bin.mjs +170 -0
  8. package/dist/handlers/Import.d.ts +5 -0
  9. package/dist/handlers/Literal.d.ts +2 -2
  10. package/dist/handlers/Typescript.d.ts +2 -2
  11. package/dist/handlers/index.d.ts +1 -0
  12. package/dist/index.mjs +3 -4267
  13. package/dist/instructions/AddressResolver.d.ts +4 -4
  14. package/dist/instructions/ControlInstructions.d.ts +3 -3
  15. package/dist/instructions/InstructionBase.d.ts +1 -0
  16. package/dist/instructions/JumpInstruction.d.ts +5 -5
  17. package/dist/instructions/index.d.ts +0 -1
  18. package/dist/macros/DynamicArray.d.ts +4 -4
  19. package/dist/macros/Function.d.ts +2 -2
  20. package/dist/macros/GetBuildings.d.ts +4 -0
  21. package/dist/macros/GetColor.d.ts +4 -0
  22. package/dist/macros/Marker.d.ts +4 -0
  23. package/dist/macros/Namespace.d.ts +16 -0
  24. package/dist/macros/Queries.d.ts +10 -0
  25. package/dist/macros/StringView.d.ts +4 -0
  26. package/dist/macros/commands/Effect.d.ts +4 -0
  27. package/dist/macros/commands/Format.d.ts +4 -0
  28. package/dist/macros/commands/LocalePrint.d.ts +4 -0
  29. package/dist/macros/commands/PlayMusic.d.ts +4 -0
  30. package/dist/macros/commands/PlaySound.d.ts +4 -0
  31. package/dist/macros/commands/PrintChar.d.ts +4 -0
  32. package/dist/macros/commands/Query.d.ts +4 -0
  33. package/dist/macros/commands/SetProp.d.ts +4 -0
  34. package/dist/macros/commands/SpawnBullet.d.ts +4 -0
  35. package/dist/macros/commands/Sync.d.ts +6 -0
  36. package/dist/macros/commands/UnpackColor.d.ts +4 -0
  37. package/dist/macros/commands/WeatherSense.d.ts +4 -0
  38. package/dist/macros/commands/WeatherSet.d.ts +4 -0
  39. package/dist/macros/commands/index.d.ts +13 -0
  40. package/dist/macros/index.d.ts +7 -1
  41. package/dist/macros/util.d.ts +5 -2
  42. package/dist/modules.d.ts +8 -0
  43. package/dist/operators.d.ts +1 -1
  44. package/dist/types.d.ts +84 -59
  45. package/dist/utils/constants.d.ts +9 -4
  46. package/dist/utils/general.d.ts +8 -9
  47. package/dist/utils/instruction.d.ts +5 -1
  48. package/dist/utils/value.d.ts +14 -5
  49. package/dist/values/AssignmentValue.d.ts +1 -1
  50. package/dist/values/BaseValue.d.ts +4 -2
  51. package/dist/values/DestructuringValue.d.ts +5 -7
  52. package/dist/values/FunctionValue.d.ts +8 -6
  53. package/dist/values/JumpOutValue.d.ts +4 -4
  54. package/dist/values/LazyValue.d.ts +3 -3
  55. package/dist/values/LiteralValue.d.ts +2 -3
  56. package/dist/values/ObjectValue.d.ts +6 -11
  57. package/dist/values/StoreValue.d.ts +10 -5
  58. package/dist/values/VoidValue.d.ts +2 -1
  59. package/dist/values/index.d.ts +0 -1
  60. package/lib/commands.d.ts +776 -730
  61. package/lib/eslib/lib.es2015.collection.d.ts +50 -39
  62. package/lib/eslib/lib.es2015.core.d.ts +59 -0
  63. package/lib/eslib/lib.es2015.d.ts +0 -3
  64. package/lib/eslib/lib.es2015.generator.d.ts +54 -53
  65. package/lib/eslib/lib.es2015.iterable.d.ts +9 -6
  66. package/lib/eslib/lib.es5.d.ts +53 -6
  67. package/lib/globals.d.ts +309 -18
  68. package/lib/helpers.d.ts +86 -52
  69. package/lib/kinds.d.ts +42 -7
  70. package/lib/macros.d.ts +53 -18
  71. package/lib/traits.d.ts +308 -146
  72. package/lib/util.d.ts +144 -48
  73. package/lib/world.d.ts +1197 -0
  74. package/package.json +27 -35
  75. package/dist/bin.cjs +0 -111
  76. package/dist/initScope.d.ts +0 -5
  77. package/dist/instructions/ZeroSpaceInstruction.d.ts +0 -4
  78. package/dist/values/SenseableValue.d.ts +0 -24
  79. /package/dist/{bin.d.ts → bin/index.d.ts} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { InstructionBase } from ".";
2
- import { IBindableValue, IScope } from "../types";
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: IBindableValue<number | null>[];
7
- constructor(...bonds: IBindableValue<number | null>[]);
6
+ bonds: TLineRef[];
7
+ constructor(...bonds: TLineRef[]);
8
8
  resolve(i: number): void;
9
- bind(bond: IBindableValue<number | null>): void;
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, IBindableValue } from "../types";
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: IBindableValue<number | null>);
5
+ constructor(address: TLineRef);
6
6
  }
7
7
  export declare class ContinueInstruction extends JumpInstruction {
8
8
  intent: EInstIntent;
9
- constructor(address: IBindableValue<number | null>);
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 { IBindableValue, IValue } from "../types";
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: IBindableValue<number | null>;
16
- constructor(address: IBindableValue<number | null>, kind: EJumpKind, left?: IValue | null, right?: IValue | null);
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
- * wether a jump should be added if the expression wasn't jump compressed.
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
  }
@@ -5,5 +5,4 @@ export * from "./EndInstruction";
5
5
  export * from "./AddressResolver";
6
6
  export * from "./JumpInstruction";
7
7
  export * from "./SetCounterInstruction";
8
- export * from "./ZeroSpaceInstruction";
9
8
  export * from "./ControlInstructions";
@@ -1,13 +1,13 @@
1
1
  import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
2
- import { LiteralValue, ObjectValue, SenseableValue, StoreValue } from "../values";
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: SenseableValue;
10
- setterTemp: SenseableValue;
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
- toString(): string;
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 | undefined): readonly TEOutput[] | undefined;
12
+ preCall(_scope: IScope, _out?: TEOutput): readonly TEOutput[] | undefined;
13
13
  debugString(): string;
14
- toString(): string;
14
+ toMlogString(): string;
15
15
  }
16
16
  export {};
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "./Function";
2
+ export declare class GetBuildings extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "./Function";
2
+ export declare class GetColor extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ObjectValue } from "../values";
2
+ export declare class MarkerConstructor extends ObjectValue {
3
+ constructor();
4
+ }
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "./Function";
2
+ export declare class StringViewBuilder extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ObjectValue } from "../../values";
2
+ export declare class Effect extends ObjectValue {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class Format extends MacroFunction<null> {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class LocalePrint extends MacroFunction<null> {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class PlayMusic extends MacroFunction<null> {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ObjectValue } from "../../values";
2
+ export declare class PlaySound extends ObjectValue {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "..";
2
+ export declare class PrintChar extends MacroFunction<null> {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ObjectValue } from "../../values";
2
+ export declare class Query extends ObjectValue {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class SetProp extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class SpawnBullet extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,6 @@
1
+ import { IScope, TEOutput } from "../../types";
2
+ import { MacroFunction } from "../Function";
3
+ export declare class SyncLockConstructor extends MacroFunction {
4
+ constructor();
5
+ preCall(scope: IScope, out?: TEOutput): readonly TEOutput[] | undefined;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class UnpackColor extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class WeatherSense extends MacroFunction {
3
+ constructor();
4
+ }
@@ -0,0 +1,4 @@
1
+ import { MacroFunction } from "../Function";
2
+ export declare class WeatherSet extends MacroFunction<null> {
3
+ constructor();
4
+ }
@@ -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";
@@ -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";
@@ -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
- /** Used to create namespaces that contain multiple methods that map into instructions */
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;
@@ -38,7 +38,7 @@ export declare const operatorMap: {
38
38
  readonly "&": "and";
39
39
  readonly "^": "xor";
40
40
  readonly ">>": "shr";
41
- readonly ">>>": "shr";
41
+ readonly ">>>": "ushr";
42
42
  readonly "<<": "shl";
43
43
  readonly "&&": "land";
44
44
  readonly "||": "or";
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
- * Means that the processor will restart or shutdown.
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
- * originates from them or other function.
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
- * indicate which instructions returned are guaranteed to run
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 value.
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
- * as well as break and continue statements and they also work as function
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
- * the instructions that make the body of a function
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
- /** The function linked to `this`, is `null` when the scope is not inside a function. */
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
- * of an operation to a previously computed value.
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
- * This field is mutable.
85
+ * Tells array macros whether to check index access performed. This field is
86
+ * mutable.
81
87
  */
82
88
  checkIndexes: boolean;
83
89
  /**
84
- * Creates a new scope that has `this` as it's parent.
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 following properties:
89
- * - uses `name` as it's primary name, it changes how variable names are formatted.
90
- * - it has `this` as it's parent
91
- * - independent variable registry
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 identifier,
102
- * throws an error if there already is an owner with the same identitifer.
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 identifier,
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 `data`)
124
- * reflect on the original scope. Note that changes to the children of data also follow this rule.
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
- "delete"(scope: IScope, out?: TEOutput): TValueInstructions;
145
- "typeof"(scope: IScope, out?: TEOutput): TValueInstructions;
146
- "void"(scope: IScope, out?: TEOutput): TValueInstructions;
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
- * but it's still not safe from mutations coming from the runtime.
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
- /** Constant values, won't change during execution */
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
- * value like `StoreValue` with the instructions required to compute that value
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
- * This method is used to know if it's safe to get a
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
- * before evaluating the function parameters.
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
- * after the call has been evaluated.
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
- * when they are used as operation outputs.
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: string;
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
+ };