#include <list>
#include <map>
+#include <set>
#include <string>
#include <vector>
#include <msp/core/refptr.h>
#include "features.h"
+#include "glsl_error.h"
#include "sourcemap.h"
#pragma push_macro("interface")
enum Associativity
{
LEFT_TO_RIGHT,
- RIGHT_TO_LEFT
+ RIGHT_TO_LEFT,
+ ASSOCIATIVE
};
char token[4];
Associativity assoc;
static const Operator operators[];
+
+ static const Operator &get_operator(const std::string &, Type);
+};
+
+enum
+{
+ BUILTIN_SOURCE = -1,
+ GENERATED_SOURCE = 0
};
struct NodeVisitor;
struct StructDeclaration;
struct VariableDeclaration;
+struct InterfaceBlock;
struct FunctionDeclaration;
struct Statement: Node
{
- unsigned source;
+ int source;
unsigned line;
Statement();
{
NodeList<Statement> body;
bool use_braces;
- bool anonymous;
- std::map<std::string, StructDeclaration *> types;
+
std::map<std::string, VariableDeclaration *> variables;
Block *parent;
struct Expression: Node
{
+ const Operator *oper;
+
+ Expression();
+
virtual Expression *clone() const = 0;
};
struct VariableReference: Expression
{
std::string name;
+
VariableDeclaration *declaration;
VariableReference();
virtual void visit(NodeVisitor &);
};
+struct InterfaceBlockReference: Expression
+{
+ std::string name;
+
+ InterfaceBlock *declaration;
+
+ InterfaceBlockReference();
+ InterfaceBlockReference(const InterfaceBlockReference &);
+
+ virtual InterfaceBlockReference *clone() const { return new InterfaceBlockReference(*this); }
+ virtual void visit(NodeVisitor &);
+};
+
struct MemberAccess: Expression
{
NodePtr<Expression> left;
std::string member;
+
VariableDeclaration *declaration;
MemberAccess();
struct UnaryExpression: Expression
{
- std::string oper;
NodePtr<Expression> expression;
- bool prefix;
-
- UnaryExpression();
virtual UnaryExpression *clone() const { return new UnaryExpression(*this); }
virtual void visit(NodeVisitor &);
struct BinaryExpression: Expression
{
NodePtr<Expression> left;
- std::string oper;
NodePtr<Expression> right;
- std::string after;
virtual BinaryExpression *clone() const { return new BinaryExpression(*this); }
virtual void visit(NodeVisitor &);
struct Assignment: BinaryExpression
{
bool self_referencing;
+
VariableDeclaration *target_declaration;
Assignment();
struct FunctionCall: Expression
{
std::string name;
- FunctionDeclaration *declaration;
bool constructor;
NodeArray<Expression> arguments;
+ FunctionDeclaration *declaration;
+
FunctionCall();
FunctionCall(const FunctionCall &);
struct VariableDeclaration: Statement
{
+ NodePtr<Layout> layout;
bool constant;
std::string sampling;
std::string interpolation;
std::string interface;
std::string precision;
std::string type;
- StructDeclaration *type_declaration;
std::string name;
bool array;
NodePtr<Expression> array_size;
NodePtr<Expression> init_expression;
+
+ StructDeclaration *type_declaration;
VariableDeclaration *linked_declaration;
- NodePtr<Layout> layout;
VariableDeclaration();
VariableDeclaration(const VariableDeclaration &);
+ ~VariableDeclaration();
virtual VariableDeclaration *clone() const { return new VariableDeclaration(*this); }
virtual void visit(NodeVisitor &);
std::string instance_name;
bool array;
+ InterfaceBlock *linked_block;
+
InterfaceBlock();
+ InterfaceBlock(const InterfaceBlock &);
+ ~InterfaceBlock();
virtual InterfaceBlock *clone() const { return new InterfaceBlock(*this); }
virtual void visit(NodeVisitor &);
std::string return_type;
std::string name;
NodeArray<VariableDeclaration> parameters;
- FunctionDeclaration *definition;
Block body;
+ FunctionDeclaration *definition;
+
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, VariableDeclaration *> in_variables;
- std::map<std::string, VariableDeclaration *> out_variables;
+ std::map<std::string, StructDeclaration *> 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);