Started load directive.

This commit is contained in:
2025-09-03 22:31:18 +02:00
parent 4924b01eac
commit 11c936ba7f
5 changed files with 89 additions and 8 deletions

View File

@@ -4,6 +4,8 @@
#load "Semantic_Analysis.jai";
#load "Codegen.jai";
#import "File_Utilities";
add_define :: (env : *Environment, key : string) {
for define : env.defines {
if define == key {
@@ -143,8 +145,11 @@ Token_Stream :: struct {
tokens : [..]Token;
}
Compile_Result :: struct {
Compile_Result :: struct {
file : Input_File;
environment : Environment;
tokens : Token_Stream;
root : *AST_Node;
nodes : [..]AST_Node;
@@ -192,6 +197,10 @@ record_error :: (result : *Compile_Result, format : string, args : .. Any) {
}
make_file :: (result : *Compile_Result, path : string) -> Input_File {
if !file_exists(path) {
record_error(result, "Unable to load file: %", path);
return .{};
}
file_string, ok := read_entire_file(path);
if !ok {
@@ -479,6 +488,7 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
result.allocator = make_arena(*result.arena);
result.file = make_file(*result, path);
result.environment = compiler.environment;
lex(*result);
parse(*result);