Skip to content

Move module creation to program #2550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,12 @@ export class Compiler extends DiagnosticEmitter {

/** Program reference. */
program: Program;
/** Resolver reference. */
get resolver(): Resolver { return this.program.resolver; }
/** Module instance being compiled. */
get module(): Module { return this.program.module; }
/** Provided options. */
get options(): Options { return this.program.options; }
/** Module instance being compiled. */
module: Module;
/** Resolver reference. */
get resolver(): Resolver { return this.program.resolver; }

/** Current control flow. */
currentFlow: Flow;
Expand Down Expand Up @@ -443,9 +443,8 @@ export class Compiler extends DiagnosticEmitter {
constructor(program: Program) {
super(program.diagnostics);
this.program = program;
let module = program.module;
let options = program.options;
let module = Module.create(options.stackSize > 0, options.sizeTypeRef);
this.module = module;
if (options.memoryBase) {
this.memoryOffset = i64_new(options.memoryBase);
module.setLowMemoryUnused(false);
Expand Down
3 changes: 3 additions & 0 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,16 @@ export class Program extends DiagnosticEmitter {
super(diagnostics);
let nativeSource = new Source(SourceKind.LibraryEntry, LIBRARY_PREFIX + "native.ts", "[native code]");
this.nativeSource = nativeSource;
this.module = Module.create(options.stackSize > 0, options.sizeTypeRef);
this.parser = new Parser(this.diagnostics, this.sources);
this.resolver = new Resolver(this);
let nativeFile = new File(this, nativeSource);
this.nativeFile = nativeFile;
this.filesByName.set(nativeFile.internalName, nativeFile);
}

/** Module instance. */
module: Module;
/** Parser instance. */
parser: Parser;
/** Resolver instance. */
Expand Down