forked from JavaTX/JavaCompilerCore
Backup
This commit is contained in:
parent
7a556fbafb
commit
31473630f8
@ -6,9 +6,9 @@ Backup von JavaParser.jay 10.April 17 Uhr
|
|||||||
|
|
||||||
package mycompiler.myparser;
|
package mycompiler.myparser;
|
||||||
|
|
||||||
|
import mycompiler.myclass.FieldDeclaration;
|
||||||
|
import mycompiler.myclass.Field;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import mycompiler.myclass.FieldInitialization;
|
|
||||||
import mycompiler.SourceFile;
|
import mycompiler.SourceFile;
|
||||||
import mycompiler.AClassOrInterface;
|
import mycompiler.AClassOrInterface;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
@ -18,7 +18,6 @@ import mycompiler.myclass.Constant;
|
|||||||
import mycompiler.myclass.ImportDeclarations;
|
import mycompiler.myclass.ImportDeclarations;
|
||||||
import mycompiler.myclass.DeclId;
|
import mycompiler.myclass.DeclId;
|
||||||
import mycompiler.myclass.ExceptionList;
|
import mycompiler.myclass.ExceptionList;
|
||||||
import mycompiler.myclass.FieldDecl;
|
|
||||||
import mycompiler.myclass.FormalParameter;
|
import mycompiler.myclass.FormalParameter;
|
||||||
import mycompiler.myclass.InstVarDecl;
|
import mycompiler.myclass.InstVarDecl;
|
||||||
import mycompiler.myclass.Method;
|
import mycompiler.myclass.Method;
|
||||||
@ -207,21 +206,21 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <Interface> interfacedeclaration
|
%type <Interface> interfacedeclaration
|
||||||
%type <InterfaceBody> interfacebody
|
%type <InterfaceBody> interfacebody
|
||||||
%type <InterfaceBody> interfacememberdeclarations
|
%type <InterfaceBody> interfacememberdeclarations
|
||||||
%type <FieldDecl> interfacememberdeclaration
|
%type <Field> interfacememberdeclaration
|
||||||
%type <Method> abstractmethoddeclaration
|
%type <Method> abstractmethoddeclaration
|
||||||
%type <ClassBody> classbody
|
%type <ClassBody> classbody
|
||||||
%type <ClassAndParameter> classidentifier
|
%type <ClassAndParameter> classidentifier
|
||||||
%type <InterfaceAndParameter> interfaceidentifier
|
%type <InterfaceAndParameter> interfaceidentifier
|
||||||
%type <Constant> constantdeclaration
|
%type <Constant> constantdeclaration
|
||||||
%type <FieldDecl> fielddeclaration
|
%type <Field> fielddeclaration
|
||||||
%type <Method> methodheader
|
%type <Method> methodheader
|
||||||
%type <Method> methoddeclaration
|
%type <Method> methoddeclaration
|
||||||
%type <Method> methoddeclarator
|
%type <Method> methoddeclarator
|
||||||
%type <ClassBody> classbodydeclarations
|
%type <ClassBody> classbodydeclarations
|
||||||
%type <FieldDecl> classbodydeclaration
|
%type <Field> classbodydeclaration
|
||||||
%type <FieldDecl> classmemberdeclaration
|
%type <Field> classmemberdeclaration
|
||||||
%type <InstVarDecl> variabledeclarators
|
%type <InstVarDecl> variabledeclarators
|
||||||
%type <FieldInitialization> fielddeclarator;
|
%type <FieldDeclaration> fielddeclarator;
|
||||||
%type <DeclId> variabledeclarator
|
%type <DeclId> variabledeclarator
|
||||||
%type <DeclId> variabledeclaratorid
|
%type <DeclId> variabledeclaratorid
|
||||||
%type <UsedId> simplename
|
%type <UsedId> simplename
|
||||||
@ -309,7 +308,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <ArgumentList> argumentlist
|
%type <ArgumentList> argumentlist
|
||||||
%type <MethodCall> methodinvocation
|
%type <MethodCall> methodinvocation
|
||||||
%type <AClassOrInterface> typedeclaration
|
%type <AClassOrInterface> typedeclaration
|
||||||
%type <FieldDecl> constructordeclaration
|
%type <Field> constructordeclaration
|
||||||
%type <Constructor> constructordeclarator
|
%type <Constructor> constructordeclarator
|
||||||
%type <Block> constructorbody
|
%type <Block> constructorbody
|
||||||
%type <Statement> explicitconstructorinvocation
|
%type <Statement> explicitconstructorinvocation
|
||||||
@ -871,7 +870,7 @@ Dieses Problem ist bei Feldern nicht der Fall.
|
|||||||
*/
|
*/
|
||||||
fielddeclarator : variabledeclarator '=' expression
|
fielddeclarator : variabledeclarator '=' expression
|
||||||
{
|
{
|
||||||
FieldInitialization ret = new FieldInitialization();
|
FieldDeclaration ret = new FieldDeclaration();
|
||||||
ret.set_DeclId($1);
|
ret.set_DeclId($1);
|
||||||
ret.setWert($3);
|
ret.setWert($3);
|
||||||
$$=ret;
|
$$=ret;
|
||||||
|
@ -41,8 +41,11 @@ import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.xml.DOMConfigurator;
|
import org.apache.log4j.xml.DOMConfigurator;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xerces.internal.impl.xs.identity.Field;
|
||||||
|
|
||||||
import typinferenz.TypinferenzException;
|
import typinferenz.TypinferenzException;
|
||||||
// ino.end
|
// ino.end
|
||||||
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -297,8 +300,8 @@ public class MyCompiler implements MyCompilerAPI
|
|||||||
{
|
{
|
||||||
Class tempKlasse = null;
|
Class tempKlasse = null;
|
||||||
ClassBody tempKlassBody = null;
|
ClassBody tempKlassBody = null;
|
||||||
Vector<FieldDecl> tempVectorFieldDecl;
|
Vector<mycompiler.myclass.Field> tempVectorFieldDecl;
|
||||||
FieldDecl tempFieldDecl = null;
|
mycompiler.myclass.Field tempFieldDecl = null;
|
||||||
String strKlasse;
|
String strKlasse;
|
||||||
|
|
||||||
for( int i = 0; i < srcFile.KlassenVektor.size(); i++ )
|
for( int i = 0; i < srcFile.KlassenVektor.size(); i++ )
|
||||||
@ -320,13 +323,13 @@ public class MyCompiler implements MyCompilerAPI
|
|||||||
parserlog.debug( "------------------------------------");
|
parserlog.debug( "------------------------------------");
|
||||||
|
|
||||||
// Schleife <EFBFBD>ber alle fielddeclarations
|
// Schleife <EFBFBD>ber alle fielddeclarations
|
||||||
tempVectorFieldDecl = tempKlassBody.get_FieldDeclVector();
|
tempVectorFieldDecl = tempKlassBody.getFields();
|
||||||
for( int k = 0; k < tempVectorFieldDecl.size(); k++ )
|
for( int k = 0; k < tempVectorFieldDecl.size(); k++ )
|
||||||
{
|
{
|
||||||
tempFieldDecl = tempVectorFieldDecl.elementAt(k);
|
tempFieldDecl = tempVectorFieldDecl.elementAt(k);
|
||||||
if( tempFieldDecl instanceof Constructor )
|
if( tempFieldDecl instanceof Constructor )
|
||||||
{
|
{
|
||||||
parserlog.debug("T->Konstruktor: " + ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name() + " - ReturnType: " + tempFieldDecl.getTypeName());
|
//parserlog.debug("T->Konstruktor: " + ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name() + " - ReturnType: " + tempFieldDecl.getTypeName());
|
||||||
|
|
||||||
// pr<EFBFBD>fen, ob Construktorname == Klassenname - falls nein: Construktor in Methode umwandeln !!!
|
// pr<EFBFBD>fen, ob Construktorname == Klassenname - falls nein: Construktor in Methode umwandeln !!!
|
||||||
String strConstName = ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name(); // Konstruktorname
|
String strConstName = ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name(); // Konstruktorname
|
||||||
@ -359,12 +362,9 @@ public class MyCompiler implements MyCompilerAPI
|
|||||||
}
|
}
|
||||||
if( tempFieldDecl instanceof Method && !(tempFieldDecl instanceof Constructor) )
|
if( tempFieldDecl instanceof Method && !(tempFieldDecl instanceof Constructor) )
|
||||||
{
|
{
|
||||||
parserlog.debug("T->Methode: " + ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name() + " - ReturnType: " + tempFieldDecl.getTypeName());
|
//parserlog.debug("T->Methode: " + ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name() + " - ReturnType: " + tempFieldDecl.getTypeName());
|
||||||
}
|
|
||||||
if( tempFieldDecl instanceof InstVarDecl )
|
|
||||||
{
|
|
||||||
parserlog.debug("T->Instanzv.: " + ((DeclId)tempFieldDecl.get_Name().elementAt(0)).get_Name() + " - ReturnType: " + tempFieldDecl.getTypeName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugg-Infos
|
// Debugg-Infos
|
||||||
@ -549,8 +549,10 @@ public class MyCompiler implements MyCompilerAPI
|
|||||||
inferencelog.info("##########################################");
|
inferencelog.info("##########################################");
|
||||||
inferencelog.info("# TypeReconstruction-Algorithmus - START #");
|
inferencelog.info("# TypeReconstruction-Algorithmus - START #");
|
||||||
inferencelog.info("##########################################\n");
|
inferencelog.info("##########################################\n");
|
||||||
|
|
||||||
Vector<TypeinferenceResultSet> result = m_AbstractSyntaxTree.typeReconstruction();
|
TypeAssumptions globalAssumptions = m_AbstractSyntaxTree.makeBasicAssumptions();
|
||||||
|
|
||||||
|
Vector<TypeinferenceResultSet> result = m_AbstractSyntaxTree.typeReconstruction(globalAssumptions);
|
||||||
|
|
||||||
inferencelog.info("#########################################");
|
inferencelog.info("#########################################");
|
||||||
inferencelog.info("# TypeReconstruction-Algorithmus - ENDE #");
|
inferencelog.info("# TypeReconstruction-Algorithmus - ENDE #");
|
||||||
|
@ -40,6 +40,9 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
|
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
|
||||||
|
import typinferenz.ConstraintsSet;
|
||||||
|
import typinferenz.FunN;
|
||||||
|
import typinferenz.UndConstraint;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
|
|
||||||
@ -599,6 +602,15 @@ public class SourceFile
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
public TypeAssumptions getPublicFieldAssumptions(){
|
||||||
|
TypeAssumptions publicAssumptions = new TypeAssumptions();
|
||||||
|
//Alle PublicAssumptions der in dieser SourceFile enthaltenen Klassen sammeln:
|
||||||
|
for(Class klasse : KlassenVektor){
|
||||||
|
publicAssumptions.add(klasse.getPublicFieldAssumptions());
|
||||||
|
}
|
||||||
|
return publicAssumptions;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// TypeReconstructionAlgorithmus
|
// TypeReconstructionAlgorithmus
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
@ -614,12 +626,105 @@ public class SourceFile
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.typeReconstruction.21406.definition
|
// ino.method.typeReconstruction.21406.definition
|
||||||
public Vector<TypeinferenceResultSet> typeReconstruction()
|
public Vector<TypeinferenceResultSet> typeReconstruction(TypeAssumptions globalAssumptions)
|
||||||
throws CTypeReconstructionException
|
throws CTypeReconstructionException
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.typeReconstruction.21406.body
|
// ino.method.typeReconstruction.21406.body
|
||||||
{
|
{
|
||||||
|
Vector<TypeinferenceResultSet> ret = new Vector<TypeinferenceResultSet>();
|
||||||
|
|
||||||
|
//Logger initialisieren:
|
||||||
|
Logger typinferenzLog = Logger.getLogger("Typeinference");
|
||||||
|
|
||||||
|
//FiniteClosure generieren:
|
||||||
|
FC_TTO finiteClosure = this.makeFC();
|
||||||
|
|
||||||
|
//Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln:
|
||||||
|
for(Class klasse : KlassenVektor){
|
||||||
|
ConstraintsSet oderConstraints = klasse.typeReconstruction(finiteClosure, globalAssumptions);
|
||||||
|
|
||||||
|
//Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden):
|
||||||
|
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
|
||||||
|
for(Vector<UndConstraint> uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
|
||||||
|
Vector<Pair> cons = new Vector<Pair>();
|
||||||
|
for(UndConstraint undCons:uC){
|
||||||
|
cons.addAll(undCons.getConstraintPairs());
|
||||||
|
}
|
||||||
|
xConstraints.add(cons);
|
||||||
|
}
|
||||||
|
typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints);
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// Unifizierung der Constraints:
|
||||||
|
//////////////////////////////
|
||||||
|
for(Vector<Pair> constraints : xConstraints){
|
||||||
|
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
|
||||||
|
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
|
||||||
|
|
||||||
|
//Alle FunN-Typen werden per clone-methode in RefTypes verwandelt. (Die clone Methode in FunN darf nicht überschrieben werden.
|
||||||
|
for(Pair p : constraints){
|
||||||
|
if(p.TA1 instanceof FunN){
|
||||||
|
p.TA1 = p.TA1.clone();
|
||||||
|
}
|
||||||
|
if(p.TA2 instanceof FunN){
|
||||||
|
p.TA2 = p.TA2.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Erst die Unifizierung erstellen:
|
||||||
|
Vector<Vector<Pair>> unifyResult = Unify.unify(constraints, finiteClosure);
|
||||||
|
//Dann den Ergebnissen anfügen
|
||||||
|
result.addAll(unifyResult);
|
||||||
|
|
||||||
|
// Debugoutput:Vector<Vector<Pair>>
|
||||||
|
typinferenzLog.debug("Unifiziertes Ergebnis: "+result);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Prüfe ob eindeutige Lösung:
|
||||||
|
if(result.size()>1 && !Unify.hasSolvedForm(result.elementAt(0))){
|
||||||
|
|
||||||
|
typinferenzLog.debug("Keine eindeutige Lösung!");
|
||||||
|
|
||||||
|
}else if(result.size()>1){
|
||||||
|
|
||||||
|
//Replace TPH:
|
||||||
|
for(Pair res : result.elementAt(0)){
|
||||||
|
if(res.OperatorEqual()){
|
||||||
|
if(res.TA1 instanceof TypePlaceholder)((TypePlaceholder)res.TA1).fireReplaceTypeEvent(new CReplaceTypeEvent(res.TA1, res.TA2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//typinferenzLog.debug();
|
||||||
|
//typinferenzLog.debug(supportData.getFiniteClosure());
|
||||||
|
//typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers));
|
||||||
|
|
||||||
|
typinferenzLog.debug("\nJavaFiles:\n");
|
||||||
|
|
||||||
|
//typinferenzLog.debug(this.printJavaCode(new ResultSet(new Vector<Pair>())));
|
||||||
|
|
||||||
|
|
||||||
|
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
|
||||||
|
for(Vector<Pair> resultSet : result){
|
||||||
|
//Add Result set as a new ReconstructionResult to ret:
|
||||||
|
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse);
|
||||||
|
reconstructionResult.setConstraints(constraints);
|
||||||
|
reconstructionResult.setUnifiedConstraints(resultSet);
|
||||||
|
ret.add(reconstructionResult);
|
||||||
|
|
||||||
|
//ResultSet res = new ResultSet(resultSet);
|
||||||
|
typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n");
|
||||||
|
typinferenzLog.debug(klasse.printJavaCode(reconstructionResult));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
/*
|
||||||
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit
|
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit
|
||||||
// in der GUI (Eclipse-Plugin) die Console nicht zugemüllt wird.
|
// in der GUI (Eclipse-Plugin) die Console nicht zugemüllt wird.
|
||||||
// Wers braucht kanns natürlich ausschalten
|
// Wers braucht kanns natürlich ausschalten
|
||||||
@ -739,10 +844,11 @@ public class SourceFile
|
|||||||
Class cl = class_it.next();
|
Class cl = class_it.next();
|
||||||
CSupportData supportData = new CSupportData(finiteClosure, A, cl.getName(), cl.get_ParaList());
|
CSupportData supportData = new CSupportData(finiteClosure, A, cl.getName(), cl.get_ParaList());
|
||||||
inferencelog.info("Rufe " + cl.getName() + ".TRProg()...");
|
inferencelog.info("Rufe " + cl.getName() + ".TRProg()...");
|
||||||
A.addAll(cl.TRProg(supportData, publicFieldsAssumptions));
|
A.addAll(cl.typeReconstruction(supportData, publicFieldsAssumptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
return A;
|
return A;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@ -1102,7 +1208,7 @@ public class SourceFile
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.makeBasicAssumptions.21418.definition
|
// ino.method.makeBasicAssumptions.21418.definition
|
||||||
private TypeAssumptions makeBasicAssumptions()
|
public TypeAssumptions makeBasicAssumptions()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.makeBasicAssumptions.21418.body
|
// ino.method.makeBasicAssumptions.21418.body
|
||||||
{
|
{
|
||||||
|
5
src/mycompiler/SyntaxTreeNode.java
Normal file
5
src/mycompiler/SyntaxTreeNode.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package mycompiler;
|
||||||
|
|
||||||
|
public interface SyntaxTreeNode {
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import mycompiler.AClassOrInterface;
|
import mycompiler.AClassOrInterface;
|
||||||
|
import mycompiler.SyntaxTreeNode;
|
||||||
import mycompiler.mybytecode.ClassFile;
|
import mycompiler.mybytecode.ClassFile;
|
||||||
import mycompiler.myexception.CTypeReconstructionException;
|
import mycompiler.myexception.CTypeReconstructionException;
|
||||||
import mycompiler.myexception.JVMCodeException;
|
import mycompiler.myexception.JVMCodeException;
|
||||||
@ -42,6 +43,7 @@ import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
|
|||||||
import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
|
import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
|
||||||
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
||||||
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
|
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
|
||||||
|
import mycompiler.mytypereconstruction.unify.FC_TTO;
|
||||||
import mycompiler.mytypereconstruction.unify.Unify;
|
import mycompiler.mytypereconstruction.unify.Unify;
|
||||||
import mycompiler.SourceFile;
|
import mycompiler.SourceFile;
|
||||||
|
|
||||||
@ -49,6 +51,8 @@ import org.apache.log4j.Logger;
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
@ -62,7 +66,7 @@ import typinferenz.assumptions.TypeAssumptions;
|
|||||||
|
|
||||||
|
|
||||||
// ino.class.Class.23010.declaration
|
// ino.class.Class.23010.declaration
|
||||||
public class Class extends AClassOrInterface
|
public class Class extends AClassOrInterface implements SyntaxTreeNode
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Class.23010.body
|
// ino.class.Class.23010.body
|
||||||
{
|
{
|
||||||
@ -196,110 +200,6 @@ public class Class extends AClassOrInterface
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.para_check.23059.definition
|
|
||||||
public void para_check(Vector<Class> classlist, boolean ext)
|
|
||||||
throws SCClassException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.para_check.23059.body
|
|
||||||
{
|
|
||||||
//pr�ft, ob jeder Key in der parahash-Tabelle auch im Vector paralist steht bzw. umgekehrt.
|
|
||||||
|
|
||||||
parahash = body.init_parahashtable(paralist,ext);
|
|
||||||
// Para_check erstellt Hashtabelle der Klasse this.get_classname + parahash.toString()+paralist.toString());
|
|
||||||
|
|
||||||
for(Enumeration el = paralist.elements(); el.hasMoreElements();)
|
|
||||||
{
|
|
||||||
Type typ = (Type)el.nextElement();
|
|
||||||
if(!parahash.contains(typ.getName()))
|
|
||||||
{
|
|
||||||
parserlog.error("");
|
|
||||||
parserlog.error("Fehler: unbekannter Parameter: "+ typ.getName());
|
|
||||||
|
|
||||||
SCExcept neu=new SCExcept();
|
|
||||||
neu.set_error("Fehler: unbekannter Parameter: "+ typ.getName());
|
|
||||||
neu.set_statement("Class");
|
|
||||||
SCClassException except = new SCClassException();
|
|
||||||
Vector<SCExcept> v = new Vector<SCExcept>();
|
|
||||||
v.add(neu);
|
|
||||||
except.addException(v);
|
|
||||||
except.addClassname(getName());
|
|
||||||
throw except;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(superclassid != null)
|
|
||||||
{
|
|
||||||
String superclassname;
|
|
||||||
Vector superclass = superclassid.get_Name();
|
|
||||||
|
|
||||||
// superclass darf nur ein Element haben, da es in Java keine Mehrfachvererbung gibt!
|
|
||||||
for(Enumeration el = superclass.elements();el.hasMoreElements();)
|
|
||||||
{
|
|
||||||
superclassname = (String) el.nextElement();
|
|
||||||
// Alle Klassen in der Klassenliste (enth�lt alle definierten Klassen) durchgehen
|
|
||||||
for ( Enumeration<Class> e2 = classlist.elements(); e2.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
Class basis =e2.nextElement();
|
|
||||||
// Klasse im Vektor == Superklasse
|
|
||||||
if( basis.getName().equals(superclassname) )
|
|
||||||
{
|
|
||||||
if( basis.paralist != null && superclassid!=null && superclassid.get_ParaList()!=null)
|
|
||||||
{
|
|
||||||
// System/.out.println( "Basis: " + basis.get_ParaList() );
|
|
||||||
// if( basis.get_ParaList().size() > 0 ) System/.out.println( "0: " + ((TypePlaceholder)basis.get_ParaList().elementAt(0)).get_Type() );
|
|
||||||
// if( basis.get_ParaList().size() > 1 ) System/.out.println( "1: " + ((TypePlaceholder)basis.get_ParaList().elementAt(1)).get_Type() );
|
|
||||||
// otth: geaender auf vParaOrg
|
|
||||||
if(basis.paralist.size() != this.superclassid.get_ParaList().size())
|
|
||||||
{
|
|
||||||
SCExcept neu = new SCExcept();
|
|
||||||
neu.set_error("Parameterlisten von Basis und Child unterscheiden sich in der L�nge!");
|
|
||||||
neu.set_classname(getName());
|
|
||||||
neu.set_statement("Class");
|
|
||||||
SCClassException except = new SCClassException();
|
|
||||||
Vector<SCExcept> v = new Vector<SCExcept>();
|
|
||||||
v.add(neu);
|
|
||||||
except.addException(v);
|
|
||||||
except.addClassname(getName());
|
|
||||||
// Exceptions werfen aufgrund vom eingestellten
|
|
||||||
// Debug-Level???
|
|
||||||
// if( MyCompiler.DebugLevel != MyCompiler.UNIFICATION_INFO)
|
|
||||||
// throw except;
|
|
||||||
parserlog.debug("Parameterlistenl�ngenpr�fung von Basis- u. Superkl. tempor�r ausgeschalten! - otth");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
parahash = body.complete_parahashtable(classlist, superclassid,parahash, ext);
|
|
||||||
}
|
|
||||||
catch(SCClassBodyException ex){
|
|
||||||
SCClassException except = new SCClassException();
|
|
||||||
except.addException(ex.get_exlist());
|
|
||||||
except.addClassname(getName());
|
|
||||||
throw except;
|
|
||||||
}
|
|
||||||
|
|
||||||
paralist = complete_paralist(ext); //Parameterliste wird um die Eintr�ge der Basisklasse erg�nzt
|
|
||||||
// vParaOrg wird hier nicht veraendert
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// typinferenzLog.debug("\tkeine Vererbung gefunden!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(ext)
|
|
||||||
{
|
|
||||||
string_rec("++ ParaCheck Globale Parameterliste: ",paralist);typinferenzLog.debug();
|
|
||||||
string_rec("++ ParaCheck Globale ParaHashtabelle: ", parahash);typinferenzLog.debug();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.complete_paralist.23062.definition
|
// ino.method.complete_paralist.23062.definition
|
||||||
public Vector<Type> complete_paralist(boolean ext)
|
public Vector<Type> complete_paralist(boolean ext)
|
||||||
@ -320,31 +220,6 @@ public class Class extends AClassOrInterface
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.sc_check_for_extended_classes.23068.definition
|
|
||||||
public void sc_check_for_extended_classes(Vector<Class> classlist, Hashtable<String,String> childhash,boolean ext)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.sc_check_for_extended_classes.23068.body
|
|
||||||
{
|
|
||||||
// Der Semantik-Check f�r Basis-Klassen - Aufgabe: In der mit �bergegeben Hashtable childhash sollen
|
|
||||||
// die geerbten Funktionen und Methoden mit ihren zugeh�rigen Typen eingetragen werden
|
|
||||||
|
|
||||||
String strSuperKlassenName = null;
|
|
||||||
|
|
||||||
// otth: Hat diese Klasse wieder eine Supperklasse?
|
|
||||||
if( superclassid != null)
|
|
||||||
{
|
|
||||||
Vector superclass = superclassid.get_Name();
|
|
||||||
for(Enumeration el = superclass.elements();el.hasMoreElements();) //superclass darf nur ein Element haben!!!
|
|
||||||
{
|
|
||||||
strSuperKlassenName = (String) el.nextElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// otth: Hashtabelle f�r Superklasse erestellen
|
|
||||||
body.sc_init_hashtable_for_extended_classes(classlist, strSuperKlassenName, childhash, paralist, parahash, body.kill, ext);
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.codegen.23071.definition
|
// ino.method.codegen.23071.definition
|
||||||
@ -421,16 +296,7 @@ public class Class extends AClassOrInterface
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.is_member.23083.definition
|
|
||||||
public String is_member(String var)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.is_member.23083.body
|
|
||||||
{
|
|
||||||
Hashtable h;
|
|
||||||
h=body.get_hash();
|
|
||||||
return (String)h.get(var);
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_Superclass_Name.23086.definition
|
// ino.method.get_Superclass_Name.23086.definition
|
||||||
public String get_Superclass_Name()
|
public String get_Superclass_Name()
|
||||||
@ -632,7 +498,7 @@ public class Class extends AClassOrInterface
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.TRProg.23110.definition
|
// ino.method.TRProg.23110.definition
|
||||||
public Vector<TypeinferenceResultSet> TRProg(CSupportData supportData, TypeAssumptions globalAssumptions)
|
public ConstraintsSet typeReconstruction(FC_TTO supportData, TypeAssumptions globalAssumptions)
|
||||||
throws CTypeReconstructionException
|
throws CTypeReconstructionException
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.TRProg.23110.body
|
// ino.method.TRProg.23110.body
|
||||||
@ -666,84 +532,9 @@ public class Class extends AClassOrInterface
|
|||||||
ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
|
ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
|
||||||
typinferenzLog.debug("Erstellte Constraints: "+oderConstraints);
|
typinferenzLog.debug("Erstellte Constraints: "+oderConstraints);
|
||||||
|
|
||||||
//Die Constraints in Pair's umwandeln:
|
return oderConstraints;
|
||||||
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
|
|
||||||
for(Vector<UndConstraint> uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
|
|
||||||
Vector<Pair> cons = new Vector<Pair>();
|
|
||||||
for(UndConstraint undCons:uC){
|
|
||||||
cons.addAll(undCons.getConstraintPairs());
|
|
||||||
}
|
|
||||||
xConstraints.add(cons);
|
|
||||||
}
|
|
||||||
typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints);
|
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
// Unifizierung der Constraints:
|
|
||||||
//////////////////////////////
|
|
||||||
Vector<TypeinferenceResultSet> ret = new Vector<TypeinferenceResultSet>(); //Generiere das Result-Set
|
|
||||||
for(Vector<Pair> constraints : xConstraints){
|
|
||||||
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
|
|
||||||
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
|
|
||||||
|
|
||||||
//Alle FunN-Typen werden per clone-methode in RefTypes verwandelt. (Die clone Methode in FunN darf nicht überschrieben werden.
|
|
||||||
for(Pair p : constraints){
|
|
||||||
if(p.TA1 instanceof FunN){
|
|
||||||
p.TA1 = p.TA1.clone();
|
|
||||||
}
|
|
||||||
if(p.TA2 instanceof FunN){
|
|
||||||
p.TA2 = p.TA2.clone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Erst die Unifizierung erstellen:
|
|
||||||
Vector<Vector<Pair>> unifyResult = Unify.unify(constraints, supportData.getFiniteClosure());
|
|
||||||
//Dann den Ergebnissen anfügen
|
|
||||||
result.addAll(unifyResult);
|
|
||||||
|
|
||||||
// Debugoutput:Vector<Vector<Pair>>
|
|
||||||
typinferenzLog.debug("Unifiziertes Ergebnis: "+result);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Prüfe ob eindeutige Lösung:
|
|
||||||
if(result.size()>1 && !Unify.hasSolvedForm(result.elementAt(0))){
|
|
||||||
|
|
||||||
typinferenzLog.debug("Keine eindeutige Lösung!");
|
|
||||||
|
|
||||||
}else if(result.size()>1){
|
|
||||||
|
|
||||||
//Replace TPH:
|
|
||||||
for(Pair res : result.elementAt(0)){
|
|
||||||
if(res.OperatorEqual()){
|
|
||||||
if(res.TA1 instanceof TypePlaceholder)((TypePlaceholder)res.TA1).fireReplaceTypeEvent(new CReplaceTypeEvent(res.TA1, res.TA2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//typinferenzLog.debug();
|
|
||||||
//typinferenzLog.debug(supportData.getFiniteClosure());
|
|
||||||
typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers));
|
|
||||||
|
|
||||||
typinferenzLog.debug("\nJavaFiles:\n");
|
|
||||||
|
|
||||||
//typinferenzLog.debug(this.printJavaCode(new ResultSet(new Vector<Pair>())));
|
|
||||||
|
|
||||||
|
|
||||||
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
|
|
||||||
for(Vector<Pair> resultSet : result){
|
|
||||||
//Add Result set as a new ReconstructionResult to ret:
|
|
||||||
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(this);
|
|
||||||
reconstructionResult.setConstraints(constraints);
|
|
||||||
reconstructionResult.setUnifiedConstraints(resultSet);
|
|
||||||
ret.add(reconstructionResult);
|
|
||||||
|
|
||||||
//ResultSet res = new ResultSet(resultSet);
|
|
||||||
typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n");
|
|
||||||
typinferenzLog.debug(this.printJavaCode(reconstructionResult));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
/*
|
/*
|
||||||
CReconstructionTupleSet retTupleSet = this.TRStart(methodList, V, V_fields_methods, supportData);
|
CReconstructionTupleSet retTupleSet = this.TRStart(methodList, V, V_fields_methods, supportData);
|
||||||
inferencelog.debug("Bin aus TRStart() zur�ck in TRProg().");
|
inferencelog.debug("Bin aus TRStart() zur�ck in TRProg().");
|
||||||
@ -795,6 +586,8 @@ public class Class extends AClassOrInterface
|
|||||||
* @return Eine Liste mit allen Methoden dieser Klasse
|
* @return Eine Liste mit allen Methoden dieser Klasse
|
||||||
*/
|
*/
|
||||||
private Vector<Method> getMethodList() {
|
private Vector<Method> getMethodList() {
|
||||||
|
//TODO: Diese Methode ersetzen: Nach dem Parsen muss es ein Parser-Postprocessing geben. Anschließend sind alle Felder und Methoden der Klasse bekannt
|
||||||
|
|
||||||
if(this.methodList != null) return this.methodList;
|
if(this.methodList != null) return this.methodList;
|
||||||
//TODO: Unnötige Berechnungen im folgenden Code rauskürzen:
|
//TODO: Unnötige Berechnungen im folgenden Code rauskürzen:
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
@ -812,25 +605,15 @@ public class Class extends AClassOrInterface
|
|||||||
// ge�ndert: hoth 06.04.2006
|
// ge�ndert: hoth 06.04.2006
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
for(FieldDecl field : body.get_FieldDeclVector())
|
for(Field field : body.getFields())
|
||||||
{
|
{
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Attribut:
|
// Attribut:
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
if(field instanceof InstVarDecl){
|
|
||||||
InstVarDecl instVar = (InstVarDecl)field;
|
|
||||||
//////////////////////////////
|
|
||||||
// Alle Variablendeklarationen (int a, b, c) durchgehen:
|
|
||||||
//////////////////////////////
|
|
||||||
for(int i=0; i<instVar.getDeclIdVector().size(); i++){
|
|
||||||
DeclId id = (DeclId)instVar.getDeclIdVector().elementAt(i);
|
|
||||||
CInstVarTypeAssumption assum = new CInstVarTypeAssumption(this.getName(), id.get_Name(), instVar.getType(), instVar.getLineNumber(),instVar.getOffset(),new Vector<Integer>()); // Typannahme bauen...
|
|
||||||
V_fields_methods.add(assum); // ...und hinzuf�gen.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(FieldDecl field : body.get_FieldDeclVector())
|
for(Field field : body.getFields())
|
||||||
{
|
{
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Methode:
|
// Methode:
|
||||||
@ -921,7 +704,7 @@ public class Class extends AClassOrInterface
|
|||||||
//CLocalVarTypeAssumption thisAssumption = new CLocalVarTypeAssumption(this.name, name, 0, 0, name, "this", new RefType(name,0), 0, 0, null);
|
//CLocalVarTypeAssumption thisAssumption = new CLocalVarTypeAssumption(this.name, name, 0, 0, name, "this", new RefType(name,0), 0, 0, null);
|
||||||
//assumptions.setThisV(thisAssumption);
|
//assumptions.setThisV(thisAssumption);
|
||||||
|
|
||||||
for(FieldDecl field : body.get_FieldDeclVector()){
|
for(Field field : body.getFields()){
|
||||||
assumptions.add(field.createTypeAssumptions(this));
|
assumptions.add(field.createTypeAssumptions(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,7 +824,7 @@ public class Class extends AClassOrInterface
|
|||||||
if(body==null)
|
if(body==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector fieldsAndMethods=body.get_FieldDeclVector();
|
Vector fieldsAndMethods=body.getFields();
|
||||||
|
|
||||||
// Alle Methoden und Instanzvariablen durchgehen
|
// Alle Methoden und Instanzvariablen durchgehen
|
||||||
for(int i=0;i<fieldsAndMethods.size();i++){
|
for(int i=0;i<fieldsAndMethods.size();i++){
|
||||||
|
@ -27,13 +27,7 @@ public class ClassBody
|
|||||||
// ino.class.ClassBody.23143.body
|
// ino.class.ClassBody.23143.body
|
||||||
{
|
{
|
||||||
// ino.attribute.fielddecl.23146.declaration
|
// ino.attribute.fielddecl.23146.declaration
|
||||||
private Vector<FieldDecl> fielddecl = new Vector<FieldDecl>();
|
private Vector<Field>fielddecl = new Vector<Field>();
|
||||||
// ino.end
|
|
||||||
// ino.attribute.hash.23149.declaration
|
|
||||||
private Hashtable<String,String> hash = new Hashtable<String,String>(); // otth: Speichert folgende Paare: <Identifier> --> <Type>
|
|
||||||
// ino.end
|
|
||||||
// ino.attribute.paraclasshash.23152.declaration
|
|
||||||
private Hashtable paraclasshash = new Hashtable();
|
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.kill.23155.declaration
|
// ino.attribute.kill.23155.declaration
|
||||||
public Hashtable<Type,Type> kill = new Hashtable<Type,Type>();
|
public Hashtable<Type,Type> kill = new Hashtable<Type,Type>();
|
||||||
@ -43,244 +37,7 @@ public class ClassBody
|
|||||||
protected static Logger parserlog = Logger.getLogger("parser");
|
protected static Logger parserlog = Logger.getLogger("parser");
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.sc_init_hashtable.23161.definition
|
|
||||||
public void sc_init_hashtable( Vector<Class> KlassenVektor, String strSuperKlassenName, String classname, boolean ext )
|
|
||||||
throws SCClassBodyException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.sc_init_hashtable.23161.body
|
|
||||||
{
|
|
||||||
// Methoden und Vardeclarationen werden in die Hashtabelle eingefuegt
|
|
||||||
// KlassenVektor: Vektor mit allen Klassen im Sourcefile
|
|
||||||
// strSuperKlassenName: Name der Superklasse, Klasse ohne Vererbung <--> strSuperKlassenName = null
|
|
||||||
|
|
||||||
SCClassBodyException ex = null;
|
|
||||||
|
|
||||||
// otth: Vektor mit den Felddeklarationen durchgehen und Hashtabelle f<EFBFBD>r Felddeklarationen aufbauen
|
|
||||||
for( Enumeration<FieldDecl> el = fielddecl.elements(); el.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
FieldDecl field = el.nextElement(); // Felddeklaration, also Instanzvariable oder Mehtode
|
|
||||||
Vector v = field.get_Name(); // verschiedene DeclId's, f<EFBFBD>r int a, b, c z.B 3
|
|
||||||
DeclId hilf;
|
|
||||||
Method init;
|
|
||||||
String name; // enth<EFBFBD>lt den Namen des Identifiers, also ein Instanzvariablenname oder ein Methodennamen
|
|
||||||
|
|
||||||
// otth: bei Funktionen: Parameterliste erstellen!
|
|
||||||
if( field instanceof Method )
|
|
||||||
{
|
|
||||||
init=(Method) field;
|
|
||||||
init.sc_init_parameterlist(ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// otth: Vektor einer Felddeklaration mit ver. DeclIds durchgehen -
|
|
||||||
// otth: hier wird z.B. folgende Liste durchlaufen: a, b, c bei int a, b, c;
|
|
||||||
for ( Enumeration el1 = v.elements(); el1.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
hilf = (DeclId)el1.nextElement();
|
|
||||||
name = hilf.get_Name();
|
|
||||||
|
|
||||||
// otth: pr<EFBFBD>fen, ob Identifier bereits vorhanden ???
|
|
||||||
if( hash.containsKey( name ) )
|
|
||||||
{
|
|
||||||
parserlog.error("SEMANTIK-CHECK-Fehler: '" + name + "' ist bereits definiert!\n");
|
|
||||||
//FIXME Throw Exception or Error instead of simple exit the program
|
|
||||||
System.exit(1);
|
|
||||||
|
|
||||||
/* otth: Wenn dieser Code vorhanden ist, wird ... int a; int a; akkzeptiert!
|
|
||||||
String typedervar;
|
|
||||||
typedervar = (String)hash.get(name);
|
|
||||||
if ( !typedervar.equals(field.get_Type()) )
|
|
||||||
// otth: abstrakte Methode, z.B. von InstVarDecl gibt den Typ zur<EFBFBD>ck
|
|
||||||
{
|
|
||||||
SCExcept neu=new SCExcept();
|
|
||||||
neu.set_error("Es kann nicht noch eine Variable mit dem Namen "+name+" angelegt werden.");
|
|
||||||
neu.set_statement("ClassBody");
|
|
||||||
if(ex==null)
|
|
||||||
{
|
|
||||||
System.out.println("neue classbodyexception anlegen");
|
|
||||||
ex=new SCClassBodyException();
|
|
||||||
}
|
|
||||||
ex.addException(neu);
|
|
||||||
if(ext)
|
|
||||||
System.out.println("Exception wurde angelegt!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// otth: Aufnahme in die Hash-Tabelle!
|
|
||||||
// otth: Typen pr<EFBFBD>fen, field.get_Type() z.B. = int oder void, bei null --> Konstruktor
|
|
||||||
if( field.getTypeName() == null )
|
|
||||||
hash.put(name,"__CONSTRUCTOR__");
|
|
||||||
else
|
|
||||||
hash.put(name, field.getTypeName()); // Name & Typ, z.B. "a" --> "int"
|
|
||||||
} // Ende: Schleife <EFBFBD>ber alle Feldvariablendeklarationen
|
|
||||||
}
|
|
||||||
|
|
||||||
// otth: Klassenname in Hash-Tabelle einfuegen
|
|
||||||
hash.put("###_classname", classname);
|
|
||||||
|
|
||||||
// otth: Ist Klasse eine Subklasse?
|
|
||||||
if( strSuperKlassenName != null ) // 'strSuperKlassenName' = <EFBFBD>bergebener Parameter von 'Class'
|
|
||||||
{
|
|
||||||
Class tempKlasse;
|
|
||||||
String strTempKlassenName;
|
|
||||||
hash.put( "###_class_is_extended", "yes" );
|
|
||||||
|
|
||||||
// otth: Basisklasse wird im Vektor aller Klassen 'KlassenVektor` gesucht!
|
|
||||||
|
|
||||||
// <EFBFBD>nderung von otth: Falls Klasse nicht gefunden wurde --> Superklasse ist undefiniert --> Fehler!
|
|
||||||
boolean bSuperKlasseGefunden = false;
|
|
||||||
|
|
||||||
for ( Enumeration<Class> el2 = KlassenVektor.elements(); el2.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
tempKlasse = el2.nextElement();
|
|
||||||
strTempKlassenName = tempKlasse.getName();
|
|
||||||
if( strTempKlassenName.equals( strSuperKlassenName ) )
|
|
||||||
{
|
|
||||||
// otth: Die Hashtabelle wird um die Attribute / Methoden der Superklasse(n) ergaenzt
|
|
||||||
// otth: Funktion 'ClassBody.sc_init_hashtable_for_extended_classes' wird (indirekt) aufgerufen
|
|
||||||
bSuperKlasseGefunden = true;
|
|
||||||
tempKlasse.sc_check_for_extended_classes( KlassenVektor, hash, ext );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// otth: Superklasse mu<EFBFBD> existieren
|
|
||||||
if ( !bSuperKlasseGefunden )
|
|
||||||
{
|
|
||||||
parserlog.error("SEMANTIK-CHECK-Fehler [otth]: Symbol '" + strSuperKlassenName + "' kann nicht aufgel<65>st werden (Location: class " + classname + ").\n" );
|
|
||||||
System.exit( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fehler erkennen und werfen!!!
|
|
||||||
if( ex != null )
|
|
||||||
{
|
|
||||||
parserlog.error("SEMANTIK-CHECK-Fehler: Fehler beim Aufbau der Hash-Tabelle!");
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ersetzen von vordefinierten Parametern bei der Vererbung
|
|
||||||
if( this.kill.size() > 0 )
|
|
||||||
{
|
|
||||||
for(Enumeration e1=this.kill.elements(),e2=this.kill.keys();e1.hasMoreElements();){
|
|
||||||
Type value = (Type)e1.nextElement(), key=(Type)e2.nextElement();
|
|
||||||
for(Enumeration e3=hash.elements(),e4=hash.keys();e3.hasMoreElements();){
|
|
||||||
String v = (String)e3.nextElement(),k=(String)e4.nextElement();
|
|
||||||
if(v.equals(key.getName())){
|
|
||||||
parserlog.debug(v+ " wird durch "+value.getName()+" ersetzt");
|
|
||||||
hash.put(k,value.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parserlog.debug( "SC --> '" + classname + "' --> Hashtabelle (ClassBody.hash):\n" + hash);
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.sc_init_hashtable_for_extended_classes.23164.definition
|
|
||||||
public void sc_init_hashtable_for_extended_classes( Vector<Class> classlist, String strSuperKlassenName, Hashtable<String,String> childhash,Vector paralist, Hashtable parahash,Hashtable kill, boolean ext )
|
|
||||||
// ino.end
|
|
||||||
// ino.method.sc_init_hashtable_for_extended_classes.23164.body
|
|
||||||
{
|
|
||||||
// Hier werden in die <EFBFBD>bergegebene Hashtable die Attribute und Methoden ergaenzt, die vererbt werden.
|
|
||||||
// otth: Struktur <EFBFBD>hnlich wie in 'sc_init_hashtable'
|
|
||||||
|
|
||||||
for( Enumeration<FieldDecl> el = fielddecl.elements(); el.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
FieldDecl field = el.nextElement();
|
|
||||||
Vector v = field.get_Name();
|
|
||||||
DeclId hilf;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
// Hashtabelle erg<EFBFBD>nzen
|
|
||||||
for ( Enumeration el1 = v.elements(); el1.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
hilf=(DeclId)el1.nextElement();
|
|
||||||
name=hilf.get_Name();
|
|
||||||
if(field.getTypeName()==null)
|
|
||||||
childhash.put(name,"__Constructor__"); //Name & Typ
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//string_rec("paralist: ", paralist);System.out.println();
|
|
||||||
childhash.put(name, field.getTypeName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sollte die Basis-Klasse zus<EFBFBD>tzlich erben muss folgendes getan werden:
|
|
||||||
if( strSuperKlassenName != null )
|
|
||||||
{
|
|
||||||
Class hilfe;
|
|
||||||
String hilfsstr;
|
|
||||||
for ( Enumeration<Class> el2=classlist.elements(); el2.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
hilfe=el2.nextElement();
|
|
||||||
hilfsstr=hilfe.getName();
|
|
||||||
if( hilfsstr.equals( strSuperKlassenName ) )
|
|
||||||
hilfe.sc_check_for_extended_classes(classlist,childhash,ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.init_parahashtable.23170.defdescription type=line
|
|
||||||
//
|
|
||||||
// ***NEU*****************************************************************************
|
|
||||||
//
|
|
||||||
// ino.end
|
|
||||||
// ino.method.init_parahashtable.23170.definition
|
|
||||||
public Hashtable<String,String> init_parahashtable(Vector paralist,boolean ext)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.init_parahashtable.23170.body
|
|
||||||
{
|
|
||||||
//hier wird die Hashtabelle erzeugt, die s<EFBFBD>mtliche zuordnungen der parametrisierbaren Variablen enth<EFBFBD>lt.
|
|
||||||
Hashtable<String,String> parahash = new Hashtable<String,String>();
|
|
||||||
FieldDecl decl;
|
|
||||||
|
|
||||||
for(Enumeration<FieldDecl> e = fielddecl.elements(); e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
//Auslesen aller Fielddecl's
|
|
||||||
decl = e.nextElement();
|
|
||||||
|
|
||||||
for(Enumeration el = decl.get_Name().elements(); el.hasMoreElements();)
|
|
||||||
{ //Auslesen der Vectoren der Fielddecl's
|
|
||||||
String key, value;
|
|
||||||
key = ((DeclId)el.nextElement()).get_Name();
|
|
||||||
value = decl.getTypeName();
|
|
||||||
if ( value == null ) value = "###CONSTRUCTOR###"; // otth: eingef<EFBFBD>gt, sonst NULLPOINTEREXCEPTION
|
|
||||||
parahash.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// entfernt ung<EFBFBD>ltige Eintr<EFBFBD>ge in der ParaHashtabelle
|
|
||||||
for(Enumeration e = parahash.elements(), ee=parahash.keys(); e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
String para = (String)e.nextElement();
|
|
||||||
String key = (String)ee.nextElement();
|
|
||||||
Enumeration e1 = paralist.elements();
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if(e1.hasMoreElements())
|
|
||||||
{
|
|
||||||
String typ = ((Type)e1.nextElement()).getName();
|
|
||||||
if(para.equals(typ))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!e1.hasMoreElements())
|
|
||||||
{
|
|
||||||
parahash.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(e1.hasMoreElements());
|
|
||||||
}
|
|
||||||
return parahash;
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.complete_parahashtable.23173.defdescription type=block
|
// ino.method.complete_parahashtable.23173.defdescription type=block
|
||||||
/* public void set_paratype(Vector classlist, UsedId superclass, Vector
|
/* public void set_paratype(Vector classlist, UsedId superclass, Vector
|
||||||
@ -311,122 +68,6 @@ Paratyp gesetzt."); }
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.complete_parahashtable.23173.definition
|
|
||||||
public Hashtable<String,String> complete_parahashtable(Vector<Class> classlist,UsedId superclassid,Hashtable childhash,boolean ext)
|
|
||||||
throws SCClassBodyException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.complete_parahashtable.23173.body
|
|
||||||
{
|
|
||||||
// vervolltaendigt die ParaHashtabelle bei Vererbung
|
|
||||||
Hashtable<String,String> parahash = new Hashtable<String,String>();
|
|
||||||
String superhilf,superclass = (String)superclassid.get_Name_1Element();
|
|
||||||
Class supercl;
|
|
||||||
if(ext)
|
|
||||||
parserlog.debug("++ Para_check hat Vererbung gefunden!");
|
|
||||||
|
|
||||||
for(Enumeration<Class> e=classlist.elements();e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
supercl = e.nextElement();
|
|
||||||
superhilf = supercl.getName();
|
|
||||||
|
|
||||||
if(superhilf.equals(superclass))
|
|
||||||
{
|
|
||||||
parahash = (Hashtable<String,String>) supercl.get_ParaHash().clone();
|
|
||||||
|
|
||||||
// otth: Pruefung: Ist ein Parameter, der keine TypePlaceholder ist
|
|
||||||
// (also RefType mit [=Typkonstruktor] oder ohne Parameter eine bereits definierte Klasse und
|
|
||||||
// stimmt die Anzahl der Parameter eines Typkonstruktors mit der zugeh<EFBFBD>rigen Klassendefinition <EFBFBD>berein?
|
|
||||||
|
|
||||||
// folgende Funktion bricht ab, falls Parameter fehlerhaft
|
|
||||||
istParameterOK( superclassid.get_ParaList(), classlist );
|
|
||||||
// end otth;
|
|
||||||
|
|
||||||
|
|
||||||
if(ext){
|
|
||||||
parserlog.debug(string_rec("++ PC\tParaHash der Basisklasse: ", parahash));
|
|
||||||
parserlog.debug(string_rec("++ PC\tParaList der Basisklasse: ", supercl.get_ParaList()));
|
|
||||||
parserlog.debug(string_rec("++ PC\tParaList der cb - klasse: ", superclassid.get_ParaList()));
|
|
||||||
parserlog.debug(string_rec("++ PC\tchildhash : ", childhash));
|
|
||||||
}
|
|
||||||
|
|
||||||
// falls bei Vererbung ein Parameter bereits festgelegt ist, so wird er hier aus dem ParaList-Vector entfernt
|
|
||||||
Vector<Type> rm = new Vector<Type>(); /* container f<>r zu entfendende Typen */
|
|
||||||
|
|
||||||
for( Enumeration<Class> e2=classlist.elements(); e2.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
Class c = e2.nextElement();
|
|
||||||
for(Enumeration e1=superclassid.get_ParaList().elements();e1.hasMoreElements();)
|
|
||||||
{
|
|
||||||
Type t=(Type)e1.nextElement();
|
|
||||||
|
|
||||||
if(c.getName().equals(t.getName()))
|
|
||||||
{
|
|
||||||
int i = superclassid.get_ParaList().indexOf(t);
|
|
||||||
|
|
||||||
// refe ...
|
|
||||||
if ( t instanceof RefType )
|
|
||||||
{
|
|
||||||
if( ((RefType)t).get_ParaList() != null)
|
|
||||||
{
|
|
||||||
if( ((RefType)t).get_ParaList().size()>0)
|
|
||||||
{
|
|
||||||
/* auf existenz der Parameter pr<70>fen */
|
|
||||||
for(Enumeration e11 = ((RefType)t).get_ParaList().elements();e11.hasMoreElements();)
|
|
||||||
{
|
|
||||||
Type ty = (Type)e11.nextElement();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
is_declared(ty,classlist);
|
|
||||||
}
|
|
||||||
catch(SCClassBodyException ex)
|
|
||||||
{
|
|
||||||
// otth: auskommentiert, den Parameter muessen nicht unbedingt bereits definierte Klassen sein
|
|
||||||
// throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rm.add(t);
|
|
||||||
Type removetype = (Type)supercl.get_ParaList().elementAt(i);
|
|
||||||
|
|
||||||
kill.put(removetype,t);
|
|
||||||
|
|
||||||
for(Enumeration e3=parahash.keys(),e4=parahash.elements();e3.hasMoreElements();)
|
|
||||||
{
|
|
||||||
String key = (String)e3.nextElement();
|
|
||||||
String ele = (String)e4.nextElement();
|
|
||||||
if(ele.equals(removetype.getName()))
|
|
||||||
{
|
|
||||||
parahash.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(rm.size()>0)
|
|
||||||
{
|
|
||||||
for(Enumeration e4 = rm.elements();e4.hasMoreElements();)
|
|
||||||
{
|
|
||||||
Type t=(Type)e4.nextElement();
|
|
||||||
superclassid.get_ParaList().remove(t);
|
|
||||||
parserlog.debug(string_rec("Typ \""+t.getName()+"\" aus ParaList entfernt! ", superclassid.get_ParaList()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Enumeration e=childhash.keys();e.hasMoreElements();){
|
|
||||||
String key = (String)e.nextElement();
|
|
||||||
parahash.put(key,(String)childhash.get(key));
|
|
||||||
}
|
|
||||||
return parahash;
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.codegen.23176.definition
|
// ino.method.codegen.23176.definition
|
||||||
public void codegen(ClassFile classfile, Vector paralist)
|
public void codegen(ClassFile classfile, Vector paralist)
|
||||||
throws JVMCodeException
|
throws JVMCodeException
|
||||||
@ -435,11 +76,13 @@ Paratyp gesetzt."); }
|
|||||||
{
|
{
|
||||||
for(int i=0 ; i < fielddecl.size() ; i++)
|
for(int i=0 ; i < fielddecl.size() ; i++)
|
||||||
{
|
{
|
||||||
if(this.fielddecl.elementAt(i) instanceof InstVarDecl)
|
/*
|
||||||
|
* if(this.fielddecl.elementAt(i) instanceof InstVarDecl)
|
||||||
{
|
{
|
||||||
((InstVarDecl)this.fielddecl.elementAt(i)).codegen(classfile, paralist);
|
((InstVarDecl)this.fielddecl.elementAt(i)).codegen(classfile, paralist);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
this.fielddecl.elementAt(i).codegen(classfile, paralist);
|
this.fielddecl.elementAt(i).codegen(classfile, paralist);
|
||||||
}
|
}
|
||||||
@ -449,17 +92,8 @@ Paratyp gesetzt."); }
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.get_hash.23179.definition
|
|
||||||
public Hashtable get_hash()
|
|
||||||
// ino.end
|
|
||||||
// ino.method.get_hash.23179.body
|
|
||||||
{
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_FieldDeclVector.23182.definition
|
// ino.method.get_FieldDeclVector.23182.definition
|
||||||
public Vector<FieldDecl> get_FieldDeclVector()
|
public Vector<Field> getFields()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.get_FieldDeclVector.23182.body
|
// ino.method.get_FieldDeclVector.23182.body
|
||||||
{
|
{
|
||||||
@ -468,7 +102,7 @@ Paratyp gesetzt."); }
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.set_FieldDecl.23185.definition
|
// ino.method.set_FieldDecl.23185.definition
|
||||||
public void set_FieldDecl(FieldDecl i)
|
public void set_FieldDecl(Field i)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.set_FieldDecl.23185.body
|
// ino.method.set_FieldDecl.23185.body
|
||||||
{
|
{
|
||||||
@ -747,7 +381,7 @@ public void istParameterOK( Vector Parameter, Vector<Class> KlassenVektor )
|
|||||||
|
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
JavaCodeResult ret = new JavaCodeResult("{\n");
|
JavaCodeResult ret = new JavaCodeResult("{\n");
|
||||||
for(FieldDecl field : this.fielddecl)ret.attach( field.printJavaCode(resultSet) ).attach( "\n" );
|
for(Field field : this.fielddecl)ret.attach( field.printJavaCode(resultSet) ).attach( "\n" );
|
||||||
return ret.attach("}\n");
|
return ret.attach("}\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.class.Constant.23212.declaration
|
// ino.class.Constant.23212.declaration
|
||||||
public class Constant extends FieldDecl
|
public class Constant extends Method
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Constant.23212.body
|
// ino.class.Constant.23212.body
|
||||||
{
|
{
|
||||||
|
88
src/mycompiler/myclass/Field.java
Normal file
88
src/mycompiler/myclass/Field.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package mycompiler.myclass;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import mycompiler.mybytecode.ClassFile;
|
||||||
|
import mycompiler.myexception.JVMCodeException;
|
||||||
|
import mycompiler.mytype.Type;
|
||||||
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||||
|
import typinferenz.JavaCodeResult;
|
||||||
|
import typinferenz.ResultSet;
|
||||||
|
import typinferenz.Typable;
|
||||||
|
import typinferenz.TypeInsertable;
|
||||||
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
|
public abstract class Field implements TypeInsertable, Typable{
|
||||||
|
// ino.attribute.declid.23370.declaration
|
||||||
|
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
||||||
|
|
||||||
|
private Type typ;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTypeVariable(Type typ) {
|
||||||
|
this.typ = typ;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Type getTypeVariable() {
|
||||||
|
return typ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ino.method.codegen.23376.declaration
|
||||||
|
public abstract void codegen(ClassFile classfile, Vector paralist)
|
||||||
|
throws JVMCodeException;
|
||||||
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ino.method.set_DeclId.23379.definition
|
||||||
|
public void set_DeclId(DeclId did)
|
||||||
|
// ino.end
|
||||||
|
// ino.method.set_DeclId.23379.body
|
||||||
|
{
|
||||||
|
this.declid.addElement(did);
|
||||||
|
}
|
||||||
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ino.method.get_Name.23382.definition
|
||||||
|
public Vector<DeclId> get_Name()
|
||||||
|
// ino.end
|
||||||
|
// ino.method.get_Name.23382.body
|
||||||
|
{
|
||||||
|
return declid;
|
||||||
|
}
|
||||||
|
// ino.end
|
||||||
|
|
||||||
|
// ino.method.getDeclIdVector.23385.definition
|
||||||
|
public Vector<DeclId> getDeclIdVector()
|
||||||
|
// ino.end
|
||||||
|
// ino.method.getDeclIdVector.23385.body
|
||||||
|
{
|
||||||
|
// otth: ganzer Vektor zur�ckgeben, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
||||||
|
return declid;
|
||||||
|
}
|
||||||
|
// ino.end
|
||||||
|
|
||||||
|
// ino.method.setDeclIdVector.23388.definition
|
||||||
|
public void setDeclIdVector( Vector<DeclId> vDeclId )
|
||||||
|
// ino.end
|
||||||
|
// ino.method.setDeclIdVector.23388.body
|
||||||
|
{
|
||||||
|
// otth: kompletter Vektor setzen, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
||||||
|
declid = vDeclId;
|
||||||
|
}
|
||||||
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode generiert die Assumptions für dieses Feld der Klasse classmember
|
||||||
|
* @param classmember
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract TypeAssumptions createTypeAssumptions(Class classmember);
|
||||||
|
}
|
@ -16,6 +16,7 @@ import mycompiler.mystatement.Expr;
|
|||||||
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
||||||
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
// ino.class.FieldDecl.23367.declaration
|
// ino.class.FieldDecl.23367.declaration
|
||||||
public abstract class FieldDecl implements TypeInsertable
|
public abstract class FieldDecl implements TypeInsertable
|
||||||
// ino.end
|
// ino.end
|
||||||
|
62
src/mycompiler/myclass/FieldDeclaration.java
Normal file
62
src/mycompiler/myclass/FieldDeclaration.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package mycompiler.myclass;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import typinferenz.JavaCodeResult;
|
||||||
|
import typinferenz.ResultSet;
|
||||||
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
import mycompiler.mybytecode.ClassFile;
|
||||||
|
import mycompiler.myexception.JVMCodeException;
|
||||||
|
import mycompiler.mystatement.Expr;
|
||||||
|
import mycompiler.mytype.Type;
|
||||||
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||||
|
|
||||||
|
public class FieldDeclaration extends Field{
|
||||||
|
|
||||||
|
private Expr wert;
|
||||||
|
//private Type type;
|
||||||
|
|
||||||
|
public void setWert(Expr initialExpression){
|
||||||
|
this.wert = initialExpression;
|
||||||
|
}
|
||||||
|
public Expr getWert(){
|
||||||
|
return this.wert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName(){
|
||||||
|
return this.get_Name().elementAt(0).name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceType(CReplaceTypeEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeLineNumber() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void codegen(ClassFile classfile, Vector paralist)
|
||||||
|
throws JVMCodeException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,7 @@ import mycompiler.mytype.Type;
|
|||||||
import mycompiler.mytype.TypePlaceholder;
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
|
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class FieldInitialization extends InstVarDecl {
|
public class FieldInitialization extends InstVarDecl {
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import typinferenz.assumptions.TypeAssumptions;
|
|||||||
|
|
||||||
|
|
||||||
// ino.class.Method.23482.declaration
|
// ino.class.Method.23482.declaration
|
||||||
public class Method extends FieldDecl implements ITypeReplacementListener, IItemWithOffset, TypeInsertable
|
public class Method extends Field implements ITypeReplacementListener, IItemWithOffset, TypeInsertable
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Method.23482.body
|
// ino.class.Method.23482.body
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,9 @@ package mycompiler.myinterface;
|
|||||||
|
|
||||||
// ino.module.InterfaceBody.8583.import
|
// ino.module.InterfaceBody.8583.import
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import mycompiler.myclass.Field;
|
||||||
|
|
||||||
import mycompiler.mybytecode.ClassFile;
|
import mycompiler.mybytecode.ClassFile;
|
||||||
import mycompiler.myclass.Constant;
|
import mycompiler.myclass.Constant;
|
||||||
import mycompiler.myclass.FieldDecl;
|
import mycompiler.myclass.FieldDecl;
|
||||||
@ -52,7 +55,7 @@ public class InterfaceBody
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.addElement.23996.definition
|
// ino.method.addElement.23996.definition
|
||||||
public void addElement(FieldDecl fd)
|
public void addElement(Field fd)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.addElement.23996.body
|
// ino.method.addElement.23996.body
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,9 +6,9 @@ Backup von JavaParser.jay 10.April 17 Uhr
|
|||||||
|
|
||||||
package mycompiler.myparser;
|
package mycompiler.myparser;
|
||||||
|
|
||||||
|
import mycompiler.myclass.FieldDeclaration;
|
||||||
|
import mycompiler.myclass.Field;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import mycompiler.myclass.FieldInitialization;
|
|
||||||
import mycompiler.SourceFile;
|
import mycompiler.SourceFile;
|
||||||
import mycompiler.AClassOrInterface;
|
import mycompiler.AClassOrInterface;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
@ -18,7 +18,6 @@ import mycompiler.myclass.Constant;
|
|||||||
import mycompiler.myclass.ImportDeclarations;
|
import mycompiler.myclass.ImportDeclarations;
|
||||||
import mycompiler.myclass.DeclId;
|
import mycompiler.myclass.DeclId;
|
||||||
import mycompiler.myclass.ExceptionList;
|
import mycompiler.myclass.ExceptionList;
|
||||||
import mycompiler.myclass.FieldDecl;
|
|
||||||
import mycompiler.myclass.FormalParameter;
|
import mycompiler.myclass.FormalParameter;
|
||||||
import mycompiler.myclass.InstVarDecl;
|
import mycompiler.myclass.InstVarDecl;
|
||||||
import mycompiler.myclass.Method;
|
import mycompiler.myclass.Method;
|
||||||
@ -207,21 +206,21 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <Interface> interfacedeclaration
|
%type <Interface> interfacedeclaration
|
||||||
%type <InterfaceBody> interfacebody
|
%type <InterfaceBody> interfacebody
|
||||||
%type <InterfaceBody> interfacememberdeclarations
|
%type <InterfaceBody> interfacememberdeclarations
|
||||||
%type <FieldDecl> interfacememberdeclaration
|
%type <Field> interfacememberdeclaration
|
||||||
%type <Method> abstractmethoddeclaration
|
%type <Method> abstractmethoddeclaration
|
||||||
%type <ClassBody> classbody
|
%type <ClassBody> classbody
|
||||||
%type <ClassAndParameter> classidentifier
|
%type <ClassAndParameter> classidentifier
|
||||||
%type <InterfaceAndParameter> interfaceidentifier
|
%type <InterfaceAndParameter> interfaceidentifier
|
||||||
%type <Constant> constantdeclaration
|
%type <Constant> constantdeclaration
|
||||||
%type <FieldDecl> fielddeclaration
|
%type <Field> fielddeclaration
|
||||||
%type <Method> methodheader
|
%type <Method> methodheader
|
||||||
%type <Method> methoddeclaration
|
%type <Method> methoddeclaration
|
||||||
%type <Method> methoddeclarator
|
%type <Method> methoddeclarator
|
||||||
%type <ClassBody> classbodydeclarations
|
%type <ClassBody> classbodydeclarations
|
||||||
%type <FieldDecl> classbodydeclaration
|
%type <Field> classbodydeclaration
|
||||||
%type <FieldDecl> classmemberdeclaration
|
%type <Field> classmemberdeclaration
|
||||||
%type <InstVarDecl> variabledeclarators
|
%type <InstVarDecl> variabledeclarators
|
||||||
%type <FieldInitialization> fielddeclarator;
|
%type <FieldDeclaration> fielddeclarator;
|
||||||
%type <DeclId> variabledeclarator
|
%type <DeclId> variabledeclarator
|
||||||
%type <DeclId> variabledeclaratorid
|
%type <DeclId> variabledeclaratorid
|
||||||
%type <UsedId> simplename
|
%type <UsedId> simplename
|
||||||
@ -309,7 +308,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <ArgumentList> argumentlist
|
%type <ArgumentList> argumentlist
|
||||||
%type <MethodCall> methodinvocation
|
%type <MethodCall> methodinvocation
|
||||||
%type <AClassOrInterface> typedeclaration
|
%type <AClassOrInterface> typedeclaration
|
||||||
%type <FieldDecl> constructordeclaration
|
%type <Field> constructordeclaration
|
||||||
%type <Constructor> constructordeclarator
|
%type <Constructor> constructordeclarator
|
||||||
%type <Block> constructorbody
|
%type <Block> constructorbody
|
||||||
%type <Statement> explicitconstructorinvocation
|
%type <Statement> explicitconstructorinvocation
|
||||||
@ -871,7 +870,7 @@ Dieses Problem ist bei Feldern nicht der Fall.
|
|||||||
*/
|
*/
|
||||||
fielddeclarator : variabledeclarator '=' expression
|
fielddeclarator : variabledeclarator '=' expression
|
||||||
{
|
{
|
||||||
FieldInitialization ret = new FieldInitialization();
|
FieldDeclaration ret = new FieldDeclaration();
|
||||||
ret.set_DeclId($1);
|
ret.set_DeclId($1);
|
||||||
ret.setWert($3);
|
ret.setWert($3);
|
||||||
$$=ret;
|
$$=ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user