@jalvin/compiler 2.0.37 → 2.0.39
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/codegen.d.ts +4 -56
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +297 -884
- package/dist/codegen.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/typechecker.d.ts.map +1 -1
- package/dist/typechecker.js +1 -3
- package/dist/typechecker.js.map +1 -1
- package/package.json +1 -1
- package/dist/codegen/index.d.ts +0 -179
- package/dist/codegen/index.d.ts.map +0 -1
- package/dist/codegen/index.js +0 -2207
- package/dist/codegen/index.js.map +0 -1
- package/dist/codegen_freestanding_c.d.ts +0 -9
- package/dist/codegen_freestanding_c.d.ts.map +0 -1
- package/dist/codegen_freestanding_c.js +0 -321
- package/dist/codegen_freestanding_c.js.map +0 -1
- package/dist/lexer/chars.d.ts +0 -5
- package/dist/lexer/chars.d.ts.map +0 -1
- package/dist/lexer/chars.js +0 -20
- package/dist/lexer/chars.js.map +0 -1
- package/dist/lexer/index.d.ts +0 -37
- package/dist/lexer/index.d.ts.map +0 -1
- package/dist/lexer/index.js +0 -630
- package/dist/lexer/index.js.map +0 -1
- package/dist/lexer/tokens.d.ts +0 -135
- package/dist/lexer/tokens.d.ts.map +0 -1
- package/dist/lexer/tokens.js +0 -89
- package/dist/lexer/tokens.js.map +0 -1
- package/dist/parser/constants.d.ts +0 -3
- package/dist/parser/constants.d.ts.map +0 -1
- package/dist/parser/constants.js +0 -7
- package/dist/parser/constants.js.map +0 -1
- package/dist/parser/helpers.d.ts +0 -2
- package/dist/parser/helpers.d.ts.map +0 -1
- package/dist/parser/helpers.js +0 -9
- package/dist/parser/helpers.js.map +0 -1
- package/dist/parser/index.d.ts +0 -118
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js +0 -2387
- package/dist/parser/index.js.map +0 -1
- package/dist/typechecker/globals.d.ts +0 -2
- package/dist/typechecker/globals.d.ts.map +0 -1
- package/dist/typechecker/globals.js +0 -15
- package/dist/typechecker/globals.js.map +0 -1
- package/dist/typechecker/index.d.ts +0 -146
- package/dist/typechecker/index.d.ts.map +0 -1
- package/dist/typechecker/index.js +0 -2288
- package/dist/typechecker/index.js.map +0 -1
- package/dist/typechecker/types.d.ts +0 -66
- package/dist/typechecker/types.d.ts.map +0 -1
- package/dist/typechecker/types.js +0 -39
- package/dist/typechecker/types.js.map +0 -1
package/dist/codegen/index.d.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as AST from "../ast.js";
|
|
2
|
-
import { JType } from "../typechecker.js";
|
|
3
|
-
export interface CodegenOptions {
|
|
4
|
-
/** Emit .tsx (React JSX) output — set for files containing `component` decls */
|
|
5
|
-
readonly jsx: boolean;
|
|
6
|
-
/** Target module format */
|
|
7
|
-
readonly module: "esm" | "cjs";
|
|
8
|
-
/** Emit type annotations in output (verbose but useful for debugging) */
|
|
9
|
-
readonly emitTypes: boolean;
|
|
10
|
-
/** Path to import from for the Jalvin runtime */
|
|
11
|
-
readonly runtimeImport: string;
|
|
12
|
-
/**
|
|
13
|
-
* Project root directory used to resolve local import paths.
|
|
14
|
-
* When set, the emitter checks whether the preceding path segments of a
|
|
15
|
-
* local import (e.g. `src/models/css`) resolve to an existing file before
|
|
16
|
-
* deciding whether to append the symbol name to the module specifier.
|
|
17
|
-
* Defaults to `process.cwd()` at emit time when not provided.
|
|
18
|
-
*/
|
|
19
|
-
readonly sourceRoot?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare const DEFAULT_CODEGEN_OPTIONS: CodegenOptions;
|
|
22
|
-
export interface CodegenResult {
|
|
23
|
-
readonly code: string;
|
|
24
|
-
readonly lineMap: number[];
|
|
25
|
-
/** Whether JSX was emitted (caller should rename output to .tsx) */
|
|
26
|
-
readonly isJsx: boolean;
|
|
27
|
-
}
|
|
28
|
-
export declare class CodeGenerator {
|
|
29
|
-
private readonly w;
|
|
30
|
-
private readonly opts;
|
|
31
|
-
private hasComponents;
|
|
32
|
-
private runtimeSymbolsNeeded;
|
|
33
|
-
/** Names of component functions — used to detect Compose-style calls and emit them as JSX */
|
|
34
|
-
private componentNames;
|
|
35
|
-
/**
|
|
36
|
-
* Param names for components resolved from imported local .jalvin files.
|
|
37
|
-
* Maps component name → ordered list of param names.
|
|
38
|
-
*/
|
|
39
|
-
private componentParamNames;
|
|
40
|
-
/** True when the program contains `import @jalvin/ui.*` — used to detect UI primitive calls */
|
|
41
|
-
private hasUiStarImport;
|
|
42
|
-
/** Operator overload resolutions from the type checker */
|
|
43
|
-
private operatorOverloadMap;
|
|
44
|
-
/** Type map from the type checker */
|
|
45
|
-
private typeMap;
|
|
46
|
-
/**
|
|
47
|
-
* Registry of extension functions declared on primitive receiver types.
|
|
48
|
-
* Maps receiverTypeName → Map<methodName, generatedFnName>
|
|
49
|
-
* Populated during top-level emit; used at call sites for rewriting.
|
|
50
|
-
*/
|
|
51
|
-
private primitiveExtensions;
|
|
52
|
-
/**
|
|
53
|
-
* When a scoped star import exists (e.g. import @jalvin/runtime.*), contains the
|
|
54
|
-
* set of external symbol names to emit as named imports from that package instead
|
|
55
|
-
* of a namespace import. Empty if namespace-import behavior is used.
|
|
56
|
-
*/
|
|
57
|
-
private externalStarCandidates;
|
|
58
|
-
/** Module specifiers whose symbols are already covered by a named star-import expansion. */
|
|
59
|
-
private handledStarImportModules;
|
|
60
|
-
constructor(opts?: Partial<CodegenOptions>);
|
|
61
|
-
generate(program: AST.Program, operatorOverloads?: Map<AST.BinaryExpr, string>, typeMap?: Map<object, JType>): CodegenResult;
|
|
62
|
-
private buildPreamble;
|
|
63
|
-
private emitHeader;
|
|
64
|
-
/**
|
|
65
|
-
* Heuristic for non-scoped imports: if the first path segment resolves to an
|
|
66
|
-
* installed package in node_modules, treat the import as npm/ESM and strip
|
|
67
|
-
* the trailing symbol name from the module specifier.
|
|
68
|
-
*/
|
|
69
|
-
private isLikelyNodeModuleImport;
|
|
70
|
-
/** Emit a @deprecated JSDoc block if the declaration has @Nuked. */
|
|
71
|
-
private emitAnnotations;
|
|
72
|
-
private emitTopLevelDecl;
|
|
73
|
-
private emitFunDecl;
|
|
74
|
-
private emitMemberFunDecl;
|
|
75
|
-
private emitComponentDecl;
|
|
76
|
-
/**
|
|
77
|
-
* Emit the body of a `component fun` block.
|
|
78
|
-
* The last statement is emitted in tail position — if it is an expression,
|
|
79
|
-
* an if/else chain, or a when block, the innermost UI call is implicitly
|
|
80
|
-
* returned (Kotlin-style implicit return of the last expression).
|
|
81
|
-
*/
|
|
82
|
-
private emitComponentBlock;
|
|
83
|
-
/** Emit a statement in tail position, adding implicit return where applicable. */
|
|
84
|
-
private emitTailStmt;
|
|
85
|
-
/** Emit a block in tail position, treating its last statement as a tail expression. */
|
|
86
|
-
private emitTailBlock;
|
|
87
|
-
/** Like emitIfStmt but with tail-return applied recursively to each branch body. */
|
|
88
|
-
private emitIfStmtWithTailReturn;
|
|
89
|
-
/** Like emitWhenStmt but with tail-return applied recursively to each branch body. */
|
|
90
|
-
private emitWhenStmtWithTailReturn;
|
|
91
|
-
private emitClassDecl;
|
|
92
|
-
private emitDataClassDecl;
|
|
93
|
-
private emitSealedClassDecl;
|
|
94
|
-
private emitEnumClassDecl;
|
|
95
|
-
private emitDestructuringDecl;
|
|
96
|
-
private emitInterfaceDecl;
|
|
97
|
-
private emitObjectDecl;
|
|
98
|
-
private emitTypeAliasDecl;
|
|
99
|
-
private emitExtensionFunDecl;
|
|
100
|
-
private receiverClassName;
|
|
101
|
-
/**
|
|
102
|
-
* Maps a JType to the primitive receiver type name used as a key
|
|
103
|
-
* in `primitiveExtensions` (e.g. JType `{ tag: "string" }` → `"String"`).
|
|
104
|
-
* Returns null for non-primitive / unknown types.
|
|
105
|
-
*/
|
|
106
|
-
private jTypeToReceiverName;
|
|
107
|
-
private classHasInvokeOperator;
|
|
108
|
-
private emitPropertyDecl;
|
|
109
|
-
private emitPropertyAccessor;
|
|
110
|
-
private emitClassBody;
|
|
111
|
-
private emitClassMember;
|
|
112
|
-
private emitPrimaryConstructorProps;
|
|
113
|
-
private emitCompanionObject;
|
|
114
|
-
private emitSecondaryConstructor;
|
|
115
|
-
private emitBlock;
|
|
116
|
-
private emitStmt;
|
|
117
|
-
private emitIfStmt;
|
|
118
|
-
private emitWhenStmt;
|
|
119
|
-
private emitWhenCondition;
|
|
120
|
-
private emitForStmt;
|
|
121
|
-
private emitTryCatch;
|
|
122
|
-
emitExpr(expr: AST.Expr): string;
|
|
123
|
-
private emitJsxElement;
|
|
124
|
-
private emitJsxAttr;
|
|
125
|
-
private emitJsxChild;
|
|
126
|
-
private emitStringTemplate;
|
|
127
|
-
private emitCallExpr;
|
|
128
|
-
/**
|
|
129
|
-
* For each non-scoped local import (e.g. `import src.views.MoveCounterView.MoveCounter`),
|
|
130
|
-
* attempt to load and parse the corresponding .jalvin source file. If the named symbol is
|
|
131
|
-
* a `component fun`, register it in `componentNames` and record its param names so that
|
|
132
|
-
* call sites can emit the correct props-object invocation.
|
|
133
|
-
*/
|
|
134
|
-
private resolveLocalComponentImports;
|
|
135
|
-
/** Returns true if a call expression's callee looks like a class constructor.
|
|
136
|
-
* In Jalvin, class names always start with an uppercase letter. */
|
|
137
|
-
private isConstructorCall;
|
|
138
|
-
/** Emit `Column(modifier = ...) { ... }` as `Column({ modifier: ... }, [children])` */
|
|
139
|
-
private emitComposeCallAsDom;
|
|
140
|
-
/** Collect each expression statement in a trailing-lambda body as DOM children. */
|
|
141
|
-
private emitLambdaBodyAsDomChildren;
|
|
142
|
-
private emitLambdaExpr;
|
|
143
|
-
private emitIfExpr;
|
|
144
|
-
private emitWhenExpr;
|
|
145
|
-
private emitTryCatchExpr;
|
|
146
|
-
private emitCollectionLiteral;
|
|
147
|
-
private emitObjectExpr;
|
|
148
|
-
private captureBlock;
|
|
149
|
-
private captureBlockStatements;
|
|
150
|
-
private captureStmt;
|
|
151
|
-
private captureClassMember;
|
|
152
|
-
private emitTypeRef;
|
|
153
|
-
private emitTypeParamsStr;
|
|
154
|
-
private emitParamsStr;
|
|
155
|
-
private emitComponentPropsStr;
|
|
156
|
-
private emitSuperTypesStr;
|
|
157
|
-
private exportPrefix;
|
|
158
|
-
private visibilityPrefix;
|
|
159
|
-
private unaryOpStr;
|
|
160
|
-
private binaryOpStr;
|
|
161
|
-
/**
|
|
162
|
-
* Walk the entire program AST and collect all identifier names that are
|
|
163
|
-
* REFERENCED (i.e., used) in the code: NameExpr values and the first name
|
|
164
|
-
* component of SimpleTypeRef / GenericTypeRef nodes.
|
|
165
|
-
*
|
|
166
|
-
* Jalvin primitive type names (String, Boolean, …) that map to TS primitives
|
|
167
|
-
* are excluded from TypeRef collection since they never need an import.
|
|
168
|
-
*/
|
|
169
|
-
private gatherReferencedNames;
|
|
170
|
-
/**
|
|
171
|
-
* Walk the entire program AST and collect all names that are LOCALLY DEFINED:
|
|
172
|
-
* top-level declaration names, non-star import aliases, function/lambda
|
|
173
|
-
* parameters, local val/var bindings, for-loop variables, catch-clause names,
|
|
174
|
-
* when-subject bindings, and type parameter names.
|
|
175
|
-
*/
|
|
176
|
-
private gatherAllLocalBindings;
|
|
177
|
-
}
|
|
178
|
-
export declare function generate(program: AST.Program, opts?: Partial<CodegenOptions>, operatorOverloads?: Map<AST.BinaryExpr, string>, typeMap?: Map<object, JType>): CodegenResult;
|
|
179
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAoD1C,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,2BAA2B;IAC3B,QAAQ,CA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