X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramsyntax.h;h=2f9f1fc08a50f47eb3a8fc6f4757217cb39f0b09;hb=74bd3813b9744550c9ac5980588e561835b616d9;hp=86cb6b906181e7686d4230dbbe1b6fbeb9cb1556;hpb=fd103d76d7546f7e22aefc18c090a844fc67409f;p=libs%2Fgl.git diff --git a/source/programsyntax.h b/source/programsyntax.h index 86cb6b90..2f9f1fc0 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -5,6 +5,7 @@ #include #include #include +#include "extension.h" namespace Msp { namespace GL { @@ -33,6 +34,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: @@ -48,6 +53,7 @@ public: struct StructDeclaration; struct VariableDeclaration; +struct FunctionDeclaration; struct Block: Node { @@ -122,17 +128,26 @@ struct BinaryExpression: Expression std::string oper; NodePtr 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; + FunctionDeclaration *declaration; bool constructor; std::vector > arguments; @@ -150,6 +165,14 @@ struct ExpressionStatement: Node virtual void visit(NodeVisitor &); }; +struct Import: Node +{ + std::string module; + + virtual Import *clone() const { return new Import(*this); } + virtual void visit(NodeVisitor &); +}; + struct Layout: Node { struct Qualifier @@ -200,6 +223,8 @@ struct InterfaceBlock: Node std::string interface; std::string name; Block members; + std::string instance_name; + bool array; InterfaceBlock(); @@ -212,10 +237,11 @@ struct FunctionDeclaration: Node std::string return_type; std::string name; std::vector > parameters; - bool definition; + FunctionDeclaration *definition; Block body; FunctionDeclaration(); + FunctionDeclaration(const FunctionDeclaration &); virtual FunctionDeclaration *clone() const { return new FunctionDeclaration(*this); } virtual void visit(NodeVisitor &); @@ -223,7 +249,7 @@ struct FunctionDeclaration: Node struct Conditional: Node { - Expression *condition; + NodePtr condition; Block body; Block else_body; @@ -269,8 +295,10 @@ 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(Import &) { } virtual void visit(Layout &) { } virtual void visit(StructDeclaration &) { } virtual void visit(VariableDeclaration &) { } @@ -312,11 +340,11 @@ enum StageType struct Stage { StageType type; - bool present; Stage *previous; ProgramSyntax::Block content; std::map in_variables; std::map out_variables; + Version required_version; Stage(StageType); }; @@ -324,9 +352,7 @@ struct Stage struct Module { Stage shared; - Stage vertex_stage; - Stage geometry_stage; - Stage fragment_stage; + std::list stages; Module(); };