32 lines
896 B
C++
32 lines
896 B
C++
|
|
#ifndef PORYGONLANG_EVALUATIONSCOPE_HPP
|
|
#define PORYGONLANG_EVALUATIONSCOPE_HPP
|
|
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include "../EvalValues/EvalValue.hpp"
|
|
|
|
class EvaluationScope {
|
|
unordered_map<int, shared_ptr<EvalValue>>* _scriptScope;
|
|
vector<unordered_map<int, shared_ptr<EvalValue>>> _localScope;
|
|
int _currentScope;
|
|
public:
|
|
explicit EvaluationScope(unordered_map<int, 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();
|
|
shared_ptr<EvalValue> GetVariable(int scope, int id);
|
|
|
|
void JumpToScope(int index);
|
|
|
|
int GetCurrentScope(){
|
|
return _currentScope;
|
|
}
|
|
};
|
|
|
|
|
|
#endif //PORYGONLANG_EVALUATIONSCOPE_HPP
|