A bunch of array fixes and some buffer stuff that doesn't quite work yet

This commit is contained in:
2025-09-24 14:04:50 +02:00
parent 50a404984d
commit 940b58331d
18 changed files with 261 additions and 137 deletions

View File

@@ -150,6 +150,7 @@ Compiler_Context :: struct {
codegen_result_text : string;
constant_buffers : Static_Array(Type_Variable_Handle, 16);
buffers : Static_Array(Type_Variable_Handle, 16);
scope_stack : Scope_Stack;
type_variables : [..]Type_Variable;
@@ -316,11 +317,7 @@ pretty_print_field :: (builder : *String_Builder, field : *Field) {
}
}
type_variable_to_field :: (checker : *Checker, variable : Type_Variable_Handle) -> Field {
return type_variable_to_field(checker, from_handle(checker, variable));
}
type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope_Stack, variable : *Type_Variable) -> Field {
type_variable_to_field :: (ctx : *Compiler_Context, variable : *Type_Variable) -> Field {
field : Field;
field.name = variable.name;
@@ -353,14 +350,14 @@ type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope
case .Struct; {
type.kind = Field_Kind.Struct;
find_result := find_symbol(scope_stack, variable.typename, xx 1);
find_result := find_symbol(ctx.scope_stack, variable.typename, xx 1);
assert(find_result != null, "Internal compiler error\n");
type_var := from_handle(type_variables, find_result.type_variable);
type_var := from_handle(ctx.type_variables, find_result.type_variable);
for i : 0..type_var.children.count - 1 {
child := type_var.children[i];
child_field := type_variable_to_field(type_variables, scope_stack, child);
child_field := type_variable_to_field(ctx, child);
array_add(*type.children, child_field);
}
@@ -397,12 +394,8 @@ type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope
return field;
}
type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope_Stack, variable : Type_Variable_Handle) -> Field {
return type_variable_to_field(type_variables, scope_stack, from_handle(type_variables, variable));
}
type_variable_to_field :: (checker : *Checker, variable : *Type_Variable) -> Field {
return type_variable_to_field(checker.ctx.type_variables, checker.ctx.scope_stack, variable);
type_variable_to_field :: (ctx : *Compiler_Context, variable : Type_Variable_Handle) -> Field {
return type_variable_to_field(ctx, from_handle(ctx.type_variables, variable));
}
generate_output_data :: (ctx : *Compiler_Context) {
@@ -422,7 +415,7 @@ generate_output_data :: (ctx : *Compiler_Context) {
field_list := node.children[0];
for child : field_list.children {
tv := from_handle(ctx.type_variables, child.type_variable);
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, tv);
field := type_variable_to_field(ctx, tv);
array_add(*ctx.vertex_entry_point.input, field);
}
}
@@ -437,7 +430,7 @@ generate_output_data :: (ctx : *Compiler_Context) {
for i : 0..variable.children.count - 1 {
child := variable.children[i];
field : Field = type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
field : Field = type_variable_to_field(ctx, from_handle(ctx.type_variables, child));
array_add(*cb.fields, field);
}
@@ -458,7 +451,7 @@ generate_output_data :: (ctx : *Compiler_Context) {
assert(type_variable.type == .Function);
if type_variable.return_type_variable > 0 {
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, type_variable.return_type_variable);
field := type_variable_to_field(ctx, type_variable.return_type_variable);
for hint : type_variable.source_node.hint_tokens {
field_hint : Field_Hint;