@tsonic/emitter 0.0.14 → 0.0.16
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/dist/.tsbuildinfo +1 -1
- package/dist/adapter-generator.js +3 -3
- package/dist/adapter-generator.js.map +1 -1
- package/dist/array.test.d.ts +1 -1
- package/dist/array.test.js +18 -17
- package/dist/array.test.js.map +1 -1
- package/dist/core/attributes.test.js +2 -2
- package/dist/core/attributes.test.js.map +1 -1
- package/dist/core/imports.d.ts.map +1 -1
- package/dist/core/imports.js +7 -12
- package/dist/core/imports.js.map +1 -1
- package/dist/core/local-types.d.ts.map +1 -1
- package/dist/core/local-types.js +12 -0
- package/dist/core/local-types.js.map +1 -1
- package/dist/core/module-emitter/orchestrator.d.ts.map +1 -1
- package/dist/core/module-emitter/orchestrator.js +15 -2
- package/dist/core/module-emitter/orchestrator.js.map +1 -1
- package/dist/core/module-emitter/static-container.d.ts.map +1 -1
- package/dist/core/module-emitter/static-container.js +30 -4
- package/dist/core/module-emitter/static-container.js.map +1 -1
- package/dist/core/module-emitter.test.js +6 -6
- package/dist/core/module-map.d.ts.map +1 -1
- package/dist/core/module-map.js +42 -0
- package/dist/core/module-map.js.map +1 -1
- package/dist/core/naming-collisions.d.ts +4 -0
- package/dist/core/naming-collisions.d.ts.map +1 -0
- package/dist/core/naming-collisions.js +191 -0
- package/dist/core/naming-collisions.js.map +1 -0
- package/dist/core/type-member-index.d.ts +4 -0
- package/dist/core/type-member-index.d.ts.map +1 -0
- package/dist/core/type-member-index.js +62 -0
- package/dist/core/type-member-index.js.map +1 -0
- package/dist/core/unsafe.d.ts +11 -0
- package/dist/core/unsafe.d.ts.map +1 -0
- package/dist/core/unsafe.js +264 -0
- package/dist/core/unsafe.js.map +1 -0
- package/dist/emitter-types/context.d.ts +1 -1
- package/dist/emitter-types/context.d.ts.map +1 -1
- package/dist/emitter-types/context.js +5 -3
- package/dist/emitter-types/context.js.map +1 -1
- package/dist/emitter-types/core.d.ts +45 -2
- package/dist/emitter-types/core.d.ts.map +1 -1
- package/dist/emitter-types/fqn.d.ts +0 -7
- package/dist/emitter-types/fqn.d.ts.map +1 -1
- package/dist/emitter-types/fqn.js +0 -8
- package/dist/emitter-types/fqn.js.map +1 -1
- package/dist/emitter-types/index.d.ts +1 -1
- package/dist/emitter-types/index.d.ts.map +1 -1
- package/dist/emitter-types/index.js.map +1 -1
- package/dist/emitter.d.ts.map +1 -1
- package/dist/emitter.js +12 -1
- package/dist/emitter.js.map +1 -1
- package/dist/expression-emitter.d.ts.map +1 -1
- package/dist/expression-emitter.js +255 -73
- package/dist/expression-emitter.js.map +1 -1
- package/dist/expressions/access.d.ts +3 -1
- package/dist/expressions/access.d.ts.map +1 -1
- package/dist/expressions/access.js +144 -50
- package/dist/expressions/access.js.map +1 -1
- package/dist/expressions/calls.d.ts.map +1 -1
- package/dist/expressions/calls.js +266 -88
- package/dist/expressions/calls.js.map +1 -1
- package/dist/expressions/collections.d.ts.map +1 -1
- package/dist/expressions/collections.js +169 -57
- package/dist/expressions/collections.js.map +1 -1
- package/dist/expressions/functions.d.ts.map +1 -1
- package/dist/expressions/functions.js +30 -10
- package/dist/expressions/functions.js.map +1 -1
- package/dist/expressions/identifiers.d.ts.map +1 -1
- package/dist/expressions/identifiers.js +11 -30
- package/dist/expressions/identifiers.js.map +1 -1
- package/dist/expressions/index.test.js +89 -200
- package/dist/expressions/index.test.js.map +1 -1
- package/dist/expressions/literals.d.ts +4 -5
- package/dist/expressions/literals.d.ts.map +1 -1
- package/dist/expressions/literals.js +94 -15
- package/dist/expressions/literals.js.map +1 -1
- package/dist/expressions/operators.d.ts +0 -4
- package/dist/expressions/operators.d.ts.map +1 -1
- package/dist/expressions/operators.js +84 -24
- package/dist/expressions/operators.js.map +1 -1
- package/dist/expressions/other.d.ts.map +1 -1
- package/dist/expressions/other.js +21 -3
- package/dist/expressions/other.js.map +1 -1
- package/dist/expressions/parentheses.d.ts +4 -0
- package/dist/expressions/parentheses.d.ts.map +1 -0
- package/dist/expressions/parentheses.js +83 -0
- package/dist/expressions/parentheses.js.map +1 -0
- package/dist/extension-methods.test.d.ts +5 -0
- package/dist/extension-methods.test.d.ts.map +1 -0
- package/dist/extension-methods.test.js +110 -0
- package/dist/extension-methods.test.js.map +1 -0
- package/dist/generator-exchange.d.ts.map +1 -1
- package/dist/generator-exchange.js +5 -2
- package/dist/generator-exchange.js.map +1 -1
- package/dist/generator-wrapper.d.ts.map +1 -1
- package/dist/generator-wrapper.js +13 -7
- package/dist/generator-wrapper.js.map +1 -1
- package/dist/generator-wrapper.test.js +12 -12
- package/dist/generator-wrapper.test.js.map +1 -1
- package/dist/generator.test.js +42 -42
- package/dist/generator.test.js.map +1 -1
- package/dist/golden-tests/discovery.d.ts +6 -11
- package/dist/golden-tests/discovery.d.ts.map +1 -1
- package/dist/golden-tests/discovery.js +14 -79
- package/dist/golden-tests/discovery.js.map +1 -1
- package/dist/golden-tests/index.d.ts +1 -1
- package/dist/golden-tests/index.d.ts.map +1 -1
- package/dist/golden-tests/index.js.map +1 -1
- package/dist/golden-tests/runner.d.ts.map +1 -1
- package/dist/golden-tests/runner.js +6 -7
- package/dist/golden-tests/runner.js.map +1 -1
- package/dist/golden-tests/types.d.ts +0 -7
- package/dist/golden-tests/types.d.ts.map +1 -1
- package/dist/golden.test.d.ts +3 -10
- package/dist/golden.test.d.ts.map +1 -1
- package/dist/golden.test.js +8 -24
- package/dist/golden.test.js.map +1 -1
- package/dist/hierarchical-bindings.test.js +18 -12
- package/dist/hierarchical-bindings.test.js.map +1 -1
- package/dist/integration.test.js +76 -35
- package/dist/integration.test.js.map +1 -1
- package/dist/invariants/emitter-globals-subset.test.d.ts +1 -1
- package/dist/invariants/emitter-globals-subset.test.js +34 -74
- package/dist/invariants/emitter-globals-subset.test.js.map +1 -1
- package/dist/invariants/numeric-proof-contract.test.js +3 -3
- package/dist/invariants/numeric-proof-contract.test.js.map +1 -1
- package/dist/naming-policy.d.ts +5 -0
- package/dist/naming-policy.d.ts.map +1 -0
- package/dist/naming-policy.js +10 -0
- package/dist/naming-policy.js.map +1 -0
- package/dist/patterns.d.ts +98 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +366 -0
- package/dist/patterns.js.map +1 -0
- package/dist/patterns.test.d.ts +15 -0
- package/dist/patterns.test.d.ts.map +1 -0
- package/dist/patterns.test.js +1262 -0
- package/dist/patterns.test.js.map +1 -0
- package/dist/specialization/generation.d.ts.map +1 -1
- package/dist/specialization/generation.js +2 -2
- package/dist/specialization/generation.js.map +1 -1
- package/dist/specialization/generic-classes.test.js +1 -1
- package/dist/specialization/generic-functions.test.js +6 -6
- package/dist/specialization/interfaces.test.js +5 -5
- package/dist/specialization/substitution.d.ts.map +1 -1
- package/dist/specialization/substitution.js +4 -0
- package/dist/specialization/substitution.js.map +1 -1
- package/dist/specialization/type-aliases.test.js +6 -6
- package/dist/specialization/type-aliases.test.js.map +1 -1
- package/dist/statement-emitter.d.ts.map +1 -1
- package/dist/statement-emitter.js +1 -1
- package/dist/statement-emitter.js.map +1 -1
- package/dist/statements/blocks.d.ts.map +1 -1
- package/dist/statements/blocks.js +14 -45
- package/dist/statements/blocks.js.map +1 -1
- package/dist/statements/classes/index.d.ts +1 -1
- package/dist/statements/classes/index.d.ts.map +1 -1
- package/dist/statements/classes/index.js +1 -1
- package/dist/statements/classes/index.js.map +1 -1
- package/dist/statements/classes/inline-types.d.ts +1 -1
- package/dist/statements/classes/inline-types.d.ts.map +1 -1
- package/dist/statements/classes/inline-types.js +15 -5
- package/dist/statements/classes/inline-types.js.map +1 -1
- package/dist/statements/classes/members/constructors.d.ts.map +1 -1
- package/dist/statements/classes/members/constructors.js +40 -14
- package/dist/statements/classes/members/constructors.js.map +1 -1
- package/dist/statements/classes/members/methods.d.ts.map +1 -1
- package/dist/statements/classes/members/methods.js +62 -25
- package/dist/statements/classes/members/methods.js.map +1 -1
- package/dist/statements/classes/members/orchestrator.d.ts.map +1 -1
- package/dist/statements/classes/members/orchestrator.js +1 -3
- package/dist/statements/classes/members/orchestrator.js.map +1 -1
- package/dist/statements/classes/members/properties.d.ts.map +1 -1
- package/dist/statements/classes/members/properties.js +70 -10
- package/dist/statements/classes/members/properties.js.map +1 -1
- package/dist/statements/classes/parameters.d.ts +43 -1
- package/dist/statements/classes/parameters.d.ts.map +1 -1
- package/dist/statements/classes/parameters.js +73 -13
- package/dist/statements/classes/parameters.js.map +1 -1
- package/dist/statements/classes/properties.d.ts.map +1 -1
- package/dist/statements/classes/properties.js +6 -7
- package/dist/statements/classes/properties.js.map +1 -1
- package/dist/statements/classes.d.ts +1 -1
- package/dist/statements/classes.d.ts.map +1 -1
- package/dist/statements/classes.js +1 -1
- package/dist/statements/classes.js.map +1 -1
- package/dist/statements/control/conditionals.d.ts.map +1 -1
- package/dist/statements/control/conditionals.js +193 -23
- package/dist/statements/control/conditionals.js.map +1 -1
- package/dist/statements/control/loops.d.ts.map +1 -1
- package/dist/statements/control/loops.js +25 -5
- package/dist/statements/control/loops.js.map +1 -1
- package/dist/statements/declarations/classes.d.ts.map +1 -1
- package/dist/statements/declarations/classes.js +150 -12
- package/dist/statements/declarations/classes.js.map +1 -1
- package/dist/statements/declarations/enums.d.ts.map +1 -1
- package/dist/statements/declarations/enums.js +2 -1
- package/dist/statements/declarations/enums.js.map +1 -1
- package/dist/statements/declarations/functions.d.ts.map +1 -1
- package/dist/statements/declarations/functions.js +44 -19
- package/dist/statements/declarations/functions.js.map +1 -1
- package/dist/statements/declarations/interfaces.d.ts.map +1 -1
- package/dist/statements/declarations/interfaces.js +71 -10
- package/dist/statements/declarations/interfaces.js.map +1 -1
- package/dist/statements/declarations/structs.test.js +5 -5
- package/dist/statements/declarations/type-aliases.d.ts.map +1 -1
- package/dist/statements/declarations/type-aliases.js +24 -5
- package/dist/statements/declarations/type-aliases.js.map +1 -1
- package/dist/statements/declarations/variables.d.ts.map +1 -1
- package/dist/statements/declarations/variables.js +194 -37
- package/dist/statements/declarations/variables.js.map +1 -1
- package/dist/statements/index.test.js +7 -5
- package/dist/statements/index.test.js.map +1 -1
- package/dist/type-assertion.test.js +1 -1
- package/dist/types/arrays.d.ts +3 -9
- package/dist/types/arrays.d.ts.map +1 -1
- package/dist/types/arrays.js +5 -19
- package/dist/types/arrays.js.map +1 -1
- package/dist/types/emitter.d.ts.map +1 -1
- package/dist/types/emitter.js +3 -2
- package/dist/types/emitter.js.map +1 -1
- package/dist/types/index.test.js +3 -3
- package/dist/types/parameters.d.ts +1 -1
- package/dist/types/parameters.d.ts.map +1 -1
- package/dist/types/parameters.js +77 -8
- package/dist/types/parameters.js.map +1 -1
- package/dist/types/parameters.test.js +1 -1
- package/dist/types/parameters.test.js.map +1 -1
- package/dist/types/references.d.ts.map +1 -1
- package/dist/types/references.js +126 -55
- package/dist/types/references.js.map +1 -1
- package/dist/types/references.test.js +46 -106
- package/dist/types/references.test.js.map +1 -1
- package/dist/types/unions.d.ts.map +1 -1
- package/dist/types/unions.js +20 -0
- package/dist/types/unions.js.map +1 -1
- package/dist/types/unions.test.js +9 -9
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { applyNamingPolicy, resolveNamingPolicy, } from "@tsonic/frontend";
|
|
2
|
+
import { escapeCSharpIdentifier } from "./emitter-types/index.js";
|
|
3
|
+
export const getCSharpName = (name, bucket, context) => {
|
|
4
|
+
const policy = resolveNamingPolicy(context.options.namingPolicy, bucket);
|
|
5
|
+
return applyNamingPolicy(name, policy);
|
|
6
|
+
};
|
|
7
|
+
export const emitCSharpName = (name, bucket, context) => {
|
|
8
|
+
return escapeCSharpIdentifier(getCSharpName(name, bucket, context));
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=naming-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-policy.js","sourceRoot":"","sources":["../src/naming-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,IAAY,EACZ,MAA0B,EAC1B,OAAuB,EACf,EAAE;IACV,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACzE,OAAO,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,MAA0B,EAC1B,OAAuB,EACf,EAAE;IACV,OAAO,sBAAsB,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Lowering Module
|
|
3
|
+
*
|
|
4
|
+
* Transforms destructuring patterns into sequences of C# variable declarations.
|
|
5
|
+
* This module is used by variable declarations, for-of loops, and function parameters.
|
|
6
|
+
*
|
|
7
|
+
* Example transformations:
|
|
8
|
+
*
|
|
9
|
+
* Array pattern:
|
|
10
|
+
* const [a, b, c] = arr;
|
|
11
|
+
* =>
|
|
12
|
+
* var __t0 = arr;
|
|
13
|
+
* var a = __t0[0];
|
|
14
|
+
* var b = __t0[1];
|
|
15
|
+
* var c = __t0[2];
|
|
16
|
+
*
|
|
17
|
+
* Array pattern with rest:
|
|
18
|
+
* const [first, ...rest] = arr;
|
|
19
|
+
* =>
|
|
20
|
+
* var __t0 = arr;
|
|
21
|
+
* var first = __t0[0];
|
|
22
|
+
* var rest = Tsonic.Runtime.ArrayHelpers.Slice(__t0, 1);
|
|
23
|
+
*
|
|
24
|
+
* Object pattern:
|
|
25
|
+
* const { name, age } = person;
|
|
26
|
+
* =>
|
|
27
|
+
* var __t0 = person;
|
|
28
|
+
* var name = __t0.name;
|
|
29
|
+
* var age = __t0.age;
|
|
30
|
+
*
|
|
31
|
+
* Object pattern with rest:
|
|
32
|
+
* const { name, ...rest } = person;
|
|
33
|
+
* =>
|
|
34
|
+
* var __t0 = person;
|
|
35
|
+
* var name = __t0.name;
|
|
36
|
+
* var rest = new __Rest_xxxx { age = __t0.age, email = __t0.email };
|
|
37
|
+
*/
|
|
38
|
+
import { IrPattern, IrType } from "@tsonic/frontend";
|
|
39
|
+
import { EmitterContext } from "./emitter-types/index.js";
|
|
40
|
+
/**
|
|
41
|
+
* Result of pattern lowering - a list of C# statements
|
|
42
|
+
*/
|
|
43
|
+
export type LoweringResult = {
|
|
44
|
+
/** Variable declarations generated from the pattern */
|
|
45
|
+
readonly statements: readonly string[];
|
|
46
|
+
/** The context after lowering (with any new locals registered) */
|
|
47
|
+
readonly context: EmitterContext;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Lower a pattern to a sequence of C# statements
|
|
51
|
+
*
|
|
52
|
+
* @param pattern - The pattern to lower (identifier, array, or object)
|
|
53
|
+
* @param inputExpr - The C# expression being destructured
|
|
54
|
+
* @param type - The type of the input expression (for type annotations)
|
|
55
|
+
* @param indent - Indentation prefix for generated code
|
|
56
|
+
* @param ctx - The current emitter context
|
|
57
|
+
* @returns The generated statements and updated context
|
|
58
|
+
*/
|
|
59
|
+
export declare const lowerPattern: (pattern: IrPattern, inputExpr: string, type: IrType | undefined, indent: string, ctx: EmitterContext) => LoweringResult;
|
|
60
|
+
/**
|
|
61
|
+
* Lower a pattern for a for-of loop variable
|
|
62
|
+
* Similar to lowerPattern but handles the iteration context
|
|
63
|
+
*/
|
|
64
|
+
export declare const lowerForOfPattern: (pattern: IrPattern, iteratorVar: string, elementType: IrType | undefined, indent: string, ctx: EmitterContext) => LoweringResult;
|
|
65
|
+
/**
|
|
66
|
+
* Lower a parameter pattern for function definitions
|
|
67
|
+
* Generates statements to go at the beginning of the function body
|
|
68
|
+
*/
|
|
69
|
+
export declare const lowerParameterPattern: (pattern: IrPattern, paramName: string, paramType: IrType | undefined, indent: string, ctx: EmitterContext) => LoweringResult;
|
|
70
|
+
/**
|
|
71
|
+
* Result of assignment pattern lowering - an expression and context
|
|
72
|
+
*
|
|
73
|
+
* Assignment destructuring is an expression (returns the RHS value),
|
|
74
|
+
* so we return an expression string instead of statements.
|
|
75
|
+
*/
|
|
76
|
+
export type AssignmentLoweringResult = {
|
|
77
|
+
/** The C# expression that performs the assignment and returns the value */
|
|
78
|
+
readonly expression: string;
|
|
79
|
+
/** The context after lowering */
|
|
80
|
+
readonly context: EmitterContext;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Lower an assignment pattern to a C# expression
|
|
84
|
+
*
|
|
85
|
+
* In JavaScript, destructuring assignment is an expression that returns the RHS:
|
|
86
|
+
* const result = ([a, b] = arr); // result === arr
|
|
87
|
+
*
|
|
88
|
+
* We emit this as a parenthesized sequence expression:
|
|
89
|
+
* ((__t = rhs), (a = __t[0]), (b = __t[1]), __t)
|
|
90
|
+
*
|
|
91
|
+
* @param pattern - The pattern being assigned to
|
|
92
|
+
* @param rhsExpr - The C# expression for the right-hand side
|
|
93
|
+
* @param type - The type of the RHS expression
|
|
94
|
+
* @param ctx - The current emitter context
|
|
95
|
+
* @returns The expression and updated context
|
|
96
|
+
*/
|
|
97
|
+
export declare const lowerAssignmentPattern: (pattern: IrPattern, rhsExpr: string, type: IrType | undefined, ctx: EmitterContext) => AssignmentLoweringResult;
|
|
98
|
+
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EACL,SAAS,EAGT,MAAM,EAEP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AA8QF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,SAAS,EAClB,WAAW,MAAM,EACjB,MAAM,MAAM,GAAG,SAAS,EACxB,QAAQ,MAAM,EACd,KAAK,cAAc,KAClB,cA6BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,SAAS,EAClB,aAAa,MAAM,EACnB,aAAa,MAAM,GAAG,SAAS,EAC/B,QAAQ,MAAM,EACd,KAAK,cAAc,KAClB,cASF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,SAAS,EAClB,WAAW,MAAM,EACjB,WAAW,MAAM,GAAG,SAAS,EAC7B,QAAQ,MAAM,EACd,KAAK,cAAc,KAClB,cAQF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,SAAS,EAClB,SAAS,MAAM,EACf,MAAM,MAAM,GAAG,SAAS,EACxB,KAAK,cAAc,KAClB,wBAoFF,CAAC"}
|
package/dist/patterns.js
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Lowering Module
|
|
3
|
+
*
|
|
4
|
+
* Transforms destructuring patterns into sequences of C# variable declarations.
|
|
5
|
+
* This module is used by variable declarations, for-of loops, and function parameters.
|
|
6
|
+
*
|
|
7
|
+
* Example transformations:
|
|
8
|
+
*
|
|
9
|
+
* Array pattern:
|
|
10
|
+
* const [a, b, c] = arr;
|
|
11
|
+
* =>
|
|
12
|
+
* var __t0 = arr;
|
|
13
|
+
* var a = __t0[0];
|
|
14
|
+
* var b = __t0[1];
|
|
15
|
+
* var c = __t0[2];
|
|
16
|
+
*
|
|
17
|
+
* Array pattern with rest:
|
|
18
|
+
* const [first, ...rest] = arr;
|
|
19
|
+
* =>
|
|
20
|
+
* var __t0 = arr;
|
|
21
|
+
* var first = __t0[0];
|
|
22
|
+
* var rest = Tsonic.Runtime.ArrayHelpers.Slice(__t0, 1);
|
|
23
|
+
*
|
|
24
|
+
* Object pattern:
|
|
25
|
+
* const { name, age } = person;
|
|
26
|
+
* =>
|
|
27
|
+
* var __t0 = person;
|
|
28
|
+
* var name = __t0.name;
|
|
29
|
+
* var age = __t0.age;
|
|
30
|
+
*
|
|
31
|
+
* Object pattern with rest:
|
|
32
|
+
* const { name, ...rest } = person;
|
|
33
|
+
* =>
|
|
34
|
+
* var __t0 = person;
|
|
35
|
+
* var name = __t0.name;
|
|
36
|
+
* var rest = new __Rest_xxxx { age = __t0.age, email = __t0.email };
|
|
37
|
+
*/
|
|
38
|
+
import { emitType } from "./types/emitter.js";
|
|
39
|
+
import { escapeCSharpIdentifier } from "./emitter-types/identifiers.js";
|
|
40
|
+
/**
|
|
41
|
+
* Generate a unique temporary variable name
|
|
42
|
+
*/
|
|
43
|
+
const generateTemp = (prefix, ctx) => {
|
|
44
|
+
const tempId = ctx.tempVarId ?? 0;
|
|
45
|
+
const name = `__${prefix}${tempId}`;
|
|
46
|
+
const newCtx = { ...ctx, tempVarId: tempId + 1 };
|
|
47
|
+
return [name, newCtx];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Lower an identifier pattern to a simple variable declaration
|
|
51
|
+
*/
|
|
52
|
+
const lowerIdentifier = (name, inputExpr, type, indent, ctx) => {
|
|
53
|
+
const escapedName = escapeCSharpIdentifier(name);
|
|
54
|
+
// In static context, we can't use 'var' - need explicit type with modifiers
|
|
55
|
+
if (ctx.isStatic) {
|
|
56
|
+
const typeStr = type ? emitType(type, ctx)[0] : "object";
|
|
57
|
+
const stmt = `${indent}private static readonly ${typeStr} ${escapedName} = ${inputExpr};`;
|
|
58
|
+
return { statements: [stmt], context: ctx };
|
|
59
|
+
}
|
|
60
|
+
// Local context: use var when type not available
|
|
61
|
+
const typeStr = type ? emitType(type, ctx)[0] : "var";
|
|
62
|
+
const stmt = `${indent}${typeStr} ${escapedName} = ${inputExpr};`;
|
|
63
|
+
return { statements: [stmt], context: ctx };
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Lower an array pattern to a sequence of indexed accesses
|
|
67
|
+
*/
|
|
68
|
+
const lowerArrayPattern = (pattern, inputExpr, elementType, indent, ctx, arrayType) => {
|
|
69
|
+
const statements = [];
|
|
70
|
+
let currentCtx = ctx;
|
|
71
|
+
// Create temporary for the input to avoid re-evaluation
|
|
72
|
+
const [tempName, ctx1] = generateTemp("arr", currentCtx);
|
|
73
|
+
currentCtx = ctx1;
|
|
74
|
+
// In static context, we can't use 'var' - need explicit type
|
|
75
|
+
if (ctx.isStatic && arrayType) {
|
|
76
|
+
const [typeStr, ctx2] = emitType(arrayType, currentCtx);
|
|
77
|
+
currentCtx = ctx2;
|
|
78
|
+
statements.push(`${indent}private static readonly ${typeStr} ${tempName} = ${inputExpr};`);
|
|
79
|
+
}
|
|
80
|
+
else if (ctx.isStatic) {
|
|
81
|
+
// Static without type - use object as fallback
|
|
82
|
+
statements.push(`${indent}private static readonly object ${tempName} = ${inputExpr};`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
statements.push(`${indent}var ${tempName} = ${inputExpr};`);
|
|
86
|
+
}
|
|
87
|
+
// Process each element
|
|
88
|
+
let index = 0;
|
|
89
|
+
for (const elem of pattern.elements) {
|
|
90
|
+
if (!elem) {
|
|
91
|
+
// Hole in pattern - skip this index
|
|
92
|
+
index++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (elem.isRest) {
|
|
96
|
+
// Rest element: use ArrayHelpers.Slice
|
|
97
|
+
const result = lowerPattern(elem.pattern, `Tsonic.Runtime.ArrayHelpers.Slice(${tempName}, ${index})`, elementType ? { kind: "arrayType", elementType } : undefined, indent, currentCtx);
|
|
98
|
+
statements.push(...result.statements);
|
|
99
|
+
currentCtx = result.context;
|
|
100
|
+
// Rest must be last, so break
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
// Regular element: index access
|
|
104
|
+
const accessExpr = `${tempName}[${index}]`;
|
|
105
|
+
// Handle default value
|
|
106
|
+
let valueExpr = accessExpr;
|
|
107
|
+
if (elem.defaultExpr) {
|
|
108
|
+
// For nullable types: value ?? default
|
|
109
|
+
// For now, use simple null-coalescing (assumes nullable element type)
|
|
110
|
+
const defaultValue = emitDefaultExpr(elem.defaultExpr, currentCtx);
|
|
111
|
+
valueExpr = `${accessExpr} ?? ${defaultValue}`;
|
|
112
|
+
}
|
|
113
|
+
const result = lowerPattern(elem.pattern, valueExpr, elementType, indent, currentCtx);
|
|
114
|
+
statements.push(...result.statements);
|
|
115
|
+
currentCtx = result.context;
|
|
116
|
+
index++;
|
|
117
|
+
}
|
|
118
|
+
return { statements, context: currentCtx };
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Lower an object pattern to a sequence of property accesses
|
|
122
|
+
*/
|
|
123
|
+
const lowerObjectPattern = (pattern, inputExpr, inputType, indent, ctx) => {
|
|
124
|
+
const statements = [];
|
|
125
|
+
let currentCtx = ctx;
|
|
126
|
+
// Create temporary for the input to avoid re-evaluation
|
|
127
|
+
const [tempName, ctx1] = generateTemp("obj", currentCtx);
|
|
128
|
+
currentCtx = ctx1;
|
|
129
|
+
// In static context, we can't use 'var' - need explicit type with modifiers
|
|
130
|
+
if (ctx.isStatic && inputType) {
|
|
131
|
+
const [typeStr, ctx2] = emitType(inputType, currentCtx);
|
|
132
|
+
currentCtx = ctx2;
|
|
133
|
+
statements.push(`${indent}private static readonly ${typeStr} ${tempName} = ${inputExpr};`);
|
|
134
|
+
}
|
|
135
|
+
else if (ctx.isStatic) {
|
|
136
|
+
// Static without type - use object as fallback
|
|
137
|
+
statements.push(`${indent}private static readonly object ${tempName} = ${inputExpr};`);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
statements.push(`${indent}var ${tempName} = ${inputExpr};`);
|
|
141
|
+
}
|
|
142
|
+
// Process each property
|
|
143
|
+
for (const prop of pattern.properties) {
|
|
144
|
+
if (prop.kind === "rest") {
|
|
145
|
+
// Rest property: create new synthetic object with remaining props
|
|
146
|
+
if (prop.restShapeMembers && prop.restSynthTypeName) {
|
|
147
|
+
// Generate object initializer for rest
|
|
148
|
+
const initProps = prop.restShapeMembers
|
|
149
|
+
.filter((m) => m.kind === "propertySignature")
|
|
150
|
+
.map((m) => `${m.name} = ${tempName}.${m.name}`)
|
|
151
|
+
.join(", ");
|
|
152
|
+
const restExpr = `new ${prop.restSynthTypeName} { ${initProps} }`;
|
|
153
|
+
const result = lowerPattern(prop.pattern, restExpr, undefined, // Type is the synthetic type
|
|
154
|
+
indent, currentCtx);
|
|
155
|
+
statements.push(...result.statements);
|
|
156
|
+
currentCtx = result.context;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error("Object rest destructuring requires rest shape information from the frontend (restShapeMembers/restSynthTypeName).");
|
|
160
|
+
}
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// Regular property
|
|
164
|
+
const propAccessExpr = `${tempName}.${prop.key}`;
|
|
165
|
+
// Handle default value
|
|
166
|
+
let valueExpr = propAccessExpr;
|
|
167
|
+
if (prop.defaultExpr) {
|
|
168
|
+
const defaultValue = emitDefaultExpr(prop.defaultExpr, currentCtx);
|
|
169
|
+
valueExpr = `${propAccessExpr} ?? ${defaultValue}`;
|
|
170
|
+
}
|
|
171
|
+
// Get property type if available
|
|
172
|
+
const propType = getPropertyType(inputType, prop.key);
|
|
173
|
+
const result = lowerPattern(prop.value, valueExpr, propType, indent, currentCtx);
|
|
174
|
+
statements.push(...result.statements);
|
|
175
|
+
currentCtx = result.context;
|
|
176
|
+
}
|
|
177
|
+
return { statements, context: currentCtx };
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Get property type from an object/interface type
|
|
181
|
+
*/
|
|
182
|
+
const getPropertyType = (type, key) => {
|
|
183
|
+
if (!type)
|
|
184
|
+
return undefined;
|
|
185
|
+
if (type.kind === "objectType") {
|
|
186
|
+
const prop = type.members.find((m) => m.kind === "propertySignature" && m.name === key);
|
|
187
|
+
if (prop && prop.kind === "propertySignature") {
|
|
188
|
+
return prop.type;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (type.kind === "referenceType" && type.structuralMembers) {
|
|
192
|
+
const prop = type.structuralMembers.find((m) => m.kind === "propertySignature" && m.name === key);
|
|
193
|
+
if (prop && prop.kind === "propertySignature") {
|
|
194
|
+
return prop.type;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Emit a default expression (simplified - just literals for now)
|
|
201
|
+
*/
|
|
202
|
+
const emitDefaultExpr = (expr, _ctx) => {
|
|
203
|
+
// Simplified default expression emission
|
|
204
|
+
if (expr.kind === "literal") {
|
|
205
|
+
if (typeof expr.value === "string") {
|
|
206
|
+
return `"${expr.value}"`;
|
|
207
|
+
}
|
|
208
|
+
if (typeof expr.value === "number") {
|
|
209
|
+
return String(expr.value);
|
|
210
|
+
}
|
|
211
|
+
if (typeof expr.value === "boolean") {
|
|
212
|
+
return expr.value ? "true" : "false";
|
|
213
|
+
}
|
|
214
|
+
if (expr.value === null) {
|
|
215
|
+
return "null";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (expr.kind === "identifier") {
|
|
219
|
+
return escapeCSharpIdentifier(expr.name);
|
|
220
|
+
}
|
|
221
|
+
// For complex expressions, emit a placeholder
|
|
222
|
+
return "default!";
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Lower a pattern to a sequence of C# statements
|
|
226
|
+
*
|
|
227
|
+
* @param pattern - The pattern to lower (identifier, array, or object)
|
|
228
|
+
* @param inputExpr - The C# expression being destructured
|
|
229
|
+
* @param type - The type of the input expression (for type annotations)
|
|
230
|
+
* @param indent - Indentation prefix for generated code
|
|
231
|
+
* @param ctx - The current emitter context
|
|
232
|
+
* @returns The generated statements and updated context
|
|
233
|
+
*/
|
|
234
|
+
export const lowerPattern = (pattern, inputExpr, type, indent, ctx) => {
|
|
235
|
+
switch (pattern.kind) {
|
|
236
|
+
case "identifierPattern":
|
|
237
|
+
return lowerIdentifier(pattern.name, inputExpr, type, indent, ctx);
|
|
238
|
+
case "arrayPattern": {
|
|
239
|
+
// Get element type from array type, and pass full array type for static context
|
|
240
|
+
const elementType = type?.kind === "arrayType" ? type.elementType : undefined;
|
|
241
|
+
return lowerArrayPattern(pattern, inputExpr, elementType, indent, ctx, type);
|
|
242
|
+
}
|
|
243
|
+
case "objectPattern":
|
|
244
|
+
return lowerObjectPattern(pattern, inputExpr, type, indent, ctx);
|
|
245
|
+
default:
|
|
246
|
+
// Unknown pattern kind
|
|
247
|
+
return {
|
|
248
|
+
statements: [`${indent}// Unsupported pattern kind`],
|
|
249
|
+
context: ctx,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Lower a pattern for a for-of loop variable
|
|
255
|
+
* Similar to lowerPattern but handles the iteration context
|
|
256
|
+
*/
|
|
257
|
+
export const lowerForOfPattern = (pattern, iteratorVar, elementType, indent, ctx) => {
|
|
258
|
+
// For simple identifier patterns, no lowering needed
|
|
259
|
+
if (pattern.kind === "identifierPattern") {
|
|
260
|
+
// The for-of loop itself declares the variable
|
|
261
|
+
return { statements: [], context: ctx };
|
|
262
|
+
}
|
|
263
|
+
// For complex patterns, lower to statements inside the loop body
|
|
264
|
+
return lowerPattern(pattern, iteratorVar, elementType, indent, ctx);
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Lower a parameter pattern for function definitions
|
|
268
|
+
* Generates statements to go at the beginning of the function body
|
|
269
|
+
*/
|
|
270
|
+
export const lowerParameterPattern = (pattern, paramName, paramType, indent, ctx) => {
|
|
271
|
+
// For simple identifier patterns, no lowering needed
|
|
272
|
+
if (pattern.kind === "identifierPattern") {
|
|
273
|
+
return { statements: [], context: ctx };
|
|
274
|
+
}
|
|
275
|
+
// For complex patterns, generate statements to destructure the synthetic param
|
|
276
|
+
return lowerPattern(pattern, paramName, paramType, indent, ctx);
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Lower an assignment pattern to a C# expression
|
|
280
|
+
*
|
|
281
|
+
* In JavaScript, destructuring assignment is an expression that returns the RHS:
|
|
282
|
+
* const result = ([a, b] = arr); // result === arr
|
|
283
|
+
*
|
|
284
|
+
* We emit this as a parenthesized sequence expression:
|
|
285
|
+
* ((__t = rhs), (a = __t[0]), (b = __t[1]), __t)
|
|
286
|
+
*
|
|
287
|
+
* @param pattern - The pattern being assigned to
|
|
288
|
+
* @param rhsExpr - The C# expression for the right-hand side
|
|
289
|
+
* @param type - The type of the RHS expression
|
|
290
|
+
* @param ctx - The current emitter context
|
|
291
|
+
* @returns The expression and updated context
|
|
292
|
+
*/
|
|
293
|
+
export const lowerAssignmentPattern = (pattern, rhsExpr, type, ctx) => {
|
|
294
|
+
// For identifier pattern, just emit simple assignment
|
|
295
|
+
if (pattern.kind === "identifierPattern") {
|
|
296
|
+
const escapedName = escapeCSharpIdentifier(pattern.name);
|
|
297
|
+
return {
|
|
298
|
+
expression: `${escapedName} = ${rhsExpr}`,
|
|
299
|
+
context: ctx,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// For complex patterns, generate sequence expression
|
|
303
|
+
const [tempName, ctx1] = generateTemp("t", ctx);
|
|
304
|
+
let currentCtx = ctx1;
|
|
305
|
+
// Collect assignment expressions
|
|
306
|
+
const assignments = [];
|
|
307
|
+
if (pattern.kind === "arrayPattern") {
|
|
308
|
+
const elementType = type?.kind === "arrayType" ? type.elementType : undefined;
|
|
309
|
+
let index = 0;
|
|
310
|
+
for (const elem of pattern.elements) {
|
|
311
|
+
if (!elem) {
|
|
312
|
+
// Hole in pattern - skip
|
|
313
|
+
index++;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (elem.isRest) {
|
|
317
|
+
// Rest element
|
|
318
|
+
const result = lowerAssignmentPatternElement(elem.pattern, `Tsonic.Runtime.ArrayHelpers.Slice(${tempName}, ${index})`, elementType ? { kind: "arrayType", elementType } : undefined, currentCtx);
|
|
319
|
+
assignments.push(result.expression);
|
|
320
|
+
currentCtx = result.context;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
// Regular element
|
|
324
|
+
const result = lowerAssignmentPatternElement(elem.pattern, `${tempName}[${index}]`, elementType, currentCtx);
|
|
325
|
+
assignments.push(result.expression);
|
|
326
|
+
currentCtx = result.context;
|
|
327
|
+
index++;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (pattern.kind === "objectPattern") {
|
|
331
|
+
for (const prop of pattern.properties) {
|
|
332
|
+
if (prop.kind === "rest") {
|
|
333
|
+
// Rest property - would need synthetic type
|
|
334
|
+
if (prop.pattern.kind === "identifierPattern") {
|
|
335
|
+
const escapedName = escapeCSharpIdentifier(prop.pattern.name);
|
|
336
|
+
assignments.push(`/* ${escapedName} = rest of ${tempName} - needs synthetic type */`);
|
|
337
|
+
}
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
// Regular property
|
|
341
|
+
const propType = getPropertyType(type, prop.key);
|
|
342
|
+
const result = lowerAssignmentPatternElement(prop.value, `${tempName}.${prop.key}`, propType, currentCtx);
|
|
343
|
+
assignments.push(result.expression);
|
|
344
|
+
currentCtx = result.context;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
// Build sequence expression: (__t = rhs, a = __t[0], ..., __t)
|
|
348
|
+
const allParts = [`${tempName} = ${rhsExpr}`, ...assignments, tempName];
|
|
349
|
+
const expression = `(${allParts.join(", ")})`;
|
|
350
|
+
return { expression, context: currentCtx };
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Helper to lower a single element/property in an assignment pattern
|
|
354
|
+
*/
|
|
355
|
+
const lowerAssignmentPatternElement = (pattern, inputExpr, type, ctx) => {
|
|
356
|
+
if (pattern.kind === "identifierPattern") {
|
|
357
|
+
const escapedName = escapeCSharpIdentifier(pattern.name);
|
|
358
|
+
return {
|
|
359
|
+
expression: `${escapedName} = ${inputExpr}`,
|
|
360
|
+
context: ctx,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// Nested pattern - recurse
|
|
364
|
+
return lowerAssignmentPattern(pattern, inputExpr, type, ctx);
|
|
365
|
+
};
|
|
366
|
+
//# sourceMappingURL=patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAUH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAYxE;;GAEG;AACH,MAAM,YAAY,GAAG,CACnB,MAAc,EACd,GAAmB,EACO,EAAE;IAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;IACjD,OAAO,CAAC,IAAI,EAAE,MAAM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ehensive Tests for Destructuring Pattern Lowering
|
|
3
|
+
*
|
|
4
|
+
* Tests all forms of destructuring:
|
|
5
|
+
* - Variable declaration destructuring (array and object)
|
|
6
|
+
* - For-of loop destructuring
|
|
7
|
+
* - Parameter destructuring
|
|
8
|
+
* - Assignment destructuring
|
|
9
|
+
* - Nested patterns
|
|
10
|
+
* - Rest elements
|
|
11
|
+
* - Default values
|
|
12
|
+
* - Edge cases
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=patterns.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.test.d.ts","sourceRoot":"","sources":["../src/patterns.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|