Multiple small fixes
- Foreign functions can now have names for parameters - Fix property renaming crash - Properly output texture sampling calls
This commit is contained in:
@@ -842,10 +842,14 @@ proper_type_to_string :: (checker : *Semantic_Checker, var : Type_Variable, allo
|
||||
get_type_from_identifier :: (checker : *Semantic_Checker, scope : Scope_Handle, node : *AST_Node, typename : *string = null) -> Semantic_Type {
|
||||
type_string := node.token.ident_value;
|
||||
|
||||
if type_string == Typenames[Semantic_Type.Int] return .Int;
|
||||
if type_string == Typenames[Semantic_Type.Half] return .Half;
|
||||
if type_string == Typenames[Semantic_Type.Float] return .Float;
|
||||
if type_string == Typenames[Semantic_Type.Double] return .Double;
|
||||
if type_string == {
|
||||
case Typenames[Semantic_Type.Int]; return .Int;
|
||||
case Typenames[Semantic_Type.Half]; return .Half;
|
||||
case Typenames[Semantic_Type.Float]; return .Float;
|
||||
case Typenames[Semantic_Type.Double]; return .Double;
|
||||
case Typenames[Semantic_Type.Sampler]; return .Sampler;
|
||||
case Typenames[Semantic_Type.Texture2D]; return .Texture2D;
|
||||
}
|
||||
|
||||
symbol := find_symbol(checker, type_string, scope);
|
||||
if symbol {
|
||||
@@ -1199,6 +1203,9 @@ create_variable :: (checker : *Semantic_Checker, node : *AST_Node, struct_field_
|
||||
return 0;
|
||||
} else {
|
||||
lookup_name : string = variable.typename;
|
||||
if variable.typename == "properties" {
|
||||
lookup_name = variable.name;
|
||||
}
|
||||
struct_symbol := find_symbol(checker, lookup_name, checker.current_scope);
|
||||
type_variable := h2tv(checker, struct_symbol.type_variable);
|
||||
|
||||
@@ -1530,13 +1537,17 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
|
||||
rhs_var := h2tv(checker, rhs);
|
||||
|
||||
if lhs_var.type == {
|
||||
case .Int; #through;
|
||||
case .Half; #through;
|
||||
case .Float; #through;
|
||||
case .Int; #through;
|
||||
case .Half; #through;
|
||||
case .Float; #through;
|
||||
case .Double; {
|
||||
return rhs_var.type == .Int || rhs_var.type == .Half ||
|
||||
rhs_var.type == .Float || rhs_var.type == .Double;
|
||||
}
|
||||
case .Sampler; #through;
|
||||
case .Texture2D; {
|
||||
return rhs_var.type == lhs_var.type;
|
||||
}
|
||||
case .Struct; {
|
||||
if rhs_var.type != .Struct {
|
||||
return false;
|
||||
@@ -1653,13 +1664,13 @@ union_find :: (checker : *Semantic_Checker) -> bool {
|
||||
}
|
||||
|
||||
add_hlsl_builtins :: (checker : *Semantic_Checker) {
|
||||
#load "hlsl_builtin.jai";
|
||||
|
||||
HLSL_BUILTIN := read_entire_file("hlsl_builtin.shd");
|
||||
|
||||
checker.state = .Adding_Builtins;
|
||||
|
||||
lexer : Lexer;
|
||||
|
||||
init_lexer_from_string(*lexer, HLSL_BULTIN);
|
||||
init_lexer_from_string(*lexer, HLSL_BUILTIN);
|
||||
if lexer.result.had_error {
|
||||
print("%\n", report_messages(lexer.result.messages));
|
||||
return;
|
||||
@@ -1741,9 +1752,11 @@ type_to_string :: (type_variable : Type_Variable) -> string {
|
||||
return "{{invalid}}";
|
||||
case .Unit;
|
||||
return "()";
|
||||
case .Int; #through;
|
||||
case .Half; #through;
|
||||
case .Float; #through;
|
||||
case .Int; #through;
|
||||
case .Half; #through;
|
||||
case .Float; #through;
|
||||
case .Sampler; #through;
|
||||
case .Texture2D; #through;
|
||||
case .Double; {
|
||||
return Typenames[type_variable.type];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user