mlogjs 0.4.6 → 0.4.7

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.
@@ -1,5 +1,5 @@
1
1
  import { CompilerError } from "./CompilerError";
2
- import { es, IScope, IValue, THandler, TValueInstructions } from "./types";
2
+ import { es, IScope, IValue, TEOutput, THandler, TValueInstructions } from "./types";
3
3
  declare type THandlerMap = {
4
4
  [k in es.Node["type"]]?: THandler<IValue | null>;
5
5
  };
@@ -21,16 +21,15 @@ export declare class Compiler {
21
21
  protected serialize(resLines: TValueInstructions<IValue | null>): string;
22
22
  protected parse(script: string): import("@babel/parser").ParseResult<es.File>;
23
23
  protected mapSources(valueInst: TValueInstructions<IValue | null>): es.SourceLocation[];
24
- handle(scope: IScope, node: es.Node, handler?: THandler<IValue | null> | undefined): TValueInstructions<IValue | null>;
25
- handleEval(scope: IScope, node: es.Node): TValueInstructions;
26
- handleConsume(scope: IScope, node: es.Node): TValueInstructions;
24
+ handle(scope: IScope, node: es.Node, handler?: THandler<IValue | null> | undefined, out?: TEOutput): TValueInstructions<IValue | null>;
25
+ handleEval(scope: IScope, node: es.Node, out?: TEOutput): TValueInstructions;
27
26
  /**
28
27
  * Handles many nodes in order.
29
28
  *
30
29
  * The usage of this method over a regular loop over an array of nodes
31
30
  * is only required if the code inside the loop generates
32
31
  * instructions that are not tracked by the compiler
33
- * handler methods ({@link handle}, {@link handleEval}, {@link handleConsume}
32
+ * handler methods ({@link handle}, {@link handleEval}
34
33
  * and {@link handleMany})
35
34
  *
36
35
  */
package/dist/Scope.d.ts CHANGED
@@ -1,25 +1,25 @@
1
1
  import { SenseableValue } from "./values";
2
2
  import { AddressResolver } from "./instructions";
3
- import { IFunctionValue, IInstruction, IOwnedValue, IScope, IValue, IValueOwner } from "./types";
3
+ import { IFunctionValue, IInstruction, INamedValue, IScope, IValue } from "./types";
4
4
  export declare class Scope implements IScope {
5
5
  parent: IScope | null;
6
6
  stacked: boolean;
7
7
  ntemp: number;
8
8
  name: string;
9
9
  inst: IInstruction[];
10
- data: Record<string, IValueOwner | null>;
10
+ data: Record<string, IValue | null>;
11
11
  break: AddressResolver;
12
12
  continue: AddressResolver;
13
13
  function: IFunctionValue;
14
14
  label?: string;
15
- constructor(values: Record<string, IValueOwner | null>, parent?: IScope | null, stacked?: boolean, ntemp?: number, name?: string, inst?: IInstruction[]);
15
+ constructor(values: Record<string, IValue | null>, parent?: IScope | null, stacked?: boolean, ntemp?: number, name?: string, inst?: IInstruction[]);
16
16
  copy(): IScope;
17
17
  createScope(): IScope;
18
18
  createFunction(name: string, stacked?: boolean): IScope;
19
19
  has(identifier: string): boolean;
20
- get(identifier: string): IOwnedValue;
21
- set<T extends IValue>(...args: [name: string, value: T] | [owner: IValueOwner<T>]): T;
22
- hardSet<T extends IValue>(...args: [name: string, value: T] | [owner: IValueOwner<T>]): T;
20
+ get(identifier: string): INamedValue;
21
+ set<T extends IValue>(name: string, value: T): T;
22
+ hardSet<T extends IValue>(name: string, value: T): T;
23
23
  make(identifier: string, name: string): SenseableValue;
24
24
  makeTempName(): string;
25
25
  }
@@ -1,19 +1,19 @@
1
1
  import { IValue } from "./types";
2
2
  import { LiteralValue, ObjectValue, StoreValue } from "./values";
3
3
  /** Asserts that `value` is a `LiteralValue` that contains a string */
4
- export declare function assertStringLiteral(value: IValue | undefined, name: string): asserts value is LiteralValue & {
5
- data: string;
6
- };
4
+ export declare function assertStringLiteral(value: IValue | undefined, name: string): asserts value is LiteralValue<string>;
7
5
  /** Asserts that `value` is a string literal that is part of a given set of `members`*/
8
- export declare function assertLiteralOneOf<T extends readonly string[]>(value: IValue | undefined, members: T, name: string): asserts value is LiteralValue & {
9
- data: T[number];
10
- };
6
+ export declare function assertLiteralOneOf<T extends readonly string[]>(value: IValue | undefined, members: T, name: string): asserts value is LiteralValue<T[number]>;
11
7
  /** Asserts that `value` is either a store or a literal */
12
8
  export declare function assertIsRuntimeValue(value: IValue | undefined, name: string): asserts value is LiteralValue | StoreValue;
13
9
  /** Asserts that `value` is an `ObjectValue` */
14
10
  export declare function assertIsObjectMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
15
11
  /** Asserts that `value` is an `ObjectValue` that has a length property */
16
- export declare function assertIsArrayMacro(value: IValue | undefined, name: string): asserts value is ObjectValue;
12
+ export declare function assertIsArrayMacro(value: IValue | undefined, name: string): asserts value is ObjectValue & {
13
+ data: {
14
+ length: LiteralValue<number>;
15
+ };
16
+ };
17
17
  /** Helper type used to describe the overloads of a macro function. See {@link assertObjectFields} */
18
18
  export declare type TOverloadDescriptor<K extends string> = Record<K, (string | IParameterDescriptor)[]>;
19
19
  /** Describes an object destructuring paremeter. Generally used with `assertObjectFields` */
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The prefix for internal variables inside the compiler output
3
+ */
4
+ export declare const internalPrefix = "&";
5
+ export declare const discardedName: string;