Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5a66ce97ca
@ -49,6 +49,9 @@ public class MethodDecl implements Node {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Es wird kein Bytecode für Standardkonstruktoren für die Klassen generiert
|
||||||
|
//TODO: Stack computing schlägt fehl --> Reihenfolge aufruf? --> Sobald if-else / if / while drin sind? --> vllt auch schon bei MethodenDecl
|
||||||
//Need to get the returnType of the method if it is an object
|
//Need to get the returnType of the method if it is an object
|
||||||
// methodContext (class, (returnType, (identifier, parameter)))
|
// methodContext (class, (returnType, (identifier, parameter)))
|
||||||
public void codeGen(ClassWriter cw, HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext, HashMap<String, HashMap<String, String>> typeContext) throws Exception {
|
public void codeGen(ClassWriter cw, HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext, HashMap<String, HashMap<String, String>> typeContext) throws Exception {
|
||||||
|
@ -57,6 +57,7 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
|
|||||||
//Generate Bytecode for the receiver
|
//Generate Bytecode for the receiver
|
||||||
if (classThatHasTheMethodIfNotThis != null) {
|
if (classThatHasTheMethodIfNotThis != null) {
|
||||||
//TODO: classThatHasTheMethodIfNotThis must be an object --> instance of the class not the class itself
|
//TODO: classThatHasTheMethodIfNotThis must be an object --> instance of the class not the class itself
|
||||||
|
// This is not finished
|
||||||
// Need to call codeGen so it pushes the instance onto the stack, which will be popped of
|
// Need to call codeGen so it pushes the instance onto the stack, which will be popped of
|
||||||
//classThatHasTheMethodIfNotThis.codeGen();
|
//classThatHasTheMethodIfNotThis.codeGen();
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
|
|||||||
for (MethodDecl methodDecl : methodDecls) {
|
for (MethodDecl methodDecl : methodDecls) {
|
||||||
if (methodDecl.name.equals(methodName)) {
|
if (methodDecl.name.equals(methodName)) {
|
||||||
//Get the method descriptor
|
//Get the method descriptor
|
||||||
// descriptor = methodDecl.getMethodDescriptor(methodContext);
|
//descriptor = methodDecl.getMethodDescriptor(methodContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, thisClass.name, methodName, descriptor, false);
|
// mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, thisClass.name, methodName, descriptor, false);
|
||||||
|
@ -66,7 +66,10 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
|||||||
@Override
|
@Override
|
||||||
public Node visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) {
|
public Node visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) {
|
||||||
String name = ctx.Identifier().getText();
|
String name = ctx.Identifier().getText();
|
||||||
ParameterList parameterList = (ParameterList) visit(ctx.parameterList());
|
ParameterList parameterList = new ParameterList(new ArrayList<>());
|
||||||
|
if (ctx.parameterList() != null) {
|
||||||
|
parameterList = (ParameterList) visit(ctx.parameterList());
|
||||||
|
}
|
||||||
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
||||||
return new MethodDecl("", null, name, parameterList, block);
|
return new MethodDecl("", null, name, parameterList, block);
|
||||||
}
|
}
|
||||||
@ -76,8 +79,11 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
|||||||
String type;
|
String type;
|
||||||
String name = ctx.Identifier().getText();
|
String name = ctx.Identifier().getText();
|
||||||
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
||||||
ParameterList parameterList = (ParameterList) visit(ctx.parameterList());
|
ParameterList parameterList = new ParameterList(new ArrayList<>());
|
||||||
if (ctx.Void() != null) {
|
if (ctx.parameterList() != null) {
|
||||||
|
parameterList = (ParameterList) visit(ctx.parameterList());
|
||||||
|
}
|
||||||
|
if (ctx.Void() != null) {
|
||||||
type = "void";
|
type = "void";
|
||||||
} else {
|
} else {
|
||||||
type = ctx.type().getText();
|
type = ctx.type().getText();
|
||||||
|
Loading…
Reference in New Issue
Block a user