#include <string>
#include <vector>
#include <msp/core/refptr.h>
+#include <msp/core/variant.h>
#include "features.h"
+#include "glsl_error.h"
#include "sourcemap.h"
#pragma push_macro("interface")
struct Node
{
-protected:
- Node() { }
- Node(const Node &) { }
+ int source;
+ unsigned line;
+
+ Node(): source(GENERATED_SOURCE), line(1) { }
+ Node(const Node &n): source(n.source), line(n.line) { }
private:
Node &operator=(const Node &);
public:
class NodeArray: public NodeContainer<std::vector<RefPtr<T> > >
{ };
-struct StructDeclaration;
+struct TypeDeclaration;
struct VariableDeclaration;
struct InterfaceBlock;
struct FunctionDeclaration;
struct Statement: Node
{
- int source;
- unsigned line;
-
- Statement();
-
virtual Statement *clone() const = 0;
};
{
const Operator *oper;
+ TypeDeclaration *type;
+ bool lvalue;
+
Expression();
virtual Expression *clone() const = 0;
struct Literal: Expression
{
std::string token;
+ Variant value;
virtual Literal *clone() const { return new Literal(*this); }
virtual void visit(NodeVisitor &);
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();
NodePtr<Expression> array_size;
NodePtr<Expression> init_expression;
- StructDeclaration *type_declaration;
+ TypeDeclaration *type_declaration;
VariableDeclaration *linked_declaration;
VariableDeclaration();
Block body;
FunctionDeclaration *definition;
+ TypeDeclaration *return_type_declaration;
FunctionDeclaration();
FunctionDeclaration(const FunctionDeclaration &);
struct Iteration: Statement
{
- NodePtr<Node> init_statement;
+ NodePtr<Statement> init_statement;
NodePtr<Expression> condition;
NodePtr<Expression> loop_expression;
Block body;
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;
Features required_features;
+ std::vector<Diagnostic> diagnostics;
Stage(Type);