Done TODOs for TypedWhile

This commit is contained in:
ahmad 2024-05-10 08:31:23 +02:00
parent 9b12c843bc
commit e9e4f8ccd3
2 changed files with 3 additions and 1 deletions

View File

@ -69,7 +69,7 @@ public class TypedBlock implements TypedNode {
}
if (stmt instanceof While whileStmt) {
TypedWhile typedWhile = new TypedWhile(localVar, clas, whileStmt);
//TODO: check the type
typedWhile.typeCheck(localVar, clas);
stmts.add(typedWhile);
continue;
}

View File

@ -13,6 +13,7 @@ import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression;
public class TypedWhile implements TypedStatement {
private TypedExpression cond;
private TypedBlock typedBlock;
private Type type;
public TypedWhile(Map<String, Type> localVar, TypedClass clas, While unTypedWhile) {
convertToTypedWhile(localVar, clas, unTypedWhile);
@ -28,6 +29,7 @@ public class TypedWhile implements TypedStatement {
throw new RuntimeException("While condition must be a boolean");
}
typedBlock.typeCheck(localVar, clas);
this.type = Type.VOID;
return Type.BOOL;
}