From c19f456156f0c322281439c41d326233f5b4fd76 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Thu, 17 Apr 2025 17:08:54 -0600 Subject: [PATCH] Tiny progress on the self-hosted compiler --- src/bootstrap.zig | 7 +++++++ src/compiler.bbb | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/bootstrap.zig b/src/bootstrap.zig index bcf0902..c25248b 100644 --- a/src/bootstrap.zig +++ b/src/bootstrap.zig @@ -7204,6 +7204,13 @@ pub const Module = struct { u64_type.resolve(module); _ = module.llvm.builder.create_memset(left_llvm, u8_type.llvm.abi.?.get_zero().to_value(), u64_type.llvm.abi.?.to_integer().get_constant(value_type.get_byte_size(), 0).to_value(), pointer_type.bb.pointer.alignment); }, + .variable_reference => |variable| switch (right.kind) { + .left => @trap(), + .right => { + const uint64 = module.integer_type(64, false); + _ = module.llvm.builder.create_memcpy(left_llvm, pointer_type.bb.pointer.alignment, variable.storage.?.llvm.?, variable.storage.?.type.?.bb.pointer.alignment, uint64.llvm.abi.?.to_integer().get_constant(value_type.get_byte_size(), @intFromBool(false)).to_value()); + }, + }, else => @trap(), }, .complex => @trap(), diff --git a/src/compiler.bbb b/src/compiler.bbb index 9b9922d..0bc445d 100644 --- a/src/compiler.bbb +++ b/src/compiler.bbb @@ -243,9 +243,22 @@ BuildMode = enum aggressively_optimize_for_size, } +CompileFile = struct +{ + relative_file_path: []u8, + build_mode: BuildMode, + has_debug_info: u1, + silent: u1, +} + +compile_file = fn (arena: &Arena, compile: CompileFile) void +{ +} + [export] main = fn [cc(c)] (argument_count: u32, argv: &&u8) s32 { global_state_initialize(); + >arena = global_state.arena; if (argument_count < 2) { @@ -323,6 +336,13 @@ BuildMode = enum { return 1; } + + compile_file(arena, { + .relative_file_path = relative_file_path, + .build_mode = build_mode, + .has_debug_info = has_debug_info, + .silent = 0, + }); }, .test => {