]> git.tdb.fi Git - libs/gl.git/commitdiff
Resolve constructors in FunctionResolver
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Mar 2021 19:36:56 +0000 (21:36 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 14 Mar 2021 00:23:37 +0000 (02:23 +0200)
source/glsl/generate.cpp
source/glsl/parser.cpp

index 9dff1e607ae40f6fd7019cdbac2f2338ff81de23..11116b11ecb164cb704fdcf277de380ac882ba82 100644 (file)
@@ -937,22 +937,28 @@ bool FunctionResolver::apply(Stage &s)
 
 void FunctionResolver::visit(FunctionCall &call)
 {
-       string arg_types;
-       bool has_signature = true;
-       for(NodeArray<Expression>::const_iterator i=call.arguments.begin(); (has_signature && i!=call.arguments.end()); ++i)
-       {
-               if((*i)->type)
-                       append(arg_types, ",", (*i)->type->name);
-               else
-                       has_signature = false;
-       }
-
        FunctionDeclaration *declaration = 0;
-       if(has_signature)
+       if(stage->types.count(call.name))
+               call.constructor = true;
+       else
        {
-               map<string, FunctionDeclaration *>::iterator i = stage->functions.find(format("%s(%s)", call.name, arg_types));
-               declaration = (i!=stage->functions.end() ? i->second : 0);
+               string arg_types;
+               bool has_signature = true;
+               for(NodeArray<Expression>::const_iterator i=call.arguments.begin(); (has_signature && i!=call.arguments.end()); ++i)
+               {
+                       if((*i)->type)
+                               append(arg_types, ",", (*i)->type->name);
+                       else
+                               has_signature = false;
+               }
+
+               if(has_signature)
+               {
+                       map<string, FunctionDeclaration *>::iterator i = stage->functions.find(format("%s(%s)", call.name, arg_types));
+                       declaration = (i!=stage->functions.end() ? i->second : 0);
+               }
        }
+
        r_any_resolved |= (declaration!=call.declaration);
        call.declaration = declaration;
 
index a2e3296d81b9c52ff70139a3cf91f747aed03485..8f2160a626674675b1f63b76ce5dc992d92451ff 100644 (file)
@@ -575,7 +575,6 @@ RefPtr<FunctionCall> Parser::parse_function_call(const VariableReference &var)
 {
        RefPtr<FunctionCall> call = create_node<FunctionCall>();
        call->name = var.name;
-       call->constructor = is_type(call->name);
        call->oper = &Operator::get_operator("(", Operator::POSTFIX);
        tokenizer.expect("(");
        while(tokenizer.peek_token()!=")")