Files
PorygonLang/src/Binder/BoundStatements/BoundStatement.hpp
2019-05-23 18:50:09 +02:00

76 lines
1.7 KiB
C++

#include <utility>
#ifndef PORYGONLANG_BOUNDSTATEMENT_HPP
#define PORYGONLANG_BOUNDSTATEMENT_HPP
#include <vector>
#include "../BoundExpressions/BoundExpression.hpp"
using namespace std;
enum class BoundStatementKind{
Script,
Block,
Expression,
};
class BoundStatement{
public:
virtual BoundStatementKind GetKind() = 0;
virtual ~BoundStatement() = default;
};
class BoundBlockStatement : public BoundStatement{
vector<BoundStatement*> _statements;
public:
explicit BoundBlockStatement(vector<BoundStatement*> statements){
_statements = std::move(statements);
}
~BoundBlockStatement() override {
for (auto s : _statements){
delete s;
}
_statements.clear();
}
BoundStatementKind GetKind() override{
return BoundStatementKind ::Block;
}
vector<BoundStatement*> GetStatements(){
return _statements;
}
};
class BoundScriptStatement : public BoundBlockStatement{
public:
explicit BoundScriptStatement(vector<BoundStatement*> statements) : BoundBlockStatement(std::move(statements)){
}
BoundStatementKind GetKind() final{
return BoundStatementKind ::Script;
}
};
class BoundExpressionStatement : public BoundStatement{
BoundExpression* _expression;
public:
explicit BoundExpressionStatement(BoundExpression* expression){
_expression = expression;
}
~BoundExpressionStatement() final{
delete _expression;
}
BoundStatementKind GetKind() final{
return BoundStatementKind ::Expression;
}
BoundExpression* GetExpression(){
return _expression;
}
};
#endif //PORYGONLANG_BOUNDSTATEMENT_HPP