More small changes

This commit is contained in:
2025-08-27 22:12:19 +02:00
parent 4825623c73
commit 14f8b20d5f
4 changed files with 24 additions and 57 deletions

View File

@@ -142,12 +142,6 @@ Token_Stream :: struct {
tokens : [..]Token;
}
// Compiled_File :: struct {
// allocator : Allocator;
// arena : Arena;
// }
Compile_Result :: struct {
file : Input_File;
tokens : Token_Stream;
@@ -196,43 +190,24 @@ record_error :: (result : *Compile_Result, format : string, args : .. Any) {
array_add(*result.messages, error);
}
//@Incomplete(niels): need to consider allocation
add_file :: (result : *Compile_Result, path : string) {
make_file :: (result : *Compile_Result, path : string) -> Input_File {
file_string, ok := read_entire_file(path);
if !ok {
record_error(result, "Unable to load file: %", path);
return;
return .{};
}
add_file_from_string(result, file_string, path);
return make_file_from_string(file_string, path);
}
add_file_from_string :: (result : *Compile_Result, source : string, path : string = "") {
make_file_from_string :: (source : string, path : string = "") -> Input_File {
input_file : Input_File;
input_file.source = source;
input_file.path = path;
result.file = input_file;
result.allocator = make_arena(*result.arena);
}
// @Incomplete(nb): Will we ever even use this?
from_file :: (path : string) -> Compile_Result {
arr : [1]string;
arr[0] = path;
return from_files(arr);
}
from_files :: (paths : []string) -> Compile_Result {
result : Compile_Result;
for path : paths {
add_file(*result, path);
}
return result;
return input_file;
}
pretty_print_field :: (field : *Field) -> string {
@@ -493,7 +468,9 @@ generate_output_data :: (result : *Compile_Result) {
compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
result : Compile_Result;
add_file(*result, path);
result.allocator = make_arena(*result.arena);
result.file = make_file(*result, path);
lex(*result);
parse(*result);
@@ -503,21 +480,3 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
return result;
}
compile_files :: (compiler : *Shader_Compiler, paths : ..string) -> Compile_Result {
result : Compile_Result;
for path : paths {
add_file(*result, path);
}
lex(*result);
parse(*result);
check(*result);
codegen(*result);
generate_output_data(*result);
return result;
}