Files
PorygonLang/src/Binder/BoundVariables/BoundScope.hpp
Deukhoofd fde102d954
Some checks failed
continuous-integration/drone/push Build is failing
Added namespaces to most classes, general cleanup
2019-06-17 18:35:12 +02:00

51 lines
1.2 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;
namespace Porygon::Binder {
class BoundScope {
unordered_map<uint32_t, BoundVariable *> *_tableScope;
vector<unordered_map<uint32_t, BoundVariable *> *> _localScope;
int _currentScope;
int _lastCreatedScope;
public:
explicit BoundScope(unordered_map<uint32_t, BoundVariable *> *tableScope);
~BoundScope();
void GoInnerScope();
void GoOuterScope();
int Exists(int key);
BoundVariable *GetVariable(uint32_t scope, uint32_t identifier);
VariableAssignment CreateExplicitLocal(uint32_t identifier, std::shared_ptr<ScriptType> type);
VariableAssignment AssignVariable(uint32_t identifier, const std::shared_ptr<ScriptType> &type);
size_t GetLocalVariableCount() {
return _localScope.size();
}
int GetCurrentScope() {
return _currentScope;
}
};
}
#endif //PORYGONLANG_BOUNDSCOPE_HPP