]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Refactor resolution of declarations for MemberAccess
[libs/gl.git] / source / glsl / compiler.cpp
index 66a487fbccd4b7a63f2575295ecc03fcbfcddf5a..30a3f08c58a98b34cf10ffc8224540375978c69e 100644 (file)
@@ -241,16 +241,12 @@ void Compiler::generate(Stage &stage, Mode mode)
 
        // Initial resolving pass
        BlockHierarchyResolver().apply(stage);
-       TypeResolver().apply(stage);
-       FunctionResolver().apply(stage);
-       VariableResolver().apply(stage);
+       resolve(stage);
 
        /* All variables local to a stage have been resolved.  Resolve non-local
        variables through interfaces. */
        InterfaceGenerator().apply(stage);
-       TypeResolver().apply(stage);
-       VariableResolver().apply(stage);
-       ExpressionResolver().apply(stage);
+       resolve(stage);
 
        FunctionResolver().apply(stage);
        ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0));
@@ -258,6 +254,15 @@ void Compiler::generate(Stage &stage, Mode mode)
                LegacyConverter().apply(stage, features);
 }
 
+void Compiler::resolve(Stage &stage)
+{
+       TypeResolver().apply(stage);
+       // Use the bitwise or to always evaluate both operands
+       while(VariableResolver().apply(stage) |
+               ExpressionResolver().apply(stage)) ;
+       FunctionResolver().apply(stage);
+}
+
 bool Compiler::validate(Stage &stage)
 {
        TypeValidator().apply(stage);
@@ -279,12 +284,7 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage)
        bool any_inlined = FunctionInliner().apply(stage);
        any_inlined |= ExpressionInliner().apply(stage);
        if(any_inlined)
-       {
-               TypeResolver().apply(stage);
-               VariableResolver().apply(stage);
-               FunctionResolver().apply(stage);
-               ExpressionResolver().apply(stage);
-       }
+               resolve(stage);
 
        /* Removing variables or functions may cause things from the previous stage
        to become unused. */