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

@@ -72,8 +72,8 @@ namespace Porygon::Binder {
auto boundExpression = this->BindExpression(s->GetExpression());
VariableAssignment assignment =
s->IsLocal() ?
this->_scope->CreateExplicitLocal(s->GetIdentifier().GetHash(), boundExpression->GetType())
: this->_scope->AssignVariable(s->GetIdentifier().GetHash(), boundExpression->GetType());
this->_scope->CreateExplicitLocal(s->GetIdentifier(), boundExpression->GetType())
: this->_scope->AssignVariable(s->GetIdentifier(), boundExpression->GetType());
if (assignment.GetResult() == VariableAssignmentResult::Ok) {
auto key = assignment.GetKey();
return new BoundAssignmentStatement(key, boundExpression);
@@ -139,7 +139,7 @@ namespace Porygon::Binder {
return new BoundBadStatement();
}
parameterTypes.at(i) = parsedType;
auto parameterAssignment = this->_scope->CreateExplicitLocal(var->GetIdentifier().GetHash(), parsedType);
auto parameterAssignment = this->_scope->CreateExplicitLocal(var->GetIdentifier(), parsedType);
if (parameterAssignment.GetResult() == VariableAssignmentResult::Ok) {
parameterKeys.at(i) = std::shared_ptr<BoundVariableKey>(parameterAssignment.GetKey());
} else {
@@ -153,7 +153,7 @@ namespace Porygon::Binder {
auto type = make_shared<FunctionScriptType>(returnType, parameterTypes, parameterKeys, scopeIndex);
this->_currentFunction = type;
auto assignment = this->_scope->AssignVariable(identifier.GetHash(), type);
auto assignment = this->_scope->AssignVariable(identifier, type);
if (assignment.GetResult() != VariableAssignmentResult::Ok) {
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
statement->GetLength());
@@ -242,7 +242,7 @@ namespace Porygon::Binder {
}
this -> _scope ->GoInnerScope();
auto variableKey = this -> _scope ->CreateExplicitLocal(identifier.GetHash(), make_shared<NumericScriptType>(true, false));
auto variableKey = this -> _scope ->CreateExplicitLocal(identifier, make_shared<NumericScriptType>(true, false));
if (variableKey.GetResult() != VariableAssignmentResult::Ok){
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
statement->GetLength());
@@ -300,15 +300,15 @@ namespace Porygon::Binder {
BoundExpression *Binder::BindVariableExpression(const VariableExpression *expression) {
auto key = expression->GetValue();
auto scope = this->_scope->Exists(key.GetHash());
auto scope = this->_scope->Exists(key);
if (scope == -1) {
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::VariableNotFound, expression->GetStartPosition(),
expression->GetLength());
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
}
auto var = this->_scope->GetVariable(scope, key.GetHash());
auto var = this->_scope->GetVariable(scope, key);
auto type = var->GetType();
return new BoundVariableExpression(new BoundVariableKey(key.GetHash(), scope, false), type,
return new BoundVariableExpression(new BoundVariableKey(key, scope, false), type,
expression->GetStartPosition(), expression->GetLength());
}
@@ -616,7 +616,7 @@ namespace Porygon::Binder {
}
BoundExpression *Binder::BindTableExpression(const ParsedTableExpression *expression) {
auto tableScope = new unordered_map<uint32_t, BoundVariable *>();
auto tableScope = new map<Utilities::HashedString, BoundVariable *>();
auto innerScope = new BoundScope(tableScope);
auto currentScope = this->_scope;
this->_scope = innerScope;