This commit is contained in:
@@ -48,6 +48,8 @@ namespace Porygon::Binder {
|
||||
return this->BindNumericalForStatement(statement);
|
||||
case ParsedStatementKind::GenericFor:
|
||||
return this -> BindGenericForStatement(statement);
|
||||
case ParsedStatementKind::While:
|
||||
return this -> BindWhileStatement(statement);
|
||||
case ParsedStatementKind::Break:
|
||||
//TODO: Validate we're in a loop
|
||||
return new BoundBreakStatement();
|
||||
@@ -298,6 +300,18 @@ namespace Porygon::Binder {
|
||||
return new BoundGenericForStatement(keyVariable, valueVariable, boundIterator, boundBlock);
|
||||
}
|
||||
|
||||
BoundStatement *Binder::BindWhileStatement(const ParsedStatement *statement) {
|
||||
auto whileStatement = (ParsedWhileStatement*)statement;
|
||||
auto boundCondition = this -> BindExpression(whileStatement->GetCondition());
|
||||
if (boundCondition->GetType()->GetClass() != TypeClass::Bool){
|
||||
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::ConditionNotABool, statement->GetStartPosition(),
|
||||
statement->GetLength());
|
||||
return new BoundBadStatement();
|
||||
}
|
||||
auto boundBlock = this -> BindBlockStatement(whileStatement->GetBlock());
|
||||
return new BoundWhileStatement(boundCondition, boundBlock);
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Expressions //
|
||||
/////////////////
|
||||
@@ -674,4 +688,5 @@ namespace Porygon::Binder {
|
||||
return new BoundTableExpression((BoundBlockStatement *) block, tableType, expression->GetStartPosition(),
|
||||
expression->GetLength());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user