]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programsyntax.h
Parse true and false as literals rather than identifiers
[libs/gl.git] / source / programsyntax.h
index c8b0e1f74ed9d1679e8c652ddb1f52f896872df5..03b5aa8863d1e70af4e9be52383431ed9b331a96 100644 (file)
@@ -33,6 +33,10 @@ public:
        NodePtr(T *n = 0): node(n) { }
        NodePtr(const NodePtr &p): node(clone(p.node)) { }
        NodePtr &operator=(const NodePtr &p) { delete node; node = clone(p.node); return *this; }
+#if __cplusplus>=201103L
+       NodePtr(NodePtr &&p): node(p.node) { p.node = 0; }
+       NodePtr &operator=(NodePtr &&p) { delete node; node = p.node; p.node = 0; return *this; }
+#endif
        ~NodePtr() { delete node; }
 
 private:
@@ -122,14 +126,22 @@ struct BinaryExpression: Expression
        std::string oper;
        NodePtr<Expression> right;
        std::string after;
-       bool assignment;
-
-       BinaryExpression();
 
        virtual BinaryExpression *clone() const { return new BinaryExpression(*this); }
        virtual void visit(NodeVisitor &);
 };
 
+struct Assignment: BinaryExpression
+{
+       bool self_referencing;
+       VariableDeclaration *target_declaration;
+
+       Assignment();
+
+       virtual Assignment *clone() const { return new Assignment(*this); }
+       virtual void visit(NodeVisitor &);
+};
+
 struct FunctionCall: Expression
 {
        std::string name;
@@ -200,6 +212,8 @@ struct InterfaceBlock: Node
        std::string interface;
        std::string name;
        Block members;
+       std::string instance_name;
+       bool array;
 
        InterfaceBlock();
 
@@ -223,7 +237,7 @@ struct FunctionDeclaration: Node
 
 struct Conditional: Node
 {
-       Expression *condition;
+       NodePtr<Expression> condition;
        Block body;
        Block else_body;
 
@@ -269,6 +283,7 @@ struct NodeVisitor
        virtual void visit(MemberAccess &) { }
        virtual void visit(UnaryExpression &) { }
        virtual void visit(BinaryExpression &) { }
+       virtual void visit(Assignment &);
        virtual void visit(FunctionCall &) { }
        virtual void visit(ExpressionStatement &) { }
        virtual void visit(Layout &) { }
@@ -301,32 +316,29 @@ struct TraversingVisitor: NodeVisitor
        virtual void visit(Return &);
 };
 
-enum ContextType
+enum StageType
 {
-       GLOBAL,
+       SHARED,
        VERTEX,
        GEOMETRY,
        FRAGMENT
 };
 
-struct Context
+struct Stage
 {
-       ContextType type;
-       bool present;
-       Context *previous;
+       StageType type;
+       Stage *previous;
        ProgramSyntax::Block content;
        std::map<std::string, VariableDeclaration *> in_variables;
        std::map<std::string, VariableDeclaration *> out_variables;
 
-       Context(ContextType);
+       Stage(StageType);
 };
 
 struct Module
 {
-       Context global_context;
-       Context vertex_context;
-       Context geometry_context;
-       Context fragment_context;
+       Stage shared;
+       std::list<Stage> stages;
 
        Module();
 };