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:
struct StructDeclaration;
struct VariableDeclaration;
+struct FunctionDeclaration;
struct Block: Node
{
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;
+ FunctionDeclaration *declaration;
bool constructor;
std::vector<NodePtr<Expression> > arguments;
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
std::string interface;
std::string name;
Block members;
+ std::string instance_name;
+ bool array;
InterfaceBlock();
std::string return_type;
std::string name;
std::vector<NodePtr<VariableDeclaration> > parameters;
- bool definition;
+ FunctionDeclaration *definition;
Block body;
FunctionDeclaration();
+ FunctionDeclaration(const FunctionDeclaration &);
virtual FunctionDeclaration *clone() const { return new FunctionDeclaration(*this); }
virtual void visit(NodeVisitor &);
struct Conditional: Node
{
- Expression *condition;
+ NodePtr<Expression> condition;
Block body;
Block else_body;
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 &) { }