diff --git a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java index 514b1821..be42c2ba 100644 --- a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java @@ -32,10 +32,9 @@ public class ClassGenerator extends ClassGen{ private Menge usedTPHs = new Menge<>(); - private Map extraClasses = new HashMap(); + private Map extraClasses = new HashMap<>(); - public ClassGenerator(String name, Type superClass, String string, - short accPublic, String[] strings, TypeinferenceResultSet resultSet) { + public ClassGenerator(String name, Type superClass, String string, short accPublic, String[] strings, TypeinferenceResultSet resultSet) { super(name,superClass.get_Name(),string,accPublic,strings, new DHBWConstantPoolGen()); this.tiResult = resultSet; this.superClass = superClass; diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index 29940082..fca21942 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -7,6 +7,9 @@ import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.statement.SuperCall; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.ResultSet; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; public class ASTFactory { public static Method createMethod(String name, Block block, Class parent) { @@ -36,7 +39,16 @@ public class ASTFactory { } public static ClassGenerator createClass(String className, Class superClass) { - // TODO Auto-generated method stub - return null; + // TODO bytecode createClass + Class generatedClass = new Class(className, 0); + Block konstruktorBlock = new Block(); + konstruktorBlock.setType(new de.dhbwstuttgart.syntaxtree.type.Void(konstruktorBlock, 0)); + konstruktorBlock.statements.add(new SuperCall(konstruktorBlock)); + Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(konstruktorBlock, className, superClass), superClass); + standardKonstruktor.parserPostProcessing(generatedClass); + + generatedClass.addField(standardKonstruktor); + + return generatedClass.genByteCode(new TypeinferenceResultSet(generatedClass, new Menge<>(), new ResultSet())).getByteCode(); } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index e044c065..f66c8b0c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -837,7 +837,10 @@ public class RefType extends ObjectType implements IMatchable */ //TODO: bytecode woher bekommt ich die parent klasse - cg.addExtraClass(ASTFactory.createClass(getCombinedType(cg), null)); + String combinedType = getCombinedType(cg); + if(!combinedType.equals(get_Name())){ + cg.addExtraClass(ASTFactory.createClass(getCombinedType(cg), getParentClass())); + } return "L"+getCombinedType(cg)+";"; }