Move Diagnostics to separate namespace
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Porygon::Binder {
|
||||
auto key = assignment.GetKey();
|
||||
return new BoundAssignmentStatement(key, boundExpression);
|
||||
} else {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Porygon::Binder {
|
||||
auto boundIndexType = indexable->GetType();
|
||||
if (boundIndexType->GetClass() != TypeClass::Error &&
|
||||
boundIndexType->operator!=(valueExpression->GetType().get())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::InvalidTableValueType,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidTableValueType,
|
||||
statement->GetStartPosition(), statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace Porygon::Binder {
|
||||
auto var = parameters->at(i);
|
||||
auto parsedType = ParseTypeIdentifier(var->GetType());
|
||||
if (parsedType == nullptr) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::InvalidTypeName, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidTypeName, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace Porygon::Binder {
|
||||
|
||||
auto assignment = this->_scope->AssignVariable(identifier.GetHash(), type);
|
||||
if (assignment.GetResult() != VariableAssignmentResult::Ok) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantAssignVariable, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -173,7 +173,7 @@ namespace Porygon::Binder {
|
||||
currentReturnType = this->_currentFunction->GetReturnType();
|
||||
}
|
||||
if (expression == nullptr && currentReturnType != nullptr) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::InvalidReturnType, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidReturnType, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace Porygon::Binder {
|
||||
return new BoundReturnStatement(boundExpression);
|
||||
}
|
||||
if (currentReturnType.get()->operator!=(expresionType.get())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::InvalidReturnType, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidReturnType, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace Porygon::Binder {
|
||||
auto conditionalStatement = (ParsedConditionalStatement *) statement;
|
||||
auto boundCondition = this->BindExpression(conditionalStatement->GetCondition());
|
||||
if (boundCondition->GetType()->GetClass() != TypeClass::Bool) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::ConditionNotABool, statement->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::ConditionNotABool, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
@@ -256,7 +256,7 @@ namespace Porygon::Binder {
|
||||
auto key = expression->GetValue();
|
||||
auto scope = this->_scope->Exists(key.GetHash());
|
||||
if (scope == -1) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::VariableNotFound, expression->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::VariableNotFound, expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
@@ -400,7 +400,7 @@ namespace Porygon::Binder {
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
break;
|
||||
}
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::NoBinaryOperationFound, expression->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::NoBinaryOperationFound, expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
@@ -435,7 +435,7 @@ namespace Porygon::Binder {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::NoUnaryOperationFound, expression->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::NoUnaryOperationFound, expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Porygon::Binder {
|
||||
auto functionExpression = BindExpression(expression->GetFunction());
|
||||
auto type = functionExpression->GetType();
|
||||
if (type->GetClass() != TypeClass::Function) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::ExpressionIsNotAFunction,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::ExpressionIsNotAFunction,
|
||||
expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
@@ -454,7 +454,7 @@ namespace Porygon::Binder {
|
||||
auto parameterTypes = functionType->GetParameterTypes();
|
||||
auto givenParameters = expression->GetParameters();
|
||||
if (parameterTypes.size() != givenParameters->size()) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::ParameterCountMismatch,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::ParameterCountMismatch,
|
||||
expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
@@ -464,7 +464,7 @@ namespace Porygon::Binder {
|
||||
auto parameter = givenParameters->at(i);
|
||||
auto boundParameter = this->BindExpression(parameter);
|
||||
if (boundParameter->GetType().get()->operator!=(parameterTypes.at(i).get())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::ParameterTypeMismatch,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::ParameterTypeMismatch,
|
||||
parameter->GetStartPosition(),
|
||||
parameter->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
@@ -482,7 +482,7 @@ namespace Porygon::Binder {
|
||||
|
||||
auto indexerType = indexer->GetType();
|
||||
if (!indexerType->CanBeIndexedWith(index->GetType().get())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::CantIndex, index->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, index->GetStartPosition(),
|
||||
index->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
@@ -491,14 +491,14 @@ namespace Porygon::Binder {
|
||||
auto field = dynamic_pointer_cast<UserData::UserDataScriptType>(indexerType)->GetField(stringKey->GetHashValue());
|
||||
if (!setter) {
|
||||
if (!field->HasGetter()) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::UserDataFieldNoGetter,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UserDataFieldNoGetter,
|
||||
index->GetStartPosition(),
|
||||
index->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
} else {
|
||||
if (!field->HasSetter()) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::UserDataFieldNoSetter,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UserDataFieldNoSetter,
|
||||
index->GetStartPosition(),
|
||||
index->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
@@ -516,7 +516,7 @@ namespace Porygon::Binder {
|
||||
const auto &identifier = expression->GetIndex();
|
||||
const auto &indexerType = indexer->GetType();
|
||||
if (!indexerType->CanBeIndexedWithIdentifier(identifier.GetHash())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::CantIndex, expression->GetStartPosition(),
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::CantIndex, expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
@@ -524,14 +524,14 @@ namespace Porygon::Binder {
|
||||
auto field = dynamic_pointer_cast<UserData::UserDataScriptType>(indexerType)->GetField(identifier.GetHash());
|
||||
if (!setter) {
|
||||
if (!field->HasGetter()) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::UserDataFieldNoGetter,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UserDataFieldNoGetter,
|
||||
expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
} else {
|
||||
if (!field->HasSetter()) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::UserDataFieldNoSetter,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UserDataFieldNoSetter,
|
||||
expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
@@ -555,7 +555,7 @@ namespace Porygon::Binder {
|
||||
for (int i = 1; i < expressions->size(); i++) {
|
||||
boundExpressions[i] = this->BindExpression(expressions->at(i));
|
||||
if (boundExpressions[i]->GetType().get()->operator!=(valueType.get())) {
|
||||
this->_scriptData->Diagnostics->LogError(DiagnosticCode::InvalidTableValueType,
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidTableValueType,
|
||||
boundExpressions[i]->GetStartPosition(),
|
||||
boundExpressions[i]->GetLength());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user