throw exception when exception map is not empty

This commit is contained in:
simon 2024-07-04 18:13:28 +02:00
parent a259aa3a51
commit af757561bb
2 changed files with 11 additions and 10 deletions

View File

@ -70,7 +70,7 @@ public class Compiler {
return generateAST(sources);
}
public static TypedProgram generateTypedASTFromAst(Program ast) {
public static TypedProgram generateTypedASTFromAst(Program ast) throws IllegalArgumentException {
return new TypedProgram(ast);
}
@ -80,7 +80,8 @@ public class Compiler {
public static List<byte[]> generateByteCodeArrayFromFiles(List<String> sourcePaths) {
Program program = generateASTFromFiles(sourcePaths);
TypedProgram typedAST = generateTypedASTFromAst(program);
TypedProgram typedAST;
typedAST = generateTypedASTFromAst(program);
List<byte[]> byteCode = new ArrayList<>();
if (TypedProgram.EXCEPTIONS.isEmpty()) {
for (TypedClass c : typedAST.getTypedClasses()) {

View File

@ -17,11 +17,11 @@ public class TypedProgram {
public static Map<String, Exception> EXCEPTIONS = new HashMap<>();
private TypedClass currentClass;
public TypedProgram(Program program) {
public TypedProgram(Program program) throws IllegalArgumentException {
startConversion(program);
}
public void startConversion(Program program) {
public void startConversion(Program program) throws IllegalArgumentException {
// Initialisiere die Klassen nur mit den Klassennamen und deren Typ
for (var clas : program.classes()) {
@ -61,7 +61,7 @@ public class TypedProgram {
);
counter++;
}
throw new RuntimeException(stringBuilder.toString());
throw new IllegalArgumentException(stringBuilder.toString());
}
}