]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Give declaration nodes to all GLSL types.
[libs/gl.git] / source / glsl / syntax.h
index f275eab8c4ae454ee369ac10e40d3c0e4499190a..62c289d9fbb6ec48f61be268b7eec67072718e98 100644 (file)
@@ -285,9 +285,66 @@ struct InterfaceLayout: Statement
        virtual void visit(NodeVisitor &);
 };
 
-struct StructDeclaration: Statement
+struct TypeDeclaration: Statement
 {
        std::string name;
+
+       virtual TypeDeclaration *clone() const = 0;
+};
+
+struct BasicTypeDeclaration: TypeDeclaration
+{
+       enum Kind
+       {
+               ALIAS,
+               VOID,
+               BOOL,
+               INT,
+               FLOAT,
+               VECTOR,
+               MATRIX,
+               ARRAY
+       };
+
+       Kind kind;
+       unsigned size;
+       std::string base;
+
+       TypeDeclaration *base_type;
+
+       BasicTypeDeclaration();
+       BasicTypeDeclaration(const BasicTypeDeclaration &);
+
+       virtual BasicTypeDeclaration *clone() const { return new BasicTypeDeclaration(*this); }
+       virtual void visit(NodeVisitor &);
+};
+
+struct ImageTypeDeclaration: TypeDeclaration
+{
+       enum Dimensions
+       {
+               ONE = 1,
+               TWO,
+               THREE,
+               CUBE
+       };
+
+       Dimensions dimensions;
+       bool array;
+       bool sampled;
+       bool shadow;
+       std::string base;
+
+       TypeDeclaration *base_type;
+
+       ImageTypeDeclaration();
+
+       virtual ImageTypeDeclaration *clone() const { return new ImageTypeDeclaration(*this); }
+       virtual void visit(NodeVisitor &);
+};
+
+struct StructDeclaration: TypeDeclaration
+{
        Block members;
 
        StructDeclaration();
@@ -310,7 +367,7 @@ struct VariableDeclaration: Statement
        NodePtr<Expression> array_size;
        NodePtr<Expression> init_expression;
 
-       StructDeclaration *type_declaration;
+       TypeDeclaration *type_declaration;
        VariableDeclaration *linked_declaration;
 
        VariableDeclaration();
@@ -413,7 +470,7 @@ struct Stage
        Type type;
        Stage *previous;
        Block content;
-       std::map<std::string, StructDeclaration *> types;
+       std::map<std::string, TypeDeclaration *> types;
        std::map<std::string, InterfaceBlock *> interface_blocks;
        std::map<std::string, FunctionDeclaration *> functions;
        std::map<std::string, unsigned> locations;