forked from JavaTX/JavaCompilerCore
ASTFactory createClass
This commit is contained in:
parent
bfb00ac1d1
commit
422f3b4144
@ -32,10 +32,9 @@ public class ClassGenerator extends ClassGen{
|
|||||||
|
|
||||||
private Menge<TypePlaceholder> usedTPHs = new Menge<>();
|
private Menge<TypePlaceholder> usedTPHs = new Menge<>();
|
||||||
|
|
||||||
private Map<String, ClassGenerator> extraClasses = new HashMap();
|
private Map<String, ClassGenerator> extraClasses = new HashMap<>();
|
||||||
|
|
||||||
public ClassGenerator(String name, Type superClass, String string,
|
public ClassGenerator(String name, Type superClass, String string, short accPublic, String[] strings, TypeinferenceResultSet resultSet) {
|
||||||
short accPublic, String[] strings, TypeinferenceResultSet resultSet) {
|
|
||||||
super(name,superClass.get_Name(),string,accPublic,strings, new DHBWConstantPoolGen());
|
super(name,superClass.get_Name(),string,accPublic,strings, new DHBWConstantPoolGen());
|
||||||
this.tiResult = resultSet;
|
this.tiResult = resultSet;
|
||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
|
@ -7,6 +7,9 @@ import de.dhbwstuttgart.syntaxtree.Method;
|
|||||||
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
|
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
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 class ASTFactory {
|
||||||
public static Method createMethod(String name, Block block, Class parent) {
|
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) {
|
public static ClassGenerator createClass(String className, Class superClass) {
|
||||||
// TODO Auto-generated method stub
|
// TODO bytecode createClass
|
||||||
return null;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,10 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: bytecode woher bekommt ich die parent klasse
|
//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)+";";
|
return "L"+getCombinedType(cg)+";";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user