Support for loading variables from module with require
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-08-11 12:32:18 +02:00
parent c39f3a0884
commit 641b6784c7
8 changed files with 89 additions and 28 deletions

View File

@@ -630,12 +630,12 @@ namespace Porygon::Binder {
exp->GetLength());
return new BoundBadExpression(exp->GetStartPosition(), exp ->GetLength());
}
auto module = opt->ResolveModule(transformedKey);
auto module = Script::Clone(opt->ResolveModule(transformedKey));
if (module -> GetReturnType() == nullptr){
for (const auto& v: *module->GetScriptVariables()){
//TODO: Currently a hack, will always make all variables nil
auto type = make_shared<const ScriptType>(TypeClass::Nil);
this -> _scope -> AssignVariable(v.first, type);
auto type = module->GetVariableType(v.first);
auto result = this -> _scope -> AssignVariable(v.first, type);
delete result.GetKey();
}
}
@@ -737,7 +737,7 @@ namespace Porygon::Binder {
BoundExpression *Binder::BindTableExpression(const ParsedTableExpression *expression) {
auto tableScope = new map<Utilities::HashedString, BoundVariable *>();
auto innerScope = new BoundScope(tableScope);
auto innerScope = new BoundScope(tableScope, nullptr);
auto currentScope = this->_scope;
this->_scope = innerScope;
auto block = dynamic_cast<BoundBlockStatement*>(this->BindBlockStatement(expression->GetBlock()));