]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.cpp
Resolve constructors in FunctionResolver
[libs/gl.git] / source / glsl / generate.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;