mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-26 19:08:03 +00:00
throw exception when exception map is not empty
This commit is contained in:
parent
a259aa3a51
commit
af757561bb
@ -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,21 +80,22 @@ 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()){
|
||||
if (TypedProgram.EXCEPTIONS.isEmpty()) {
|
||||
for (TypedClass c : typedAST.getTypedClasses()) {
|
||||
byteCode.add(generateByteCodeArrayFromTypedAst(c));
|
||||
}
|
||||
return byteCode;
|
||||
}else{
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateByteCodeFilesFromFiles(List<String> sourcePaths) {
|
||||
List<byte[]> bytes = generateByteCodeArrayFromFiles(sourcePaths);
|
||||
if(bytes.isEmpty()){
|
||||
if (bytes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < bytes.size(); i++) {
|
||||
@ -118,8 +119,8 @@ public class Compiler {
|
||||
|
||||
if (cmd.hasOption("debug")) {
|
||||
Logger rootLog = Logger.getLogger("");
|
||||
rootLog.setLevel( Level.FINEST );
|
||||
rootLog.getHandlers()[0].setLevel( Level.FINEST );
|
||||
rootLog.setLevel(Level.FINEST);
|
||||
rootLog.getHandlers()[0].setLevel(Level.FINEST);
|
||||
Formatter logFormatter = new LogFormatter();
|
||||
for (Handler handler : rootLog.getHandlers()) {
|
||||
handler.setFormatter(logFormatter);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user