Add record error to add file. Change compile_file to take varargs
This commit is contained in:
2
Test.jai
2
Test.jai
@@ -201,7 +201,7 @@ run_codegen_test :: (result : *Compile_Result, output_type : Output_Type = 0) ->
|
|||||||
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result {
|
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result {
|
||||||
compiler : Shader_Compiler;
|
compiler : Shader_Compiler;
|
||||||
result : Result;
|
result : Result;
|
||||||
compilation_result := compile_file(*compiler, .[path]);
|
compilation_result := compile_file(*compiler, path);
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
||||||
if compilation_result.had_error {
|
if compilation_result.had_error {
|
||||||
|
|||||||
12
module.jai
12
module.jai
@@ -186,12 +186,20 @@ Compile_Result :: struct {
|
|||||||
arena : Arena;
|
arena : Arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record_error :: (result : *Compile_Result, format : string, args : .. Any) {
|
||||||
|
error : Compiler_Message;
|
||||||
|
error.message_kind = .Error;
|
||||||
|
error.message = sprint(format, args);
|
||||||
|
|
||||||
|
array_add(*result.messages, error);
|
||||||
|
}
|
||||||
|
|
||||||
//@Incomplete(niels): need to consider allocation
|
//@Incomplete(niels): need to consider allocation
|
||||||
add_file :: (result : *Compile_Result, path : string) {
|
add_file :: (result : *Compile_Result, path : string) {
|
||||||
file_string, ok := read_entire_file(path);
|
file_string, ok := read_entire_file(path);
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
// record_error(.File_Load_Failed, "Unable to load file: %", path);
|
record_error(result, "Unable to load file: %", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +492,7 @@ generate_output_data :: (result : *Compile_Result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Result {
|
compile_file :: (compiler : *Shader_Compiler, paths : ..string) -> Compile_Result {
|
||||||
result : Compile_Result;
|
result : Compile_Result;
|
||||||
|
|
||||||
for path : paths {
|
for path : paths {
|
||||||
|
|||||||
Reference in New Issue
Block a user