44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
|
|
#ifndef PORYGONLANG_BOUNDSCOPE_HPP
|
|
#define PORYGONLANG_BOUNDSCOPE_HPP
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "BoundVariable.hpp"
|
|
#include "BoundVariableKey.hpp"
|
|
#include "VariableAssigmentResult.hpp"
|
|
#include "../../Utilities/HashedString.hpp"
|
|
|
|
using namespace std;
|
|
|
|
class BoundScope {
|
|
unordered_map<int, BoundVariable*>* _tableScope;
|
|
vector<unordered_map<int, BoundVariable*>*> _localScope;
|
|
int _currentScope;
|
|
int _deepestScope;
|
|
public:
|
|
explicit BoundScope(unordered_map<int, BoundVariable*> *tableScope);
|
|
~BoundScope();
|
|
|
|
void GoInnerScope();
|
|
void GoOuterScope();
|
|
|
|
int Exists(int key);
|
|
BoundVariable* GetVariable(int scope, int identifier);
|
|
VariableAssignment CreateExplicitLocal(int identifier, std::shared_ptr<ScriptType> type);
|
|
VariableAssignment AssignVariable(int identifier, const std::shared_ptr<ScriptType>& type);
|
|
|
|
int GetDeepestScope(){
|
|
return _deepestScope;
|
|
}
|
|
|
|
int GetCurrentScope(){
|
|
return _currentScope;
|
|
}
|
|
};
|
|
|
|
|
|
#endif //PORYGONLANG_BOUNDSCOPE_HPP
|