68 lines
1.5 KiB
C++
68 lines
1.5 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;
|
|
}
|
|
};
|
|
|
|
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;
|
|
}
|
|
};
|
|
|
|
#endif //PORYGONLANG_BOUNDSTATEMENT_HPP
|