From 59b5e950f42781c083d14a210845148b01e39eb2 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 20 Oct 2014 12:41:56 +0200 Subject: Expression compiler. --- AST.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'AST.h') diff --git a/AST.h b/AST.h index df146ab1..a55f58c1 100644 --- a/AST.h +++ b/AST.h @@ -61,6 +61,12 @@ public: /// the given description TypeError createTypeError(std::string const& _description); + ///@{ + /// Equality relies on the fact that nodes cannot be copied. + bool operator==(ASTNode const& _other) const { return this == &_other; } + bool operator!=(ASTNode const& _other) const { return !operator==(_other); } + ///@} + private: Location m_location; }; @@ -386,7 +392,9 @@ public: virtual void accept(ASTVisitor& _visitor) override; virtual void checkTypeRequirements() override; + Expression& getLeftHandSide() const { return *m_leftHandSide; } Token::Value getAssignmentOperator() const { return m_assigmentOperator; } + Expression& getRightHandSide() const { return *m_rightHandSide; } private: ASTPointer m_leftHandSide; @@ -422,6 +430,8 @@ public: virtual void accept(ASTVisitor& _visitor) override; virtual void checkTypeRequirements() override; + Expression& getLeftExpression() const { return *m_left; } + Expression& getRightExpression() const { return *m_right; } Token::Value getOperator() const { return m_operator; } private: @@ -441,6 +451,9 @@ public: Expression(_location), m_expression(_expression), m_arguments(_arguments) {} virtual void accept(ASTVisitor& _visitor) override; virtual void checkTypeRequirements() override; + /// Returns true if this is not an actual function call, but an explicit type conversion + /// or constructor call. + bool isTypeConversion() const; private: ASTPointer m_expression; -- cgit