Compare commits

..

2 Commits

4 changed files with 45 additions and 10 deletions

View File

@@ -122,7 +122,10 @@ report_message :: (builder : *String_Builder, path : string, message : string, s
} else { } else {
append(builder, "internal:"); append(builder, "internal:");
} }
if source_locations.count > 0 {
print_to_builder(builder, "%,%: ", source_locations[0].main_token.line, source_locations[0].main_token.column); print_to_builder(builder, "%,%: ", source_locations[0].main_token.line, source_locations[0].main_token.column);
}
if kind == .Log { if kind == .Log {
append(builder, "\x1b[31mlog: "); append(builder, "\x1b[31mlog: ");

View File

@@ -178,6 +178,8 @@ Semantic_Check_Result :: struct {
scope_stack : Scope_Stack; scope_stack : Scope_Stack;
type_variables : [..]Type_Variable; type_variables : [..]Type_Variable;
property_name : string;
} }
Checker_State :: enum { Checker_State :: enum {
@@ -930,6 +932,10 @@ declare_struct :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variab
declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_Handle { declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_Handle {
name := ifx node.name.count == 0 then "properties" else node.name; 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); type_var := declare_struct(checker, node, name);
var := h2tv(checker, type_var); var := h2tv(checker, type_var);
var.type = .Properties; var.type = .Properties;
@@ -999,7 +1005,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
symbol.name = name_to_check; symbol.name = name_to_check;
symbol.source_node = node; symbol.source_node = node;
symbol.type_variable = 0; symbol.type_variable = 0;
array_reserve(*symbol.functions, 16); array_reserve(*symbol.functions, 32);
array_add(*symbol.functions, function); array_add(*symbol.functions, function);
add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol); add_symbol_to_scope(checker, checker.current_scope, name_to_check, symbol);
@@ -1676,8 +1682,35 @@ union_find :: (checker : *Semantic_Checker) -> bool {
return true; return true;
} }
// HLSL_BUILTIN :: #run -> string {
// T := #load "hlsl_builtin.jai";
// return "";
// };
add_hlsl_builtins :: (checker : *Semantic_Checker) { 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; checker.state = .Adding_Builtins;

View File

@@ -1,6 +1,5 @@
HLSL_BUILTIN : string; HLSL_BUILTIN :: #run -> string {
// return read_entire_file("./hlsl_builtin.shd");
#run { return "";
HLSL_BUILTIN = read_entire_file("hlsl_builtin.shd"); };
}

View File

@@ -386,7 +386,7 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Resu
cb.buffer_index = variable.resource_index; cb.buffer_index = variable.resource_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 { if find_result {
property_variable := h2tv(check_result.type_variables, find_result.type_variable); property_variable := h2tv(check_result.type_variables, find_result.type_variable);