Added namespaces to most classes, general cleanup
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -2,34 +2,37 @@
|
||||
#include "EvaluationScope.hpp"
|
||||
#include <memory>
|
||||
|
||||
EvaluationScope::EvaluationScope(unordered_map<uint32_t, shared_ptr<EvalValue>> *scriptVariables, int localVariableCount) {
|
||||
_scriptScope = scriptVariables;
|
||||
_localScope = unordered_map<uint64_t, shared_ptr<EvalValue>>(localVariableCount);
|
||||
}
|
||||
namespace Porygon::Evaluation {
|
||||
EvaluationScope::EvaluationScope(unordered_map<uint32_t, shared_ptr<EvalValue>> *scriptVariables,
|
||||
int localVariableCount) {
|
||||
_scriptScope = scriptVariables;
|
||||
_localScope = unordered_map<uint64_t, shared_ptr<EvalValue>>(localVariableCount);
|
||||
}
|
||||
|
||||
void EvaluationScope::CreateVariable(const BoundVariableKey* key, const shared_ptr<EvalValue> &value) {
|
||||
if (key->GetScopeId() == 0){
|
||||
_scriptScope -> at(key->GetIdentifier()) = value;
|
||||
} else{
|
||||
auto insert = _localScope.insert({key->GetHash(), value});
|
||||
if (!insert.second){
|
||||
void EvaluationScope::CreateVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value) {
|
||||
if (key->GetScopeId() == 0) {
|
||||
_scriptScope->at(key->GetIdentifier()) = value;
|
||||
} else {
|
||||
auto insert = _localScope.insert({key->GetHash(), value});
|
||||
if (!insert.second) {
|
||||
_localScope[key->GetHash()] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EvaluationScope::SetVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value) {
|
||||
if (key->GetScopeId() == 0) {
|
||||
_scriptScope->at(key->GetIdentifier()) = value;
|
||||
} else {
|
||||
_localScope[key->GetHash()] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EvaluationScope::SetVariable(const BoundVariableKey* key, const shared_ptr<EvalValue> &value) {
|
||||
if (key->GetScopeId() == 0){
|
||||
_scriptScope -> at(key->GetIdentifier()) = value;
|
||||
} else{
|
||||
_localScope[key->GetHash()] = value;
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> EvaluationScope::GetVariable(const BoundVariableKey* key) {
|
||||
if (key->GetScopeId() == 0){
|
||||
return _scriptScope -> at(key->GetIdentifier());
|
||||
} else{
|
||||
return _localScope[key->GetHash()];
|
||||
shared_ptr<EvalValue> EvaluationScope::GetVariable(const BoundVariableKey *key) {
|
||||
if (key->GetScopeId() == 0) {
|
||||
return _scriptScope->at(key->GetIdentifier());
|
||||
} else {
|
||||
return _localScope[key->GetHash()];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,24 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "../EvalValues/EvalValue.hpp"
|
||||
using namespace Porygon::Binder;
|
||||
|
||||
class EvaluationScope {
|
||||
unordered_map<uint32_t, shared_ptr<EvalValue>>* _scriptScope;
|
||||
unordered_map<uint64_t, shared_ptr<EvalValue>> _localScope;
|
||||
public:
|
||||
explicit EvaluationScope(unordered_map<uint32_t, shared_ptr<EvalValue>>* scriptVariables, int deepestScope);
|
||||
~EvaluationScope() = default;
|
||||
namespace Porygon::Evaluation {
|
||||
class EvaluationScope {
|
||||
unordered_map<uint32_t, shared_ptr<EvalValue>> *_scriptScope;
|
||||
unordered_map<uint64_t, shared_ptr<EvalValue>> _localScope;
|
||||
public:
|
||||
explicit EvaluationScope(unordered_map<uint32_t, shared_ptr<EvalValue>> *scriptVariables, int deepestScope);
|
||||
|
||||
void CreateVariable(const BoundVariableKey* key, const shared_ptr<EvalValue>& value);
|
||||
void SetVariable(const BoundVariableKey* key, const shared_ptr<EvalValue>& value);
|
||||
shared_ptr<EvalValue> GetVariable(const BoundVariableKey* key);
|
||||
};
|
||||
~EvaluationScope() = default;
|
||||
|
||||
void CreateVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value);
|
||||
|
||||
void SetVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value);
|
||||
|
||||
shared_ptr<EvalValue> GetVariable(const BoundVariableKey *key);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //PORYGONLANG_EVALUATIONSCOPE_HPP
|
||||
|
||||
Reference in New Issue
Block a user