]> git.tdb.fi Git - libs/gl.git/commitdiff
Apply implicit conversions to function arguments
authorMikko Rasa <tdb@tdb.fi>
Sun, 28 Nov 2021 23:02:54 +0000 (01:02 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 28 Nov 2021 23:02:54 +0000 (01:02 +0200)
source/glsl/resolve.cpp

index 3aeab30bd703711d28909cea07b15adc4fc1318d..fbe60d79def36ee514e9598541a2ab99f05b4539 100644 (file)
@@ -1084,7 +1084,24 @@ void ExpressionResolver::visit(FunctionCall &call)
        TraversingVisitor::visit(call);
 
        if(call.declaration)
+       {
+               for(unsigned i=0; i<call.arguments.size(); ++i)
+               {
+                       TypeDeclaration *arg_type = call.arguments[i]->type;
+                       TypeDeclaration *param_type = call.declaration->parameters[i]->type_declaration;
+                       BasicTypeDeclaration *arg_basic = dynamic_cast<BasicTypeDeclaration *>(arg_type);
+                       BasicTypeDeclaration *param_basic = dynamic_cast<BasicTypeDeclaration *>(param_type);
+                       if(arg_basic && param_basic)
+                       {
+                               Compatibility compat = get_compatibility(*param_basic, *arg_basic);
+                               if(compat==RIGHT_CONVERTIBLE)
+                                       convert_to(call.arguments[i], *param_basic);
+                       }
+                       else if(!arg_type || !param_type || arg_type!=param_type)
+                               return;
+               }
                resolve(call, call.declaration->return_type_declaration, false);
+       }
        else if(call.constructor)
                visit_constructor(call);
 }