forked from JavaTX/JavaCompilerCore
Zusätzliche Kommentare und geringfügige Änderungen in der Überlegung
This commit is contained in:
parent
1d9f58b196
commit
2fac549cf5
@ -53,19 +53,18 @@ public class Constructor extends Method {
|
||||
|
||||
@Override
|
||||
public void genByteCode(ClassGen cg) {
|
||||
ConstantPoolGen _cp = cg.getConstantPool();
|
||||
InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||
InstructionList il = new InstructionList();
|
||||
//ConstantPoolGen _cp = cg.getConstantPool();
|
||||
//InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||
//InstructionList il = new InstructionList();
|
||||
Class parentClass = this.getParentClass();
|
||||
//TODO: Hier return type und Argument-Typen dynamisch generieren. return type mittels method.getReturnType() ermitteln
|
||||
|
||||
//Hier müsste drin stehen: Kreiere einen Block, welcher ein Statement enthält, welches ein Super Statement ist.
|
||||
|
||||
|
||||
// MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(methode.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
|
||||
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(methode.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
|
||||
|
||||
|
||||
il.dispose();
|
||||
//il.dispose();
|
||||
}
|
||||
// super statement muss drin sein
|
||||
// stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren
|
||||
|
@ -721,20 +721,25 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
|
||||
@Override
|
||||
public void genByteCode(ClassGen cg) {
|
||||
ConstantPoolGen _cp = cg.getConstantPool();
|
||||
InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||
InstructionList il = new InstructionList();
|
||||
//ConstantPoolGen _cp = cg.getConstantPool();
|
||||
//InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||
//InstructionList il = new InstructionList();
|
||||
Class parentClass = this.getParentClass();
|
||||
//TODO: Hier return type und Argument-Typen dynamisch generieren. return type mittels method.getReturnType() ermitteln
|
||||
|
||||
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(methode.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
|
||||
//Über Statements iterieren um den Block abzurufen
|
||||
for(Statement statements : ){
|
||||
statements.genByteCode(cg);
|
||||
}
|
||||
|
||||
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(Constructor.createEmptyMethod(getTypeInformation(), parent).getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
|
||||
|
||||
//GenByteCode Constructor
|
||||
|
||||
method.setMaxStack();
|
||||
method.setMaxLocals();
|
||||
cg.addMethod(method.getMethod());
|
||||
il.dispose();
|
||||
// il.dispose();
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,17 +258,17 @@ public class Block extends Statement
|
||||
|
||||
@Override
|
||||
public void genByteCode(ClassGen cg) {
|
||||
|
||||
ConstantPoolGen _cp = cg.getConstantPool();
|
||||
//ConstantPoolGen _cp = cg.getConstantPool();
|
||||
InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||
InstructionList il = new InstructionList();
|
||||
Class parentClass = this.getParentClass();
|
||||
//Instructionhandle dynamisch
|
||||
//Frage: Wenn Block von Statements erbt, und Block selbst keinen BCEL Code besitzt, ist das hier dann nicht eine Sackgasse?
|
||||
|
||||
for(Statement statements : this.statements){
|
||||
statements.genByteCode(_cg);
|
||||
}
|
||||
InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0)); //creates Constructor
|
||||
il.append(_factory.createInvoke(this.getParentClass().superclassid.toString(), "<init>", org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, Constants.INVOKESPECIAL));
|
||||
InstructionHandle ih_4 = il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); //creates Constructor
|
||||
|
||||
il.dispose();
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user