forked from tact-lang/tact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
precompile.ts
41 lines (33 loc) · 1.37 KB
/
precompile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { CompilerContext } from "../context";
import { resolveDescriptors } from "../types/resolveDescriptors";
import { resolveAllocations } from "../storage/resolveAllocation";
import { openContext } from "../grammar/store";
import { resolveStatements } from "../types/resolveStatements";
import { resolveErrors } from "../types/resolveErrors";
import { resolveSignatures } from "../types/resolveSignatures";
import { resolveImports } from "../imports/resolveImports";
import { VirtualFileSystem } from "../vfs/VirtualFileSystem";
export function precompile(
ctx: CompilerContext,
project: VirtualFileSystem,
stdlib: VirtualFileSystem,
entrypoint: string,
) {
// Load all sources
const imported = resolveImports({ entrypoint, project, stdlib });
// Add information about all the source code entries to the context
ctx = openContext(ctx, imported.tact, imported.func);
// First load type descriptors and check that
// they all have valid signatures
ctx = resolveDescriptors(ctx);
// This creates TLB-style type definitions
ctx = resolveSignatures(ctx);
// This creates allocations for all defined types
ctx = resolveAllocations(ctx);
// This checks and resolves all statements
ctx = resolveStatements(ctx);
// This extracts error messages
ctx = resolveErrors(ctx);
// Prepared context
return ctx;
}