diff --git a/.classpath b/.classpath index bd1be8d1..1a1e4004 100755 --- a/.classpath +++ b/.classpath @@ -9,3 +9,4 @@ + diff --git a/bin/log4j.xml b/bin/log4j.xml index 64e7c5db..f36fb342 100755 --- a/bin/log4j.xml +++ b/bin/log4j.xml @@ -1,35 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/log4jTesting.xml b/bin/log4jTesting.xml index dc30c245..ef849218 100755 --- a/bin/log4jTesting.xml +++ b/bin/log4jTesting.xml @@ -1,24 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/de/dhbwstuttgart/core/MyCompiler.java b/src/de/dhbwstuttgart/core/MyCompiler.java index 1b776429..5c066cee 100755 --- a/src/de/dhbwstuttgart/core/MyCompiler.java +++ b/src/de/dhbwstuttgart/core/MyCompiler.java @@ -864,7 +864,9 @@ public class MyCompiler implements MyCompilerAPI * - wird der Rückgabetyp von generateBytecode in MyCompiler geändert, so muss auch der Rückgabetyp im Interface MyCompilerAPI geändert werden */ try { - return this.m_AbstractSyntaxTree.firstElement().KlassenVektor.firstElement().genByteCode(); + SourceFile parsedFile = this.m_AbstractSyntaxTree.firstElement(); + Class parsedClass = parsedFile.KlassenVektor.firstElement(); + return parsedClass.genByteCode(); } catch (IOException e) { e.printStackTrace(); return null; diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 5acd3c00..6cb761af 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -16,9 +16,9 @@ import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.MethodGen; import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.logger.SectionLogger; import de.dhbwstuttgart.core.AClassOrInterface; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.parser.JavaClassName; @@ -37,13 +37,16 @@ import de.dhbwstuttgart.typeinference.*; import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.unify.FC_TTO; import de.dhbwstuttgart.typeinference.unify.Unify; + import org.apache.bcel.generic.*; import org.apache.bcel.classfile.*; import org.apache.bcel.*; + import java.io.*; @@ -57,8 +60,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I * Log4j - Loggerinstanzen */ protected static Logger inferencelog = Logger.getLogger("inference"); - //protected static Logger codegenlog = Logger.getLogger("codegen"); - //protected static Logger parserlog = Logger.getLogger("parser"); + protected static Logger codegenlog = Logger.getLogger("codegen"); + protected static Logger parserlog = Logger.getLogger("parser"); protected UsedId pkgName; protected Modifiers modifiers; protected String name; @@ -69,34 +72,27 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I //Method created with BCEL to generate ByteCode public ByteCodeResult genByteCode() throws IOException { + + SectionLogger logger = Logger.getSectionLogger(this.getClass().getName(), Section.CODEGEN); + logger.debug("Test"); - ByteCodeResult code = new ByteCodeResult(); - - _cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //new String necessary? + if(pkgName != null)throw new NotImplementedException(); + _cg = new ClassGen(name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //new String necessary? _cp = _cg.getConstantPool(); _factory = new InstructionFactory(_cg, _cp); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, new String[] { }, "", pkgName.get_Name() + "." + name, il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0)); //creates Constructor - il.append(_factory.createInvoke("java.lang.Object", "", 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 - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - _cg.getJavaClass().dump(out); - code.attach(out.toString()); - + for(Field field : this.fielddecl){ + field.genByteCode(_cg); + } + + ByteCodeResult code = new ByteCodeResult(_cg); return code; - /*ByteCodeResult bc = new ByteCodeResult(); - _cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); + //ByteCodeResult bc = new ByteCodeResult(); + //_cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //_cg zurückgeben - bc.append(BCELByteCodeOutput); - return _cg;*/ + //bc.append(BCELByteCodeOutput); + //return _cg; } private Menge superif = new Menge(); diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java index e7b29569..0635bdbd 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java +++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java @@ -1,7 +1,15 @@ package de.dhbwstuttgart.syntaxtree; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.InstructionFactory; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.InstructionList; +import org.apache.bcel.generic.MethodGen; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.misc.DeclId; @@ -42,7 +50,30 @@ public class Constructor extends Method { ret.addAssumption(new ConstructorAssumption(this, parentClass)); return ret; } - /* + + @Override + public void genByteCode(ClassGen cg) { + ConstantPoolGen _cp = cg.getConstantPool(); + //InstructionFactory _factory = new InstructionFactory(cg, _cp); + InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen + Class parentClass = this.getParentClass(); + + //Hier müsste drin stehen: Kreiere einen Block, welcher ein Statement enthält, welches ein Super Statement ist. + + //TODO: Alles dynamisch gestalten + //init darf nur drin stehen, wenn Konstruktor; + methode.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[] { }, "", parentClass.name, il, _cp); + + methode.genByteCode(cg); //Aufrufen um Iteration über Block zu starten + + } + // super statement muss drin sein + // stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren + // de.dhbw.systanxtree.stmts supercall + // Aufrufhierarchie: Class->Felder->Konstruktor->Methode innerhalb Konstruktor->Block->Statements (in diesem Fall nur super())->hier wird bytecode für superaufruf generiert + + + @Override public void parserPostProcessing(SyntaxTreeNode parent){ if(this.parameterlist != null){ @@ -54,7 +85,7 @@ public class Constructor extends Method { gtv.parserPostProcessing(this); } } - */ + @Override public ConstraintsSet TYPE(TypeAssumptions ass) { //super.setType(this.getParentClass().getType()); @@ -67,13 +98,13 @@ public class Constructor extends Method { //throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this); //this.methode.setType(t); } - /* - public Constructor(Method methode){ + + /*public Constructor(Method methode){ super(methode.getOffset()); this.methode = methode; this.setDeclIdMenge(methode.getDeclIdMenge()); this.methode.setType(this.methode.getParentClass().getType()); - } + }*/ @Override public Menge getGenericParameter() { @@ -198,11 +229,11 @@ public class Constructor extends Method { this.methode.setOverloadedID(overloadedID); } - @Override + /*@Override public String get_codegen_Param_Type(Menge paralist) { return this.methode.get_codegen_Param_Type(paralist); - } + }*/ @Override public String get_Method_Name() { @@ -216,12 +247,12 @@ public class Constructor extends Method { return this.methode.get_Type_Paralist(); } - @Override + /*@Override public void codegen(ClassFile classfile, Menge paralist) throws JVMCodeException { this.methode.codegen(classfile, paralist); - } + }*/ @Override public int getLineNumber() { @@ -289,11 +320,11 @@ public class Constructor extends Method { this.methode.set_Method_Name(string); } - public ConstraintsSet TYPE(TypeAssumptions ass) { + /*public ConstraintsSet TYPE(TypeAssumptions ass) { ConstraintsSet ret = new ConstraintsSet(); ret.add(this.methode.get_Block().TYPEStmt(ass)); return ret; - } + }*/ @Override public String getTypeInformation() { @@ -307,24 +338,24 @@ public class Constructor extends Method { return this.methode.printJavaCode(resultSet); } - @Override + /*@Override public TypeAssumptions createTypeAssumptions(Class classmember) { Class parentClass = this.getParentClass(); TypeAssumptions ret = new TypeAssumptions(); ret.addAssumption(new ConstructorAssumption(this, parentClass)); return ret; - } + }*/ @Override public SyntaxTreeNode getParent(){ return this.methode.getParent(); } - @Override + /*@Override public void parserPostProcessing(SyntaxTreeNode parent) { this.methode.parserPostProcessing(parent); - } + }*/ @Override public Menge getChildren() { @@ -332,11 +363,11 @@ public class Constructor extends Method { return this.methode.getChildren(); } - @Override + /*@Override public void setType(Type t) { throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this); //this.methode.setType(t); - } + }*/ @Override public Type getType() { @@ -390,7 +421,7 @@ public class Constructor extends Method { public Class getParentClass() { return this.methode.getParentClass(); } - */ + } diff --git a/src/de/dhbwstuttgart/syntaxtree/Field.java b/src/de/dhbwstuttgart/syntaxtree/Field.java index 2b40a085..55c553ac 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Field.java +++ b/src/de/dhbwstuttgart/syntaxtree/Field.java @@ -1,7 +1,8 @@ package de.dhbwstuttgart.syntaxtree; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; @@ -171,4 +172,11 @@ public abstract class Field extends GTVDeclarationContext implements TypeInserta public boolean isClass() { return false; } + + /** + * Fügt das das Feld zu ClassGen hinzu + * @param cg + */ + public abstract void genByteCode(ClassGen cg); } + diff --git a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java index b452e3fc..8d321a04 100644 --- a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java +++ b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java @@ -1,7 +1,8 @@ package de.dhbwstuttgart.syntaxtree; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.statement.Expr; @@ -157,4 +158,16 @@ public class FieldDeclaration extends Field{ if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Menge()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben } + @Override + public void genByteCode(ClassGen cg) { + // TODO Auto-generated method stub + + } + + /*@Override + public void genByteCode(ClassGen cg) { + // TODO Auto-generated method stub + + }*/ + } diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index a288aa98..796bb800 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -1,14 +1,22 @@ // ino.module.Method.8564.package package de.dhbwstuttgart.syntaxtree; + // ino.end // ino.module.Method.8564.import import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.Constants; +import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.InstructionFactory; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.InstructionList; +import org.apache.bcel.generic.MethodGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -19,6 +27,7 @@ import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.statement.Return; +import de.dhbwstuttgart.syntaxtree.statement.Statement; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; @@ -34,13 +43,12 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; - - - // ino.class.Method.23482.declaration /** - * Stellt eine Methode dar. - * Problem: Parser kann nicht zwischen Methode und Konstruktor unterscheiden. Daher kann diese Klasse beides sein. Dies wird mit dem ParserPostProcessing behoben. + * Stellt eine Methode dar. Problem: Parser kann nicht zwischen Methode und + * Konstruktor unterscheiden. Daher kann diese Klasse beides sein. Dies wird mit + * dem ParserPostProcessing behoben. + * * @author janulrich * */ @@ -48,619 +56,628 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable // ino.end // ino.class.Method.23482.body { - // ino.attribute.block.23488.declaration - private Block block; - // ino.end - // ino.attribute.parameterlist.23491.declaration - public ParameterList parameterlist = new ParameterList(); - // ino.end - // ino.attribute.exceptionlist.23494.declaration - private ExceptionList exceptionlist; - // ino.end - // ino.attribute.returntype.23497.declaration - private Type returntype; - // ino.end - - // ino.attribute.genericMethodParameters.23500.decldescription type=javadoc - /** - * HOTI 4.5.06 - * Dieser Vektor beinhaltet alle Generischen Typen und v.a. die - * F-Bounded-Generics, die die Methode besitzt - * size()==0, falls es keine gibt - */ - // ino.end - // ino.attribute.genericMethodParameters.23500.declaration - //private Menge genericMethodParameters=new Menge(); - // ino.end - - // ino.attribute.overloadedID.23503.declaration - private int overloadedID; - // ino.end - // ino.attribute.isAbstract.23506.declaration - private boolean isAbstract = false; - // ino.end - // ino.attribute.types_in_parameterlist.23509.declaration - private Menge types_in_parameterlist = new Menge(); - // ino.end - // ino.attribute.m_LineNumber.23512.declaration - private int m_LineNumber = MyCompiler.NO_LINENUMBER; - // ino.end - private int m_Offset = -1; //hinzugef�gt hoth: 07.04.2006 - // ino.attribute.inferencelog.23515.declaration - protected static Logger inferencelog = Logger.getLogger("inference"); - // ino.end - // ino.attribute.parserlog.23518.declaration - protected static Logger parserlog = Logger.getLogger("parser"); - // ino.end - - public Method(int offset){ - super(offset); - } - - public Method(String name, Type returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset){ - this(offset); - /* - if(parameterList != null)parameterList.parserPostProcessing(this); - if(block != null)block.parserPostProcessing(this); - if(gtvDeclarations != null)gtvDeclarations.parserPostProcessing(this); - */ - this.set_Method_Name(name); - this.setParameterList(parameterList); - this.set_Block(block); - this.setGenericParameter(gtvDeclarations); - this.setReturnType(returnType); - } - - /* - // ino.method.setGenericMethodParameters.23521.definition - public void setGenericMethodParameters(Menge genericMethodParameters) - // ino.end - // ino.method.setGenericMethodParameters.23521.body - { - this.genericMethodParameters=genericMethodParameters; - } - // ino.end - // ino.method.getGenericMethodParameters.23524.definition - public Menge getGenericMethodParameters() - // ino.end - // ino.method.getGenericMethodParameters.23524.body - { - return(genericMethodParameters); - } - // ino.end - */ - /* - // ino.method.sc_init_parameterlist.23530.definition - public void sc_init_parameterlist(boolean ext) - // ino.end - // ino.method.sc_init_parameterlist.23530.body - { - DeclId hilf=null; - Menge list; - FormalParameter para; - String typeofpara; - int i=1; - if(this.getParameterList()!=null) //es gibt Parameter, dann: - { - hilf=declid.elementAt(0); - if(ext) - parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" bergabewerte gefunden:"); - list=this.getParameterList().sc_get_Formalparalist(); //Menge Formalparalist aus FormalParameterList wird zwischen gesichert - for(Enumeration el2=list.elements(); el2.hasMoreElements();) - { - para=el2.nextElement(); - typeofpara=para.getTypeName(); - if(ext) - parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara); - types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden im Menge abgelegt - i++; - } - } - else //keine Parameter vorhanden: - { - if(ext) - { - hilf=declid.elementAt(0); - parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" keine bergabewerte gefunden."); - } - } - if(ext) - { - parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+ types_in_parameterlist.size()+" bergabeparameter gefunden."); - parserlog.debug(" namentlich: "+types_in_parameterlist.toString()); - } - } - // ino.end - */ - // ino.method.getTypeName.23533.defdescription type=line - // Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die - // get_ReturnType() auf eigene Gefahr lschen. - // ino.end - - // ino.method.getTypeName.23533.definition - public JavaClassName getTypeName() - // ino.end - // ino.method.getTypeName.23533.body - { - if( this.getType() == null ) - return null; - else - return this.getType().getName(); - } - // ino.end + // ino.attribute.block.23488.declaration + private Block block; + // ino.end + // ino.attribute.parameterlist.23491.declaration + public ParameterList parameterlist = new ParameterList(); + // ino.end + // ino.attribute.exceptionlist.23494.declaration + private ExceptionList exceptionlist; + // ino.end + // ino.attribute.returntype.23497.declaration + private Type returntype; + // ino.end + protected MethodGen method; + // ino.attribute.genericMethodParameters.23500.decldescription type=javadoc + /** + * HOTI 4.5.06 Dieser Vektor beinhaltet alle Generischen Typen und v.a. die + * F-Bounded-Generics, die die Methode besitzt size()==0, falls es keine + * gibt + */ + // ino.end + // ino.attribute.genericMethodParameters.23500.declaration + // private Menge genericMethodParameters=new + // Menge(); + // ino.end - // ino.method.get_Block.23536.definition - public Block get_Block() - // ino.end - // ino.method.get_Block.23536.body - { - return block; - } - // ino.end - - // ino.method.setReturnType.23539.defdescription type=javadoc - /** - *
Author: Jrg Buerle - * @param type - */ - // ino.end - // ino.method.setReturnType.23539.definition - private void setReturnType(Type type) - // ino.end - // ino.method.setReturnType.23539.body - { - this.returntype = type; - } - // ino.end + // ino.attribute.overloadedID.23503.declaration + private int overloadedID; + // ino.end + // ino.attribute.isAbstract.23506.declaration + private boolean isAbstract = false; + // ino.end + // ino.attribute.types_in_parameterlist.23509.declaration + private Menge types_in_parameterlist = new Menge(); + // ino.end + // ino.attribute.m_LineNumber.23512.declaration + private int m_LineNumber = MyCompiler.NO_LINENUMBER; + // ino.end + private int m_Offset = -1; // hinzugef�gt hoth: 07.04.2006 + // ino.attribute.inferencelog.23515.declaration + protected static Logger inferencelog = Logger.getLogger("inference"); + // ino.end + // ino.attribute.parserlog.23518.declaration + protected static Logger parserlog = Logger.getLogger("parser"); - // ino.method.set_Block.23542.definition - public void set_Block( Block blo) - // ino.end - // ino.method.set_Block.23542.body - { - if(blo.getType() == null)blo.setType(this.returntype); - this.block = blo; - } - // ino.end + // ino.end - // ino.method.set_Modifiers.23545.definition - public void set_Modifiers(Modifiers modif) - // ino.end - // ino.method.set_Modifiers.23545.body - { - declid.firstElement().set_Modifiers(modif); - // this.modi = modif; - } - // ino.end + public Method(int offset) { + super(offset); + } - // ino.method.set_ExceptionList.23548.definition - public void set_ExceptionList(ExceptionList exlist) - // ino.end - // ino.method.set_ExceptionList.23548.body - { - this.exceptionlist = exlist; - } - // ino.end + public Method(String name, Type returnType, ParameterList parameterList, + Block block, GenericDeclarationList gtvDeclarations, int offset) { + this(offset); + /* + * if(parameterList != null)parameterList.parserPostProcessing(this); + * if(block != null)block.parserPostProcessing(this); if(gtvDeclarations + * != null)gtvDeclarations.parserPostProcessing(this); + */ + this.set_Method_Name(name); + this.setParameterList(parameterList); + this.set_Block(block); + this.setGenericParameter(gtvDeclarations); + this.setReturnType(returnType); + } - // ino.method.setParameterList.23551.definition - public void setParameterList( ParameterList paralist ) - // ino.end - // ino.method.setParameterList.23551.body - { - this.parameterlist = paralist; - } - // ino.end + /* + * // ino.method.setGenericMethodParameters.23521.definition public void + * setGenericMethodParameters(Menge genericMethodParameters) + * // ino.end // ino.method.setGenericMethodParameters.23521.body { + * this.genericMethodParameters=genericMethodParameters; } // ino.end // + * ino.method.getGenericMethodParameters.23524.definition public + * Menge getGenericMethodParameters() // ino.end // + * ino.method.getGenericMethodParameters.23524.body { + * return(genericMethodParameters); } // ino.end + */ + /* + * // ino.method.sc_init_parameterlist.23530.definition public void + * sc_init_parameterlist(boolean ext) // ino.end // + * ino.method.sc_init_parameterlist.23530.body { DeclId hilf=null; + * Menge list; FormalParameter para; String typeofpara; int + * i=1; if(this.getParameterList()!=null) //es gibt Parameter, dann: { + * hilf=declid.elementAt(0); if(ext) + * parserlog.debug("Semantik-Check hat in Methode " + * +hilf.get_Name()+" bergabewerte gefunden:"); + * list=this.getParameterList().sc_get_Formalparalist(); //Menge + * Formalparalist aus FormalParameterList wird zwischen gesichert + * for(Enumeration el2=list.elements(); + * el2.hasMoreElements();) { para=el2.nextElement(); + * typeofpara=para.getTypeName(); if(ext) + * parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara); + * types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden + * im Menge abgelegt i++; } } else //keine Parameter vorhanden: { if(ext) { + * hilf=declid.elementAt(0); + * parserlog.debug("Semantik-Check hat in Methode " + * +hilf.get_Name()+" keine bergabewerte gefunden."); } } if(ext) { + * parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+ + * types_in_parameterlist.size()+" bergabeparameter gefunden."); + * parserlog.debug + * (" namentlich: "+types_in_parameterlist.toString()); } } // + * ino.end + */ + // ino.method.getTypeName.23533.defdescription type=line + // Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die + // get_ReturnType() auf eigene Gefahr lschen. + // ino.end - // ino.method.getParameterList.23554.definition - public ParameterList getParameterList( ) - // ino.end - // ino.method.getParameterList.23554.body - { - // otth: gibt die Parameterliste zurueck - return this.parameterlist; - } - // ino.end - - // ino.method.getParameterCount.23557.defdescription type=javadoc - /** - * Author: Jrg Buerle
- * @return Die Anzahl der Methoden-Paramater - */ - // ino.end - // ino.method.getParameterCount.23557.definition - public int getParameterCount() - // ino.end - // ino.method.getParameterCount.23557.body - { - if(this.getParameterList() == null) - return 0; - else - return this.getParameterList().getParameterCount(); - } - // ino.end + // ino.method.getTypeName.23533.definition + public JavaClassName getTypeName() + // ino.end + // ino.method.getTypeName.23533.body + { + if (this.getType() == null) + return null; + else + return this.getType().getName(); + } - // ino.method.get_ExceptionList.23560.definition - public ExceptionList get_ExceptionList() - // ino.end - // ino.method.get_ExceptionList.23560.body - { - // otth: gibt die Exceptionliste zurueck - return this.exceptionlist; - } - // ino.end - - // ino.method.getOverloadedID.23563.definition - public int getOverloadedID() - // ino.end - // ino.method.getOverloadedID.23563.body - { - return(overloadedID); - } - // ino.end + // ino.end - // ino.method.setOverloadedID.23566.definition - public void setOverloadedID(int overloadedID) - // ino.end - // ino.method.setOverloadedID.23566.body - { - this.overloadedID=overloadedID; - } - // ino.end - + // ino.method.get_Block.23536.definition + public Block get_Block() + // ino.end + // ino.method.get_Block.23536.body + { + return block; + } - - - - // ino.method.get_Method_Name.23575.definition - public String get_Method_Name() - // ino.end - // ino.method.get_Method_Name.23575.body - { - DeclId hilf=declid.elementAt(0); - return hilf.get_Name(); - } - // ino.end + // ino.end - // ino.method.get_Type_Paralist.23578.definition - public Menge get_Type_Paralist() - // ino.end - // ino.method.get_Type_Paralist.23578.body - { - return types_in_parameterlist; - } - // ino.end - - + // ino.method.setReturnType.23539.defdescription type=javadoc + /** + *
+ * Author: Jrg Buerle + * + * @param type + */ + // ino.end + // ino.method.setReturnType.23539.definition + private void setReturnType(Type type) + // ino.end + // ino.method.setReturnType.23539.body + { + this.returntype = type; + } - // ino.method.getLineNumber.23584.definition - public int getLineNumber() - // ino.end - // ino.method.getLineNumber.23584.body - { - return m_LineNumber; - } - // ino.end - - // ino.method.setLineNumber.23587.definition - public void setLineNumber(int lineNumber) - // ino.end - // ino.method.setLineNumber.23587.body - { - m_LineNumber = lineNumber; - } - // ino.end - - // ino.method.getOffset.23590.defdescription type=line - // hinzugef�gt hoth: 07.04.2006 - // ino.end - // ino.method.getOffset.23590.definition - public int getOffset() - // ino.end - // ino.method.getOffset.23590.body - { - return m_Offset; - } - // ino.end - - // ino.method.getVariableLength.23593.definition - public int getVariableLength() - // ino.end - // ino.method.getVariableLength.23593.body - { - return get_Method_Name().length(); - } - // ino.end - - // ino.method.setOffset.23596.defdescription type=line - // hinzugef�gt hoth: 07.04.2006 - // ino.end - // ino.method.setOffset.23596.definition - public void setOffset(int Offset) - // ino.end - // ino.method.setOffset.23596.body - { - m_Offset = Offset; - } - // ino.end + // ino.end - - // ino.method.getTypeLineNumber.23602.defdescription type=javadoc - /** - *
Author: Jrg Buerle - * @return - */ - // ino.end - // ino.method.getTypeLineNumber.23602.definition - public int getTypeLineNumber() - // ino.end - // ino.method.getTypeLineNumber.23602.body - { - return this.getLineNumber(); - } - // ino.end + // ino.method.set_Block.23542.definition + public void set_Block(Block blo) + // ino.end + // ino.method.set_Block.23542.body + { + if (blo.getType() == null) + blo.setType(this.returntype); + this.block = blo; + } + + // ino.end + + // ino.method.set_Modifiers.23545.definition + public void set_Modifiers(Modifiers modif) + // ino.end + // ino.method.set_Modifiers.23545.body + { + declid.firstElement().set_Modifiers(modif); + // this.modi = modif; + } + + // ino.end + + // ino.method.set_ExceptionList.23548.definition + public void set_ExceptionList(ExceptionList exlist) + // ino.end + // ino.method.set_ExceptionList.23548.body + { + this.exceptionlist = exlist; + } + + // ino.end + + // ino.method.setParameterList.23551.definition + public void setParameterList(ParameterList paralist) + // ino.end + // ino.method.setParameterList.23551.body + { + this.parameterlist = paralist; + } + + // ino.end + + // ino.method.getParameterList.23554.definition + public ParameterList getParameterList() + // ino.end + // ino.method.getParameterList.23554.body + { + // otth: gibt die Parameterliste zurueck + return this.parameterlist; + } + + // ino.end + + // ino.method.getParameterCount.23557.defdescription type=javadoc + /** + * Author: Jrg Buerle
+ * + * @return Die Anzahl der Methoden-Paramater + */ + // ino.end + // ino.method.getParameterCount.23557.definition + public int getParameterCount() + // ino.end + // ino.method.getParameterCount.23557.body + { + if (this.getParameterList() == null) + return 0; + else + return this.getParameterList().getParameterCount(); + } + + // ino.end + + // ino.method.get_ExceptionList.23560.definition + public ExceptionList get_ExceptionList() + // ino.end + // ino.method.get_ExceptionList.23560.body + { + // otth: gibt die Exceptionliste zurueck + return this.exceptionlist; + } + + // ino.end + + // ino.method.getOverloadedID.23563.definition + public int getOverloadedID() + // ino.end + // ino.method.getOverloadedID.23563.body + { + return (overloadedID); + } + + // ino.end + + // ino.method.setOverloadedID.23566.definition + public void setOverloadedID(int overloadedID) + // ino.end + // ino.method.setOverloadedID.23566.body + { + this.overloadedID = overloadedID; + } + + // ino.end + + // ino.method.get_Method_Name.23575.definition + public String get_Method_Name() + // ino.end + // ino.method.get_Method_Name.23575.body + { + DeclId hilf = declid.elementAt(0); + return hilf.get_Name(); + } + + // ino.end + + // ino.method.get_Type_Paralist.23578.definition + public Menge get_Type_Paralist() + // ino.end + // ino.method.get_Type_Paralist.23578.body + { + return types_in_parameterlist; + } + + // ino.end + + // ino.method.getLineNumber.23584.definition + public int getLineNumber() + // ino.end + // ino.method.getLineNumber.23584.body + { + return m_LineNumber; + } + + // ino.end + + // ino.method.setLineNumber.23587.definition + public void setLineNumber(int lineNumber) + // ino.end + // ino.method.setLineNumber.23587.body + { + m_LineNumber = lineNumber; + } + + // ino.end + + // ino.method.getOffset.23590.defdescription type=line + // hinzugef�gt hoth: 07.04.2006 + // ino.end + // ino.method.getOffset.23590.definition + public int getOffset() + // ino.end + // ino.method.getOffset.23590.body + { + return m_Offset; + } + + // ino.end + + // ino.method.getVariableLength.23593.definition + public int getVariableLength() + // ino.end + // ino.method.getVariableLength.23593.body + { + return get_Method_Name().length(); + } + + // ino.end + + // ino.method.setOffset.23596.defdescription type=line + // hinzugef�gt hoth: 07.04.2006 + // ino.end + // ino.method.setOffset.23596.definition + public void setOffset(int Offset) + // ino.end + // ino.method.setOffset.23596.body + { + m_Offset = Offset; + } + + // ino.end + + // ino.method.getTypeLineNumber.23602.defdescription type=javadoc + /** + *
+ * Author: Jrg Buerle + * + * @return + */ + // ino.end + // ino.method.getTypeLineNumber.23602.definition + public int getTypeLineNumber() + // ino.end + // ino.method.getTypeLineNumber.23602.body + { + return this.getLineNumber(); + } + + // ino.end + + // ino.method.toString.23605.defdescription type=javadoc + /** + *
+ * Author: Martin Pl�micke + * + * @return + */ + // ino.end + // ino.method.toString.23605.definition + public String toString() + // ino.end + // ino.method.toString.23605.body + { + return this.getType() + " " + this.get_Name() + + ((block != null) ? block.toString() : ""); + } + + // ino.end + + // ino.method.setAbstract.23608.defdescription type=javadoc + /** + * Legt fuer die ByteCodeGen fest, ob Bytecode innerhalb der Methode + * generiert wird. + */ + // ino.end + // ino.method.setAbstract.23608.definition + public void setAbstract(boolean b) + // ino.end + // ino.method.setAbstract.23608.body + { + isAbstract = b; + } + + // ino.end + + // ino.method.isAbstract.23611.defdescription type=javadoc + /** + * Gibt zurueck, ob ByteCode innerhabl der Methode generiert wird. + */ + // ino.end + // ino.method.isAbstract.23611.definition + public boolean isAbstract() + // ino.end + // ino.method.isAbstract.23611.body + { + return isAbstract; + } + + @Override + public void wandleRefTypeAttributes2GenericAttributes( + Menge classParalist) { + /* + * Menge paralist = new Menge();//Mit den Generischen Typen + * der Methode paralist.addAll(classParalist); + * paralist.addAll(this.genericMethodParameters); + * + * // Zuerst Returntype untersuchen Type returnType=getType(); Type + * pendantReturnType = null; if(returnType instanceof + * RefType)pendantReturnType = + * ((RefType)returnType).findGenericType(paralist, new + * Menge()); //GenericTypeVar + * pendantReturnType=ClassHelper.findGenericType(returnType, + * paralist,genericMethodParameters); if(pendantReturnType!=null){ + * //Wenn generisch, dann modifizieren setReturnType(pendantReturnType); + * } + * + * // Dann parameterlist untersuchen for(int + * par=0;par()); //GenericTypeVar + * pendantPara=ClassHelper.findGenericType + * (fpType,paralist,genericMethodParameters); if(pendantPara!=null){ + * //Wenn generisch, dann modifizieren fp.setType(pendantPara); } } + * + * // Zuletzt alle Lokalen Variablendeklarationen durchgehen + * if(block!=null){ + * block.wandleRefTypeAttributes2GenericAttributes(paralist + * ,genericMethodParameters); } + */ + } + + public void set_Method_Name(String string) { + if (declid.size() == 0) + declid.add(0, new DeclId(string)); + declid.set(0, new DeclId(string)); + } - // ino.method.toString.23605.defdescription type=javadoc - /** - *
Author: Martin Pl�micke - * @return - */ - // ino.end - // ino.method.toString.23605.definition - public String toString() - // ino.end - // ino.method.toString.23605.body - { - return this.getType() + " "+ this.get_Name() +( (block!=null)?block.toString():""); - } - // ino.end - - // ino.method.setAbstract.23608.defdescription type=javadoc - /** - * Legt fuer die ByteCodeGen fest, ob Bytecode - * innerhalb der Methode generiert wird. - */ - // ino.end - // ino.method.setAbstract.23608.definition - public void setAbstract(boolean b) - // ino.end - // ino.method.setAbstract.23608.body - { - isAbstract = b; - } - // ino.end - - // ino.method.isAbstract.23611.defdescription type=javadoc - /** - * Gibt zurueck, ob ByteCode innerhabl der Methode - * generiert wird. - */ - // ino.end - // ino.method.isAbstract.23611.definition - public boolean isAbstract() - // ino.end - // ino.method.isAbstract.23611.body - { - return isAbstract; - } - - @Override - public void wandleRefTypeAttributes2GenericAttributes(Menge classParalist) - { - /* - Menge paralist = new Menge();//Mit den Generischen Typen der Methode - paralist.addAll(classParalist); - paralist.addAll(this.genericMethodParameters); - - // Zuerst Returntype untersuchen - Type returnType=getType(); - Type pendantReturnType = null; - if(returnType instanceof RefType)pendantReturnType = ((RefType)returnType).findGenericType(paralist, new Menge()); - //GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters); - if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren - setReturnType(pendantReturnType); - } - - // Dann parameterlist untersuchen - for(int par=0;par()); - //GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters); - if(pendantPara!=null){ //Wenn generisch, dann modifizieren - fp.setType(pendantPara); - } - } - - // Zuletzt alle Lokalen Variablendeklarationen durchgehen - if(block!=null){ - block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters); - } - */ - } - - public void set_Method_Name(String string) - { - if(declid.size()==0)declid.add(0, new DeclId(string)); - declid.set(0,new DeclId(string)); - } - - - public ConstraintsSet TYPE(TypeAssumptions ass) { ConstraintsSet ret = new ConstraintsSet(); TypeAssumptions localAss = new TypeAssumptions(); - localAss.add(ass); //Die globalen Assumptions anhängen - //Generische Parameterdeklarationen den Assumptions anfügen: - for(GenericTypeVar gtv : this.getGenericParameter()){ + localAss.add(ass); // Die globalen Assumptions anhängen + // Generische Parameterdeklarationen den Assumptions anfügen: + for (GenericTypeVar gtv : this.getGenericParameter()) { localAss.add(gtv.createAssumptions()); } - for(GenericTypeVar gtv : this.getGenericParameter()){ + for (GenericTypeVar gtv : this.getGenericParameter()) { ret.add(gtv.TYPE(localAss)); } - - //TypeCheck, falls es sich um einen RefType handelt: + + // TypeCheck, falls es sich um einen RefType handelt: this.returntype = this.returntype.checkTYPE(localAss, this); /* - if(this.returntype!=null && (this.returntype instanceof RefType)&& - !(this.returntype instanceof mycompiler.mytype.Void)){//Sonderfall der Methode: Ihr Typ darf Void definiert werden. - Type replaceType = null; - replaceType = ass.getTypeFor((RefType)this.returntype); - if(replaceType == null)throw new TypeinferenceException("Der Typ "+this.getType().getName()+" ist nicht korrekt",this); - this.returntype = replaceType; - } - */ - //Die Parameter zu den Assumptions hinzufügen: - if(this.parameterlist!=null)for(FormalParameter param : this.parameterlist){ - - param.setType(param.getType().checkTYPE(localAss, this)); - /* - if(param.getType() instanceof RefType) - { - Type replaceType = null; - replaceType = ass.getTypeFor((RefType)param.getType()); - if(replaceType == null) - throw new TypeinferenceException("Der Typ "+param.getType().getName()+" ist nicht korrekt",param); - param.setType(replaceType); + * if(this.returntype!=null && (this.returntype instanceof RefType)&& + * !(this.returntype instanceof mycompiler.mytype.Void)){//Sonderfall + * der Methode: Ihr Typ darf Void definiert werden. Type replaceType = + * null; replaceType = ass.getTypeFor((RefType)this.returntype); + * if(replaceType == null)throw new + * TypeinferenceException("Der Typ "+this + * .getType().getName()+" ist nicht korrekt",this); this.returntype = + * replaceType; } + */ + // Die Parameter zu den Assumptions hinzufügen: + if (this.parameterlist != null) + for (FormalParameter param : this.parameterlist) { + + param.setType(param.getType().checkTYPE(localAss, this)); + /* + * if(param.getType() instanceof RefType) { Type replaceType = + * null; replaceType = ass.getTypeFor((RefType)param.getType()); + * if(replaceType == null) throw new + * TypeinferenceException("Der Typ " + * +param.getType().getName()+" ist nicht korrekt",param); + * param.setType(replaceType); } + */ + + localAss.addAssumption(new ParameterAssumption(param)); } - */ - - localAss.addAssumption(new ParameterAssumption(param)); - } ret.add(this.block.TYPEStmt(localAss)); - //eine Verknüpfung mit der Type Assumption aus dem Assumption Set und dem ermittelten Typ der Methode: - ret.add(new SingleConstraint(this.block.getType().TYPE(localAss, this), this.returntype.TYPE(localAss, this))); + // eine Verknüpfung mit der Type Assumption aus dem Assumption Set + // und dem ermittelten Typ der Methode: + ret.add(new SingleConstraint(this.block.getType().TYPE(localAss, this), + this.returntype.TYPE(localAss, this))); return ret; } - + /** * @author Andreas Stadelmeier, a10023 * @return die TypInformationen der Statements dieser Methode. */ - public String getTypeInformation(){ - if(this.parameterlist!=null)return "Methode "+this.get_Name()+ " Parameter: "+this.parameterlist.getTypeInformation()+", Block: "+this.block.getTypeInformation(); - return "Methode "+this.get_Name()+" : "+this.getType()+", Block: "+this.block.getTypeInformation(); + public String getTypeInformation() { + if (this.parameterlist != null) + return "Methode " + this.get_Name() + " Parameter: " + + this.parameterlist.getTypeInformation() + ", Block: " + + this.block.getTypeInformation(); + return "Methode " + this.get_Name() + " : " + this.getType() + + ", Block: " + this.block.getTypeInformation(); } - + @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { JavaCodeResult ret = new JavaCodeResult(); - ret.attach(this.getType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("(").attach(this.getParameterList().printJavaCode(resultSet)).attach(")\n"); + ret.attach(this.getType().printJavaCode(resultSet)).attach(" ") + .attach(this.get_Method_Name()).attach("(") + .attach(this.getParameterList().printJavaCode(resultSet)) + .attach(")\n"); ret.attach(this.block.printJavaCode(resultSet)); return ret; } - + /** * Liefert die MethodAssumption zu dieser Methode */ @Override public TypeAssumptions createTypeAssumptions(Class classmember) { - Class parentClass = classmember;//this.getParentClass(); + Class parentClass = classmember;// this.getParentClass(); TypeAssumptions ret = new TypeAssumptions(); ret.addAssumption(new MethodAssumption(this, parentClass)); return ret; /* - TypeAssumptions assumptions = new TypeAssumptions(); - this.assumedType = null; - //if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("")) && ((this.getType().equals(new mycompiler.mytype.Void(0))) || this.getType() instanceof TypePlaceholder)){ - if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals(""))) { - this.set_Method_Name(""); - this.assumedType = new RefType(classmember.getName(),0); - this.setReturnType(this.assumedType); - this.assumedType = new RefType("void",0); - //Return constructorReturnStatement = new Return(0,0); - //constructorReturnStatement.retexpr = - //this.block.statements.add(constructorReturnStatement); - } - //hoth: 06.04.2006 - //durchlaufe Block und suche nach Objektvariablen fuer Offset-Markierung - Iterator fieldVarIterator = assumptions.iterator(); - while (fieldVarIterator.hasNext()) - { - //Wenn ObjektVariable - CTypeAssumption dieAssum = fieldVarIterator.next(); - if(dieAssum instanceof CInstVarTypeAssumption) - { - Class.isFirstLocalVarDecl=false; - if(this.get_Block() != null) - this.get_Block().addOffsetsToAssumption(dieAssum,dieAssum.getIdentifier(),true); - } - } - - //methodList.addElement(method); - - //F�r V_fields_methods: - CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Menge(),this.getGenericMethodParameters()); // Typannahme bauen... - - - //Methode in V_Fields_methods ablegen - //Dabei wird die OverloadedMethodID ermittelt !! - //=> Method setzenuct - - - assumptions.add(methodAssum); - this.setOverloadedID(methodAssum.getHashSetKey().getOverloadedMethodID()); - - - //F�r die V_i: - CTypeAssumptionSet localAssum = new CTypeAssumptionSet(); - - //Bauen... - ParameterList parameterList = this.getParameterList(); - if(parameterList!=null){ - for(int i=0; i()); - //fuege Offsets fuer Parameter hinzu, hoth: 06.04.2006 - Class.isFirstLocalVarDecl=false; - - if(this.get_Block() != null) - this.get_Block().addOffsetsToAssumption(paraAssum,paraAssum.getIdentifier(),true); - - methodAssum.addParaAssumption(paraAssum); - - // F�r die V_i: - CLocalVarTypeAssumption varAssum = new CLocalVarTypeAssumption(classmember.getName(), this.get_Method_Name(), this.getParameterCount(), this.getOverloadedID(),"1", para.get_Name(),para.getType(), para.getLineNumber(),para.getOffset(),new Menge()); - localAssum.addElement(varAssum); - //rememberLocals.addElement(varAssum); - } - } - //...und hinzuf�gen: - - assumptions.add(localAssum);//Assumptions für lokale Variablen den Assumptions hinzufügen - - //Hier wird der Typ der als Assumption eingetragen wird in die Variable assumedType dieser Klasse geschrieben: - if(this.assumedType == null) // Falls der Typ nicht schon gesetzt ist. Das ist der Fall, falls die Methode ein Konstruktor ist - this.assumedType = methodAssum.getAssumedType(); - - return assumptions; - */ + * TypeAssumptions assumptions = new TypeAssumptions(); this.assumedType + * = null; //if((this.get_Method_Name().equals(classmember.getName()) || + * this.get_Method_Name().equals("")) && + * ((this.getType().equals(new mycompiler.mytype.Void(0))) || + * this.getType() instanceof TypePlaceholder)){ + * if((this.get_Method_Name().equals(classmember.getName()) || + * this.get_Method_Name().equals(""))) { + * this.set_Method_Name(""); this.assumedType = new + * RefType(classmember.getName(),0); + * this.setReturnType(this.assumedType); this.assumedType = new + * RefType("void",0); //Return constructorReturnStatement = new + * Return(0,0); //constructorReturnStatement.retexpr = + * //this.block.statements.add(constructorReturnStatement); } //hoth: + * 06.04.2006 //durchlaufe Block und suche nach Objektvariablen fuer + * Offset-Markierung Iterator fieldVarIterator = + * assumptions.iterator(); while (fieldVarIterator.hasNext()) { //Wenn + * ObjektVariable CTypeAssumption dieAssum = fieldVarIterator.next(); + * if(dieAssum instanceof CInstVarTypeAssumption) { + * Class.isFirstLocalVarDecl=false; if(this.get_Block() != null) + * this.get_Block + * ().addOffsetsToAssumption(dieAssum,dieAssum.getIdentifier(),true); } + * } + * + * //methodList.addElement(method); + * + * //F�r V_fields_methods: CMethodTypeAssumption methodAssum + * = new CMethodTypeAssumption(classmember.getType(), + * this.get_Method_Name(), this.getType(), + * this.getParameterCount(),this.getLineNumber(),this.getOffset(),new + * Menge(),this.getGenericMethodParameters()); // Typannahme + * bauen... + * + * + * //Methode in V_Fields_methods ablegen //Dabei wird die + * OverloadedMethodID ermittelt !! //=> Method setzenuct + * + * + * assumptions.add(methodAssum); + * this.setOverloadedID(methodAssum.getHashSetKey + * ().getOverloadedMethodID()); + * + * + * //F�r die V_i: CTypeAssumptionSet localAssum = new + * CTypeAssumptionSet(); + * + * //Bauen... ParameterList parameterList = this.getParameterList(); + * if(parameterList!=null){ for(int i=0; + * i()); //fuege Offsets fuer Parameter hinzu, hoth: + * 06.04.2006 Class.isFirstLocalVarDecl=false; + * + * if(this.get_Block() != null) + * this.get_Block().addOffsetsToAssumption(paraAssum + * ,paraAssum.getIdentifier(),true); + * + * methodAssum.addParaAssumption(paraAssum); + * + * // F�r die V_i: CLocalVarTypeAssumption varAssum = new + * CLocalVarTypeAssumption(classmember.getName(), + * this.get_Method_Name(), this.getParameterCount(), + * this.getOverloadedID(),"1", para.get_Name(),para.getType(), + * para.getLineNumber(),para.getOffset(),new Menge()); + * localAssum.addElement(varAssum); + * //rememberLocals.addElement(varAssum); } } //...und + * hinzuf�gen: + * + * assumptions.add(localAssum);//Assumptions für lokale Variablen den + * Assumptions hinzufügen + * + * //Hier wird der Typ der als Assumption eingetragen wird in die + * Variable assumedType dieser Klasse geschrieben: if(this.assumedType + * == null) // Falls der Typ nicht schon gesetzt ist. Das ist der Fall, + * falls die Methode ein Konstruktor ist this.assumedType = + * methodAssum.getAssumedType(); + * + * return assumptions; + */ } - - + @Override - public void parserPostProcessing(SyntaxTreeNode parent){ - if(this.getType()==null)this.setType(TypePlaceholder.fresh(this)); - //Bei dem Elterntyp der Methode darf es sich nur um eine Klasse handeln, daher Cast ohne Prüfung: - //Class parentClass = (Class)parent; - if(this.returntype == null)this.returntype = TypePlaceholder.fresh(this); + public void parserPostProcessing(SyntaxTreeNode parent) { + if (this.getType() == null) + this.setType(TypePlaceholder.fresh(this)); + // Bei dem Elterntyp der Methode darf es sich nur um eine Klasse + // handeln, daher Cast ohne Prüfung: + // Class parentClass = (Class)parent; + if (this.returntype == null) + this.returntype = TypePlaceholder.fresh(this); super.parserPostProcessing(parent); /* - this.returntype.parserPostProcessing(this); - if(this.parameterlist != null){ - for(FormalParameter fp : this.parameterlist){ - fp.parserPostProcessing(this); - } - } - for(GenericTypeVar gtv : this.getGenericParameter()){ - gtv.parserPostProcessing(this); - } - */ + * this.returntype.parserPostProcessing(this); if(this.parameterlist != + * null){ for(FormalParameter fp : this.parameterlist){ + * fp.parserPostProcessing(this); } } for(GenericTypeVar gtv : + * this.getGenericParameter()){ gtv.parserPostProcessing(this); } + */ } - + @Override public Menge getChildren() { Menge ret = new Menge(); @@ -670,47 +687,70 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable ret.add(this.returntype); return ret; } - + @Override - public void setType(Type t){ + public void setType(Type t) { // Methode und Block teilen sich einen ReturnType: - //this.block.setType(t); + // this.block.setType(t); this.returntype = t; - this.returntype.parent = this; //TODO: Dieser Hack sollte nicht nötig sein. (Parser ändern) + this.returntype.parent = this; // TODO: Dieser Hack sollte nicht + // nötig sein. (Parser ändern) } - + /** * Der Typ einer Methode ist ihr Returntype */ @Override - public Type getType(){ - //Methode und Block teilen sich einen ReturnType: + public Type getType() { + // Methode und Block teilen sich einen ReturnType: return this.returntype; } - - public static Method createEmptyMethod(String withSignature, Class parent){ + + public static Method createEmptyMethod(String withSignature, Class parent) { Method ret = new Method(0); DeclId DImethod = new DeclId(); DImethod.set_Name(withSignature); ret.set_DeclId(DImethod); Block tempBlock = new Block(); - //tempBlock.setType(new RefType(parent.getName(),0)); + // tempBlock.setType(new RefType(parent.getName(),0)); ret.set_Block(tempBlock); ret.parserPostProcessing(parent); return ret; } - + @Override - public boolean equals(Object obj){ - if(!(obj instanceof Method))return false; + public boolean equals(Object obj) { + if (!(obj instanceof Method)) + return false; Method equals = (Method) obj; - if((this.returntype!=null && equals.returntype==null))return false; - if((this.returntype==null && equals.returntype!=null))return false; - if(this.returntype!=null && equals.returntype!=null)if(!this.returntype.equals(equals.returntype))return false; - if(!this.parameterlist.equals(equals.parameterlist))return false; + if ((this.returntype != null && equals.returntype == null)) + return false; + if ((this.returntype == null && equals.returntype != null)) + return false; + if (this.returntype != null && equals.returntype != null) + if (!this.returntype.equals(equals.returntype)) + return false; + if (!this.parameterlist.equals(equals.parameterlist)) + return false; return super.equals(obj); } - - + + @Override + public void genByteCode(ClassGen cg) { + /*ConstantPoolGen _cp = cg.getConstantPool(); + * InstructionFactory _factory = new InstructionFactory(cg, _cp); + * InstructionList il = new InstructionList(); + * Class parentClass = this.getParentClass(); + */ + + //oben steht MethodGen method als Variable (Z. 71) + + // Über Statements iterieren um Block abzurufen + for (Statement statements : block.get_Statement()) { + statements.genByteCode(cg); + } + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java index 5a8e494a..deb03d89 100644 --- a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java +++ b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java @@ -1,7 +1,8 @@ package de.dhbwstuttgart.syntaxtree; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.Type; @@ -126,4 +127,6 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{ return this.getParent().getGTVDeclarationContext(); } + + } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java index 03551933..2bfab538 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java @@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -166,5 +167,15 @@ public class Assign extends Expr return ret; } + + + + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java index 2283b0da..c71fbe04 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java @@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -210,6 +211,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { ret.add(this.expr2); return ret; } + + + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java index 639a98c2..6ec92ad5 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java @@ -5,8 +5,16 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.Constants; +import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.InstructionFactory; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.InstructionList; +import org.apache.bcel.generic.MethodGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.myexception.CTypeReconstructionException; @@ -14,6 +22,7 @@ import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.syntaxtree.Class; +import de.dhbwstuttgart.syntaxtree.Field; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.Type; @@ -37,6 +46,9 @@ public class Block extends Statement // ino.end // ino.class.Block.25037.body { + private InstructionFactory _factory; + private ConstantPoolGen _cp; + private ClassGen _cg; // ino.method.Block.25041.definition public Block() @@ -79,6 +91,7 @@ public class Block extends Statement } // ino.end + // ino.method.set_Statement.25068.definition @@ -224,6 +237,7 @@ public class Block extends Statement ret.attach(stmt.printJavaCode(resultSet)); ret.attach((stmt instanceof ExprStmt ? ";" : "") + "\n"); } + return ret.attach("}"); } @@ -241,5 +255,24 @@ public class Block extends Statement public String getDescription(){ return "Block"; } + + @Override + public void genByteCode(ClassGen cg) { + //ConstantPoolGen _cp = cg.getConstantPool(); + InstructionFactory _factory = new InstructionFactory(cg, _cp); + InstructionList il = new InstructionList(); + + //Frage: Wenn Block von Statements erbt, und Block selbst keinen BCEL Code besitzt, ist das hier dann nicht eine Sackgasse? + + //Instructionhandle dynamisch + InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0)); + il.append(_factory.createInvoke(this.getParentClass().superclassid.toString(), "", 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)); + + il.dispose(); + + } } // ino.end + + diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java index c2a7eb92..efcd682a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java @@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.BoolLiteral.8626.import import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -28,7 +30,15 @@ public class BoolLiteral extends Literal // ino.end // ino.class.BoolLiteral.25089.body { - // ino.attribute.Bool.25093.declaration + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + + + + // ino.attribute.Bool.25093.declaration private boolean Bool; // ino.end // ino.attribute.parserlog.25096.declaration diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java index d2b0fedd..71002127 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java @@ -4,8 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.CastExpr.8627.import import java.util.Hashtable; import java.util.Iterator; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -117,6 +119,14 @@ public class CastExpr extends UnaryExpr return ret; } + + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java index b0aa0568..594dc495 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java @@ -3,6 +3,9 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.CharLiteral.8628.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; @@ -107,5 +110,12 @@ public class CharLiteral extends Literal Menge paralist, Menge genericMethodParameters) { } + + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java index ca888b97..cd2ac8a0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java @@ -3,11 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.IntLiteral.8635.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Class; @@ -130,5 +130,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { Menge ret = new Menge(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java index 67c80dc7..a6dc7bbc 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java @@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.EmptyStmt.8629.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Class; @@ -85,5 +86,12 @@ public class EmptyStmt extends Statement return new Menge(); } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java index ed809fab..5ad61fa1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java @@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.IntLiteral.8635.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Class; @@ -126,5 +127,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { Menge ret = new Menge(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java index cbbb7075..723295c3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java @@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -115,4 +116,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { //throw new NotImplementedException(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } \ No newline at end of file diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java index 5e23f141..559dbcb4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java @@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -160,5 +161,13 @@ public class IfStmt extends Statement if(this.then_block!=null)ret.add(this.then_block); return ret; } + + + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java index a223621d..94e49231 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java @@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Class; @@ -214,5 +215,11 @@ public class InstVar extends Expr ret.add(this.expr); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java index e000fe24..fae17dbf 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.InstanceOf.8633.import import java.util.Enumeration; import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCStatementException; @@ -114,6 +115,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { ret.add(this.expr); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java index e9632e9b..3c804482 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java @@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.IntLiteral.8635.import import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -128,5 +130,11 @@ public class IntLiteral extends Literal Menge ret = new Menge(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index 133fe6d0..07d2a1a0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -1,8 +1,10 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCStatementException; @@ -206,4 +208,10 @@ public class LambdaExpression extends Expr{ return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java index 23ada8aa..107c5a3c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java @@ -4,8 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.LocalOrFieldVar.8637.import import java.util.Enumeration; import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -133,5 +135,11 @@ public class LocalOrFieldVar extends Expr return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java index 14b7e3fe..464a692a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.LocalVarDecl.8638.import import java.util.Enumeration; import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -422,5 +423,11 @@ public class LocalVarDecl extends Statement implements TypeInsertable ResultSet resultSet) { return new TypeInsertPoint(this, this, resultSet.getTypeEqualTo(tph),resultSet); } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java index cb9f4272..dcb14c4a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java @@ -3,11 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.IntLiteral.8635.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Class; @@ -125,5 +125,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { Menge ret = new Menge(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index 76461859..3815d88b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.MethodCall.8639.import import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Method; @@ -48,7 +50,6 @@ public class MethodCall extends Expr } // ino.end - // ino.attribute.receiver.25639.declaration /** * Diese Variable speichert die Expression, welche die Klasse von welcher die Methode aufgerufen wird darstellt. @@ -302,6 +303,12 @@ public class MethodCall extends Expr public void parserPostProcessing(SyntaxTreeNode parent) { super.parserPostProcessing(parent); } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java index 8e84ce7f..2562c862 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.NegativeExpr.8640.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -107,5 +108,11 @@ public class NegativeExpr extends UnaryExpr return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java index 3349dd04..6c60bc9c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java @@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.NewArray.8641.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -142,5 +143,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index 91c7d912..cb2c6935 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -5,9 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -201,6 +202,12 @@ public class NewClass extends Expr } return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java index a3cfbb67..d2d2397a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.NotExpr.8643.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCStatementException; @@ -132,5 +133,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java index 325e6727..5cac43a3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java @@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.Null.8644.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -89,5 +90,11 @@ public class Null extends Literal return new Menge(); } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java index ab5b1712..deb5ccfe 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java @@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.PositivExpr.8645.import import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -115,5 +116,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java index 3a006cd0..8996932f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.PostDecExpr.8646.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -88,5 +89,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java index 1899fe91..ac16826f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.PostIncExpr.8647.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -94,5 +95,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java index 1f7fd415..78f6647b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.PreDecExpr.8648.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -86,6 +87,11 @@ public class PreDecExpr extends UnaryExpr ret.add(this.expr); return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java index 49df77d5..6b66c5af 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java @@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.PreIncExpr.8649.import import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -89,5 +90,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) { return ret; } + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java index 57ed3ac5..2246614a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java @@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.Return.8651.import import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -126,5 +128,11 @@ public class Return extends Statement public Type getReturnType(){ return this.getType(); } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java index b844a30f..70d3e540 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java @@ -4,8 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.Statement.8652.import import java.util.Enumeration; import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.InstructionFactory; +import org.apache.bcel.generic.InstructionList; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -122,5 +127,12 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse public Type getReturnType(){ return new de.dhbwstuttgart.syntaxtree.type.Void(this,-1); } -} + + + public abstract void genByteCode(ClassGen _cg); + +} + + + // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java index 20803b2d..f1a87e3b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java @@ -1,9 +1,13 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.typeinference.Menge; +// ino.end +// ino.module.StringLiteral.8653.import +import java.util.Hashtable; + +import org.apache.bcel.generic.ClassGen; import de.dhbwstuttgart.typeinference.Menge; - - import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; @@ -97,6 +101,12 @@ public class StringLiteral extends Literal public String toString(){ return "\""+this.string+"\""; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java index cc13362f..dfb5f32a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java @@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.This.8654.import import java.util.Hashtable; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; @@ -139,5 +141,11 @@ public class This extends Expr Menge ret = new Menge(); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java index 2de82c39..44d1eca3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java @@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + +import org.apache.bcel.generic.ClassGen; + import de.dhbwstuttgart.typeinference.Menge; - import de.dhbwstuttgart.logger.Logger; - import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.SCExcept; @@ -133,5 +134,11 @@ public class WhileStmt extends Statement ret.add(this.loop_block); return ret; } + + @Override + public void genByteCode(ClassGen _cg) { + // TODO Auto-generated method stub + + } } // ino.end diff --git a/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java b/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java index e0f2b382..b83a5d65 100644 --- a/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java +++ b/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java @@ -1,38 +1,24 @@ package de.dhbwstuttgart.typeinference; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; public class ByteCodeResult{ - private String byteCode = ""; + private ClassGen byteCode; //TODO: unresolvedTPHs entfernen. BROKEN! private Menge unresolvedTPHs = new Menge(); - public ByteCodeResult(){ - + public ByteCodeResult(ClassGen byteCode){ + this.byteCode = byteCode; } - public ByteCodeResult(String byteCode){ - this.byteCode += byteCode; - } - - public String getByteCode(){ + public ClassGen getByteCode(){ return byteCode; } - public ByteCodeResult attach(ByteCodeResult byteCodeResult){ - this.byteCode += byteCodeResult.getByteCode(); - //Alle TPH anfügen: - for(TypePlaceholder tph : byteCodeResult.getUnresolvedTPH())this.addUnresolvedTPH(tph); - return this; - } - - public ByteCodeResult attach(String javaCode){ - this.byteCode += javaCode; - return this; - } public void addUnresolvedTPH(TypePlaceholder typePlaceholder) { unresolvedTPHs.add(typePlaceholder); @@ -49,7 +35,7 @@ public class ByteCodeResult{ @Override public String toString(){ - return getByteCode(); + return getByteCode().toString(); } @Override diff --git a/test/bytecode/EmptyClass.jav b/test/bytecode/EmptyClass.jav index 29d3c626..44dfecf2 100644 --- a/test/bytecode/EmptyClass.jav +++ b/test/bytecode/EmptyClass.jav @@ -1,2 +1,7 @@ class EmptyClass{ + +public EmptyClass(){} + +public void leckMichAmArsch(){} + } \ No newline at end of file diff --git a/test/bytecode/EmptyClass.java b/test/bytecode/EmptyClass.java index 44c78d50..5ce92d79 100644 --- a/test/bytecode/EmptyClass.java +++ b/test/bytecode/EmptyClass.java @@ -13,6 +13,7 @@ import plugindevelopment.TypeInsertTester; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.core.MyCompilerAPI; import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.parser.JavaParser.yyException; import de.dhbwstuttgart.typeinference.ByteCodeResult; import de.dhbwstuttgart.typeinference.Menge; @@ -23,16 +24,18 @@ public class EmptyClass { public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; public final static String testFile = "EmptyClass.jav"; - + public final static String outputFile = "EmptyClassTest.class"; + @Test public void test() { - LoggerConfiguration logConfig = new LoggerConfiguration(); + LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out); MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { compiler.parse(new File(rootDirectory + testFile)); compiler.typeReconstruction(); ByteCodeResult bytecode = compiler.generateBytecode(); System.out.println(bytecode); + bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile)); } catch (IOException | yyException e) { e.printStackTrace(); TestCase.fail();