diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index b0a42c427..1c15f678e 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -445,7 +445,7 @@ public class StatementGenerator { } return (new Assign(new AssignToField( new FieldVar(new This(varDecl.getStart()), name.getText(), - new Void(varDecl.getStart()), varDecl.getStart())), + type, varDecl.getStart())), initValue, name.getSymbol())); } diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index a0dd57f53..981bf7b9e 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -5,6 +5,7 @@ import de.dhbwstuttgart.exceptions.NotImplementedException; import java.lang.ClassNotFoundException; import de.dhbwstuttgart.exceptions.TypeinferenceException; +import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.scope.GatherNames; import de.dhbwstuttgart.parser.scope.GenericsRegistry; @@ -195,6 +196,7 @@ public class SyntaxTreeGenerator{ superClass = new RefType(ASTFactory.createObjectClass().getClassName(), ctx.getStart()); } List fielddecl = convertFields(ctx.classBody(), generics); + //fieldInitializations = generateFieldInitializations(ctx.classBody(), generics); List methods = convertMethods(ctx.classBody(), name, superClass, generics); List konstruktoren = new ArrayList<>(); for(int i = 0; i generateFieldInitializations(Java8Parser.ClassBodyContext classBodyContext, GenericsRegistry generics) { + List ret = new ArrayList<>(); + for(Java8Parser.ClassBodyDeclarationContext classMember : classBodyContext.classBodyDeclaration()){ + if(classMember.classMemberDeclaration() != null){ + Java8Parser.ClassMemberDeclarationContext classMemberDeclarationContext = classMember.classMemberDeclaration(); + if(classMemberDeclarationContext.fieldDeclaration() != null + && classMemberDeclarationContext.fieldDeclaration().variableDeclaratorList() != null){ + for(Java8Parser.VariableDeclaratorContext ctx : classMemberDeclarationContext.fieldDeclaration().variableDeclaratorList().variableDeclarator()) { + String fieldName = ctx.variableDeclaratorId().Identifier().getText(); + if(ctx.variableDeclaratorId().dims() != null)throw new NotImplementedException(); + Token offset = ctx.getStart(); + RefTypeOrTPHOrWildcardOrGeneric fieldType; + for(Field f : fields) + AssignToField leftSide = new AssignToField(new FieldVar(new This(offset), fieldName, )); + ret.addAll(); + } + }else if(classMemberDeclarationContext.methodDeclaration()!= null){ + //Do nothing! + } + } + } + return ret; + } +*/ + private List convert(Java8Parser.SuperinterfacesContext ctx, GenericsRegistry generics) { if(ctx == null)return new ArrayList<>(); return convert(ctx.interfaceTypeList(), generics); diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java index a99692bb8..79db5ced9 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java +++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java @@ -28,6 +28,7 @@ public class Constructor extends Method { protected static Block prepareBlock(Block constructorBlock, List fieldInitializations){ List statements = constructorBlock.getStatements(); statements.add(0, new SuperCall(constructorBlock.getOffset())); + statements.addAll(fieldInitializations); return new Block(statements, constructorBlock.getOffset()); }