Implements assignment binding

This commit is contained in:
2019-05-28 17:49:03 +02:00
parent dbd7dfdd73
commit 5d1c3ac9ba
20 changed files with 443 additions and 152 deletions

View File

@@ -1,14 +1,13 @@
#include <utility>
#include <unordered_map>
#include "Script.hpp"
#include "Parser/Lexer.hpp"
#include "Parser/Parser.hpp"
#include "Binder/Binder.hpp"
Script Script::Create(string script) {
auto s = Script();
s.Parse(std::move(script));
Script* Script::Create(string script) {
auto s = new Script();
s -> Parse(std::move(script));
return s;
}
@@ -40,7 +39,14 @@ void Script::Parse(string script) {
}
lexResult.clear();
if (!Diagnostics->HasErrors()){
this->BoundScript = Binder::Bind(this, parseResult);
unordered_map<int, BoundVariable*> scriptScope;
auto bindScope = new BoundScope(&scriptScope);
this->BoundScript = Binder::Bind(this, parseResult, bindScope);
for (const auto& v : scriptScope){
this->_scopeVariables.insert({v.first, nullptr});
delete v.second;
}
scriptScope.clear();
}
delete parseResult;
}