Implements complex tables
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include "EvaluationScope.hpp"
|
||||
#include <memory>
|
||||
|
||||
EvaluationScope::EvaluationScope(unordered_map<int, shared_ptr<EvalValue>> *scriptVariables, int deepestScope) {
|
||||
EvaluationScope::EvaluationScope(unordered_map<size_t, shared_ptr<EvalValue>> *scriptVariables, int deepestScope) {
|
||||
_scriptScope = scriptVariables;
|
||||
_localScope = vector<shared_ptr<unordered_map<int, shared_ptr<EvalValue>>>>(deepestScope);
|
||||
for (int i = 0; i < deepestScope; i++){
|
||||
@@ -42,6 +42,7 @@ EvaluationScope* EvaluationScope::CreateBranchingScope(int index){
|
||||
for (int i = 0; i < index; i++){
|
||||
scope->_localScope[i] = this->_localScope[i];
|
||||
}
|
||||
scope->_currentScope = index;
|
||||
return scope;
|
||||
}
|
||||
|
||||
@@ -49,9 +50,11 @@ void EvaluationScope::OuterScope() {
|
||||
_currentScope++;
|
||||
}
|
||||
|
||||
void EvaluationScope::InnerScope() {
|
||||
auto scope = this->_localScope[_currentScope];
|
||||
scope->clear();
|
||||
void EvaluationScope::InnerScope(bool clearScope) {
|
||||
if (clearScope){
|
||||
auto scope = this->_localScope[_currentScope];
|
||||
scope->clear();
|
||||
}
|
||||
_currentScope--;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
#include "../EvalValues/EvalValue.hpp"
|
||||
|
||||
class EvaluationScope {
|
||||
unordered_map<int, shared_ptr<EvalValue>>* _scriptScope;
|
||||
unordered_map<size_t, shared_ptr<EvalValue>>* _scriptScope;
|
||||
vector<shared_ptr<unordered_map<int, shared_ptr<EvalValue>>>> _localScope;
|
||||
int _currentScope;
|
||||
public:
|
||||
explicit EvaluationScope(unordered_map<int, shared_ptr<EvalValue>>* scriptVariables, int deepestScope);
|
||||
explicit EvaluationScope(unordered_map<size_t, shared_ptr<EvalValue>>* scriptVariables, int deepestScope);
|
||||
~EvaluationScope() = default;
|
||||
|
||||
void CreateVariable(int scope, int id, const shared_ptr<EvalValue>& value);
|
||||
void SetVariable(int scope, int id, const shared_ptr<EvalValue>& value);
|
||||
void OuterScope();
|
||||
void InnerScope();
|
||||
void InnerScope(bool clearScope = true);
|
||||
shared_ptr<EvalValue> GetVariable(int scope, int id);
|
||||
|
||||
EvaluationScope* CreateBranchingScope(int index);
|
||||
|
||||
Reference in New Issue
Block a user