]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Unify handling of variables and interface blocks in the GLSL compiler
[libs/gl.git] / source / glsl / syntax.h
index 7a372dc59e2402d5f1872da7aa24415c66c1e783..95347e1bbb5831deaf9ffceb58cc1e196df25cde 100644 (file)
@@ -111,7 +111,6 @@ class NodeArray: public NodeContainer<std::vector<RefPtr<T> > >
 
 struct TypeDeclaration;
 struct VariableDeclaration;
-struct InterfaceBlock;
 struct FunctionDeclaration;
 
 struct Statement: Node
@@ -166,19 +165,6 @@ struct VariableReference: Expression
        virtual void visit(NodeVisitor &);
 };
 
-struct InterfaceBlockReference: Expression
-{
-       std::string name;
-
-       InterfaceBlock *declaration = 0;
-
-       InterfaceBlockReference() = default;
-       InterfaceBlockReference(const InterfaceBlockReference &);
-
-       virtual InterfaceBlockReference *clone() const { return new InterfaceBlockReference(*this); }
-       virtual void visit(NodeVisitor &);
-};
-
 struct MemberAccess: Expression
 {
        NodePtr<Expression> left;
@@ -391,13 +377,13 @@ struct ImageTypeDeclaration: TypeDeclaration
 struct StructDeclaration: TypeDeclaration
 {
        Block members;
+       std::string block_name;
        bool extended_alignment = false;
 
-       InterfaceBlock *interface_block = 0;
+       VariableDeclaration *block_declaration = 0;
 
        StructDeclaration();
        StructDeclaration(const StructDeclaration &);
-       ~StructDeclaration();
 
        virtual StructDeclaration *clone() const { return new StructDeclaration(*this); }
        virtual void visit(NodeVisitor &);
@@ -418,6 +404,7 @@ struct VariableDeclaration: Statement
        NodePtr<Expression> init_expression;
 
        TypeDeclaration *type_declaration = 0;
+       StructDeclaration *block_declaration = 0;
        VariableDeclaration *linked_declaration = 0;
 
        VariableDeclaration() = default;
@@ -428,29 +415,6 @@ struct VariableDeclaration: Statement
        virtual void visit(NodeVisitor &);
 };
 
-struct InterfaceBlock: Statement
-{
-       NodePtr<Layout> layout;
-       std::string interface;
-       std::string block_name;
-       NodePtr<Block> members;
-       std::string instance_name;
-       bool array = false;
-
-       /* An interface block's ultimate base type is always a struct.  The
-       immediate type may be either that same struct or an array of it. */
-       TypeDeclaration *type_declaration = 0;
-       StructDeclaration *struct_declaration = 0;
-       InterfaceBlock *linked_block = 0;
-
-       InterfaceBlock() = default;
-       InterfaceBlock(const InterfaceBlock &);
-       ~InterfaceBlock();
-
-       virtual InterfaceBlock *clone() const { return new InterfaceBlock(*this); }
-       virtual void visit(NodeVisitor &);
-};
-
 struct FunctionDeclaration: Statement
 {
        std::string return_type;
@@ -530,7 +494,7 @@ struct Stage
        Stage *previous = 0;
        Block content;
        std::map<std::string, TypeDeclaration *> types;
-       std::map<std::string, InterfaceBlock *> interface_blocks;
+       std::map<std::string, VariableDeclaration *> interface_blocks;
        std::map<std::string, FunctionDeclaration *> functions;
        std::map<std::string, unsigned> locations;
        std::map<std::string, unsigned> texture_bindings;
@@ -554,7 +518,7 @@ struct Module
 };
 
 std::string get_unused_variable_name(const Block &, const std::string &);
-const TypeDeclaration *get_ultimate_base_type(const TypeDeclaration *);
+TypeDeclaration *get_ultimate_base_type(TypeDeclaration *);
 bool has_layout_qualifier(const Layout *, const std::string &);
 int get_layout_value(const Layout *, const std::string &, int = -1);
 void add_layout_qualifier(RefPtr<Layout> &, const Layout::Qualifier &);