Implements variable usage, tweaks and fixes for variable assignment

This commit is contained in:
2019-05-30 15:23:48 +02:00
parent 257eb942c7
commit 6fad5a0a7d
17 changed files with 145 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
#include <string>
#include "../../ScriptType.hpp"
#include "../BoundOperators.hpp"
#include "../BoundVariables/BoundVariableKey.hpp"
using namespace std;
@@ -17,6 +18,7 @@ enum class BoundExpressionKind{
LiteralFloat,
LiteralString,
LiteralBool,
Variable,
Unary,
Binary,
@@ -129,6 +131,36 @@ public:
}
};
class BoundVariableExpression : public BoundExpression{
int _scope;
int _id;
ScriptType _type;
public:
BoundVariableExpression(int scope, int id, const ScriptType& type, unsigned int start, unsigned int length)
: BoundExpression(start, length, nullptr), _type(type){
_scope = scope;
_id = id;
}
~BoundVariableExpression() override = default;
ScriptType* GetType() final{
return &_type;
};
BoundExpressionKind GetKind() final{
return BoundExpressionKind ::Variable;
}
int GetScope(){
return _scope;
}
int GetId(){
return _id;
}
};
class BoundBinaryExpression : public BoundExpression {
BoundExpression* _left;
BoundExpression* _right;