X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramsyntax.h;h=cbce078e2d65c1eb74bb9985fa2639c4bc525326;hb=78cec1556c85db6beb4f3d9f918b5a1f421719ef;hp=11a67430926849adee88a32cb636bcde544d1736;hpb=a36992487d018d8801ead6980b362b00a2f5f5c5;p=libs%2Fgl.git diff --git a/source/programsyntax.h b/source/programsyntax.h index 11a67430..cbce078e 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -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: @@ -187,6 +191,7 @@ struct VariableDeclaration: Node bool array; NodePtr array_size; NodePtr init_expression; + VariableDeclaration *linked_declaration; VariableDeclaration(); @@ -222,7 +227,7 @@ struct FunctionDeclaration: Node struct Conditional: Node { - Expression *condition; + NodePtr condition; Block body; Block else_body; @@ -241,6 +246,14 @@ struct Iteration: Node virtual void visit(NodeVisitor &); }; +struct Passthrough: Node +{ + NodePtr subscript; + + virtual Passthrough *clone() const { return new Passthrough(*this); } + virtual void visit(NodeVisitor &); +}; + struct Return: Node { NodePtr expression; @@ -269,6 +282,7 @@ struct NodeVisitor virtual void visit(FunctionDeclaration &) { } virtual void visit(Conditional &) { } virtual void visit(Iteration &) { } + virtual void visit(Passthrough &) { } virtual void visit(Return &) { } }; @@ -287,32 +301,33 @@ struct TraversingVisitor: NodeVisitor virtual void visit(FunctionDeclaration &); virtual void visit(Conditional &); virtual void visit(Iteration &); + virtual void visit(Passthrough &); virtual void visit(Return &); }; -enum ContextType +enum StageType { - GLOBAL, + SHARED, VERTEX, GEOMETRY, FRAGMENT }; -struct Context +struct Stage { - ContextType type; - bool present; + StageType type; + Stage *previous; ProgramSyntax::Block content; + std::map in_variables; + std::map out_variables; - Context(ContextType); + Stage(StageType); }; struct Module { - Context global_context; - Context vertex_context; - Context geometry_context; - Context fragment_context; + Stage shared; + std::list stages; Module(); };