]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.cpp
Fix a bug with resolving member declarations
[libs/gl.git] / source / glsl / generate.cpp
index c4a29110ffc8783f6d671340a5bdb05f8d0c5759..8626cac6761c6f42f896b76ef47d53111df5c460 100644 (file)
@@ -197,12 +197,7 @@ void VariableResolver::visit(VariableReference &var)
                        var.declaration = i->second;
        }
 
-       if(var.declaration)
-       {
-               if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(var.declaration->type_declaration))
-                       r_members = &strct->members.variables;
-       }
-       else
+       if(!var.declaration)
        {
                const map<string, InterfaceBlock *> &blocks = stage->interface_blocks;
                map<string, InterfaceBlock *>::const_iterator i = blocks.find("_"+var.name);
@@ -211,6 +206,8 @@ void VariableResolver::visit(VariableReference &var)
                        /* The name refers to an interface block with an instance name rather
                        than a variable.  Prepare a new syntax tree node accordingly. */
                        r_iface_ref = new InterfaceBlockReference;
+                       r_iface_ref->source = var.source;
+                       r_iface_ref->line = var.line;
                        r_iface_ref->name = var.name;
                        r_iface_ref->declaration = i->second;
                        r_members = &i->second->members.variables;
@@ -228,6 +225,10 @@ void VariableResolver::visit(VariableReference &var)
                }
        }
 
+       if(var.declaration)
+               if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(var.declaration->type_declaration))
+                       r_members = &strct->members.variables;
+
        if(record_target)
        {
                if(r_assignment_target)