Compare commits
3 Commits
johns-bran
...
b7863d0684
Author | SHA1 | Date | |
---|---|---|---|
|
b7863d0684 | ||
|
7ccff3208c | ||
|
3e0e6f8327 |
@@ -5,7 +5,6 @@ import bytecode.visitor.MethodVisitor;
|
||||
import visitor.Visitable;
|
||||
|
||||
public class MainMethodNode extends MethodNode implements Visitable {
|
||||
public BlockNode block;
|
||||
|
||||
public MainMethodNode(BlockNode block) {
|
||||
this.block = block;
|
||||
|
@@ -96,16 +96,24 @@ public class Main {
|
||||
// Log the typed AST
|
||||
RaupenLogger.logSemanticAnalyzer(typedAst);
|
||||
|
||||
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
||||
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
||||
if(SemanticAnalyzer.errors.isEmpty()){
|
||||
/*------------------------- 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();
|
||||
}
|
||||
}
|
@@ -344,11 +344,13 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
}
|
||||
} else {
|
||||
if (toCheck.target.thisTar != null) {
|
||||
if (toCheck.target.thisTar) {
|
||||
var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier));
|
||||
if (type != null) {
|
||||
return new TypeCheckResult(true, type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var result = toCheck.target.accept(this);
|
||||
if (result.getType() instanceof ReferenceType reference) {
|
||||
@@ -394,9 +396,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
if (context.containsClass(toCheck.identifier)) {
|
||||
return new TypeCheckResult(true, new ReferenceType(toCheck.identifier));
|
||||
} else {
|
||||
throw new RuntimeException("Cannot find class " + toCheck.identifier);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
3
src/main/resources/META-INF/MANIFEST.MF
Normal 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.
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/combinedFeatureTests/LoopExamples.class
Normal file
BIN
src/test/resources/input/combinedFeatureTests/LoopExamples.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Char.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Char.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Comments.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Comments.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/DoWhile.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/DoWhile.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/EmptyClass.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/EmptyClass.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Field.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Field.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/For.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/For.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Increment.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Increment.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/MainMethod.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/MainMethod.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/Null.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/Null.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/SelfReference.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/SelfReference.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/TestClass2.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/TestClass2.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/ThisDot.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/ThisDot.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/VoidMethod.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/VoidMethod.class
Normal file
Binary file not shown.
BIN
src/test/resources/input/singleFeatureTests/While.class
Normal file
BIN
src/test/resources/input/singleFeatureTests/While.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,21 +1,7 @@
|
||||
public class CorrectTest {
|
||||
int a;
|
||||
boolean b;
|
||||
char c;
|
||||
|
||||
public void controlStructures(int adf, boolean bool) {
|
||||
if (a > (10 + 8)) {
|
||||
} else {
|
||||
public class Run {
|
||||
public static void main(String[] args) {
|
||||
// Test t = new Test();
|
||||
// System.out.println(t.test());
|
||||
}
|
||||
|
||||
|
||||
while (a > adf) {
|
||||
a--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user