Compare commits
2 Commits
b7e34a22b2
...
382d790c5b
| Author | SHA1 | Date | |
|---|---|---|---|
| 382d790c5b | |||
| 27933e599a |
@@ -617,7 +617,7 @@ codegen :: (result : *Compile_Result) {
|
|||||||
|
|
||||||
for *file : result.files {
|
for *file : result.files {
|
||||||
state : Codegen_State;
|
state : Codegen_State;
|
||||||
init_codegen_state(*state, file.ast_root, file.semantic_check_result, .HLSL);
|
// init_codegen_state(*state, file.ast_root, file.semantic_check_result, .HLSL);
|
||||||
|
|
||||||
//@Incomplete(nb): just call the codegen function for now with old result struct
|
//@Incomplete(nb): just call the codegen function for now with old result struct
|
||||||
codegen_result := codegen(*state);
|
codegen_result := codegen(*state);
|
||||||
|
|||||||
@@ -1774,7 +1774,24 @@ check :: (result : *Compile_Result) {
|
|||||||
|
|
||||||
type_check(*checker, file.ast_root);
|
type_check(*checker, file.ast_root);
|
||||||
|
|
||||||
file.semantic_check_result = checker.result;
|
file.constant_buffers = array_copy(*checker.result.constant_buffers);
|
||||||
|
|
||||||
|
//@Incomplete: should just be a copy?
|
||||||
|
file.scope_stack.stack.allocator = file.allocator;
|
||||||
|
array_reserve(*file.scope_stack.stack, checker.result.scope_stack.stack.count);
|
||||||
|
for scope : checker.result.scope_stack.stack {
|
||||||
|
array_add(*file.scope_stack.stack, scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.type_variables.allocator = file.allocator;
|
||||||
|
array_reserve(*file.type_variables, checker.result.type_variables.count);
|
||||||
|
for tv : checker.result.type_variables {
|
||||||
|
array_add(*file.type_variables, tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.vertex_entry_point.node = checker.result.vertex_entry_point;
|
||||||
|
file.pixel_entry_point.node = checker.result.pixel_entry_point;
|
||||||
|
|
||||||
result.had_error |= checker.result.had_error;
|
result.had_error |= checker.result.had_error;
|
||||||
copy_messages(checker.result.messages, *result.messages);
|
copy_messages(checker.result.messages, *result.messages);
|
||||||
}
|
}
|
||||||
@@ -2084,8 +2101,7 @@ pretty_print_symbol_table :: (result : *Compile_Result, allocator : Allocator) -
|
|||||||
|
|
||||||
for *file : result.files {
|
for *file : result.files {
|
||||||
current_scope := cast(Scope_Handle)1;
|
current_scope := cast(Scope_Handle)1;
|
||||||
check_result := file.semantic_check_result;
|
pretty_print_scope(current_scope, file.scope_stack, file.type_variables, *file.scope_stack.stack[0], *builder);
|
||||||
pretty_print_scope(current_scope, check_result.scope_stack, check_result.type_variables, *check_result.scope_stack.stack[0], *builder);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
47
module.jai
47
module.jai
@@ -149,17 +149,22 @@ Compiled_File :: struct {
|
|||||||
|
|
||||||
codegen_result_text : string;
|
codegen_result_text : string;
|
||||||
|
|
||||||
semantic_check_result : Semantic_Check_Result;
|
constant_buffers : Static_Array(Type_Variable_Handle, 16);
|
||||||
|
|
||||||
|
scope_stack : Scope_Stack;
|
||||||
|
type_variables : [..]Type_Variable;
|
||||||
|
|
||||||
|
property_name : string;
|
||||||
|
|
||||||
vertex_entry_point : struct {
|
vertex_entry_point : struct {
|
||||||
|
node : *AST_Node;
|
||||||
name : string;
|
name : string;
|
||||||
|
|
||||||
input : [..]Field;
|
input : [..]Field;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel_entry_point : struct {
|
pixel_entry_point : struct {
|
||||||
|
node : *AST_Node;
|
||||||
name : string;
|
name : string;
|
||||||
|
|
||||||
return_value : Field;
|
return_value : Field;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +172,9 @@ Compiled_File :: struct {
|
|||||||
|
|
||||||
max_constant_buffers :: 16;
|
max_constant_buffers :: 16;
|
||||||
cbuffers : Static_Array(Constant_Buffer, max_constant_buffers);
|
cbuffers : Static_Array(Constant_Buffer, max_constant_buffers);
|
||||||
|
|
||||||
|
allocator : Allocator;
|
||||||
|
arena : Arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
Compile_Result :: struct {
|
Compile_Result :: struct {
|
||||||
@@ -196,6 +204,8 @@ add_file :: (result : *Compile_Result, path : string) {
|
|||||||
compiled_file : Compiled_File;
|
compiled_file : Compiled_File;
|
||||||
compiled_file.file = input_file;
|
compiled_file.file = input_file;
|
||||||
|
|
||||||
|
compiled_file.allocator = make_arena(*compiled_file.arena);
|
||||||
|
|
||||||
array_add(*result.files, compiled_file);
|
array_add(*result.files, compiled_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,11 +417,10 @@ compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Resul
|
|||||||
}
|
}
|
||||||
|
|
||||||
for *file : result.files {
|
for *file : result.files {
|
||||||
check_result := file.semantic_check_result;
|
if file.vertex_entry_point.node {
|
||||||
if check_result.vertex_entry_point {
|
file.vertex_entry_point.name = file.vertex_entry_point.node.name;
|
||||||
file.vertex_entry_point.name = check_result.vertex_entry_point.name;
|
|
||||||
|
|
||||||
type_variable := from_handle(check_result.type_variables, check_result.vertex_entry_point.type_variable);
|
type_variable := from_handle(file.type_variables, file.vertex_entry_point.node.type_variable);
|
||||||
assert(type_variable.type == .Function);
|
assert(type_variable.type == .Function);
|
||||||
|
|
||||||
node := type_variable.source_node;
|
node := type_variable.source_node;
|
||||||
@@ -419,36 +428,36 @@ compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Resul
|
|||||||
if node.children[0].kind == .FieldList {
|
if node.children[0].kind == .FieldList {
|
||||||
field_list := node.children[0];
|
field_list := node.children[0];
|
||||||
for child : field_list.children {
|
for child : field_list.children {
|
||||||
tv := from_handle(check_result.type_variables, child.type_variable);
|
tv := from_handle(file.type_variables, child.type_variable);
|
||||||
field := type_variable_to_field(check_result.type_variables, check_result.scope_stack, tv);
|
field := type_variable_to_field(file.type_variables, file.scope_stack, tv);
|
||||||
array_add(*file.vertex_entry_point.input, field);
|
array_add(*file.vertex_entry_point.input, field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for buffer_variable : to_array(*check_result.constant_buffers) {
|
for buffer_variable : file.constant_buffers {
|
||||||
variable := from_handle(check_result.type_variables, buffer_variable);
|
variable := from_handle(file.type_variables, buffer_variable);
|
||||||
|
|
||||||
cb := array_add(*file.cbuffers);
|
cb := array_add(*file.cbuffers);
|
||||||
|
|
||||||
for i : 0..variable.children.count - 1 {
|
for i : 0..variable.children.count - 1 {
|
||||||
child := variable.children[i];
|
child := variable.children[i];
|
||||||
field : Property_Field;
|
field : Property_Field;
|
||||||
field.base_field = type_variable_to_field(check_result.type_variables, check_result.scope_stack, from_handle(check_result.type_variables, child));
|
field.base_field = type_variable_to_field(file.type_variables, file.scope_stack, from_handle(file.type_variables, child));
|
||||||
array_add(*cb.fields, field);
|
array_add(*cb.fields, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
cb.buffer_index = variable.resource_index;
|
cb.buffer_index = variable.resource_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
find_result := find_symbol(*check_result.scope_stack, check_result.property_name, xx 1);
|
find_result := find_symbol(*file.scope_stack, file.property_name, xx 1);
|
||||||
if find_result {
|
if find_result {
|
||||||
property_variable := from_handle(check_result.type_variables, find_result.type_variable);
|
property_variable := from_handle(file.type_variables, find_result.type_variable);
|
||||||
|
|
||||||
for i : 0..property_variable.children.count - 1 {
|
for i : 0..property_variable.children.count - 1 {
|
||||||
child := property_variable.children[i];
|
child := property_variable.children[i];
|
||||||
field := type_variable_to_field(check_result.type_variables, check_result.scope_stack, from_handle(check_result.type_variables, child));
|
field := type_variable_to_field(file.type_variables, file.scope_stack, from_handle(file.type_variables, child));
|
||||||
prop_field : Property_Field;
|
prop_field : Property_Field;
|
||||||
prop_field.base_field = field;
|
prop_field.base_field = field;
|
||||||
array_add(*file.properties.fields, prop_field);
|
array_add(*file.properties.fields, prop_field);
|
||||||
@@ -456,13 +465,13 @@ compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Resul
|
|||||||
file.properties.buffer_index = property_variable.resource_index;
|
file.properties.buffer_index = property_variable.resource_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if check_result.pixel_entry_point {
|
if file.pixel_entry_point.node {
|
||||||
file.pixel_entry_point.name = check_result.pixel_entry_point.name;
|
file.pixel_entry_point.name = file.pixel_entry_point.node.name;
|
||||||
|
|
||||||
type_variable := from_handle(check_result.type_variables, check_result.pixel_entry_point.type_variable);
|
type_variable := from_handle(file.type_variables, file.pixel_entry_point.node.type_variable);
|
||||||
assert(type_variable.type == .Function);
|
assert(type_variable.type == .Function);
|
||||||
|
|
||||||
field := type_variable_to_field(check_result.type_variables, check_result.scope_stack, type_variable.return_type_variable);
|
field := type_variable_to_field(file.type_variables, file.scope_stack, type_variable.return_type_variable);
|
||||||
for hint : type_variable.source_node.hint_tokens {
|
for hint : type_variable.source_node.hint_tokens {
|
||||||
field_hint : Field_Hint;
|
field_hint : Field_Hint;
|
||||||
|
|
||||||
|
|||||||
Submodule modules/ncore updated: 9db7ff0940...051a035bb8
Reference in New Issue
Block a user