@elaraai/east 0.0.1-beta.0 → 0.0.1-beta.10
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/README.md +44 -16
- package/dist/src/analyze.d.ts +4 -4
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +142 -44
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/ast.d.ts +18 -7
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +1 -146
- package/dist/src/ast.js.map +1 -1
- package/dist/src/ast_to_ir.d.ts +7 -0
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +80 -11
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +89 -64
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +31 -2
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +137 -221
- package/dist/src/compile.js.map +1 -1
- package/dist/src/default.d.ts.map +1 -1
- package/dist/src/default.js +2 -0
- package/dist/src/default.js.map +1 -1
- package/dist/src/eastir.d.ts +12 -10
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +20 -19
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/expr/array.d.ts +66 -0
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +161 -51
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/ast.d.ts.map +1 -1
- package/dist/src/expr/ast.js +6 -0
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.d.ts +49 -0
- package/dist/src/expr/asyncfunction.d.ts.map +1 -0
- package/dist/src/expr/asyncfunction.js +60 -0
- package/dist/src/expr/asyncfunction.js.map +1 -0
- package/dist/src/expr/blob.d.ts +25 -1
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +36 -1
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +82 -8
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +278 -16
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/dict.js +47 -47
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +9 -0
- package/dist/src/expr/expr.d.ts.map +1 -1
- package/dist/src/expr/expr.js +5 -1
- package/dist/src/expr/expr.js.map +1 -1
- package/dist/src/expr/index.d.ts +112 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +110 -8
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/libs/array.js +1 -1
- package/dist/src/expr/libs/array.js.map +1 -1
- package/dist/src/expr/libs/dict.js +3 -3
- package/dist/src/expr/libs/dict.js.map +1 -1
- package/dist/src/expr/libs/integer.d.ts +19 -0
- package/dist/src/expr/libs/integer.d.ts.map +1 -1
- package/dist/src/expr/libs/integer.js +47 -0
- package/dist/src/expr/libs/integer.js.map +1 -1
- package/dist/src/expr/libs/set.js +2 -2
- package/dist/src/expr/libs/set.js.map +1 -1
- package/dist/src/expr/ref.js +1 -1
- package/dist/src/expr/ref.js.map +1 -1
- package/dist/src/expr/set.js +38 -38
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/struct.d.ts +2 -0
- package/dist/src/expr/struct.d.ts.map +1 -1
- package/dist/src/expr/types.d.ts +8 -5
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +53 -0
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +56 -0
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +5 -0
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/internal.d.ts +18 -9
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +22 -5
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +231 -33
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +3 -1
- package/dist/src/ir.js.map +1 -1
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +59 -18
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast2-stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2-stream.js +5 -0
- package/dist/src/serialization/beast2-stream.js.map +1 -1
- package/dist/src/serialization/beast2.d.ts.map +1 -1
- package/dist/src/serialization/beast2.js +10 -4
- package/dist/src/serialization/beast2.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +139 -0
- package/dist/src/serialization/csv.d.ts.map +1 -0
- package/dist/src/serialization/csv.js +615 -0
- package/dist/src/serialization/csv.js.map +1 -0
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +9 -1
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/index.d.ts +1 -0
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -0
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +8 -2
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/type_of_type.d.ts +29 -31
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.js +187 -14
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/types.d.ts +59 -44
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +191 -91
- package/dist/src/types.js.map +1 -1
- package/package.json +6 -6
package/dist/src/ast.d.ts
CHANGED
|
@@ -69,6 +69,14 @@ export type FunctionAST = {
|
|
|
69
69
|
body: AST;
|
|
70
70
|
};
|
|
71
71
|
/** @internal */
|
|
72
|
+
export type AsyncFunctionAST = {
|
|
73
|
+
ast_type: "AsyncFunction";
|
|
74
|
+
type: EastType;
|
|
75
|
+
location: Location;
|
|
76
|
+
parameters: VariableAST[];
|
|
77
|
+
body: AST;
|
|
78
|
+
};
|
|
79
|
+
/** @internal */
|
|
72
80
|
export type CallAST = {
|
|
73
81
|
ast_type: "Call";
|
|
74
82
|
type: EastType;
|
|
@@ -77,6 +85,14 @@ export type CallAST = {
|
|
|
77
85
|
arguments: AST[];
|
|
78
86
|
};
|
|
79
87
|
/** @internal */
|
|
88
|
+
export type CallAsyncAST = {
|
|
89
|
+
ast_type: "CallAsync";
|
|
90
|
+
type: EastType;
|
|
91
|
+
location: Location;
|
|
92
|
+
function: AST;
|
|
93
|
+
arguments: AST[];
|
|
94
|
+
};
|
|
95
|
+
/** @internal */
|
|
80
96
|
export type NewRefAST = {
|
|
81
97
|
ast_type: "NewRef";
|
|
82
98
|
type: EastType;
|
|
@@ -251,13 +267,8 @@ export type PlatformAST = {
|
|
|
251
267
|
location: Location;
|
|
252
268
|
name: string;
|
|
253
269
|
arguments: AST[];
|
|
270
|
+
async: boolean;
|
|
254
271
|
};
|
|
255
272
|
/** @internal */
|
|
256
|
-
export type AST = ErrorAST | TryCatchAST | ValueAST | AsAST | VariableAST | LetAST | AssignAST | FunctionAST | CallAST | NewRefAST | NewArrayAST | NewSetAST | NewDictAST | StructAST | GetFieldAST | VariantAST | BlockAST | IfElseAST | MatchAST | UnwrapRecursiveAST | WrapRecursiveAST | WhileAST | ForArrayAST | ForSetAST | ForDictAST | ReturnAST | ContinueAST | BreakAST | BuiltinAST | PlatformAST;
|
|
257
|
-
/** Get the platform functions used inside an AST node. Useful to obtrain the potential effects performed by a function.
|
|
258
|
-
*
|
|
259
|
-
* @internal */
|
|
260
|
-
export declare function getPlatforms(ast: AST): string[];
|
|
261
|
-
/** @internal */
|
|
262
|
-
export declare function _getPlatforms(ast: AST, platforms: Set<string>): void;
|
|
273
|
+
export type AST = ErrorAST | TryCatchAST | ValueAST | AsAST | VariableAST | LetAST | AssignAST | FunctionAST | AsyncFunctionAST | CallAST | CallAsyncAST | NewRefAST | NewArrayAST | NewSetAST | NewDictAST | StructAST | GetFieldAST | VariantAST | BlockAST | IfElseAST | MatchAST | UnwrapRecursiveAST | WrapRecursiveAST | WhileAST | ForArrayAST | ForSetAST | ForDictAST | ReturnAST | ContinueAST | BreakAST | BuiltinAST | PlatformAST;
|
|
263
274
|
//# sourceMappingURL=ast.d.ts.map
|
package/dist/src/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQ9C,gBAAgB;AAChB,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,GAAG,CAAC;CACd,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ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SAAS,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,eAAe,EAAE,QAAQ,EAAE,CAAC;IAC5B,SAAS,EAAE,GAAG,EAAE,CAAC;CAClB,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,GAAG,EAAE,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC"}
|
package/dist/src/ast.js
CHANGED
|
@@ -2,150 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
/** Get the platform functions used inside an AST node. Useful to obtrain the potential effects performed by a function.
|
|
7
|
-
*
|
|
8
|
-
* @internal */
|
|
9
|
-
export function getPlatforms(ast) {
|
|
10
|
-
const platforms = new Set();
|
|
11
|
-
_getPlatforms(ast, platforms);
|
|
12
|
-
return [...platforms].sort();
|
|
13
|
-
}
|
|
14
|
-
/** @internal */
|
|
15
|
-
export function _getPlatforms(ast, platforms) {
|
|
16
|
-
if (ast.ast_type === "Platform") {
|
|
17
|
-
// The trivial case
|
|
18
|
-
platforms.add(ast.name);
|
|
19
|
-
}
|
|
20
|
-
else if (ast.ast_type === "Call") {
|
|
21
|
-
// We need to obtain the callee, which may require platforms to evaluate
|
|
22
|
-
_getPlatforms(ast.function, platforms);
|
|
23
|
-
// We need to obtain the arguments
|
|
24
|
-
for (const arg of ast.arguments) {
|
|
25
|
-
_getPlatforms(arg, platforms);
|
|
26
|
-
}
|
|
27
|
-
// Finally, we need to add any platforms the function uses
|
|
28
|
-
const callee_platforms = ast.function.type.platforms;
|
|
29
|
-
if (callee_platforms === null) {
|
|
30
|
-
throw new Error(`Called function has not populated the 'platforms' field`);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
for (const p of callee_platforms) {
|
|
34
|
-
platforms.add(p);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else if (ast.ast_type === "Builtin") {
|
|
39
|
-
const builtin_def = Builtins[ast.builtin];
|
|
40
|
-
if (!builtin_def) {
|
|
41
|
-
throw new Error(`Unknown builtin ${ast.builtin}`);
|
|
42
|
-
}
|
|
43
|
-
if (builtin_def.inputs.length !== ast.arguments.length) {
|
|
44
|
-
throw new Error(`Builtin ${ast.builtin} expected ${builtin_def.inputs.length} arguments, got ${ast.arguments.length}`);
|
|
45
|
-
}
|
|
46
|
-
for (const [i, arg] of ast.arguments.entries()) {
|
|
47
|
-
// Find the platform functions required to evaluate the argument
|
|
48
|
-
_getPlatforms(arg, platforms);
|
|
49
|
-
// Some platform functions are higher-order functions
|
|
50
|
-
// - No existing builtin returns a function
|
|
51
|
-
// - Any functions they call are direct arguments
|
|
52
|
-
// - Such arguments have "Function" type in their Builtin definition
|
|
53
|
-
const expected_type = builtin_def.inputs[i];
|
|
54
|
-
if (typeof expected_type === "object" && expected_type.type === "Function") {
|
|
55
|
-
if (arg.type.type !== "Function") {
|
|
56
|
-
throw new Error(`Builtin ${ast.builtin} expected argument ${i} to be a function`);
|
|
57
|
-
}
|
|
58
|
-
const func_platforms = arg.type.platforms;
|
|
59
|
-
if (func_platforms === null) {
|
|
60
|
-
throw new Error(`Builtin ${ast.builtin} argument ${i} function has not populated the 'platforms' field`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
for (const p of func_platforms) {
|
|
64
|
-
platforms.add(p);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (ast.ast_type === "Value" || ast.ast_type === "Variable" || ast.ast_type === "Function" || ast.ast_type === "Continue" || ast.ast_type === "Break") {
|
|
71
|
-
// effect free (Function only collects captured variables here)
|
|
72
|
-
}
|
|
73
|
-
else if (ast.ast_type === "As" || ast.ast_type === "UnwrapRecursive" || ast.ast_type === "WrapRecursive" || ast.ast_type === "Let" || ast.ast_type === "Assign" || ast.ast_type === "Return" || ast.ast_type === "NewRef") {
|
|
74
|
-
_getPlatforms(ast.value, platforms);
|
|
75
|
-
}
|
|
76
|
-
else if (ast.ast_type === "Error") {
|
|
77
|
-
_getPlatforms(ast.message, platforms);
|
|
78
|
-
}
|
|
79
|
-
else if (ast.ast_type === "TryCatch") {
|
|
80
|
-
_getPlatforms(ast.try_body, platforms);
|
|
81
|
-
_getPlatforms(ast.catch_body, platforms);
|
|
82
|
-
if (ast.finally_body) {
|
|
83
|
-
_getPlatforms(ast.finally_body, platforms);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (ast.ast_type === "NewArray") {
|
|
87
|
-
for (const v of ast.values) {
|
|
88
|
-
_getPlatforms(v, platforms);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (ast.ast_type === "NewSet") {
|
|
92
|
-
for (const v of ast.values) {
|
|
93
|
-
_getPlatforms(v, platforms);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else if (ast.ast_type === "NewDict") {
|
|
97
|
-
for (const [k, v] of ast.values) {
|
|
98
|
-
_getPlatforms(k, platforms);
|
|
99
|
-
_getPlatforms(v, platforms);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (ast.ast_type === "Struct") {
|
|
103
|
-
for (const f of Object.values(ast.fields)) {
|
|
104
|
-
_getPlatforms(f, platforms);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (ast.ast_type === "GetField") {
|
|
108
|
-
_getPlatforms(ast.struct, platforms);
|
|
109
|
-
}
|
|
110
|
-
else if (ast.ast_type === "Variant") {
|
|
111
|
-
_getPlatforms(ast.value, platforms);
|
|
112
|
-
}
|
|
113
|
-
else if (ast.ast_type === "Match") {
|
|
114
|
-
_getPlatforms(ast.variant, platforms);
|
|
115
|
-
for (const case_body of Object.values(ast.cases)) {
|
|
116
|
-
_getPlatforms(case_body.body, platforms);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else if (ast.ast_type === "Block") {
|
|
120
|
-
for (const s of ast.statements) {
|
|
121
|
-
_getPlatforms(s, platforms);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else if (ast.ast_type === "IfElse") {
|
|
125
|
-
for (const if_case of ast.ifs) {
|
|
126
|
-
_getPlatforms(if_case.predicate, platforms);
|
|
127
|
-
_getPlatforms(if_case.body, platforms);
|
|
128
|
-
}
|
|
129
|
-
_getPlatforms(ast.else_body, platforms);
|
|
130
|
-
}
|
|
131
|
-
else if (ast.ast_type === "While") {
|
|
132
|
-
_getPlatforms(ast.predicate, platforms);
|
|
133
|
-
_getPlatforms(ast.body, platforms);
|
|
134
|
-
}
|
|
135
|
-
else if (ast.ast_type === "ForArray") {
|
|
136
|
-
_getPlatforms(ast.array, platforms);
|
|
137
|
-
_getPlatforms(ast.body, platforms);
|
|
138
|
-
}
|
|
139
|
-
else if (ast.ast_type === "ForSet") {
|
|
140
|
-
_getPlatforms(ast.set, platforms);
|
|
141
|
-
_getPlatforms(ast.body, platforms);
|
|
142
|
-
}
|
|
143
|
-
else if (ast.ast_type === "ForDict") {
|
|
144
|
-
_getPlatforms(ast.dict, platforms);
|
|
145
|
-
_getPlatforms(ast.body, platforms);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
throw new Error(`Unhandled AST node type in getPlatforms: ${ast.ast_type}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
5
|
+
import {} from "./builtins.js";
|
|
151
6
|
//# sourceMappingURL=ast.js.map
|
package/dist/src/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAoB,MAAM,eAAe,CAAC"}
|
package/dist/src/ast_to_ir.d.ts
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { AST, Label, VariableAST } from "./ast.js";
|
|
6
6
|
import { type IR, type IRLabel, type VariableIR } from "./ir.js";
|
|
7
|
+
import { type Location } from "./location.js";
|
|
7
8
|
import { type EastType } from "./types.js";
|
|
9
|
+
/** @internal An exception throw for the purpose of early loop continue */
|
|
10
|
+
export declare class OutOfScopeException extends Error {
|
|
11
|
+
definedLocation: Location;
|
|
12
|
+
constructor(definedLocation: Location);
|
|
13
|
+
}
|
|
8
14
|
type Ctx = {
|
|
9
15
|
local_ctx: Map<VariableAST, VariableIR>;
|
|
10
16
|
parent_ctx: Map<VariableAST, VariableIR>;
|
|
@@ -15,6 +21,7 @@ type Ctx = {
|
|
|
15
21
|
n_loops: number;
|
|
16
22
|
inputs: EastType[];
|
|
17
23
|
output: EastType;
|
|
24
|
+
async: boolean;
|
|
18
25
|
};
|
|
19
26
|
/** Perform scope resolution and type checking on `AST`, produce `IR` ready for serialization, compilation or evaluation.
|
|
20
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast_to_ir.d.ts","sourceRoot":"","sources":["../../src/ast_to_ir.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAsB,KAAK,EAAE,EAAE,KAAK,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ast_to_ir.d.ts","sourceRoot":"","sources":["../../src/ast_to_ir.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAsB,KAAK,EAAE,EAAE,KAAK,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAuB,KAAK,QAAQ,EAAmH,MAAM,YAAY,CAAC;AAKjL,0EAA0E;AAC1E,qBAAa,mBAAoB,SAAQ,KAAK;IACzB,eAAe,EAAE,QAAQ;gBAAzB,eAAe,EAAE,QAAQ;CAG7C;AAED,KAAK,GAAG,GAAG;IACT,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACzC,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1B,QAAQ,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9B,aAAa,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAA;AAYD;;cAEc;AACd,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAmK,GAAG,EAAE,CAs6BhN"}
|
package/dist/src/ast_to_ir.js
CHANGED
|
@@ -4,6 +4,14 @@ import { toEastTypeValue } from "./type_of_type.js";
|
|
|
4
4
|
import { ArrayType, DictType, FunctionType, isSubtype, isTypeEqual, NeverType, NullType, printType, RefType, SetType, StructType, VariantType } from "./types.js";
|
|
5
5
|
import { variant } from "./containers/variant.js";
|
|
6
6
|
import { applyTypeParameters, Builtins } from "./builtins.js";
|
|
7
|
+
/** @internal An exception throw for the purpose of early loop continue */
|
|
8
|
+
export class OutOfScopeException extends Error {
|
|
9
|
+
definedLocation;
|
|
10
|
+
constructor(definedLocation) {
|
|
11
|
+
super(`Variable defined at ${printLocation(definedLocation)} is out of scope here`);
|
|
12
|
+
this.definedLocation = definedLocation;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
7
15
|
// TODO we should probably redo type checking exhaustively here?
|
|
8
16
|
function toLocationValue(location) {
|
|
9
17
|
return {
|
|
@@ -15,7 +23,7 @@ function toLocationValue(location) {
|
|
|
15
23
|
/** Perform scope resolution and type checking on `AST`, produce `IR` ready for serialization, compilation or evaluation.
|
|
16
24
|
*
|
|
17
25
|
* @internal */
|
|
18
|
-
export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map(), captures: new Set(), loop_ctx: new Map(), n_vars: 0, n_loops: 0, inputs: [], output: NeverType }) {
|
|
26
|
+
export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map(), captures: new Set(), loop_ctx: new Map(), n_vars: 0, n_loops: 0, inputs: [], output: NeverType, async: false }) {
|
|
19
27
|
try {
|
|
20
28
|
if (ast.ast_type === "Variable") {
|
|
21
29
|
if (ctx.local_ctx.has(ast)) {
|
|
@@ -29,7 +37,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
29
37
|
return ir;
|
|
30
38
|
}
|
|
31
39
|
else {
|
|
32
|
-
throw new
|
|
40
|
+
throw new OutOfScopeException(ast.location);
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
}
|
|
@@ -131,14 +139,6 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
131
139
|
arguments: ast.arguments.map((arg, i) => {
|
|
132
140
|
let arg_ir = ast_to_ir(arg, ctx);
|
|
133
141
|
const expectedType = applyTypeParameters(builtin_def.inputs[i], type_map, [], []);
|
|
134
|
-
// Special handling of FunctionType
|
|
135
|
-
if (expectedType.type === "Function") {
|
|
136
|
-
if (arg.type.type !== "Function") {
|
|
137
|
-
throw new Error(`Builtin ${builtin_name} with type parameters [${ast.type_parameters.map(tp => printType(tp)).join(", ")}] argument ${i} of type ${printType(arg.type)} is not compatible with expected type ${printType(expectedType)} at ${printLocation(ast.location)}`);
|
|
138
|
-
}
|
|
139
|
-
// Take the function argument's actual platform functions and populate here as a form of specialization
|
|
140
|
-
expectedType.platforms = arg.type.platforms;
|
|
141
|
-
}
|
|
142
142
|
// Now check type compatibility
|
|
143
143
|
if (arg.type.type !== "Never" && !isTypeEqual(arg.type, expectedType)) {
|
|
144
144
|
if (!isSubtype(arg.type, expectedType)) {
|
|
@@ -155,11 +155,15 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
else if (ast.ast_type === "Platform") {
|
|
158
|
+
if (ctx.async === false && ast.async === true) {
|
|
159
|
+
throw new Error(`Async platform call not allowed outside async function at ${printLocation(ast.location)}`);
|
|
160
|
+
}
|
|
158
161
|
return variant("Platform", {
|
|
159
162
|
type: toEastTypeValue(ast.type),
|
|
160
163
|
location: toLocationValue(ast.location),
|
|
161
164
|
name: ast.name,
|
|
162
165
|
arguments: ast.arguments.map(ast => ast_to_ir(ast, ctx)), // type equality handled at Expr/AST level
|
|
166
|
+
async: ast.async,
|
|
163
167
|
});
|
|
164
168
|
}
|
|
165
169
|
else if (ast.ast_type === "Struct") {
|
|
@@ -235,7 +239,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
235
239
|
const local_ctx = new Map(parameters.map((parameter, i) => [ast.parameters[i], parameter]));
|
|
236
240
|
const parent_ctx = new Map([...ctx.local_ctx, ...ctx.parent_ctx]);
|
|
237
241
|
const captures = new Set();
|
|
238
|
-
const ctx2 = { local_ctx, parent_ctx, captures, loop_ctx: new Map(), n_vars: ctx.n_vars, n_loops: ctx.n_loops, inputs: ast.type.inputs, output: ast.type.output };
|
|
242
|
+
const ctx2 = { local_ctx, parent_ctx, captures, loop_ctx: new Map(), n_vars: ctx.n_vars, n_loops: ctx.n_loops, inputs: ast.type.inputs, output: ast.type.output, async: false };
|
|
239
243
|
const body = ast_to_ir(ast.body, ctx2);
|
|
240
244
|
ctx.n_vars = ctx2.n_vars;
|
|
241
245
|
ctx.n_loops = ctx2.n_loops;
|
|
@@ -247,8 +251,36 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
247
251
|
body,
|
|
248
252
|
});
|
|
249
253
|
}
|
|
254
|
+
else if (ast.ast_type === "AsyncFunction") {
|
|
255
|
+
const parameters = ast.parameters.map(parameter => {
|
|
256
|
+
const param = variant("Variable", {
|
|
257
|
+
type: toEastTypeValue(parameter.type),
|
|
258
|
+
name: `_${ctx.n_vars}`,
|
|
259
|
+
location: toLocationValue(parameter.location),
|
|
260
|
+
mutable: parameter.mutable, // false...
|
|
261
|
+
captured: false,
|
|
262
|
+
});
|
|
263
|
+
ctx.n_vars += 1;
|
|
264
|
+
return param;
|
|
265
|
+
});
|
|
266
|
+
const local_ctx = new Map(parameters.map((parameter, i) => [ast.parameters[i], parameter]));
|
|
267
|
+
const parent_ctx = new Map([...ctx.local_ctx, ...ctx.parent_ctx]);
|
|
268
|
+
const captures = new Set();
|
|
269
|
+
const ctx2 = { local_ctx, parent_ctx, captures, loop_ctx: new Map(), n_vars: ctx.n_vars, n_loops: ctx.n_loops, inputs: ast.type.inputs, output: ast.type.output, async: true };
|
|
270
|
+
const body = ast_to_ir(ast.body, ctx2);
|
|
271
|
+
ctx.n_vars = ctx2.n_vars;
|
|
272
|
+
ctx.n_loops = ctx2.n_loops;
|
|
273
|
+
return variant("AsyncFunction", {
|
|
274
|
+
type: toEastTypeValue(ast.type),
|
|
275
|
+
location: toLocationValue(ast.location),
|
|
276
|
+
parameters,
|
|
277
|
+
captures: [...captures],
|
|
278
|
+
body,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
250
281
|
else if (ast.ast_type === "Call") {
|
|
251
282
|
// TODO - type equality could have been handled at Expr/AST level instead
|
|
283
|
+
// TODO - what about widening the result with As?
|
|
252
284
|
return variant("Call", {
|
|
253
285
|
type: toEastTypeValue(ast.type),
|
|
254
286
|
location: toLocationValue(ast.location),
|
|
@@ -270,6 +302,33 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
270
302
|
}),
|
|
271
303
|
});
|
|
272
304
|
}
|
|
305
|
+
else if (ast.ast_type === "CallAsync") {
|
|
306
|
+
if (ctx.async === false) {
|
|
307
|
+
throw new Error(`Async function call not allowed outside async function at ${printLocation(ast.location)}`);
|
|
308
|
+
}
|
|
309
|
+
// TODO - type equality could have been handled at Expr/AST level instead
|
|
310
|
+
// TODO - what about widening the result with As?
|
|
311
|
+
return variant("CallAsync", {
|
|
312
|
+
type: toEastTypeValue(ast.type),
|
|
313
|
+
location: toLocationValue(ast.location),
|
|
314
|
+
function: ast_to_ir(ast.function, ctx),
|
|
315
|
+
arguments: ast.arguments.map((argument, i) => {
|
|
316
|
+
let arg = ast_to_ir(argument, ctx);
|
|
317
|
+
const expectedType = ast.function.type.inputs[i];
|
|
318
|
+
if (!isTypeEqual(argument.type, expectedType)) {
|
|
319
|
+
if (!isSubtype(argument.type, expectedType)) {
|
|
320
|
+
throw new Error(`Argument ${i} of type ${printType(argument.type)} is not compatible with expected type ${printType(expectedType)} at ${printLocation(ast.location)}`);
|
|
321
|
+
}
|
|
322
|
+
arg = variant("As", {
|
|
323
|
+
type: toEastTypeValue(expectedType),
|
|
324
|
+
value: arg,
|
|
325
|
+
location: toLocationValue(ast.location),
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return arg;
|
|
329
|
+
}),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
273
332
|
else if (ast.ast_type === "NewRef") {
|
|
274
333
|
const valueType = ast.type.value;
|
|
275
334
|
let value = ast_to_ir(ast.value, ctx);
|
|
@@ -377,6 +436,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
377
436
|
n_loops: ctx.n_loops,
|
|
378
437
|
inputs: ctx.inputs,
|
|
379
438
|
output: ctx.output,
|
|
439
|
+
async: ctx.async,
|
|
380
440
|
};
|
|
381
441
|
let branch_body = ast_to_ir(branch.body, ctx_branch);
|
|
382
442
|
ctx.n_vars = ctx_branch.n_vars;
|
|
@@ -402,6 +462,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
402
462
|
n_loops: ctx.n_loops,
|
|
403
463
|
inputs: ctx.inputs,
|
|
404
464
|
output: ctx.output,
|
|
465
|
+
async: ctx.async,
|
|
405
466
|
};
|
|
406
467
|
let else_body = ast_to_ir(ast.else_body, ctx_else);
|
|
407
468
|
ctx.n_vars = ctx_else.n_vars;
|
|
@@ -440,6 +501,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
440
501
|
n_loops: ctx.n_loops,
|
|
441
502
|
inputs: ctx.inputs,
|
|
442
503
|
output: ctx.output,
|
|
504
|
+
async: ctx.async,
|
|
443
505
|
};
|
|
444
506
|
const try_body = ast_to_ir(ast.try_body, ctx_try);
|
|
445
507
|
ctx.n_vars = ctx_try.n_vars;
|
|
@@ -470,6 +532,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
470
532
|
n_loops: ctx.n_loops,
|
|
471
533
|
inputs: ctx.inputs,
|
|
472
534
|
output: ctx.output,
|
|
535
|
+
async: ctx.async,
|
|
473
536
|
};
|
|
474
537
|
const catch_body = ast_to_ir(ast.catch_body, ctx_catch);
|
|
475
538
|
ctx.n_vars = ctx_catch.n_vars;
|
|
@@ -486,6 +549,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
486
549
|
n_loops: ctx.n_loops,
|
|
487
550
|
inputs: ctx.inputs,
|
|
488
551
|
output: ctx.output,
|
|
552
|
+
async: ctx.async,
|
|
489
553
|
};
|
|
490
554
|
finally_body = ast_to_ir(ast.finally_body, ctx_finally);
|
|
491
555
|
ctx.n_vars = ctx_finally.n_vars;
|
|
@@ -567,6 +631,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
567
631
|
n_loops: ctx.n_loops,
|
|
568
632
|
inputs: ctx.inputs,
|
|
569
633
|
output: ctx.output,
|
|
634
|
+
async: ctx.async,
|
|
570
635
|
};
|
|
571
636
|
const body = ast_to_ir(ast.body, ctx2);
|
|
572
637
|
ctx.n_vars = ctx2.n_vars;
|
|
@@ -611,6 +676,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
611
676
|
n_loops: ctx.n_loops,
|
|
612
677
|
inputs: ctx.inputs,
|
|
613
678
|
output: ctx.output,
|
|
679
|
+
async: ctx.async,
|
|
614
680
|
};
|
|
615
681
|
const body = ast_to_ir(ast.body, ctx2);
|
|
616
682
|
ctx.n_vars = ctx2.n_vars;
|
|
@@ -649,6 +715,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
649
715
|
n_loops: ctx.n_loops,
|
|
650
716
|
inputs: ctx.inputs,
|
|
651
717
|
output: ctx.output,
|
|
718
|
+
async: ctx.async,
|
|
652
719
|
};
|
|
653
720
|
const body = ast_to_ir(ast.body, ctx2);
|
|
654
721
|
ctx.n_vars = ctx2.n_vars;
|
|
@@ -694,6 +761,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
694
761
|
n_loops: ctx.n_loops,
|
|
695
762
|
inputs: ctx.inputs,
|
|
696
763
|
output: ctx.output,
|
|
764
|
+
async: ctx.async,
|
|
697
765
|
};
|
|
698
766
|
const body = ast_to_ir(ast.body, ctx2);
|
|
699
767
|
ctx.n_vars = ctx2.n_vars;
|
|
@@ -729,6 +797,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
|
|
|
729
797
|
n_loops: ctx.n_loops,
|
|
730
798
|
inputs: ctx.inputs,
|
|
731
799
|
output: ctx.output,
|
|
800
|
+
async: ctx.async,
|
|
732
801
|
};
|
|
733
802
|
let body = ast_to_ir(v.body, ctx2);
|
|
734
803
|
ctx.n_vars = ctx2.n_vars;
|