mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 07:18:03 +00:00
Merge branch 'refs/heads/main' into testsuites
This commit is contained in:
commit
f0ca5324d8
@ -98,7 +98,7 @@ public class Compiler {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
generateByteCodeFileFromFile(List.of("src/main/resources/JavaTestfiles/ClassCanBeBytecoded.java"),
|
||||
generateByteCodeFileFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassCanBeBytecoded.java"),
|
||||
List.of("ClassCanBeBytecoded"));
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public class TypedClass implements TypedNode {
|
||||
private List<TypedDeclaration> typedDeclarations = new ArrayList<>();
|
||||
private List<TypedMethod> typedMethods = new ArrayList<>();
|
||||
private List<TypedConstructor> typedConstructors = new ArrayList<>();
|
||||
private TypedMain typedMain;
|
||||
private TypedMethod currentMethod;
|
||||
private TypedConstructor currentConstructor;
|
||||
private Type type;
|
||||
@ -58,6 +59,12 @@ public class TypedClass implements TypedNode {
|
||||
for (Method method : c.methods()) {
|
||||
typedMethods.add(new TypedMethod(typedProgram, method));
|
||||
}
|
||||
if (c.mainmeth() != null) {
|
||||
typedMain = new TypedMain();
|
||||
typedMethods.add(typedMain.getTypedMethod());
|
||||
} else {
|
||||
typedMain = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void covertBlocksOfConstructorsAndMethods(TypedProgram typedProgram, Class c) {
|
||||
@ -77,6 +84,14 @@ public class TypedClass implements TypedNode {
|
||||
exitCurrentMethod();
|
||||
j++;
|
||||
}
|
||||
|
||||
if (c.mainmeth() != null) {
|
||||
enterCurrentMethod(typedMain.getTypedMethod());
|
||||
typedMain.convertToTypedMethod(typedProgram, c);
|
||||
exitCurrentMethod();
|
||||
} else {
|
||||
typedMain = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
34
src/main/java/de/maishai/typedast/typedclass/TypedMain.java
Normal file
34
src/main/java/de/maishai/typedast/typedclass/TypedMain.java
Normal file
@ -0,0 +1,34 @@
|
||||
package de.maishai.typedast.typedclass;
|
||||
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.typedast.Type;
|
||||
import de.maishai.typedast.TypedNode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class TypedMain implements TypedNode {
|
||||
private Type type = Type.VOID;
|
||||
private TypedMethod typedMethod;
|
||||
|
||||
public TypedMain(){
|
||||
typedMethod = new TypedMethod();
|
||||
typedMethod.setName("main");
|
||||
typedMethod.setReturnType(type);
|
||||
typedMethod.setTypedParameters(List.of(new TypedParameter("args", Type.REFERENCE("String[]"))));
|
||||
}
|
||||
|
||||
public void convertToTypedMethod(TypedProgram typedProgram, Class unTypedClass){
|
||||
typedMethod.setTypedBlock(new TypedBlock(typedProgram, unTypedClass.mainmeth()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type typeCheck(TypedProgram typedProgram) {
|
||||
return type;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user