X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramsyntax.h;h=e7b5111ea2bfd5c411c853d99bffb32ff2f74aee;hp=1f26bc568800e1f9374cb0f4b9e20647442d6804;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=7189f63c549e9061789c47726ff8d6d12afca1a0 diff --git a/source/programsyntax.h b/source/programsyntax.h index 1f26bc56..e7b5111e 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -20,6 +20,9 @@ struct NodeVisitor; struct Node { +protected: + Node() { } + Node(const Node &) { } private: Node &operator=(const Node &); public: @@ -36,6 +39,7 @@ public: NodePtr() { } NodePtr(T *p): RefPtr(p) { } NodePtr(const NodePtr &p): RefPtr(p ? p->clone() : 0) { } + NodePtr &operator=(const NodePtr &p) { RefPtr::operator=(p); return *this; } template NodePtr(const RefPtr &p): RefPtr(p) { } @@ -64,9 +68,19 @@ struct StructDeclaration; struct VariableDeclaration; struct FunctionDeclaration; +struct Statement: Node +{ + unsigned source; + unsigned line; + + Statement(); + + virtual Statement *clone() const = 0; +}; + struct Block: Node { - NodeList body; + NodeList body; bool use_braces; std::map types; std::map variables; @@ -166,7 +180,7 @@ struct FunctionCall: Expression virtual void visit(NodeVisitor &); }; -struct ExpressionStatement: Node +struct ExpressionStatement: Statement { NodePtr expression; @@ -174,7 +188,7 @@ struct ExpressionStatement: Node virtual void visit(NodeVisitor &); }; -struct Import: Node +struct Import: Statement { std::string module; @@ -182,7 +196,7 @@ struct Import: Node virtual void visit(NodeVisitor &); }; -struct Precision: Node +struct Precision: Statement { std::string precision; std::string type; @@ -206,7 +220,7 @@ struct Layout: Node virtual void visit(NodeVisitor &); }; -struct InterfaceLayout: Node +struct InterfaceLayout: Statement { std::string interface; Layout layout; @@ -215,7 +229,7 @@ struct InterfaceLayout: Node virtual void visit(NodeVisitor &); }; -struct StructDeclaration: Node +struct StructDeclaration: Statement { std::string name; Block members; @@ -226,7 +240,7 @@ struct StructDeclaration: Node virtual void visit(NodeVisitor &); }; -struct VariableDeclaration: Node +struct VariableDeclaration: Statement { bool constant; std::string sampling; @@ -248,7 +262,7 @@ struct VariableDeclaration: Node virtual void visit(NodeVisitor &); }; -struct InterfaceBlock: Node +struct InterfaceBlock: Statement { std::string interface; std::string name; @@ -262,7 +276,7 @@ struct InterfaceBlock: Node virtual void visit(NodeVisitor &); }; -struct FunctionDeclaration: Node +struct FunctionDeclaration: Statement { std::string return_type; std::string name; @@ -277,7 +291,7 @@ struct FunctionDeclaration: Node virtual void visit(NodeVisitor &); }; -struct Conditional: Node +struct Conditional: Statement { NodePtr condition; Block body; @@ -287,7 +301,7 @@ struct Conditional: Node virtual void visit(NodeVisitor &); }; -struct Iteration: Node +struct Iteration: Statement { NodePtr init_statement; NodePtr condition; @@ -298,7 +312,7 @@ struct Iteration: Node virtual void visit(NodeVisitor &); }; -struct Passthrough: Node +struct Passthrough: Statement { NodePtr subscript; @@ -306,7 +320,7 @@ struct Passthrough: Node virtual void visit(NodeVisitor &); }; -struct Return: Node +struct Return: Statement { NodePtr expression; @@ -314,7 +328,7 @@ struct Return: Node virtual void visit(NodeVisitor &); }; -struct Jump: Node +struct Jump: Statement { std::string keyword;