Ifdefs, moved semantic to check, fixed error reporting for builtins
This commit is contained in:
24
Codegen.jai
24
Codegen.jai
@@ -11,16 +11,13 @@ Output_Language :: enum {
|
||||
HLSL;
|
||||
GLSL; // @Incomplete
|
||||
MLSL; // @Incomplete
|
||||
// SPIRV; // @Incomplete: Should we do this?
|
||||
}
|
||||
|
||||
Codegen_State :: struct {
|
||||
path : string;
|
||||
|
||||
// scope_stack : Scope_Stack;
|
||||
current_scope : Scope_Handle;
|
||||
|
||||
// type_variables : []Type_Variable;
|
||||
// root : *AST_Node;
|
||||
|
||||
output_language : Output_Language;
|
||||
|
||||
@@ -29,14 +26,6 @@ Codegen_State :: struct {
|
||||
result : *Compiler_Context;
|
||||
}
|
||||
|
||||
// Codegen_Result :: struct {
|
||||
// messages : [..]Compiler_Message;
|
||||
|
||||
// had_error : bool;
|
||||
|
||||
// result_text : string; // @Incomplete(nb): Result for now, should likely be far more sophisticated.
|
||||
// }
|
||||
|
||||
Reserved_HLSL_Words :: string.[
|
||||
"texture",
|
||||
"sampler",
|
||||
@@ -131,27 +120,24 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
child := node.children[0];
|
||||
|
||||
print_to_builder(*state.builder, " = ");
|
||||
emit_node(state, child, 0);
|
||||
|
||||
emit_node(state, child, 0);
|
||||
}
|
||||
|
||||
if node.parent.kind == .Block {
|
||||
append(*state.builder, ";");
|
||||
}
|
||||
|
||||
|
||||
for i :0..field.children.count - 1 {
|
||||
child := from_handle(state.result.type_variables, field.children[i]);
|
||||
emit_node(state, child.source_node, 0);
|
||||
}
|
||||
|
||||
for hint : node.hint_tokens {
|
||||
if hint.ident_value == "position" {
|
||||
// @Incomplete(nb): Should be a lookup table somewhere
|
||||
if lookup_hint(hint.ident_value) == .Position {
|
||||
append(*state.builder, " : POSITION");
|
||||
} else if hint.ident_value == "uv" {
|
||||
} else if lookup_hint(hint.ident_value) == .UV {
|
||||
append(*state.builder, " : TEXCOORD0");
|
||||
} else if hint.ident_value == "outposition" {
|
||||
} else if lookup_hint(hint.ident_value) == .Output_Position {
|
||||
append(*state.builder, " : SV_POSITION");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user