Some unfinished commit

This commit is contained in:
David Gonzalez Martin 2025-03-26 21:14:23 +01:00
parent 17918ce4e3
commit 54500c149f
2 changed files with 61 additions and 45 deletions

View File

@ -251,6 +251,11 @@ global_state_initialize = fn () void
return 1;
}
//if (!string_equal(#slice(relative_file_path, extension_start), ".bbb"))
//{
// return 1;
//}
global_state_initialize();
return 0;
}

View File

@ -1083,7 +1083,7 @@ const Module = struct {
.name = "length",
};
const result = module.types.add(.{
const slice_type = module.types.add(.{
.bb = .{
.structure = .{
.fields = fields,
@ -1100,9 +1100,13 @@ const Module = struct {
},
.name = name,
});
return result;
const index = slice_type - module.types.get().ptr;
module.slice_type_buffer[module.slice_type_count] = @intCast(index);
module.slice_type_count += 1;
return slice_type;
}
}
fn negate_value_llvm(noalias module: *Module, value: *Value) *llvm.Value {
_ = module;
return switch (value.is_constant()) {
@ -3419,15 +3423,25 @@ const Converter = struct {
if (!expected_ty.is_slice()) {
converter.report_error();
}
const slice_type = expected_ty;
const slice_pointer_type = slice_type.bb.structure.fields[0].type;
const slice_element_type = slice_pointer_type.bb.pointer.type;
assert(slice_type != value.type);
switch (value.type.bb) {
.pointer => |pointer| {
const pointer_element_type = pointer.type;
if (pointer_element_type == slice_element_type) {
switch (element_count) {
if (slice_type == pointer_element_type) switch (element_count) {
1 => @trap(),
2 => {
// If a slice is found and two arguments are given, the second argument is a start
@trap();
},
3 => @trap(),
else => unreachable,
} else if (pointer_element_type == slice_element_type) switch (element_count) {
1 => @trap(),
2 => {
// If a pointer is found and its element type matches the slice element type, then the second argument is the length of the slice
@ -3456,9 +3470,7 @@ const Converter = struct {
},
3 => @trap(),
else => unreachable,
}
} else {
switch (pointer_element_type.bb) {
} else switch (pointer_element_type.bb) {
.array => |array| {
const array_element_type = array.element_type;
if (array_element_type == slice_element_type) {
@ -3483,7 +3495,6 @@ const Converter = struct {
},
else => @trap(),
}
}
},
else => @trap(),
}