Implements indexing, currently can only be used with strings
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_BOUNDEXPRESSION_HPP
|
||||
#define PORYGONLANG_BOUNDEXPRESSION_HPP
|
||||
@@ -26,6 +28,7 @@ enum class BoundExpressionKind{
|
||||
Unary,
|
||||
Binary,
|
||||
FunctionCall,
|
||||
Index,
|
||||
};
|
||||
|
||||
class BoundExpression{
|
||||
@@ -36,7 +39,7 @@ public:
|
||||
BoundExpression(unsigned int start, unsigned int length, std::shared_ptr<ScriptType> type){
|
||||
_start = start;
|
||||
_length = length;
|
||||
_type = type;
|
||||
_type = std::move(type);
|
||||
}
|
||||
virtual ~BoundExpression() = default;
|
||||
|
||||
@@ -247,5 +250,31 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class BoundIndexExpression : public BoundExpression {
|
||||
BoundExpression* _indexableExpression;
|
||||
BoundExpression* _indexExpression;
|
||||
public:
|
||||
BoundIndexExpression(BoundExpression* indexableExpression, BoundExpression* indexExpression, shared_ptr<ScriptType> result,
|
||||
unsigned int start, unsigned int length)
|
||||
: BoundExpression(start, length, std::move(result)), _indexableExpression(indexableExpression), _indexExpression(indexExpression) {}
|
||||
|
||||
~BoundIndexExpression() final{
|
||||
delete _indexableExpression;
|
||||
delete _indexExpression;
|
||||
}
|
||||
|
||||
BoundExpressionKind GetKind() final{
|
||||
return BoundExpressionKind ::Index;
|
||||
}
|
||||
|
||||
BoundExpression* GetIndexableExpression(){
|
||||
return _indexableExpression;
|
||||
}
|
||||
|
||||
BoundExpression* GetIndexExpression(){
|
||||
return _indexExpression;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif //PORYGONLANG_BOUNDEXPRESSION_HPP
|
||||
|
||||
Reference in New Issue
Block a user