mlogjs 0.4.10 → 0.5.1

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 (114) hide show
  1. package/README.md +15 -11
  2. package/dist/Compiler.d.ts +40 -38
  3. package/dist/CompilerError.d.ts +33 -33
  4. package/dist/Scope.d.ts +31 -30
  5. package/dist/bin.cjs +99 -58
  6. package/dist/bin.d.ts +1 -1
  7. package/dist/handlers/BlockStatement.d.ts +2 -2
  8. package/dist/handlers/CallExpression.d.ts +4 -4
  9. package/dist/handlers/File.d.ts +2 -2
  10. package/dist/handlers/ForStatement.d.ts +2 -2
  11. package/dist/handlers/Function.d.ts +5 -5
  12. package/dist/handlers/Identifier.d.ts +2 -2
  13. package/dist/handlers/IfStatement.d.ts +2 -2
  14. package/dist/handlers/Literal.d.ts +5 -5
  15. package/dist/handlers/Object.d.ts +8 -7
  16. package/dist/handlers/OperationExpressions.d.ts +9 -9
  17. package/dist/handlers/Program.d.ts +2 -2
  18. package/dist/handlers/Statements.d.ts +7 -7
  19. package/dist/handlers/SwitchStatement.d.ts +2 -2
  20. package/dist/handlers/TemplateExpression.d.ts +2 -2
  21. package/dist/handlers/Typescript.d.ts +8 -7
  22. package/dist/handlers/VariableDeclaration.d.ts +3 -3
  23. package/dist/handlers/WhileStatement.d.ts +3 -3
  24. package/dist/handlers/index.d.ts +17 -17
  25. package/dist/index.cjs +4213 -3261
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.mjs +4209 -3257
  28. package/dist/initScope.d.ts +5 -5
  29. package/dist/instructions/AddressResolver.d.ts +12 -12
  30. package/dist/instructions/ControlInstructions.d.ts +10 -10
  31. package/dist/instructions/EndInstruction.d.ts +6 -4
  32. package/dist/instructions/InstructionBase.d.ts +15 -15
  33. package/dist/instructions/JumpInstruction.d.ts +22 -16
  34. package/dist/instructions/OperationInstruction.d.ts +5 -5
  35. package/dist/instructions/SetCounterInstruction.d.ts +5 -5
  36. package/dist/instructions/SetInstruction.d.ts +8 -8
  37. package/dist/instructions/ZeroSpaceInstruction.d.ts +4 -4
  38. package/dist/instructions/index.d.ts +9 -9
  39. package/dist/macros/Asm.d.ts +4 -4
  40. package/dist/macros/DynamicArray.d.ts +33 -23
  41. package/dist/macros/Function.d.ts +16 -12
  42. package/dist/macros/GetGlobal.d.ts +5 -5
  43. package/dist/macros/Math.d.ts +4 -4
  44. package/dist/macros/Memory.d.ts +4 -4
  45. package/dist/macros/Namespace.d.ts +15 -12
  46. package/dist/macros/Other.d.ts +4 -4
  47. package/dist/macros/Unchecked.d.ts +7 -7
  48. package/dist/macros/commands/ApplyStatus.d.ts +4 -4
  49. package/dist/macros/commands/Control.d.ts +4 -4
  50. package/dist/macros/commands/Cutscene.d.ts +4 -4
  51. package/dist/macros/commands/Draw.d.ts +4 -4
  52. package/dist/macros/commands/DrawFlush.d.ts +4 -4
  53. package/dist/macros/commands/End.d.ts +4 -4
  54. package/dist/macros/commands/Explosion.d.ts +4 -4
  55. package/dist/macros/commands/Fetch.d.ts +4 -4
  56. package/dist/macros/commands/FlushMessage.d.ts +4 -4
  57. package/dist/macros/commands/GetBlock.d.ts +4 -4
  58. package/dist/macros/commands/GetFlag.d.ts +4 -4
  59. package/dist/macros/commands/GetLink.d.ts +4 -4
  60. package/dist/macros/commands/Lookup.d.ts +4 -4
  61. package/dist/macros/commands/PackColor.d.ts +4 -4
  62. package/dist/macros/commands/Print.d.ts +4 -4
  63. package/dist/macros/commands/PrintFlush.d.ts +4 -4
  64. package/dist/macros/commands/Radar.d.ts +6 -6
  65. package/dist/macros/commands/Sensor.d.ts +4 -4
  66. package/dist/macros/commands/SetBlock.d.ts +4 -4
  67. package/dist/macros/commands/SetFlag.d.ts +4 -4
  68. package/dist/macros/commands/SetRate.d.ts +4 -4
  69. package/dist/macros/commands/SetRule.d.ts +4 -4
  70. package/dist/macros/commands/SpawnUnit.d.ts +4 -4
  71. package/dist/macros/commands/SpawnWave.d.ts +4 -4
  72. package/dist/macros/commands/Stop.d.ts +4 -4
  73. package/dist/macros/commands/UnitBind.d.ts +4 -4
  74. package/dist/macros/commands/UnitControl.d.ts +4 -4
  75. package/dist/macros/commands/UnitLocate.d.ts +4 -4
  76. package/dist/macros/commands/UnitRadar.d.ts +4 -4
  77. package/dist/macros/commands/Wait.d.ts +4 -4
  78. package/dist/macros/commands/index.d.ts +30 -30
  79. package/dist/macros/index.d.ts +8 -6
  80. package/dist/macros/util.d.ts +17 -17
  81. package/dist/operators.d.ts +46 -26
  82. package/dist/types.d.ts +264 -237
  83. package/dist/utils/constants.d.ts +8 -6
  84. package/dist/utils/general.d.ts +26 -26
  85. package/dist/utils/index.d.ts +4 -4
  86. package/dist/utils/instruction.d.ts +9 -5
  87. package/dist/utils/value.d.ts +41 -36
  88. package/dist/values/AssignmentValue.d.ts +11 -0
  89. package/dist/values/BaseValue.d.ts +10 -10
  90. package/dist/values/DestructuringValue.d.ts +32 -30
  91. package/dist/values/FunctionValue.d.ts +57 -50
  92. package/dist/values/JumpOutValue.d.ts +36 -0
  93. package/dist/values/LazyValue.d.ts +11 -9
  94. package/dist/values/LiteralValue.d.ts +18 -14
  95. package/dist/values/ObjectValue.d.ts +23 -20
  96. package/dist/values/SenseableValue.d.ts +24 -24
  97. package/dist/values/StoreValue.d.ts +22 -21
  98. package/dist/values/VoidValue.d.ts +17 -13
  99. package/dist/values/index.d.ts +9 -8
  100. package/lib/commands.d.ts +59 -32
  101. package/lib/eslib/lib.es5.d.ts +36 -0
  102. package/lib/globals.d.ts +5 -5
  103. package/lib/helpers.d.ts +18 -2
  104. package/lib/index.d.ts +1 -1
  105. package/lib/macros.d.ts +150 -0
  106. package/lib/traits.d.ts +5 -5
  107. package/package.json +31 -27
  108. package/dist/assertions.d.ts +0 -28
  109. package/dist/bin.cjs.map +0 -1
  110. package/dist/discardedName.d.ts +0 -5
  111. package/dist/index.cjs.map +0 -1
  112. package/dist/index.mjs.map +0 -1
  113. package/dist/utils.d.ts +0 -45
  114. package/lib/memory.d.ts +0 -17
@@ -1,36 +1,41 @@
1
- import { IValue, TEOutput } from "../types";
2
- import { IObjectValueData, LiteralValue, ObjectValue, StoreValue } from "../values";
3
- export declare function isTemplateObjectArray(value: IValue): value is ObjectValue & {
4
- data: IObjectValueData & {
5
- raw: ObjectValue & {
6
- data: IObjectValueData & {
7
- length: LiteralValue<number>;
8
- };
9
- };
10
- length: LiteralValue<number>;
11
- };
12
- };
13
- export declare function extractOutName(out: TEOutput | undefined): string | undefined;
14
- export declare function extractDestrucuringOut(out: TEOutput | undefined, field: string | number): string | IValue | undefined;
15
- /** Asserts that `value` is a `LiteralValue` that contains a string */
16
- export declare function assertStringLiteral(value: IValue | undefined, name: string): asserts value is LiteralValue<string>;
17
- /** Asserts that `value` is a string literal that is part of a given set of `members`*/
18
- export declare function assertLiteralOneOf<T extends readonly string[]>(value: IValue | undefined, members: T, name: string): asserts value is LiteralValue<T[number]>;
19
- /** Asserts that `value` is either a store or a literal */
20
- export declare function assertIsRuntimeValue(value: IValue | undefined, name: string): asserts value is LiteralValue | StoreValue;
21
- /** Asserts that `value` is an `ObjectValue` */
22
- export declare function assertIsObjectMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
23
- /** Asserts that `value` is an `ObjectValue` that has a length property */
24
- export declare function assertIsArrayMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
25
- /** Helper type used to describe the overloads of a macro function. See {@link assertObjectFields} */
26
- export type TOverloadDescriptor<K extends string> = Record<K, (string | IParameterDescriptor)[]>;
27
- /** Describes an object destructuring paremeter. Generally used with `assertObjectFields` */
28
- export interface IParameterDescriptor {
29
- key: string;
30
- name?: string;
31
- default?: string;
32
- /** Throw an error on invalid values */
33
- validate?(value: IValue): void;
34
- }
35
- /** Asserts that all of the fields described are present on `value`*/
36
- export declare function assertObjectFields(value: ObjectValue, fields: (string | IParameterDescriptor)[]): (IValue | string)[];
1
+ import { IValue, TEOutput } from "../types";
2
+ import { IObjectValueData, LiteralValue, ObjectValue, StoreValue } from "../values";
3
+ export declare function isTemplateObjectArray(value: IValue): value is ObjectValue & {
4
+ data: IObjectValueData & {
5
+ raw: ObjectValue & {
6
+ data: IObjectValueData & {
7
+ length: LiteralValue<number>;
8
+ };
9
+ };
10
+ length: LiteralValue<number>;
11
+ };
12
+ };
13
+ export declare function extractOutName(out: TEOutput | undefined): string | undefined;
14
+ export declare function extractDestrucuringOut(out: TEOutput | undefined, field: string | number): string | IValue | undefined;
15
+ /** Asserts that `value` is a `LiteralValue` that contains a string */
16
+ export declare function assertStringLiteral(value: IValue | undefined, name: string): asserts value is LiteralValue<string>;
17
+ /** Asserts that `value` is a string literal that is part of a given set of `members`*/
18
+ export declare function assertLiteralOneOf<T extends readonly string[]>(value: IValue | undefined, members: T, name: string): asserts value is LiteralValue<T[number]>;
19
+ /** Asserts that `value` is either a store or a literal */
20
+ export declare function assertIsRuntimeValue(value: IValue | undefined, name: string): asserts value is LiteralValue | StoreValue;
21
+ /** Asserts that `value` is an `ObjectValue` */
22
+ export declare function assertIsObjectMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
23
+ /** Asserts that `value` is an `ObjectValue` that has a length property */
24
+ export declare function assertIsArrayMacro(value: IValue | undefined, name: string): asserts value is ObjectValue & {
25
+ data: {
26
+ length: LiteralValue<number>;
27
+ };
28
+ };
29
+ /** Helper type used to describe the overloads of a macro function. See {@link assertObjectFields} */
30
+ export type TOverloadDescriptor<K extends string> = Record<K, (string | IParameterDescriptor)[]>;
31
+ /** Describes an object destructuring paremeter. Generally used with `assertObjectFields` */
32
+ export interface IParameterDescriptor {
33
+ key: string;
34
+ name?: string;
35
+ default?: string;
36
+ /** Throw an error on invalid values */
37
+ validate?(value: IValue): void;
38
+ }
39
+ /** Asserts that all of the fields described are present on `value`*/
40
+ export declare function assertObjectFields(value: ObjectValue, fields: (string | IParameterDescriptor)[]): (IValue | string)[];
41
+ export declare function isDiscardedOut(out: TEOutput | undefined): boolean;
@@ -0,0 +1,11 @@
1
+ import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
2
+ import { VoidValue } from "./VoidValue";
3
+ export declare class AssignmentValue extends VoidValue {
4
+ left: IValue;
5
+ right: IValue;
6
+ constructor(left: IValue, right: IValue);
7
+ "="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
8
+ toOut(): IValue;
9
+ debugString(): string;
10
+ toString(): string;
11
+ }
@@ -1,10 +1,10 @@
1
- import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
2
- import { VoidValue } from ".";
3
- export declare class BaseValue extends VoidValue implements IValue {
4
- "u-"(scope: IScope, out?: TEOutput): TValueInstructions;
5
- "u+"(scope: IScope, out?: TEOutput): TValueInstructions;
6
- "!"(scope: IScope, out?: TEOutput): TValueInstructions;
7
- "~"(scope: IScope, out?: TEOutput): TValueInstructions;
8
- "??"(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
9
- "!=="(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
10
- }
1
+ import { IScope, IValue, TEOutput, TValueInstructions } from "../types";
2
+ import { VoidValue } from ".";
3
+ export declare class BaseValue extends VoidValue implements IValue {
4
+ "u-"(scope: IScope, out?: TEOutput): TValueInstructions;
5
+ "u+"(scope: IScope, out?: TEOutput): TValueInstructions;
6
+ "!"(scope: IScope, out?: TEOutput): TValueInstructions;
7
+ "~"(scope: IScope, out?: TEOutput): TValueInstructions;
8
+ "??"(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
9
+ "!=="(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
10
+ }
@@ -1,30 +1,32 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- import { VoidValue } from "./VoidValue";
3
- export type TDestructuringMembers = Map<IValue, {
4
- value: IValue;
5
- /**
6
- * Handles the input value, is responsible for the assignment.
7
- */
8
- handler(get: () => TValueInstructions): TValueInstructions<IValue | null>;
9
- }>;
10
- /**
11
- * Specific case class, required on the ArrayPattern and ObjectPattern handlers
12
- * in order to keep the separation of concerns and make the code more modular.
13
- *
14
- * When it is assign a value, it will get it's own properties and recursively assign
15
- * each of them to their counterparts on the right hand value.
16
- */
17
- export declare class DestructuringValue extends VoidValue {
18
- members: TDestructuringMembers;
19
- macro: boolean;
20
- /**
21
- * Contains the keys that are constant strings with their respective values.
22
- *
23
- * This is used by some macros to avoid creating unecessary temporary values
24
- * if the output value is a destructuring value.
25
- */
26
- fields: Record<string, IValue>;
27
- constructor(members: TDestructuringMembers);
28
- "="(scope: IScope, right: IValue): TValueInstructions;
29
- eval(_scope: IScope): TValueInstructions<IValue>;
30
- }
1
+ import { IScope, IValue, TValueInstructions } from "../types";
2
+ import { VoidValue } from "./VoidValue";
3
+ export type TDestructuringMembers = Map<IValue, {
4
+ value: IValue;
5
+ /**
6
+ * Handles the input value, is responsible for the assignment.
7
+ */
8
+ handler(get: () => TValueInstructions, propExists: () => boolean, scope: IScope): TValueInstructions<IValue | null>;
9
+ }>;
10
+ /**
11
+ * Specific case class, required on the ArrayPattern and ObjectPattern handlers
12
+ * in order to keep the separation of concerns and make the code more modular.
13
+ *
14
+ * When it is assign a value, it will get it's own properties and recursively assign
15
+ * each of them to their counterparts on the right hand value.
16
+ */
17
+ export declare class DestructuringValue extends VoidValue {
18
+ members: TDestructuringMembers;
19
+ macro: boolean;
20
+ /**
21
+ * Contains the keys that are constant strings with their respective values.
22
+ *
23
+ * This is used by some macros to avoid creating unecessary temporary values
24
+ * if the output value is a destructuring value.
25
+ */
26
+ fields: Record<string, IValue>;
27
+ constructor(members: TDestructuringMembers);
28
+ "="(scope: IScope, right: IValue): TValueInstructions;
29
+ eval(_scope: IScope): TValueInstructions<IValue>;
30
+ debugString(): string;
31
+ toString(): string;
32
+ }
@@ -1,50 +1,57 @@
1
- import { Compiler } from "../Compiler";
2
- import { EMutability, es, IFunctionValue, IScope, IValue, TEOutput, TValueInstructions } from "../types";
3
- import { StoreValue } from "./StoreValue";
4
- import { VoidValue } from "./VoidValue";
5
- export type TFunctionValueInitParams = (childScope: IScope) => {
6
- paramStores: StoreValue[];
7
- paramNames: string[];
8
- };
9
- export declare class FunctionValue extends VoidValue implements IFunctionValue {
10
- name: string;
11
- mutability: EMutability;
12
- macro: boolean;
13
- scope: IScope;
14
- private out?;
15
- private childScope;
16
- private params;
17
- private paramValues;
18
- private paramNames;
19
- private inst;
20
- private addr;
21
- private temp;
22
- private ret;
23
- private inline;
24
- private tryingInline;
25
- private body;
26
- private c;
27
- private callSize;
28
- private inlineTemp;
29
- private inlineEnd?;
30
- private bundled;
31
- private initialized;
32
- constructor({ scope, params, body, c, out, }: {
33
- scope: IScope;
34
- body: es.BlockStatement;
35
- c: Compiler;
36
- params: es.Identifier[];
37
- out?: TEOutput;
38
- });
39
- typeof(): TValueInstructions;
40
- private initScope;
41
- private ensureInit;
42
- private normalReturn;
43
- private normalCall;
44
- private inlineReturn;
45
- private inlineCall;
46
- call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions;
47
- return(scope: IScope, arg: IValue | null): TValueInstructions<IValue | null>;
48
- eval(_scope: IScope): TValueInstructions;
49
- paramOuts(): readonly IValue[] | undefined;
50
- }
1
+ import { Compiler } from "../Compiler";
2
+ import { EMutability, es, IFunctionValue, IScope, IValue, TEOutput, TValueInstructions } from "../types";
3
+ import { StoreValue } from "./StoreValue";
4
+ import { VoidValue } from "./VoidValue";
5
+ export type TFunctionValueInitParams = (childScope: IScope) => {
6
+ paramStores: StoreValue[];
7
+ paramNames: string[];
8
+ };
9
+ export declare class FunctionValue extends VoidValue implements IFunctionValue {
10
+ name: string;
11
+ mutability: EMutability;
12
+ macro: boolean;
13
+ scope: IScope;
14
+ private childScope;
15
+ private params;
16
+ private paramValues;
17
+ private paramNames;
18
+ private destructuringKeyData;
19
+ private paramOuts;
20
+ private minimumArgumentCount;
21
+ private maximumArgumentCount;
22
+ private inst;
23
+ private addr;
24
+ private temp;
25
+ private ret;
26
+ private inline;
27
+ private tryingInline;
28
+ private body;
29
+ private c;
30
+ private callSize;
31
+ private inlineTemp;
32
+ private inlineEnd?;
33
+ private bundled;
34
+ private initialized;
35
+ constructor({ scope, params, body, c, out, }: {
36
+ scope: IScope;
37
+ body: es.BlockStatement;
38
+ c: Compiler;
39
+ params: es.Identifier[];
40
+ out?: TEOutput;
41
+ });
42
+ typeof(): TValueInstructions;
43
+ private initScope;
44
+ private ensureInit;
45
+ private normalReturn;
46
+ private normalCall;
47
+ private inlineReturn;
48
+ private inlineCall;
49
+ call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions;
50
+ return(scope: IScope, arg: IValue | null): TValueInstructions<IValue | null>;
51
+ eval(_scope: IScope): TValueInstructions;
52
+ preCall(): readonly IValue[] | undefined;
53
+ debugString(): string;
54
+ toString(): string;
55
+ private unwrapParameter;
56
+ private hardSetParameter;
57
+ }
@@ -0,0 +1,36 @@
1
+ import { EJumpKind, JumpInstruction } from "../instructions";
2
+ import { es, IBindableValue, IScope, IValue, TEOutput, TValueInstructions } from "../types";
3
+ import { VoidValue } from "./VoidValue";
4
+ declare const operatorMap: {
5
+ readonly "!=": EJumpKind.NotEqual;
6
+ readonly "<": EJumpKind.LessThan;
7
+ readonly "<=": EJumpKind.LessThanEq;
8
+ readonly "==": EJumpKind.Equal;
9
+ readonly "===": EJumpKind.StrictEqual;
10
+ readonly ">": EJumpKind.GreaterThan;
11
+ readonly ">=": EJumpKind.GreaterThanEq;
12
+ };
13
+ declare const invertedOperatorMap: {
14
+ readonly "==": EJumpKind.NotEqual;
15
+ readonly "!=": EJumpKind.Equal;
16
+ readonly "!==": EJumpKind.StrictEqual;
17
+ readonly ">": EJumpKind.LessThanEq;
18
+ readonly "<": EJumpKind.GreaterThanEq;
19
+ readonly ">=": EJumpKind.LessThan;
20
+ readonly "<=": EJumpKind.GreaterThan;
21
+ };
22
+ type TWhenFalseOperator = keyof typeof invertedOperatorMap;
23
+ type TWhenTrueOperator = keyof typeof operatorMap;
24
+ export declare class JumpOutValue extends VoidValue {
25
+ node: es.Node;
26
+ address: IBindableValue<number | null>;
27
+ whenTrue: boolean;
28
+ macro: boolean;
29
+ constructor(node: es.Node, address: IBindableValue<number | null>, whenTrue: boolean);
30
+ canHandle(operator: string): operator is TWhenTrueOperator | TWhenFalseOperator;
31
+ handle(operator: TWhenTrueOperator | TWhenFalseOperator, left: IValue, right: IValue): JumpInstruction;
32
+ eval(_scope: IScope, _out?: TEOutput): TValueInstructions<IValue>;
33
+ debugString(): string;
34
+ toString(): string;
35
+ }
36
+ export {};
@@ -1,9 +1,11 @@
1
- import { IValue } from "../types";
2
- import { VoidValue } from "./VoidValue";
3
- /**
4
- * This class is used to handle some cases where the value
5
- * can't be directly evaluated by the node handler
6
- */
7
- export declare class LazyValue extends VoidValue {
8
- constructor(evalutate: IValue["eval"]);
9
- }
1
+ import { IValue } from "../types";
2
+ import { VoidValue } from "./VoidValue";
3
+ /**
4
+ * This class is used to handle some cases where the value
5
+ * can't be directly evaluated by the node handler
6
+ */
7
+ export declare class LazyValue extends VoidValue {
8
+ constructor(evalutate: IValue["eval"]);
9
+ debugString(): string;
10
+ toString(): string;
11
+ }
@@ -1,14 +1,18 @@
1
- import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue, EMutability } from "../types";
2
- import { BaseValue } from ".";
3
- export declare class LiteralValue<T extends TLiteral | null = TLiteral> extends BaseValue implements IBindableValue<T> {
4
- data: T;
5
- mutability: EMutability;
6
- constructor(data: T);
7
- eval(_scope: IScope): TValueInstructions;
8
- toString(): string;
9
- get(scope: IScope, name: IValue): TValueInstructions;
10
- get num(): 1 | 0 | (T & {});
11
- typeof(): TValueInstructions;
12
- isString(): this is LiteralValue<string>;
13
- isNumber(): this is LiteralValue<number>;
14
- }
1
+ import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue, EMutability, TEOutput } from "../types";
2
+ import { BaseValue } from ".";
3
+ export declare class LiteralValue<T extends TLiteral | null = TLiteral> extends BaseValue implements IBindableValue<T> {
4
+ name: string;
5
+ data: T;
6
+ mutability: EMutability;
7
+ constructor(data: T);
8
+ eval(_scope: IScope): TValueInstructions;
9
+ toString(): string;
10
+ get(scope: IScope, name: IValue): TValueInstructions;
11
+ hasProperty(scope: IScope, prop: IValue): boolean;
12
+ get num(): 1 | 0 | (T & {});
13
+ "??"(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
14
+ typeof(): TValueInstructions;
15
+ isString(): this is LiteralValue<string>;
16
+ isNumber(): this is LiteralValue<number>;
17
+ debugString(): string;
18
+ }
@@ -1,20 +1,23 @@
1
- import { MacroFunction } from "../macros";
2
- import { EMutability, IScope, IValue, TEOutput, 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
- mutability: EMutability;
12
- macro: boolean;
13
- data: IObjectValueData;
14
- constructor(data?: IObjectValueData);
15
- static fromArray(items: IObjectValueData[keyof IObjectValueData][], intialData?: IObjectValueData): ObjectValue;
16
- typeof(scope: IScope, out?: TEOutput): TValueInstructions;
17
- get(scope: IScope, key: LiteralValue, out?: TEOutput): TValueInstructions;
18
- eval(scope: IScope, out?: TEOutput): TValueInstructions;
19
- call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions<IValue | null>;
20
- }
1
+ import { MacroFunction } from "../macros";
2
+ import { EMutability, IScope, IValue, TEOutput, TOperatorMacroMap, TValueInstructions } from "../types";
3
+ import { VoidValue } from "./VoidValue";
4
+ export interface IObjectValueData extends TOperatorMacroMap {
5
+ [k: string]: IValue | undefined;
6
+ $get?: MacroFunction<IValue>;
7
+ $eval?: MacroFunction<IValue>;
8
+ }
9
+ export declare class ObjectValue extends VoidValue {
10
+ mutability: EMutability;
11
+ macro: boolean;
12
+ data: IObjectValueData;
13
+ constructor(data?: IObjectValueData);
14
+ static fromArray(items: IObjectValueData[keyof IObjectValueData][], initialData?: IObjectValueData): ObjectValue;
15
+ typeof(scope: IScope, out?: TEOutput): TValueInstructions;
16
+ get(scope: IScope, key: IValue, out?: TEOutput): TValueInstructions;
17
+ hasProperty(scope: IScope, prop: IValue): boolean;
18
+ eval(scope: IScope, out?: TEOutput): TValueInstructions;
19
+ call(scope: IScope, args: IValue[], out?: TEOutput): TValueInstructions<IValue | null>;
20
+ "??"(scope: IScope, other: IValue, out?: TEOutput): TValueInstructions;
21
+ debugString(): string;
22
+ toString(): string;
23
+ }
@@ -1,24 +1,24 @@
1
- import { EMutability, IScope, IValue, TEOutput, 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
- constructor(name: string, mutability?: EMutability);
21
- static from(scope: IScope, out?: TEOutput, mutability?: EMutability): SenseableValue;
22
- static out(scope: IScope, out?: TEOutput, mutability?: EMutability): IValue;
23
- get(scope: IScope, prop: IValue, out?: TEOutput): TValueInstructions<IValue>;
24
- }
1
+ import { EMutability, IScope, IValue, TEOutput, 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 `EMutability.mutable` if you want them to be assignable. Example:
13
+ * ```
14
+ * const value = new SenseableValue(name, EMutability.mutable);
15
+ * ```
16
+ */
17
+ export declare class SenseableValue extends StoreValue {
18
+ constructor(name: string, mutability?: EMutability);
19
+ static from(scope: IScope, out?: TEOutput, mutability?: EMutability): SenseableValue;
20
+ static out(scope: IScope, out?: TEOutput, mutability?: EMutability): IValue;
21
+ get(scope: IScope, prop: IValue, out?: TEOutput): TValueInstructions<IValue>;
22
+ debugString(): string;
23
+ hasProperty(scope: IScope, prop: IValue): boolean;
24
+ }
@@ -1,21 +1,22 @@
1
- import { BaseValue } from ".";
2
- import { EMutability, IScope, IValue, TEOutput, 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
- name: string;
9
- mutability: EMutability;
10
- constructor(name: string, mutability?: EMutability);
11
- static from(scope: IScope, out?: TEOutput, mutability?: EMutability): StoreValue;
12
- static out(scope: IScope, out?: TEOutput, mutability?: EMutability): IValue;
13
- typeof(): TValueInstructions;
14
- "="(scope: IScope, value: IValue): TValueInstructions;
15
- "=="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
16
- "==="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
17
- "!="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
18
- "!=="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
19
- eval(_scope: IScope): TValueInstructions;
20
- toString(): string;
21
- }
1
+ import { BaseValue } from ".";
2
+ import { EMutability, IScope, IValue, TEOutput, 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
+ name: string;
9
+ mutability: EMutability;
10
+ constructor(name: string, mutability?: EMutability);
11
+ static from(scope: IScope, out?: TEOutput, mutability?: EMutability): StoreValue;
12
+ static out(scope: IScope, out?: TEOutput, mutability?: EMutability): IValue;
13
+ typeof(): TValueInstructions;
14
+ "="(scope: IScope, value: IValue): TValueInstructions;
15
+ "=="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
16
+ "==="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
17
+ "!="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
18
+ "!=="(scope: IScope, value: IValue, out?: TEOutput): TValueInstructions;
19
+ eval(_scope: IScope): TValueInstructions;
20
+ debugString(): string;
21
+ toString(): string;
22
+ }
@@ -1,13 +1,17 @@
1
- import { EMutability, IScope, IValue, IValueOperators, TEOutput, TValueInstructions } from "../types";
2
- export declare class VoidValue implements IValue {
3
- name?: string;
4
- mutability: EMutability;
5
- macro: boolean;
6
- eval(_scope: IScope, _out?: TEOutput): TValueInstructions;
7
- call(_scope: IScope, _args: IValue[], _out?: TEOutput): TValueInstructions<IValue | null>;
8
- get(_scope: IScope, _name: IValue): TValueInstructions;
9
- paramOuts(): readonly IValue[] | undefined;
10
- toString(): string;
11
- }
12
- export interface VoidValue extends IValueOperators {
13
- }
1
+ import { EMutability, IScope, IValue, IValueOperators, TEOutput, TValueInstructions } from "../types";
2
+ export declare class VoidValue implements IValue {
3
+ name?: string;
4
+ mutability: EMutability;
5
+ macro: boolean;
6
+ eval(_scope: IScope, _out?: TEOutput): TValueInstructions;
7
+ call(_scope: IScope, _args: IValue[], _out?: TEOutput): TValueInstructions<IValue | null>;
8
+ get(_scope: IScope, name: IValue): TValueInstructions;
9
+ hasProperty(_scope: IScope, _prop: IValue): boolean;
10
+ preCall(_scope: IScope, _out?: TEOutput): readonly TEOutput[] | undefined;
11
+ postCall(_scope: IScope): void;
12
+ toOut(): IValue;
13
+ debugString(): string;
14
+ toString(): string;
15
+ }
16
+ export interface VoidValue extends IValueOperators {
17
+ }
@@ -1,8 +1,9 @@
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";
8
- export * from "./LazyValue";
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";
8
+ export * from "./LazyValue";
9
+ export * from "./AssignmentValue";