patterns: Added function while loops

This commit is contained in:
WerWolv
2021-06-21 00:21:38 +02:00
parent c9fae32ddf
commit fde5b39495
4 changed files with 66 additions and 6 deletions

View File

@@ -480,10 +480,14 @@ namespace hex::lang {
class ASTNodeWhileStatement : public ASTNode {
public:
explicit ASTNodeWhileStatement(ASTNode *condition) : ASTNode(), m_condition(condition) { }
explicit ASTNodeWhileStatement(ASTNode *condition, std::vector<ASTNode*> body)
: ASTNode(), m_condition(condition), m_body(std::move(body)) { }
~ASTNodeWhileStatement() override {
delete this->m_condition;
for (auto &statement : this->m_body)
delete statement;
}
ASTNodeWhileStatement(const ASTNodeWhileStatement &other) : ASTNode(other) {
@@ -498,8 +502,13 @@ namespace hex::lang {
return this->m_condition;
}
[[nodiscard]] const std::vector<ASTNode*>& getBody() {
return this->m_body;
}
private:
ASTNode *m_condition;
std::vector<ASTNode*> m_body;
};
class ASTNodeFunctionCall : public ASTNode {