@jalvin/compiler 2.0.38 → 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 +3 -56
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +252 -898
- 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.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as AST from "./ast.js";
|
|
2
2
|
import { JType } from "./typechecker.js";
|
|
3
3
|
export interface CodegenOptions {
|
|
4
|
-
/** Emit .tsx (React JSX) output — set for files containing `component` decls */
|
|
5
|
-
readonly jsx: boolean;
|
|
6
4
|
/** Target module format */
|
|
7
5
|
readonly module: "esm" | "cjs";
|
|
8
6
|
/** Emit type annotations in output (verbose but useful for debugging) */
|
|
@@ -22,15 +20,15 @@ export declare const DEFAULT_CODEGEN_OPTIONS: CodegenOptions;
|
|
|
22
20
|
export interface CodegenResult {
|
|
23
21
|
readonly code: string;
|
|
24
22
|
readonly lineMap: number[];
|
|
25
|
-
/**
|
|
26
|
-
readonly
|
|
23
|
+
/** True if the program contains component declarations or UI imports. */
|
|
24
|
+
readonly hasComponents: boolean;
|
|
27
25
|
}
|
|
28
26
|
export declare class CodeGenerator {
|
|
29
27
|
private readonly w;
|
|
30
28
|
private readonly opts;
|
|
31
29
|
private hasComponents;
|
|
32
30
|
private runtimeSymbolsNeeded;
|
|
33
|
-
/** Names of true Jalvin components — used to
|
|
31
|
+
/** Names of true Jalvin components — used to detect functional calls */
|
|
34
32
|
private userComponentNames;
|
|
35
33
|
/** Names of all potential components (including UI primitives) — used to detect props-object calls */
|
|
36
34
|
private allComponentLikeNames;
|
|
@@ -68,39 +66,21 @@ export declare class CodeGenerator {
|
|
|
68
66
|
private localStarExports;
|
|
69
67
|
private isInClass;
|
|
70
68
|
constructor(opts?: Partial<CodegenOptions>);
|
|
71
|
-
/** Returns true if the output should be treated as JSX (React components) */
|
|
72
|
-
private get isJsxMode();
|
|
73
69
|
generate(program: AST.Program, operatorOverloads?: Map<AST.BinaryExpr, string>, typeMap?: Map<object, JType>): CodegenResult;
|
|
74
70
|
/** Walk AST to see if it contains any JsxElement nodes */
|
|
75
71
|
private containsJsx;
|
|
76
72
|
private buildPreamble;
|
|
77
73
|
private emitHeader;
|
|
78
|
-
/**
|
|
79
|
-
* Heuristic for non-scoped imports: if the first path segment resolves to an
|
|
80
|
-
* installed package in node_modules, treat the import as npm/ESM and strip
|
|
81
|
-
* the trailing symbol name from the module specifier.
|
|
82
|
-
*/
|
|
83
74
|
private isLikelyNodeModuleImport;
|
|
84
|
-
/** Emit a @deprecated JSDoc block if the declaration has @Nuked. */
|
|
85
75
|
private emitAnnotations;
|
|
86
76
|
private emitTopLevelDecl;
|
|
87
77
|
private emitFunDecl;
|
|
88
78
|
private emitMemberFunDecl;
|
|
89
79
|
private emitComponentDecl;
|
|
90
|
-
/**
|
|
91
|
-
* Emit the body of a `component fun` block.
|
|
92
|
-
* The last statement is emitted in tail position — if it is an expression,
|
|
93
|
-
* an if/else chain, or a when block, the innermost UI call is implicitly
|
|
94
|
-
* returned (implicit return of the last expression).
|
|
95
|
-
*/
|
|
96
80
|
private emitComponentBlock;
|
|
97
|
-
/** Emit a statement in tail position, adding implicit return where applicable. */
|
|
98
81
|
private emitTailStmt;
|
|
99
|
-
/** Emit a block in tail position, treating its last statement as a tail expression. */
|
|
100
82
|
private emitTailBlock;
|
|
101
|
-
/** Like emitIfStmt but with tail-return applied recursively to each branch body. */
|
|
102
83
|
private emitIfStmtWithTailReturn;
|
|
103
|
-
/** Like emitWhenStmt but with tail-return applied recursively to each branch body. */
|
|
104
84
|
private emitWhenStmtWithTailReturn;
|
|
105
85
|
private emitClassDecl;
|
|
106
86
|
private emitDataClassDecl;
|
|
@@ -112,11 +92,6 @@ export declare class CodeGenerator {
|
|
|
112
92
|
private emitTypeAliasDecl;
|
|
113
93
|
private emitExtensionFunDecl;
|
|
114
94
|
private receiverClassName;
|
|
115
|
-
/**
|
|
116
|
-
* Maps a JType to the primitive receiver type name used as a key
|
|
117
|
-
* in `primitiveExtensions` (e.g. JType `{ tag: "string" }` → `"String"`).
|
|
118
|
-
* Returns null for non-primitive / unknown types.
|
|
119
|
-
*/
|
|
120
95
|
private jTypeToReceiverName;
|
|
121
96
|
private classHasInvokeOperator;
|
|
122
97
|
private emitPropertyDecl;
|
|
@@ -139,22 +114,9 @@ export declare class CodeGenerator {
|
|
|
139
114
|
private emitJsxChild;
|
|
140
115
|
private emitStringTemplate;
|
|
141
116
|
private emitCallExpr;
|
|
142
|
-
/**
|
|
143
|
-
* For each non-scoped local import (e.g. `import src.views.MoveCounterView.MoveCounter`),
|
|
144
|
-
* attempt to load and parse the corresponding .jalvin source file. If the named symbol is
|
|
145
|
-
* a `component fun`, register it in `userComponentNames` and record its param names so that
|
|
146
|
-
* call sites can emit the correct props-object invocation.
|
|
147
|
-
*/
|
|
148
117
|
private resolveLocalComponentImports;
|
|
149
|
-
/** Returns true if a call expression's callee looks like a class constructor.
|
|
150
|
-
* In Jalvin, class names always start with an uppercase letter. */
|
|
151
118
|
private isConstructorCall;
|
|
152
|
-
/** Returns true if a name refers to a "true" Jalvin component that needs a React boundary */
|
|
153
|
-
private isTrueComponent;
|
|
154
|
-
/** Emit `Column(modifier = ...) { ... }` as either direct calls or React.createElement depending on jsx option */
|
|
155
119
|
private emitComponentCall;
|
|
156
|
-
/** Collect each expression statement in a trailing-lambda body as DOM children.
|
|
157
|
-
* For-loop statements are emitted as spread IIFEs so their dynamic output is preserved. */
|
|
158
120
|
private emitLambdaBodyAsDomChildren;
|
|
159
121
|
private emitLambdaExpr;
|
|
160
122
|
private emitIfExpr;
|
|
@@ -169,27 +131,12 @@ export declare class CodeGenerator {
|
|
|
169
131
|
private emitTypeRef;
|
|
170
132
|
private emitTypeParamsStr;
|
|
171
133
|
private emitParamsStr;
|
|
172
|
-
private emitComponentPropsStr;
|
|
173
134
|
private emitSuperTypesStr;
|
|
174
135
|
private exportPrefix;
|
|
175
136
|
private visibilityPrefix;
|
|
176
137
|
private unaryOpStr;
|
|
177
138
|
private binaryOpStr;
|
|
178
|
-
/**
|
|
179
|
-
* Walk the entire program AST and collect all identifier names that are
|
|
180
|
-
* REFERENCED (i.e., used) in the code: NameExpr values and the first name
|
|
181
|
-
* component of SimpleTypeRef / GenericTypeRef nodes.
|
|
182
|
-
*
|
|
183
|
-
* Jalvin primitive type names (String, Boolean, …) that map to TS primitives
|
|
184
|
-
* are excluded from TypeRef collection since they never need an import.
|
|
185
|
-
*/
|
|
186
139
|
private gatherReferencedNames;
|
|
187
|
-
/**
|
|
188
|
-
* Walk the entire program AST and collect all names that are LOCALLY DEFINED:
|
|
189
|
-
* top-level declaration names, non-star import aliases, function/lambda
|
|
190
|
-
* parameters, local val/var bindings, for-loop variables, catch-clause names,
|
|
191
|
-
* when-subject bindings, and type parameter names.
|
|
192
|
-
*/
|
|
193
140
|
private gatherAllLocalBindings;
|
|
194
141
|
}
|
|
195
142
|
export declare function generate(program: AST.Program, opts?: Partial<CodegenOptions>, operatorOverloads?: Map<AST.BinaryExpr, string>, typeMap?: Map<object, JType>): CodegenResult;
|
package/dist/codegen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAoDzC,MAAM,WAAW,cAAc;IAC7B,
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,GAAG,MAAM,UAAU,CAA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