Fix some tests and do some cleanup.
This commit is contained in:
24
Codegen.jai
24
Codegen.jai
@@ -88,14 +88,14 @@ dx11_type_to_string :: (type_variable : Type_Variable) -> string {
|
||||
emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
find_result := find_symbol(state.scope_stack, node.name, state.current_scope);
|
||||
|
||||
field := h2tv(state.type_variables, find_result.type_variable);
|
||||
field := from_handle(state.type_variables, find_result.type_variable);
|
||||
|
||||
indent(state, indentation);
|
||||
|
||||
print_to_builder(*state.builder, "% ", dx11_type_to_string(field));
|
||||
|
||||
if field.struct_field_parent {
|
||||
parent_tv := h2tv(state.type_variables, field.struct_field_parent.type_variable);
|
||||
parent_tv := from_handle(state.type_variables, field.struct_field_parent.type_variable);
|
||||
|
||||
if parent_tv.typename == "properties" {
|
||||
append(*state.builder, "__PROPERTIES__");
|
||||
@@ -119,7 +119,7 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
}
|
||||
|
||||
for i :0..field.children.count - 1 {
|
||||
child := h2tv(state.type_variables, field.children[i]);
|
||||
child := from_handle(state.type_variables, field.children[i]);
|
||||
emit_node(state, child.source_node, 0);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
|
||||
}
|
||||
assert(find_result != null, "Attempting to generate undeclared properties buffer. This should never happen at this stage.");
|
||||
|
||||
variable := h2tv(state.type_variables, find_result.type_variable);
|
||||
variable := from_handle(state.type_variables, find_result.type_variable);
|
||||
|
||||
print_to_builder(*state.builder, "cbuffer __PROPERTIES : register(b%) \n{\n", variable.resource_index);
|
||||
|
||||
@@ -210,7 +210,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
|
||||
for child : node.children {
|
||||
if child.kind == .FieldList {
|
||||
for field : child.children {
|
||||
tv := h2tv(state.type_variables, field.type_variable);
|
||||
tv := from_handle(state.type_variables, field.type_variable);
|
||||
if tv.type == .Sampler || tv.type == .Texture2D {
|
||||
array_add(*resources, field);
|
||||
continue;
|
||||
@@ -250,12 +250,12 @@ emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, e
|
||||
}
|
||||
|
||||
for func : find_result.functions {
|
||||
function_variable := h2tv(state.type_variables, func.type_variable);
|
||||
function_variable := from_handle(state.type_variables, func.type_variable);
|
||||
|
||||
indent(state, indentation);
|
||||
|
||||
if function_variable.return_type_variable {
|
||||
return_variable := h2tv(state.type_variables, function_variable.return_type_variable);
|
||||
return_variable := from_handle(state.type_variables, function_variable.return_type_variable);
|
||||
print_to_builder(*state.builder, "% ", dx11_type_to_string(return_variable));
|
||||
} else {
|
||||
append(*state.builder, "void ");
|
||||
@@ -379,12 +379,12 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
case .Variable; {
|
||||
indent(*state.builder, indentation);
|
||||
|
||||
type_var := h2tv(state.type_variables, node.type_variable);
|
||||
type_var := from_handle(state.type_variables, node.type_variable);
|
||||
is_properties := type_var.typename == "properties";
|
||||
|
||||
if !is_properties {
|
||||
if type_var.struct_field_parent {
|
||||
parent_tv := h2tv(state.type_variables, type_var.struct_field_parent.type_variable);
|
||||
parent_tv := from_handle(state.type_variables, type_var.struct_field_parent.type_variable);
|
||||
|
||||
if parent_tv.typename == "properties" {
|
||||
append(*state.builder, "__PROPERTIES__");
|
||||
@@ -450,7 +450,7 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
print_to_builder(*state.builder, "struct %", node.name);
|
||||
|
||||
current_scope := state.current_scope;
|
||||
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
|
||||
state.current_scope = from_handle(state.type_variables, node.type_variable).scope;
|
||||
|
||||
field_list := node.children[0];
|
||||
|
||||
@@ -467,11 +467,11 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
}
|
||||
|
||||
emit_cbuffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
variable := h2tv(state.type_variables, node.type_variable);
|
||||
variable := from_handle(state.type_variables, node.type_variable);
|
||||
print_to_builder(*state.builder, "cbuffer % : register(b%)", variable.name, variable.resource_index);
|
||||
|
||||
current_scope := state.current_scope;
|
||||
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
|
||||
state.current_scope = from_handle(state.type_variables, node.type_variable).scope;
|
||||
|
||||
field_list := node.children[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user