Large cleanup
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2019-07-25 17:23:54 +02:00
parent e639a2c170
commit e2a0c35992
58 changed files with 700 additions and 539 deletions

View File

@@ -4,14 +4,14 @@
#include <memory>
namespace Porygon::Evaluation {
EvaluationScope::EvaluationScope(map<Utilities::HashedString, shared_ptr<EvalValue>> *scriptVariables,
int localVariableCount) : _scriptScope(scriptVariables),
_localScope(map<uint64_t, shared_ptr<EvalValue>>()) {
EvaluationScope::EvaluationScope(map<Utilities::HashedString, shared_ptr<const EvalValue>> *scriptVariables)
: _scriptScope(scriptVariables),
_localScope(map<uint64_t, shared_ptr<const EvalValue>>()) {
}
void EvaluationScope::CreateVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value) {
void EvaluationScope::CreateVariable(const BoundVariableKey *key, const shared_ptr<const EvalValue>& value) {
if (key->GetScopeId() == 0) {
_scriptScope->at(key->GetIdentifier()) = value;
_scriptScope->at(*key->GetIdentifier()) = value;
} else {
auto insert = _localScope.insert({key->GetHash(), value});
if (!insert.second) {
@@ -20,20 +20,20 @@ namespace Porygon::Evaluation {
}
}
void EvaluationScope::SetVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value) {
void EvaluationScope::SetVariable(const BoundVariableKey *key, const shared_ptr<const EvalValue> &value) {
if (key->GetScopeId() == 0) {
_scriptScope->at(key->GetIdentifier()) = value;
_scriptScope->at(*key->GetIdentifier()) = value;
} else {
_localScope[key->GetHash()] = value;
}
}
shared_ptr<EvalValue> EvaluationScope::GetVariable(const BoundVariableKey *key) {
shared_ptr<const EvalValue> EvaluationScope::GetVariable(const BoundVariableKey *key) {
auto scopeId = key -> GetScopeId();
if (scopeId== 0) {
return _scriptScope->at(key->GetIdentifier());
return _scriptScope->at(*key->GetIdentifier());
} else if(scopeId == -2){
return StandardLibraries::StaticScope::GetVariable(key->GetIdentifier());
return StandardLibraries::StaticScope::GetVariable(*key->GetIdentifier());
} else {
return _localScope[key->GetHash()];
}

View File

@@ -9,18 +9,18 @@ using namespace Porygon::Binder;
namespace Porygon::Evaluation {
class EvaluationScope {
map<Utilities::HashedString, shared_ptr<EvalValue>> *_scriptScope;
map<uint64_t, shared_ptr<EvalValue>> _localScope;
map<Utilities::HashedString, shared_ptr<const EvalValue>> *_scriptScope;
map<uint64_t, shared_ptr<const EvalValue>> _localScope;
public:
explicit EvaluationScope(map<Utilities::HashedString, shared_ptr<EvalValue>> *scriptVariables, int deepestScope);
explicit EvaluationScope(map<Utilities::HashedString, shared_ptr<const EvalValue>> *scriptVariables);
~EvaluationScope() = default;
void CreateVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value);
void CreateVariable(const BoundVariableKey *key, const shared_ptr<const EvalValue>&value);
void SetVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value);
void SetVariable(const BoundVariableKey *key, const shared_ptr<const EvalValue> &value);
shared_ptr<EvalValue> GetVariable(const BoundVariableKey *key);
shared_ptr<const EvalValue> GetVariable(const BoundVariableKey *key);
};
}