More small changes
This commit is contained in:
@@ -1693,7 +1693,8 @@ add_builtins :: (checker : *Semantic_Checker) {
|
|||||||
|
|
||||||
checker.state = .Adding_Builtins;
|
checker.state = .Adding_Builtins;
|
||||||
|
|
||||||
add_file_from_string(checker.result, BUILTIN);
|
checker.result.file = make_file_from_string(BUILTIN);
|
||||||
|
checker.result.allocator = make_arena(*checker.result.arena);
|
||||||
|
|
||||||
lexer : Lexer;
|
lexer : Lexer;
|
||||||
|
|
||||||
|
|||||||
18
Test.jai
18
Test.jai
@@ -154,7 +154,8 @@ do_golden_comparison :: (golden_path : string, comparison_text : string, result_
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_codegen_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
run_codegen_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||||
add_file(result, file_path);
|
result.file = make_file(result, file_path);
|
||||||
|
result.allocator = make_arena(*result.arena);
|
||||||
|
|
||||||
result_data : Result;
|
result_data : Result;
|
||||||
result_data.path = file_path;
|
result_data.path = file_path;
|
||||||
@@ -219,7 +220,9 @@ run_lexer_test :: (file_path : string, result : *Compile_Result, output_type : O
|
|||||||
|
|
||||||
result_text : string;
|
result_text : string;
|
||||||
|
|
||||||
add_file(result, file_path);
|
result.file = make_file(result, file_path);
|
||||||
|
result.allocator = make_arena(*result.arena);
|
||||||
|
|
||||||
lex(result);
|
lex(result);
|
||||||
if result.had_error {
|
if result.had_error {
|
||||||
result_data.type = .Failed;
|
result_data.type = .Failed;
|
||||||
@@ -243,7 +246,8 @@ run_parser_test :: (file_path : string, result : *Compile_Result, output_type :
|
|||||||
result_data : Result;
|
result_data : Result;
|
||||||
result_data.path = file_path;
|
result_data.path = file_path;
|
||||||
|
|
||||||
add_file(result, file_path);
|
result.file = make_file(result, file_path);
|
||||||
|
result.allocator = make_arena(*result.arena);
|
||||||
|
|
||||||
lex(result);
|
lex(result);
|
||||||
if result.had_error {
|
if result.had_error {
|
||||||
@@ -306,7 +310,8 @@ run_semantic_analysis_test :: (result : *Compile_Result, output_type : Output_Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||||
add_file(result, file_path);
|
result.file = make_file(result, file_path);
|
||||||
|
result.allocator = make_arena(*result.arena);
|
||||||
|
|
||||||
result_data : Result;
|
result_data : Result;
|
||||||
result_data.path = file_path;
|
result_data.path = file_path;
|
||||||
@@ -334,7 +339,10 @@ make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := contex
|
|||||||
|
|
||||||
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
||||||
compile_result : Compile_Result;
|
compile_result : Compile_Result;
|
||||||
add_file(*compile_result, file_path);
|
|
||||||
|
compile_result.file = make_file(*compile_result, file_path);
|
||||||
|
compile_result.allocator = make_arena(*compile_result.arena);
|
||||||
|
|
||||||
result : Result;
|
result : Result;
|
||||||
if stage_flags & .Lexer {
|
if stage_flags & .Lexer {
|
||||||
result = run_lexer_test(file_path, *compile_result, output_type);
|
result = run_lexer_test(file_path, *compile_result, output_type);
|
||||||
|
|||||||
57
module.jai
57
module.jai
@@ -142,12 +142,6 @@ Token_Stream :: struct {
|
|||||||
tokens : [..]Token;
|
tokens : [..]Token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiled_File :: struct {
|
|
||||||
|
|
||||||
// allocator : Allocator;
|
|
||||||
// arena : Arena;
|
|
||||||
// }
|
|
||||||
|
|
||||||
Compile_Result :: struct {
|
Compile_Result :: struct {
|
||||||
file : Input_File;
|
file : Input_File;
|
||||||
tokens : Token_Stream;
|
tokens : Token_Stream;
|
||||||
@@ -196,43 +190,24 @@ record_error :: (result : *Compile_Result, format : string, args : .. Any) {
|
|||||||
array_add(*result.messages, error);
|
array_add(*result.messages, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Incomplete(niels): need to consider allocation
|
make_file :: (result : *Compile_Result, path : string) -> Input_File {
|
||||||
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(result, "Unable to load file: %", path);
|
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 : Input_File;
|
||||||
|
|
||||||
input_file.source = source;
|
input_file.source = source;
|
||||||
input_file.path = path;
|
input_file.path = path;
|
||||||
|
|
||||||
result.file = input_file;
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pretty_print_field :: (field : *Field) -> string {
|
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 {
|
compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
|
||||||
result : Compile_Result;
|
result : Compile_Result;
|
||||||
|
|
||||||
add_file(*result, path);
|
result.allocator = make_arena(*result.arena);
|
||||||
|
|
||||||
|
result.file = make_file(*result, path);
|
||||||
|
|
||||||
lex(*result);
|
lex(*result);
|
||||||
parse(*result);
|
parse(*result);
|
||||||
@@ -503,21 +480,3 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
|
|||||||
|
|
||||||
return 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,5 +27,4 @@
|
|||||||
{kind = TOKEN_IDENTIFIER; ; index = 103 ; length = 3 line = 5 ; column = 7 ; value ='pos'; }
|
{kind = TOKEN_IDENTIFIER; ; index = 103 ; length = 3 line = 5 ; column = 7 ; value ='pos'; }
|
||||||
{kind = TOKEN_SEMICOLON; ; index = 106 ; length = 1 line = 5 ; column = 10 ; value =';'; }
|
{kind = TOKEN_SEMICOLON; ; index = 106 ; length = 1 line = 5 ; column = 10 ; value =';'; }
|
||||||
{kind = TOKEN_RIGHTBRACE; ; index = 109 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
{kind = TOKEN_RIGHTBRACE; ; index = 109 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 1 line = 6 ; column = 1 ; value ='x'; }
|
{kind = TOKEN_EOF; ; index = 112 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||||
{kind = TOKEN_EOF; ; index = 113 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user