3 Commits

Author SHA1 Message Date
Bruder John
b7863d0684 fixed thistar
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-03 18:33:30 +02:00
Bruder John
7ccff3208c added Semanticcheck to main
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-03 18:24:02 +02:00
Bruder John
3e0e6f8327 Commpiling Compiler in Intelij
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-03 18:22:04 +02:00
37 changed files with 28 additions and 30 deletions

View File

@@ -5,7 +5,6 @@ import bytecode.visitor.MethodVisitor;
import visitor.Visitable; import visitor.Visitable;
public class MainMethodNode extends MethodNode implements Visitable { public class MainMethodNode extends MethodNode implements Visitable {
public BlockNode block;
public MainMethodNode(BlockNode block) { public MainMethodNode(BlockNode block) {
this.block = block; this.block = block;

View File

@@ -96,16 +96,24 @@ public class Main {
// Log the typed AST // Log the typed AST
RaupenLogger.logSemanticAnalyzer(typedAst); RaupenLogger.logSemanticAnalyzer(typedAst);
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/ if(SemanticAnalyzer.errors.isEmpty()){
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory /*------------------------- Bytecode Generator -> Bytecode -------------------------*/
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
final boolean genJar = Optional.ofNullable(System.getProperty("genJar")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
final boolean genClass = Optional.ofNullable(System.getProperty("genClass")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, genJar, genClass);
assert typedAst != null;
byteCodeGenerator.visit((ProgramNode) typedAst);
// Log the bytecode generation
RaupenLogger.logBytecodeGenerator();
} else {
for(Exception exception : SemanticAnalyzer.errors){
exception.printStackTrace();
}
}
final boolean genJar = Optional.ofNullable(System.getProperty("genJar")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
final boolean genClass = Optional.ofNullable(System.getProperty("genClass")).map(String::toLowerCase).map(Boolean::parseBoolean).orElse(true);
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath, genJar, genClass);
assert typedAst != null;
byteCodeGenerator.visit((ProgramNode) typedAst);
// Log the bytecode generation
RaupenLogger.logBytecodeGenerator();
} }
} }

View File

@@ -344,11 +344,13 @@ public class SemanticAnalyzer implements SemanticVisitor {
} }
} else { } else {
if (toCheck.target.thisTar != null) {
if (toCheck.target.thisTar) { if (toCheck.target.thisTar) {
var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier)); var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier));
if (type != null) { if (type != null) {
return new TypeCheckResult(true, type); return new TypeCheckResult(true, type);
} }
}
} else { } else {
var result = toCheck.target.accept(this); var result = toCheck.target.accept(this);
if (result.getType() instanceof ReferenceType reference) { if (result.getType() instanceof ReferenceType reference) {
@@ -394,9 +396,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (context.containsClass(toCheck.identifier)) { if (context.containsClass(toCheck.identifier)) {
return new TypeCheckResult(true, new ReferenceType(toCheck.identifier)); return new TypeCheckResult(true, new ReferenceType(toCheck.identifier));
} else {
throw new RuntimeException("Cannot find class " + toCheck.identifier);
} }
return null;
} }
@Override @Override

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: main.Main

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,21 +1,7 @@
public class CorrectTest {
int a;
boolean b;
char c;
public void controlStructures(int adf, boolean bool) { public class Run {
if (a > (10 + 8)) { public static void main(String[] args) {
} else { // Test t = new Test();
// System.out.println(t.test());
} }
while (a > adf) {
a--;
}
for (int i = 0; i < 5; i++) {
}
} }
}