Initial work on iterators, rework of variable handling by including actual string
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-06-23 15:58:14 +02:00
parent 1a84661c79
commit 76b8ba3ebc
25 changed files with 185 additions and 78 deletions

View File

@@ -25,7 +25,8 @@ Porygon::Script *Porygon::Script::Create(const string &script) {
Porygon::Script::Script(const u16string& s) {
Diagnostics = new Diagnostics::DiagnosticsHolder(s);
_boundScript = nullptr;
_scriptVariables = new unordered_map<uint32_t, shared_ptr<EvalValue>>(0);
_scriptVariables = new map<Utilities::HashedString, shared_ptr<EvalValue>>();
_evaluator = new Evaluator(this -> _scriptVariables);
this -> Parse(s);
@@ -53,7 +54,7 @@ void Porygon::Script::Parse(const u16string& script) {
}
lexResult.clear();
if (!Diagnostics->HasErrors()){
unordered_map<uint32_t, BoundVariable*> scriptScope;
map<Utilities::HashedString, BoundVariable*> scriptScope;
auto bindScope = new BoundScope(&scriptScope);
this->_boundScript = Binder::Binder::Bind(this, parseResult, bindScope);
for (const auto& v : scriptScope){
@@ -66,11 +67,11 @@ void Porygon::Script::Parse(const u16string& script) {
}
EvalValue *Porygon::Script::GetVariable(const u16string &key) {
return _scriptVariables -> at(HashedString(key).GetHash()).get();
return _scriptVariables -> at(HashedString(key)).get();
}
bool Porygon::Script::HasVariable(const u16string &key) {
auto f = _scriptVariables->find(HashedString(key).GetHash());
auto f = _scriptVariables->find(HashedString(key));
return f != _scriptVariables->end();
}
@@ -79,7 +80,7 @@ EvalValue *Porygon::Script::GetLastValue() {
}
bool Porygon::Script::HasFunction(const u16string &key) {
auto f = _scriptVariables->find(HashedString(key).GetHash());
auto f = _scriptVariables->find(HashedString(key));
return f != _scriptVariables->end() && f.operator->()->second->GetTypeClass() == TypeClass ::Function;
}