Fix builtin parsing
This commit is contained in:
@@ -122,7 +122,10 @@ report_message :: (builder : *String_Builder, path : string, message : string, s
|
||||
} else {
|
||||
append(builder, "internal:");
|
||||
}
|
||||
print_to_builder(builder, "%,%: ", source_locations[0].main_token.line, source_locations[0].main_token.column);
|
||||
|
||||
if source_locations.count > 0 {
|
||||
print_to_builder(builder, "%,%: ", source_locations[0].main_token.line, source_locations[0].main_token.column);
|
||||
}
|
||||
|
||||
if kind == .Log {
|
||||
append(builder, "\x1b[31mlog: ");
|
||||
|
||||
@@ -138,7 +138,7 @@ Defined_Symbol :: struct {
|
||||
type_variable : Type_Variable_Handle;
|
||||
source_node : *AST_Node;
|
||||
|
||||
functions :[..]Defined_Symbol;
|
||||
functions : [..]Defined_Symbol;
|
||||
|
||||
builtin : bool;
|
||||
}
|
||||
@@ -178,6 +178,8 @@ Semantic_Check_Result :: struct {
|
||||
|
||||
scope_stack : Scope_Stack;
|
||||
type_variables : [..]Type_Variable;
|
||||
|
||||
property_name : string;
|
||||
}
|
||||
|
||||
Checker_State :: enum {
|
||||
@@ -928,6 +930,10 @@ current_buffer_index : u32 = 0;
|
||||
|
||||
declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_Handle {
|
||||
name := ifx node.name.count == 0 then "properties" else node.name;
|
||||
|
||||
if node.name.count > 0 {
|
||||
checker.result.property_name = name;
|
||||
}
|
||||
type_var := declare_struct(checker, node, name);
|
||||
var := h2tv(checker, type_var);
|
||||
var.type = .Properties;
|
||||
@@ -997,7 +1003,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
|
||||
symbol.name = name_to_check;
|
||||
symbol.source_node = node;
|
||||
symbol.type_variable = 0;
|
||||
array_reserve(*symbol.functions, 16);
|
||||
array_reserve(*symbol.functions, 32);
|
||||
array_add(*symbol.functions, function);
|
||||
|
||||
add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol);
|
||||
@@ -1663,8 +1669,35 @@ union_find :: (checker : *Semantic_Checker) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
// HLSL_BUILTIN :: #run -> string {
|
||||
// T := #load "hlsl_builtin.jai";
|
||||
|
||||
// return "";
|
||||
// };
|
||||
|
||||
add_hlsl_builtins :: (checker : *Semantic_Checker) {
|
||||
HLSL_BUILTIN := read_entire_file("hlsl_builtin.shd");
|
||||
source_location := #location().fully_pathed_filename;
|
||||
path_array := split(source_location, "/");
|
||||
|
||||
sb : String_Builder;
|
||||
for i : 0..path_array.count - 2 {
|
||||
print_to_builder(*sb, path_array[i]);
|
||||
append(*sb, "/");
|
||||
}
|
||||
|
||||
append(*sb, "hlsl_builtin.shd");
|
||||
|
||||
path := builder_to_string(*sb);
|
||||
|
||||
HLSL_BUILTIN, ok := read_entire_file(path);
|
||||
|
||||
if !ok {
|
||||
messages : [..]Compiler_Message;
|
||||
internal_error_message(*messages, "Error loading builtin functions.", checker.path);
|
||||
print("%\n", report_messages(messages));
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
checker.state = .Adding_Builtins;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
HLSL_BUILTIN : string;
|
||||
|
||||
#run {
|
||||
HLSL_BUILTIN = read_entire_file("hlsl_builtin.shd");
|
||||
}
|
||||
HLSL_BUILTIN :: #run -> string {
|
||||
// return read_entire_file("./hlsl_builtin.shd");
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Resu
|
||||
cb.buffer_index = variable.buffer_index;
|
||||
}
|
||||
|
||||
find_result := find_symbol(*check_result.scope_stack, "properties", xx 1);
|
||||
find_result := find_symbol(*check_result.scope_stack, check_result.property_name, xx 1);
|
||||
if find_result {
|
||||
property_variable := h2tv(check_result.type_variables, find_result.type_variable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user