Properly clear up memory of parsed results
This commit is contained in:
@@ -23,12 +23,13 @@ class ParsedExpression {
|
||||
unsigned int _position;
|
||||
unsigned int _length;
|
||||
public:
|
||||
virtual ParsedExpressionKind GetKind() = 0;
|
||||
|
||||
ParsedExpression(unsigned int position, unsigned int length){
|
||||
_position = position;
|
||||
_length = length;
|
||||
}
|
||||
virtual ~ParsedExpression() = default;
|
||||
|
||||
virtual ParsedExpressionKind GetKind() = 0;
|
||||
|
||||
unsigned int GetStartPosition(){
|
||||
return _position;
|
||||
@@ -100,6 +101,10 @@ public:
|
||||
class ParenthesizedExpression : public ParsedExpression{
|
||||
ParsedExpression* _expression;
|
||||
public:
|
||||
~ParenthesizedExpression() override {
|
||||
delete _expression;
|
||||
}
|
||||
|
||||
ParsedExpressionKind GetKind() final{
|
||||
return ParsedExpressionKind::Parenthesized;
|
||||
}
|
||||
@@ -118,6 +123,10 @@ class UnaryExpression : public ParsedExpression{
|
||||
UnaryOperatorKind _kind;
|
||||
ParsedExpression* _operand;
|
||||
public:
|
||||
~UnaryExpression() override {
|
||||
delete _operand;
|
||||
}
|
||||
|
||||
ParsedExpressionKind GetKind() final{
|
||||
return ParsedExpressionKind::Unary;
|
||||
}
|
||||
@@ -142,6 +151,11 @@ class BinaryExpression : public ParsedExpression{
|
||||
ParsedExpression* _left;
|
||||
ParsedExpression* _right;
|
||||
public:
|
||||
~BinaryExpression() override {
|
||||
delete _left;
|
||||
delete _right;
|
||||
}
|
||||
|
||||
ParsedExpressionKind GetKind() final{
|
||||
return ParsedExpressionKind::Binary;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user