cross
This commit is contained in:
@@ -7,12 +7,15 @@ const codegen = @import("codegen.zig");
|
||||
const errors = @import("errors.zig");
|
||||
const Node = ast.Node;
|
||||
|
||||
pub const TargetConfig = codegen.TargetConfig;
|
||||
|
||||
pub const Compilation = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
io: std.Io,
|
||||
file_path: []const u8,
|
||||
source: [:0]const u8,
|
||||
diagnostics: errors.DiagnosticList,
|
||||
target_config: TargetConfig,
|
||||
|
||||
// Pipeline results
|
||||
root: ?*Node = null,
|
||||
@@ -21,7 +24,7 @@ pub const Compilation = struct {
|
||||
sema_result: ?sema.SemaResult = null,
|
||||
cg: ?codegen.CodeGen = null,
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8, source: [:0]const u8) Compilation {
|
||||
pub fn init(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8, source: [:0]const u8, target_config: TargetConfig) Compilation {
|
||||
return .{
|
||||
.allocator = allocator,
|
||||
.io = io,
|
||||
@@ -29,6 +32,7 @@ pub const Compilation = struct {
|
||||
.source = source,
|
||||
.diagnostics = errors.DiagnosticList.init(allocator, source, file_path),
|
||||
.import_sources = std.StringHashMap([:0]const u8).init(allocator),
|
||||
.target_config = target_config,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,7 +87,7 @@ pub const Compilation = struct {
|
||||
|
||||
pub fn generateCode(self: *Compilation) !void {
|
||||
const root = self.resolved_root orelse self.root orelse return error.CompileError;
|
||||
var cg = codegen.CodeGen.init(self.allocator, "sx_module");
|
||||
var cg = codegen.CodeGen.init(self.allocator, "sx_module", self.target_config);
|
||||
cg.diagnostics = &self.diagnostics;
|
||||
if (self.sema_result) |*sr| {
|
||||
cg.sema_result = sr;
|
||||
|
||||
Reference in New Issue
Block a user