JavaPatternMatching/src/de/dhbwstuttgart/syntaxtree/Interface.java

257 lines
6.9 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.Interface.8582.package
2014-09-04 14:35:44 +00:00
package de.dhbwstuttgart.syntaxtree;
2013-10-18 11:33:46 +00:00
// ino.end
// ino.module.Interface.8582.import
import de.dhbwstuttgart.typeinference.Menge;
2014-02-12 01:12:12 +00:00
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.core.AClassOrInterface;
2014-09-04 14:35:44 +00:00
import de.dhbwstuttgart.myexception.JVMCodeException;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.syntaxtree.misc.UsedId;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
2013-10-18 11:33:46 +00:00
/**
* Ein Interface ist eine abstrakte Klasse, erbt daher von Class
* @author janulrich
*
*/
public class Interface extends Class {
public Interface(String name, int offset){
super(name, offset);
}
public Interface(String name, Modifiers modifiers, int offset) {
super(name,modifiers, offset);
}
public Menge getParaList() {
// TODO Auto-generated method stub
return null;
}
public void setInterfaceBody(InterfaceBody interfaceBody) {
// TODO Auto-generated method stub
}
public void setParaList(Menge<Type> paraMenge) {
// TODO Auto-generated method stub
}
}
2013-10-18 11:33:46 +00:00
// ino.class.Interface.23932.description type=javadoc
/**
* Die Klasse stellt die Definition eines Interfaces dar.
* @author SCJU
*
*/
/*
2013-10-18 11:33:46 +00:00
// ino.end
// ino.class.Interface.23932.declaration
2014-02-12 01:12:12 +00:00
public class Interface implements AClassOrInterface
2013-10-18 11:33:46 +00:00
// ino.end
// ino.class.Interface.23932.body
{
// ino.attribute.ib.23936.declaration
private InterfaceBody ib;
// ino.end
// ino.attribute.paralist.23939.decldescription type=line
// HOTI 29. Apr 06
// ino.end
// ino.attribute.paralist.23939.declaration
private Menge<Type> paralist = new Menge<Type>(); // Parameterliste 'interface xy<para1, para2,...>{}' wird gespeichert
2013-10-18 11:33:46 +00:00
// ino.end
// ino.attribute.containedTypes.23942.declaration
private Menge<Type> containedTypes;
2013-10-18 11:33:46 +00:00
// ino.end
// ino.method.Interface.23945.defdescription type=line
// Konstruktoren
// ino.end
// ino.method.Interface.23945.definition
public Interface()
// ino.end
// ino.method.Interface.23945.body
{
super();
}
// ino.end
// ino.method.Interface.23948.definition
public Interface(String name)
// ino.end
// ino.method.Interface.23948.body
{
super(name);
}
// ino.end
// ino.method.Interface.23951.definition
public Interface(String name, Modifiers mod)
// ino.end
// ino.method.Interface.23951.body
{
super(name, mod);
}
// ino.end
2013-10-18 11:33:46 +00:00
// ino.method.getParaList.23954.definition
public Menge<Type> getParaList()
2013-10-18 11:33:46 +00:00
// ino.end
// ino.method.getParaList.23954.body
{
return this.paralist;
}
// ino.end
// ino.method.setParaList.23957.definition
public void setParaList(Menge<Type> paralist)
2013-10-18 11:33:46 +00:00
// ino.end
// ino.method.setParaList.23957.body
{
this.paralist=paralist;
}
// ino.end
// ino.method.setContainedTypes.23960.definition
public void setContainedTypes(Menge<Type> containedTypes)
2013-10-18 11:33:46 +00:00
// ino.end
// ino.method.setContainedTypes.23960.body
{
this.containedTypes = containedTypes;
}
// ino.end
// ino.method.getContainedTypes.23963.definition
public Menge<Type> getContainedTypes()
2013-10-18 11:33:46 +00:00
// ino.end
// ino.method.getContainedTypes.23963.body
{
return containedTypes;
}
// ino.end
// ino.method.codegen.23966.definition
public void codegen(SourceFile sf)
throws JVMCodeException
// ino.end
// ino.method.codegen.23966.body
{
codegenlog.info("Definierte Superinterfaces: " + getSuperInterfaces().size());
codegenlog.debug("Liste der Interfaces: " + getSuperInterfaces().toString());
codegenlog.info("Definierte Konstanten: " + ib.getConstantVektor().size());
codegenlog.info("Definierte Methoden: " + ib.getMethodVektor().size());
// Erzeugen einer Classfile auf Basis des Interfaces
ClassFile classfile = new ClassFile(this, sf);
// Handling fuer Generics
classfile.addGenerics(paralist, null, getSuperInterfaces());
// Handling fuer Superinterfaces
classfile.addSuperInterfaces(getSuperInterfaces());
// Codegen fuer Interface-Body
Menge<Type> paralist = new Menge<Type>();
2013-10-18 11:33:46 +00:00
if(ib != null) ib.codegen(classfile, paralist);
classfile.codegen();
codegenlog.info("Compilierung erfolgreich abgeschlossen, "+ getName() + ".class erstellt.");
}
// ino.end
// ino.method.getInterfaceBody.23969.definition
public InterfaceBody getInterfaceBody()
// ino.end
// ino.method.getInterfaceBody.23969.body
{
return ib;
}
// ino.end
// ino.method.setInterfaceBody.23972.definition
public void setInterfaceBody(InterfaceBody ib)
// ino.end
// ino.method.setInterfaceBody.23972.body
{
this.ib = ib;
}
// ino.end
// ino.end
// ino.method.isAGenericType.23978.definition
public boolean isAGenericType(RefType type)
// ino.end
// ino.method.isAGenericType.23978.body
{
if(paralist==null)
return false;
for(int i=0;i<paralist.size();i++){
if(paralist.get(i) instanceof GenericTypeVar){
GenericTypeVar gtv=(GenericTypeVar)paralist.get(i);
if(gtv.getName().equals(type.getName())){
return true;
}
}
}
return(false);
}
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23981.defdescription type=javadoc
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23981.definition
public void wandleRefTypeAttributes2GenericAttributes()
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23981.body
{
if(ib==null)
return;
Menge<Method> methods=ib.MethodVektor;
2013-10-18 11:33:46 +00:00
// Alle Methoden durchgehen
for(int i=0;i<methods.size();i++){
Method method=methods.get(i);
method.wandleRefTypeAttributes2GenericAttributes(paralist);
}
for(int i=0;i<ib.ConstantVektor.size();i++){
Constant instVar=(Constant)ib.ConstantVektor.get(i);
Type type=instVar.getType();
// Nur wenn es sich um ein RefType-Field handelt
if(type instanceof RefType){
GenericTypeVar pendant=ClassHelper.findGenericType(type,paralist,null);
if(pendant!=null){ //Wenn generisch, dann modifizieren
instVar.setType(pendant);
}
}
}
}
// ino.end
2014-02-12 01:12:12 +00:00
2013-10-18 11:33:46 +00:00
}
// ino.end
*/