forked from JavaTX/JavaCompilerCore
Merge branch 'master' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore
This commit is contained in:
commit
8030b1edf9
42
Readme.md
Normal file
42
Readme.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Typinferenz
|
||||
|
||||
## ResultSet
|
||||
|
||||
* Spezifisch für jedes SourceFile (nicht für jede Klasse)
|
||||
* mehrere ResultSets pro Klasse
|
||||
*
|
||||
|
||||
* Enthält:
|
||||
* constraintPairs
|
||||
* unifiedConstraints
|
||||
|
||||
## TypeInsertSet
|
||||
* Stellt die Typeinsetzung für eine der generierten Lösungen dar
|
||||
* Setzt alle Typen und generischen Variablen ein, welche zu dieser Lösung gehören
|
||||
|
||||
## Ablauf Typinferenz:
|
||||
|
||||
1. Parsen
|
||||
* (Parser postProcessing)
|
||||
2. Typinferenz
|
||||
* Anfangspunkt SourceFile
|
||||
* löst geparste Typen zu richtigen Typen auf (RefTypes, GenericVar)
|
||||
* setzt TPHs ein
|
||||
* bildet Constraints, welche in ResultSet gesammelt werden. ResultSet wird durch Syntaxbaum gereicht.
|
||||
* Assumptions generieren
|
||||
* Wird im Syntaxbaum für jeden Knoten ausgeführt und die Assumptions für darunterliegende Knoten gebildet
|
||||
*
|
||||
3. Unifizierung
|
||||
* wird im SourceFile aufgerufen
|
||||
* unifiziert Constraints aller im SourceFile vorkommenden Klassen
|
||||
|
||||
4. Erstellen von TypeInsertSet
|
||||
* Durchlaufen des Syntaxbaumes
|
||||
* Jeder Knoten erstellt TypeInsertSets anhand des ResultSets.
|
||||
* Bei Knoten, welche Generische Variablen beinhalten können werden GenericTypeInsertPoints erstellt
|
||||
|
||||
5. Einsetzen eines TypeInsertSet (optional)
|
||||
1. Auf allen TypeInsertPoints die getUnresolvedTPHs-Methoden aufrufen
|
||||
2. Alle Abhängigkeiten dieser
|
||||
|
||||
|
@ -313,7 +313,8 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
||||
%type <Statement> explicitconstructorinvocation
|
||||
%type <Method> staticinitializer
|
||||
%type <CastExpr> castexpression
|
||||
%type <ParaList> paralist parameter
|
||||
%type <ParaList> paralist
|
||||
%type <Vector> typelist parameter
|
||||
%type <WildcardType> wildcardparameter
|
||||
%left ','
|
||||
%%
|
||||
@ -322,7 +323,7 @@ compilationunit : typedeclarations
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
/* |importdeclarations typedeclarations
|
||||
|importdeclarations typedeclarations
|
||||
{
|
||||
$2.addImports($1);
|
||||
$$=$2;
|
||||
@ -345,7 +346,7 @@ compilationunit : typedeclarations
|
||||
this.testPair.add(new Pair($1,$2));
|
||||
$$=$3;
|
||||
}
|
||||
*/
|
||||
|
||||
packagedeclaration : PACKAGE name ';' ;
|
||||
{
|
||||
// SCJU: Package
|
||||
@ -394,12 +395,12 @@ typedeclaration :classdeclaration
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
/* | interfacedeclaration
|
||||
| interfacedeclaration
|
||||
{
|
||||
// SCJU: Interface
|
||||
$$=$1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
qualifiedname : name '.' IDENTIFIER
|
||||
{
|
||||
@ -785,21 +786,34 @@ classbodydeclaration : classmemberdeclaration
|
||||
classorinterfacetype : simplename parameter
|
||||
{
|
||||
if ($2 != null) {
|
||||
$1.set_ParaList($2.get_ParaList());
|
||||
|
||||
//$1.set_ParaList($2.get_ParaList());
|
||||
$1.set_ParaList($2);//Änderung von Andreas Stadelmeier. Type statt GenericVarType
|
||||
/* otth: originale (also diese) Parameterliste retten */
|
||||
((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
//((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
}
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
typelist : type
|
||||
{
|
||||
Vector<Type> tl = new Vector<Type>();
|
||||
tl.add($1);
|
||||
$$ = tl;
|
||||
}
|
||||
| typelist ',' type
|
||||
{
|
||||
$1.add($3);
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
/* PL 05-07-28 erg�nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */
|
||||
//TODO: Das hier ist möglicherweise falsch. Ein Typ hat keine parameterliste, nur eine Liste von RefTypes
|
||||
parameter : { $$ = null; }
|
||||
| '<'paralist'>'
|
||||
| '<'typelist'>'//'<'paralist'>'//typelist statt
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
|
||||
interfacememberdeclaration : constantdeclaration
|
||||
{
|
||||
// SCJU: Interfaces, Spezialform Konstantendef.
|
||||
@ -821,7 +835,7 @@ classmemberdeclaration : fielddeclaration
|
||||
|
||||
staticinitializer : STATIC block
|
||||
{
|
||||
Method STAT = new Method();
|
||||
Method STAT = new Method($1.getOffset());
|
||||
DeclId DST = new DeclId();
|
||||
DST.set_Name($1.getLexem());
|
||||
STAT.set_DeclId(DST);
|
||||
@ -867,9 +881,21 @@ Beispiel: var = 2;
|
||||
Bei einer lokalen Variable lässt sich hier nicht ermitteln ob die Variable deklariert werden soll oder bereits deklariert wurde und ihr nur ein Wert zugewiesen werden soll.
|
||||
Dieses Problem ist bei Feldern nicht der Fall.
|
||||
*/
|
||||
fielddeclarator : variabledeclarator '=' expression
|
||||
fielddeclarator :
|
||||
/*
|
||||
type variabledeclarator '=' expression
|
||||
{
|
||||
FieldDeclaration ret = new FieldDeclaration();
|
||||
FieldDeclaration ret = new FieldDeclaration($2.getOffset());
|
||||
ret.setType($1);
|
||||
ret.set_DeclId($2);
|
||||
ret.setWert($4);
|
||||
$$=ret;
|
||||
}
|
||||
|
|
||||
*/
|
||||
variabledeclarator '=' expression
|
||||
{
|
||||
FieldDeclaration ret = new FieldDeclaration($1.getOffset());
|
||||
ret.set_DeclId($1);
|
||||
ret.setWert($3);
|
||||
$$=ret;
|
||||
@ -879,11 +905,17 @@ fielddeclaration : fielddeclarator ';'
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
| type fielddeclarator
|
||||
| type fielddeclarator ';'
|
||||
{
|
||||
$2.setType($1);
|
||||
$$=$2;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' type fielddeclarator ';'
|
||||
{//angefügt von Andreas Stadelmeier
|
||||
$5.setType($4);
|
||||
$5.setGenericParameter($2);
|
||||
$$=$5;
|
||||
}
|
||||
|
|
||||
variabledeclarators ';'
|
||||
{
|
||||
@ -1000,8 +1032,8 @@ boundedMethodParameter : IDENTIFIER
|
||||
}
|
||||
| IDENTIFIER EXTENDS boundedclassidentifierlist
|
||||
{
|
||||
BoundedGenericTypeVar gtv=new BoundedGenericTypeVar($1.getLexem(),$1.getOffset());
|
||||
gtv.setBounds($3);
|
||||
BoundedGenericTypeVar gtv=new BoundedGenericTypeVar($1.getLexem(),$3,$1.getOffset());
|
||||
//gtv.setBounds($3);
|
||||
$$=gtv;
|
||||
}
|
||||
// returns Vector<Type>
|
||||
@ -1035,45 +1067,45 @@ boundedMethodParameters : boundedMethodParameter
|
||||
// returns Method
|
||||
methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$5.setReturnType($4);
|
||||
$5.setType($4);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
}
|
||||
| type methoddeclarator
|
||||
{
|
||||
$2.setReturnType($1);
|
||||
$2.setType($1);
|
||||
$$=$2;
|
||||
}
|
||||
| modifiers type methoddeclarator
|
||||
{
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType($2);
|
||||
$3.setType($2);
|
||||
$$=$3;
|
||||
}
|
||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$6.set_Modifiers($1);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$6.setReturnType($5);
|
||||
$6.setType($5);
|
||||
$$=$6;
|
||||
}
|
||||
| type methoddeclarator throws
|
||||
{
|
||||
$2.setReturnType($1);
|
||||
$2.setType($1);
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' type methoddeclarator throws
|
||||
{
|
||||
$5.setGenericMethodParameters($2);
|
||||
$5.setReturnType($4);
|
||||
$5.setType($4);
|
||||
$5.set_ExceptionList($6);
|
||||
$$=$5;
|
||||
}
|
||||
| modifiers type methoddeclarator throws
|
||||
{
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType($2);
|
||||
$3.setType($2);
|
||||
$3.set_ExceptionList($4);
|
||||
$$=$3;
|
||||
}
|
||||
@ -1081,27 +1113,27 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$6.set_Modifiers($1);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$6.setReturnType($5);
|
||||
$6.setType($5);
|
||||
$6.set_ExceptionList($7);
|
||||
$$=$6;
|
||||
}
|
||||
| VOID methoddeclarator
|
||||
{
|
||||
Void Voit = new Void($1.getOffset());
|
||||
$2.setReturnType(Voit);
|
||||
$2.setType(Voit);
|
||||
$$=$2;
|
||||
}
|
||||
| modifiers VOID methoddeclarator
|
||||
{
|
||||
Void voit = new Void($2.getOffset());
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType(voit);
|
||||
$3.setType(voit);
|
||||
$$=$3;
|
||||
}
|
||||
| VOID methoddeclarator throws
|
||||
{
|
||||
Void voyt = new Void($1.getOffset());
|
||||
$2.setReturnType(voyt);
|
||||
$2.setType(voyt);
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
@ -1109,14 +1141,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voyd = new Void($2.getOffset());
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType(voyd);
|
||||
$3.setType(voyd);
|
||||
$3.set_ExceptionList($4);
|
||||
$$=$3;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' VOID methoddeclarator
|
||||
{
|
||||
Void Voit = new Void($4.getOffset());
|
||||
$5.setReturnType(Voit);
|
||||
$5.setType(Voit);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
}
|
||||
@ -1124,14 +1156,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voit = new Void($5.getOffset());
|
||||
$6.set_Modifiers($1);
|
||||
$6.setReturnType(voit);
|
||||
$6.setType(voit);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$$=$6;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
||||
{
|
||||
Void voyt = new Void($4.getOffset());
|
||||
$5.setReturnType(voyt);
|
||||
$5.setType(voyt);
|
||||
$5.set_ExceptionList($6);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
@ -1140,7 +1172,7 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voyd = new Void($5.getOffset());
|
||||
$6.set_Modifiers($1);
|
||||
$6.setReturnType(voyd);
|
||||
$6.setType(voyd);
|
||||
$6.set_ExceptionList($7);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$$=$6;
|
||||
@ -1148,12 +1180,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
|
||||
| methoddeclarator
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||
$$=$1;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' methoddeclarator
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
||||
$4.setGenericMethodParameters($2);
|
||||
$$=$4;
|
||||
}
|
||||
@ -1161,19 +1193,19 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
| modifiers methoddeclarator
|
||||
{
|
||||
$2.set_Modifiers($1);
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||||
$$=$2;
|
||||
}
|
||||
| methoddeclarator throws
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||
$1.set_ExceptionList($2);
|
||||
$$=$1;
|
||||
}
|
||||
| modifiers methoddeclarator throws
|
||||
{
|
||||
$2.set_Modifiers($1);
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
@ -1197,8 +1229,9 @@ type : primitivetype
|
||||
}
|
||||
variabledeclarators : variabledeclarator
|
||||
{
|
||||
FieldDeclaration IVD = new FieldDeclaration();
|
||||
FieldDeclaration IVD = new FieldDeclaration($1.getOffset());
|
||||
IVD.getDeclIdVector().addElement( $1 );
|
||||
IVD.setOffset($1.getOffset());
|
||||
$$ = IVD;
|
||||
}
|
||||
| variabledeclarators ',' variabledeclarator
|
||||
@ -1267,7 +1300,7 @@ classtypelist : classtype
|
||||
|
||||
methoddeclarator :IDENTIFIER '(' ')'
|
||||
{
|
||||
Method met = new Method();
|
||||
Method met = new Method($1.getOffset());
|
||||
/* #JB# 10.04.2005 */
|
||||
/* ########################################################### */
|
||||
met.setLineNumber($1.getLineNumber());
|
||||
@ -1280,7 +1313,7 @@ methoddeclarator :IDENTIFIER '(' ')'
|
||||
}
|
||||
|IDENTIFIER '(' formalparameterlist ')'
|
||||
{
|
||||
Method met_para = new Method();
|
||||
Method met_para = new Method($1.getOffset());
|
||||
/* #JB# 10.04.2005 */
|
||||
/* ########################################################### */
|
||||
met_para.setLineNumber($1.getLineNumber());
|
||||
@ -1307,7 +1340,6 @@ primitivetype :BOOLEAN
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
|
||||
referencetype :classorinterfacetype
|
||||
{
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1);
|
||||
@ -1360,9 +1392,9 @@ blockstatement :localvariabledeclarationstatement
|
||||
|
||||
formalparameter : type variabledeclaratorid
|
||||
{
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($2);
|
||||
FP.setType($1);
|
||||
FP.set_DeclId($2);
|
||||
//FP.set_DeclId($2); //auskommentiert von Andreas Stadelmeier. DeclId wird nun dem Konstruktor von FormalParameter übergeben.
|
||||
$$=FP;
|
||||
}
|
||||
|
||||
@ -1374,9 +1406,9 @@ formalparameter : type variabledeclaratorid
|
||||
Parameterliste setzen
|
||||
$5.set_Paratyp($3.get_ParaList());
|
||||
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($5);
|
||||
FP.setType($1);
|
||||
FP.set_DeclId($5);
|
||||
//FP.set_DeclId($5);
|
||||
$$=FP;
|
||||
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("P->Polymorphes Methodenargument hinzugefuegt: Name = " + $5.get_Name() + " Typ = " + $1.getName());
|
||||
@ -1387,7 +1419,7 @@ formalparameter : type variabledeclaratorid
|
||||
{
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + $1.name);
|
||||
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($1);
|
||||
|
||||
// #JB# 31.03.2005
|
||||
// ###########################################################
|
||||
@ -1397,7 +1429,7 @@ formalparameter : type variabledeclaratorid
|
||||
//org.apache.log4j.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName());
|
||||
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) FP.setType( T );
|
||||
FP.set_DeclId($1);
|
||||
//FP.set_DeclId($1);
|
||||
|
||||
$$=FP;
|
||||
}
|
||||
|
BIN
lib/junit-4.0.jar
Executable file
BIN
lib/junit-4.0.jar
Executable file
Binary file not shown.
BIN
lib/log4j-1.2.12.jar
Executable file
BIN
lib/log4j-1.2.12.jar
Executable file
Binary file not shown.
@ -13,11 +13,10 @@ import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.ClassBody;
|
||||
import mycompiler.myclass.Constructor_Backup;
|
||||
import mycompiler.myclass.DeclId;
|
||||
import mycompiler.myclass.FieldDecl;
|
||||
import mycompiler.myclass.FormalParameter;
|
||||
import mycompiler.myclass.ImportDeclarations;
|
||||
import mycompiler.myclass.Method;
|
||||
@ -43,9 +42,13 @@ import org.apache.log4j.xml.DOMConfigurator;
|
||||
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
|
||||
import com.sun.org.apache.xerces.internal.impl.xs.identity.Field;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.FunNInterface;
|
||||
import typinferenz.ResultSet;
|
||||
// ino.end
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import typinferenz.exceptions.ParserError;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -80,15 +83,6 @@ public class MyCompiler implements MyCompilerAPI
|
||||
protected String OutputDir = "";
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.m_Singleton.21277.decldescription type=javadoc
|
||||
/**
|
||||
* Die Singleton-Instanz f�r den Compiler
|
||||
* <br/>Autor: J�rg B�uerle
|
||||
*/
|
||||
// ino.end
|
||||
// ino.attribute.m_Singleton.21277.declaration
|
||||
private static MyCompiler m_Singleton = null;
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.m_AbstractSyntaxTree.21280.decldescription type=javadoc
|
||||
/**
|
||||
@ -130,10 +124,7 @@ public class MyCompiler implements MyCompilerAPI
|
||||
// ino.end
|
||||
// ino.method.getAPI.21286.body
|
||||
{
|
||||
if(m_Singleton==null){
|
||||
m_Singleton = new MyCompiler();
|
||||
}
|
||||
return m_Singleton;
|
||||
return new MyCompiler();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -496,14 +487,16 @@ public class MyCompiler implements MyCompilerAPI
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.parse.21298.definition
|
||||
public void parse(File file)
|
||||
public SourceFile parse(File file)
|
||||
throws FileNotFoundException, IOException, JavaParser.yyException
|
||||
// ino.end
|
||||
// ino.method.parse.21298.body
|
||||
{
|
||||
FileReader fr = new FileReader(file);
|
||||
this.m_AbstractSyntaxTree.add(this.parse2SyntaxTree(file.getName(), fr));
|
||||
SourceFile ret = this.parse2SyntaxTree(fr);
|
||||
this.m_AbstractSyntaxTree.add(ret);
|
||||
fr.close();
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -530,7 +523,7 @@ public class MyCompiler implements MyCompilerAPI
|
||||
inferencelog.info("# TypeReconstruction-Algorithmus - START #");
|
||||
inferencelog.info("##########################################\n");
|
||||
|
||||
TypeAssumptions globalAssumptions = m_AbstractSyntaxTree.elementAt(0).makeBasicAssumptions();
|
||||
TypeAssumptions globalAssumptions = makeFunNAssumptions();
|
||||
Vector<TypeinferenceResultSet> result = new Vector<TypeinferenceResultSet>();
|
||||
for(SourceFile srcFile : m_AbstractSyntaxTree){
|
||||
result.addAll(srcFile.typeReconstruction(globalAssumptions));
|
||||
@ -545,32 +538,49 @@ public class MyCompiler implements MyCompilerAPI
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
/**
|
||||
* Erstellt die FunN-Assumptions
|
||||
* Fun0-FunN (momentan für N = 6)
|
||||
* @return
|
||||
*/
|
||||
private TypeAssumptions makeFunNAssumptions(){
|
||||
TypeAssumptions ret = new TypeAssumptions();
|
||||
|
||||
//Basic Assumptions für die FunN Interfaces:
|
||||
//TODO: Hier mehr als Fun1-Fun5 implementieren
|
||||
for(int i = 0; i<6; i++){
|
||||
FunNInterface funN = new FunNInterface(i);
|
||||
ret.add(funN.getPublicFieldAssumptions());
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ino.method.codeGeneration.21310.defdescription type=javadoc
|
||||
/**
|
||||
* Author: J�rg B�uerle<br/>
|
||||
* Generiert den Bytecode und das Class-File f�r den Syntaxbaum.
|
||||
* @throws NullPointerException Wenn noch kein abstrakter Syntaxbaum vorhanden
|
||||
* ist.
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.codeGeneration.21310.definition
|
||||
public void codeGeneration()
|
||||
@Override
|
||||
public Vector<ClassFile> codeGeneration(ResultSet result)
|
||||
throws NullPointerException, JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codeGeneration.21310.body
|
||||
{
|
||||
if(m_AbstractSyntaxTree==null){
|
||||
throw new NullPointerException("Es wurde noch kein Abstrakter Syntaxbaum erstellt!");
|
||||
}
|
||||
codegenlog.info("Beginn der Codegenerierung ...");
|
||||
|
||||
//m_AbstractSyntaxTree.codegen();
|
||||
Vector<ClassFile> ret = new Vector<ClassFile>();
|
||||
|
||||
for(SourceFile sf : m_AbstractSyntaxTree){
|
||||
ret.addAll(sf.codegen(result));
|
||||
}
|
||||
|
||||
codegenlog.info("Codegenerierung beendet!");
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.main.21313.defdescription type=javadoc
|
||||
/**
|
||||
@ -747,7 +757,7 @@ public class MyCompiler implements MyCompilerAPI
|
||||
/**
|
||||
* Parst den Inhalt einer Datei zu einem Syntaxbaum.
|
||||
*/
|
||||
private SourceFile parse2SyntaxTree(String filename, Reader fileContent){
|
||||
private SourceFile parse2SyntaxTree(Reader fileContent) throws ParserError{
|
||||
|
||||
//StringReader reader = new StringReader(fileContent);
|
||||
//////////////////////////////////////
|
||||
@ -763,13 +773,12 @@ public class MyCompiler implements MyCompilerAPI
|
||||
try {
|
||||
srcFile = (SourceFile) parser.yyparse( scanner );
|
||||
} catch (IOException | yyException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
if(e instanceof yyException)throw new ParserError((yyException)e);
|
||||
}
|
||||
//////////////////////////////////////
|
||||
// Postprocessing:
|
||||
//////////////////////////////////////
|
||||
srcFile.setFileName(filename);
|
||||
srcFile.parserPostProcessing(null); //Muss mit null aufgerufen werden.
|
||||
//Fertig:
|
||||
return srcFile;
|
||||
@ -778,7 +787,7 @@ public class MyCompiler implements MyCompilerAPI
|
||||
/**
|
||||
* Diese Funktion nimmt einen Vector von Dateinamen. Alle diese Dateien werden zu einem SyntaxBaum geparst.
|
||||
*/
|
||||
public void parse(Vector<String> filenames) {
|
||||
public void parse(Vector<String> filenames) throws ParserError {
|
||||
|
||||
for(String filename : filenames){
|
||||
StringBuffer fileData = new StringBuffer();
|
||||
@ -787,7 +796,7 @@ public class MyCompiler implements MyCompilerAPI
|
||||
reader = new BufferedReader(
|
||||
new FileReader(filename));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new TypinferenzException("Die Datei "+ filename+" konnte nicht gelesen werden.");
|
||||
throw new DebugException("Die Datei "+ filename+" konnte nicht gelesen werden.");
|
||||
}
|
||||
char[] buf = new char[1024];
|
||||
int numRead=0;
|
||||
@ -798,13 +807,12 @@ public class MyCompiler implements MyCompilerAPI
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
StringReader srcreader = new StringReader(fileData.toString());
|
||||
//Den aus der Datei ausgelesenen Quellcode zu einem Syntaxbaum parsen:
|
||||
this.m_AbstractSyntaxTree.add(parse2SyntaxTree(filename,srcreader)); // Alle Dateien nacheinander hintereinander anhängen...
|
||||
this.m_AbstractSyntaxTree.add(parse2SyntaxTree(srcreader)); // Alle Dateien nacheinander hintereinander anhängen...
|
||||
|
||||
}
|
||||
/*
|
||||
@ -824,7 +832,6 @@ public class MyCompiler implements MyCompilerAPI
|
||||
reader.close();
|
||||
gesamterSrc += fileData.toString() + "\n"; // Alle Dateien nacheinander hintereinander anhängen...
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new TypinferenzException("Die übergebenen Dateien konnten nicht zum Parsen eingelesen werden.");
|
||||
}
|
||||
@ -840,5 +847,12 @@ public class MyCompiler implements MyCompilerAPI
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceFile parse(String sourceCode) {
|
||||
SourceFile ret = this.parse2SyntaxTree(new StringReader(sourceCode));
|
||||
this.m_AbstractSyntaxTree.add(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,6 +7,11 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.exceptions.ParserError;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.myparser.JavaParser;
|
||||
@ -50,7 +55,7 @@ public interface MyCompilerAPI
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.parse.21334.declaration
|
||||
public void parse(File file)
|
||||
public SourceFile parse(File file)
|
||||
throws FileNotFoundException, IOException, JavaParser.yyException;
|
||||
// ino.end
|
||||
|
||||
@ -81,7 +86,7 @@ public interface MyCompilerAPI
|
||||
// ino.end
|
||||
// ino.method.typeReconstruction.21340.declaration
|
||||
public Vector<TypeinferenceResultSet> typeReconstruction()
|
||||
throws NullPointerException, CTypeReconstructionException;
|
||||
throws NullPointerException, TypeinferenceException;
|
||||
// ino.end
|
||||
|
||||
// ino.method.codeGeneration.21346.decldescription type=javadoc
|
||||
@ -94,7 +99,7 @@ public interface MyCompilerAPI
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.codeGeneration.21346.declaration
|
||||
public void codeGeneration()
|
||||
public Vector<ClassFile> codeGeneration(ResultSet result)
|
||||
throws NullPointerException, JVMCodeException;
|
||||
// ino.end
|
||||
|
||||
@ -122,7 +127,14 @@ public interface MyCompilerAPI
|
||||
* Parst zusammenhängende JavaKlassen in verschiedenen Dateien.
|
||||
* @param filenames - Eine Liste von Quellcodedateien, welche gseparst werden sollen
|
||||
*/
|
||||
public void parse(Vector<String> filenames);
|
||||
public void parse(Vector<String> filenames) throws ParserError;
|
||||
|
||||
/**
|
||||
* Parst den SourceCode einer Datei.
|
||||
* @param sourceCode - SourceCode einer Java-Quellcodedatei
|
||||
* @return den aus dem sourceCode generierten Syntaxbaum
|
||||
*/
|
||||
public SourceFile parse(String sourceCode) throws ParserError;
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,13 +3,19 @@ package mycompiler;
|
||||
// ino.end
|
||||
|
||||
// ino.module.SourceFile.8722.import
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myclass.BasicAssumptionClass;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.Constructor;
|
||||
import mycompiler.myclass.Field;
|
||||
import mycompiler.myclass.FieldDeclaration;
|
||||
import mycompiler.myclass.ImportDeclarations;
|
||||
import mycompiler.myclass.UsedId;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
@ -38,13 +44,22 @@ import mycompiler.mytypereconstruction.unify.Unify;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import mycompiler.myclass.*;
|
||||
import mycompiler.*;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.FunNInterface;
|
||||
import typinferenz.FunNMethod;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.ClassAssumption;
|
||||
import typinferenz.assumptions.MethodAssumption;
|
||||
import typinferenz.assumptions.ParameterAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -123,7 +138,7 @@ public class SourceFile
|
||||
// ino.attribute.InterfaceVektor.21379.declaration
|
||||
public Vector<Interface> InterfaceVektor = new Vector<Interface>();
|
||||
// ino.end
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
|
||||
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
|
||||
@ -215,22 +230,24 @@ public class SourceFile
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.codegen.21397.definition
|
||||
public void codegen()
|
||||
public Vector<ClassFile> codegen(ResultSet result)
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.21397.body
|
||||
{
|
||||
Vector<ClassFile> ret = new Vector<ClassFile>();
|
||||
codegenlog.info("Anzahl der Interfaces: "
|
||||
+ Integer.toString(InterfaceVektor.size()));
|
||||
for(int i = 0; i < InterfaceVektor.size(); i++) {
|
||||
InterfaceVektor.elementAt(i).codegen(this);
|
||||
InterfaceVektor.elementAt(i).codegen(result);
|
||||
}
|
||||
|
||||
codegenlog.info("Anzahl der Klassen: "
|
||||
+ Integer.toString(KlassenVektor.size()));
|
||||
for(int i = 0; i < KlassenVektor.size(); i++) {
|
||||
KlassenVektor.elementAt(i).codegen(this);
|
||||
ret.add(KlassenVektor.elementAt(i).codegen(result));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -323,7 +340,7 @@ public class SourceFile
|
||||
while(interfaceIterator.hasNext()){
|
||||
UsedId superintf=interfaceIterator.next();
|
||||
String superinterfaceName=superintf.getQualifiedName();
|
||||
Pair P=createPairFromClassAndSuperclass(intf.getName(),superinterfaceName,intf. getParaList(), superintf.get_ParaList());
|
||||
Pair P=createPairFromClassAndSuperclass(intf.getName(),superinterfaceName,intf.getParaList(), superintf.get_ParaList());
|
||||
vFC.add( P );
|
||||
|
||||
}
|
||||
@ -645,90 +662,145 @@ public class SourceFile
|
||||
globalAssumptions.add(klasse.getPublicFieldAssumptions());
|
||||
}
|
||||
|
||||
//Assumptions der importierten Klassen sammeln:
|
||||
TypeAssumptions importAssumptions = this.makeBasicAssumptionsFromJRE(imports);
|
||||
globalAssumptions.add(importAssumptions);
|
||||
typinferenzLog.debug("Von JRE erstellte Assumptions: "+importAssumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
//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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
oderConstraints.add(klasse.typeReconstruction(finiteClosure, globalAssumptions));
|
||||
}
|
||||
|
||||
////////////////
|
||||
//Karthesisches Produkt bilden:
|
||||
////////////////
|
||||
//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:
|
||||
//////////////////////////////
|
||||
boolean unifyFail = true;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//Alle Generischen Typvariablen in TPH umwandeln:
|
||||
HashMap<GenericTypeVar,TypePlaceholder> gtv2tph = new HashMap<GenericTypeVar,TypePlaceholder>();
|
||||
for(Pair pair : constraints){
|
||||
if(pair.TA1 instanceof GenericTypeVar){
|
||||
TypePlaceholder tph = gtv2tph.get(pair.TA1);
|
||||
if(tph == null){
|
||||
tph = TypePlaceholder.fresh();
|
||||
gtv2tph.put((GenericTypeVar)pair.TA1, tph);
|
||||
}
|
||||
pair.TA1 = tph;
|
||||
}
|
||||
if(pair.TA2 instanceof GenericTypeVar){
|
||||
TypePlaceholder tph = gtv2tph.get(pair.TA2);
|
||||
if(tph == null){
|
||||
tph = TypePlaceholder.fresh();
|
||||
gtv2tph.put((GenericTypeVar)pair.TA2, tph);
|
||||
}
|
||||
pair.TA2 = tph;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Erst die Unifizierung erstellen:
|
||||
Vector<Pair> constraintsClone = (Vector<Pair>)constraints.clone();
|
||||
|
||||
//Typen kontrollieren:
|
||||
for(Pair p : constraintsClone){
|
||||
Type t = p.TA1;
|
||||
//TypeCheck, falls es sich um einen RefType handelt:
|
||||
if(t!=null && (t instanceof RefType)&&
|
||||
!(t instanceof mycompiler.mytype.Void)){
|
||||
Type replaceType = null;
|
||||
replaceType = globalAssumptions.getTypeFor((RefType)t);
|
||||
if(!(replaceType == null))p.TA1 = replaceType;
|
||||
}
|
||||
t = p.TA2;
|
||||
//TypeCheck, falls es sich um einen RefType handelt:
|
||||
if(t!=null && (t instanceof RefType)&&
|
||||
!(t instanceof mycompiler.mytype.Void)){
|
||||
Type replaceType = null;
|
||||
replaceType = globalAssumptions.getTypeFor((RefType)t);
|
||||
if(!(replaceType == null))p.TA2 = replaceType;
|
||||
}
|
||||
}
|
||||
|
||||
Vector<Vector<Pair>> unifyResult = Unify.unify(constraintsClone, 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>())));
|
||||
|
||||
|
||||
//Für jede Klasse in diesem SourceFile gilt das selbe ResultSet:
|
||||
for(Class klasse : this.KlassenVektor){
|
||||
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
|
||||
for(Vector<Pair> resultSet : result){
|
||||
unifyFail = false; //Ein Unifiziertes Ergebnis ist entstanden (es kann auch leer sein, das bedeutet nur, dass die Constraints mindestens in einem Fall Sinn ergaben)
|
||||
//Add Result set as a new ReconstructionResult to ret:
|
||||
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse, constraints, new ResultSet(resultSet));
|
||||
ret.add(reconstructionResult);
|
||||
|
||||
//ResultSet res = new ResultSet(resultSet);
|
||||
typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n");
|
||||
typinferenzLog.debug(klasse.printJavaCode(reconstructionResult));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(unifyFail){
|
||||
if(!this.KlassenVektor.isEmpty())throw new TypeinferenceException("Fehler in Typinferierung", this.KlassenVektor.firstElement());
|
||||
}
|
||||
return ret;
|
||||
/*
|
||||
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit
|
||||
@ -741,7 +813,7 @@ public class SourceFile
|
||||
|
||||
TypeAssumptions basics;
|
||||
|
||||
basics = this.makeBasicAssumptions(); //TODO: Diese Funktion ändern, dass nur noch TypeAssumptions zurückgegeben werden. Diese sind wichtig, da hier die Standard-Library von Java als Assumptions generiert wird.
|
||||
basics = this.makeBasicAssumptions();
|
||||
|
||||
//A.addElement(basics); //auskommentiert von Andreas Stadelmeier
|
||||
|
||||
@ -862,6 +934,7 @@ public class SourceFile
|
||||
* Erstellt die Basic Assumptions (siehe MakeBasicAssumptions) als AssumptionSet
|
||||
* @return
|
||||
*/
|
||||
@Deprecated //angefügt von Andreas Stadelmeier. Grund: Die Funktion wurde neu als makeBasicAssumptionsFromJRE angelegt
|
||||
private TypeAssumptions getBasicAssumptions() {
|
||||
TypeAssumptions ret = new TypeAssumptions(null);
|
||||
|
||||
@ -1006,20 +1079,23 @@ public class SourceFile
|
||||
}
|
||||
|
||||
// ino.method.makeBasicAssumptionsFromJRE.21409.definition
|
||||
@Deprecated //angefügt von Andreas Stadelmeier. Grund: Die Funktion wurde neu als getBasicAssumptions angelegt
|
||||
private TypeinferenceResultSet makeBasicAssumptionsFromJRE(Vector<UsedId> imports)
|
||||
private TypeAssumptions makeBasicAssumptionsFromJRE(Vector<UsedId> imports)
|
||||
// ino.end
|
||||
// ino.method.makeBasicAssumptionsFromJRE.21409.body
|
||||
{
|
||||
return null;
|
||||
/*
|
||||
//return null;
|
||||
///*
|
||||
Vector<UsedId> doneImports=new Vector<UsedId>();
|
||||
|
||||
TypeinferenceResultSet basicAssumptions = new TypeinferenceResultSet(null);
|
||||
|
||||
//TypeinferenceResultSet basicAssumptions = new TypeinferenceResultSet(null);
|
||||
TypeAssumptions basicAssumptions = new TypeAssumptions();
|
||||
|
||||
Modifiers mod = new Modifiers();
|
||||
mod.addModifier(new Public());
|
||||
|
||||
//Für Object:
|
||||
//TODO: toString()-Methode gerät nicht in die BasicAssumptions
|
||||
imports.add(new UsedId("java.lang.Object",-1));
|
||||
|
||||
// Für jede einzelne Klasse
|
||||
while (imports.size()>0) {
|
||||
@ -1051,11 +1127,13 @@ public class SourceFile
|
||||
jreSpiderRegistry.put(tvs[j].getName(),gtv);
|
||||
}
|
||||
|
||||
BasicAssumptionClass myCl = new BasicAssumptionClass(className, mod);
|
||||
|
||||
//BasicAssumptionClass myCl = new BasicAssumptionClass(className, mod);
|
||||
Class parentClass = new Class(className, mod);
|
||||
|
||||
if(typeGenPara.size()>0){
|
||||
basicAssumptions.addGenericTypeVars(className, typeGenPara);
|
||||
myCl.set_ParaList((Vector)typeGenPara);
|
||||
//auskommentiert von Andreas Stadelmeier:
|
||||
//basicAssumptions.addGenericTypeVars(className, typeGenPara);
|
||||
parentClass.set_ParaList((Vector)typeGenPara);//myCl.set_ParaList((Vector)typeGenPara);
|
||||
}
|
||||
|
||||
|
||||
@ -1089,40 +1167,52 @@ public class SourceFile
|
||||
}
|
||||
ui.set_ParaList(supertypeGenPara);
|
||||
ui.vParaOrg=supertypeGenPara;
|
||||
myCl.set_UsedId(ui);
|
||||
parentClass.set_UsedId(ui);
|
||||
}
|
||||
}
|
||||
|
||||
this.addElement(myCl);
|
||||
|
||||
basicAssumptions.addClassName(className);
|
||||
//auskommentiert von Andreas Stadelmeier
|
||||
//this.addElement(myCl);
|
||||
//basicAssumptions.addClassName(className);
|
||||
|
||||
for(int j=0;j<fields.length;j++){
|
||||
if(java.lang.reflect.Modifier.isPublic(fields[j].getModifiers())){
|
||||
//CInstVarTypeAssumption instVar = new CInstVarTypeAssumption(className, fields[j].getName(), new RefType(fields[j].getType().getSimpleName()), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>());
|
||||
CInstVarTypeAssumption instVar = new CInstVarTypeAssumption(className, fields[j].getName(), new RefType(fields[j].getType().getName(),-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>());
|
||||
basicAssumptions.addFieldOrLocalVarAssumption(instVar);
|
||||
//basicAssumptions.addFieldOrLocalVarAssumption(instVar);
|
||||
parentClass.addField(new FieldDeclaration(fields[j].getName(),new RefType(fields[j].getType().getName(),-1)));
|
||||
}
|
||||
}
|
||||
for(int j=0;j<methods.length;j++){
|
||||
if(java.lang.reflect.Modifier.isPublic(methods[j].getModifiers())){
|
||||
String methodName=methods[j].getName();
|
||||
if(methodName.equals("add")){
|
||||
|
||||
java.lang.reflect.Type genericReturnType=methods[j].getGenericReturnType();
|
||||
Type returnType=createTypeFromJavaGenericType(genericReturnType,methods[j].getReturnType(),jreSpiderRegistry);
|
||||
|
||||
java.lang.reflect.Type[] gpt=methods[j].getGenericParameterTypes();
|
||||
java.lang.Class[] pt=methods[j].getParameterTypes();
|
||||
|
||||
CMethodTypeAssumption method = new CMethodTypeAssumption(new RefType(className, 0), methodName, returnType, pt.length,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>(),null);
|
||||
|
||||
//CMethodTypeAssumption method = new CMethodTypeAssumption(new RefType(className, 0), methodName, returnType, pt.length,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>(),null);
|
||||
Method method = mycompiler.myclass.Method.createEmptyMethod(methodName, parentClass);
|
||||
method.setType(returnType);
|
||||
ParameterList parameterList = new ParameterList();
|
||||
|
||||
for(int k=0;k<gpt.length;k++){
|
||||
Type type=createTypeFromJavaGenericType(gpt[k],pt[k],jreSpiderRegistry);
|
||||
// Fixme HOTI beachte overloaded id
|
||||
method.addParaAssumption(new CParaTypeAssumption(className, methodName, pt.length,0,type.getName(), type, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>()));
|
||||
//method.addParaAssumption(new CParaTypeAssumption(className, methodName, pt.length,0,type.getName(), type, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>()));
|
||||
FormalParameter parameter = new FormalParameter(new DeclId(type.get_Name()));
|
||||
parameter.setType(type);
|
||||
parameterList.formalparameter.add(parameter);
|
||||
}
|
||||
basicAssumptions.addMethodIntersectionType(new CIntersectionType(method));
|
||||
}
|
||||
method.setParameterList(parameterList);
|
||||
//basicAssumptions.addMethodIntersectionType(new CIntersectionType(method));
|
||||
parentClass.addField(method);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=0;j<constructors.length;j++){
|
||||
@ -1135,18 +1225,21 @@ public class SourceFile
|
||||
// Fixme HOTI beachte overloaded id
|
||||
constructor.addParaAssumption(new CParaTypeAssumption(className, methodName, constructors[j].getParameterTypes().length,0,paraType, new RefType(paraType,-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>()));
|
||||
}
|
||||
basicAssumptions.addMethodIntersectionType(new CIntersectionType(constructor));
|
||||
//basicAssumptions.addMethodIntersectionType(new CIntersectionType(constructor));
|
||||
Method constructorMethod = mycompiler.myclass.Method.createEmptyMethod(methodName, parentClass);
|
||||
parentClass.addField(new Constructor(constructorMethod));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
basicAssumptions.add(parentClass.getPublicFieldAssumptions());
|
||||
basicAssumptions.addClassAssumption(new ClassAssumption(parentClass));
|
||||
imports.removeElement(importDecl);
|
||||
doneImports.addElement(importDecl);
|
||||
|
||||
}
|
||||
|
||||
imports.addAll(doneImports);
|
||||
return basicAssumptions;
|
||||
*/
|
||||
//*/
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -1214,7 +1307,7 @@ public class SourceFile
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.makeBasicAssumptions.21418.definition
|
||||
public TypeAssumptions makeBasicAssumptions()
|
||||
private TypeAssumptions makeBasicAssumptions()
|
||||
// ino.end
|
||||
// ino.method.makeBasicAssumptions.21418.body
|
||||
{
|
||||
@ -1376,7 +1469,17 @@ public class SourceFile
|
||||
|
||||
return foo;
|
||||
*/
|
||||
return new TypeAssumptions(null); //TODO: Diese TypeAssumptions mit basic-Assumptions füllen
|
||||
TypeAssumptions ret = new TypeAssumptions();
|
||||
|
||||
//Basic Assumptions für die FunN Interfaces:
|
||||
//TODO: Hier mehr als Fun1-Fun5 implementieren
|
||||
for(int i = 0; i<6; i++){
|
||||
FunNInterface funN = new FunNInterface(i);
|
||||
ret.add(funN.getPublicFieldAssumptions());
|
||||
}
|
||||
|
||||
|
||||
return ret; //TODO: Diese TypeAssumptions mit basic-Assumptions füllen
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -1507,21 +1610,21 @@ public class SourceFile
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
if(parent!=null)throw new TypinferenzException("Eine SourceFile hat keine Elternelement im Syntaxbaum");
|
||||
for(SyntaxTreeNode node : this.getChildren())node.parserPostProcessing(this);
|
||||
if(parent!=null)throw new DebugException("Eine SourceFile hat kein Elternelement im Syntaxbaum");
|
||||
super.parserPostProcessing(parent);
|
||||
//for(SyntaxTreeNode node : this.getChildren())node.parserPostProcessing(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SyntaxTreeNode getParent() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = super.getChildren();
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
for(Class cl : this.KlassenVektor){
|
||||
ret.add(cl);
|
||||
}
|
||||
@ -1533,8 +1636,9 @@ public class SourceFile
|
||||
* SourceFile stellt eine geparste Java-Datei dar. Mit dieser Methode wird der Name der eingelesenen Datei gesetzt.
|
||||
* @param filename - Der Name der eingelesenen JavaDatei
|
||||
*/
|
||||
@Deprecated
|
||||
public void setFileName(String filename) {
|
||||
this.filename = filename;
|
||||
//this.filename = filename;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,21 @@ package mycompiler;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.GenericTypeInsertPoint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
import typinferenz.typedeployment.TypeInsertSet;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.Generic;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
|
||||
public abstract class SyntaxTreeNode {
|
||||
public abstract class SyntaxTreeNode{
|
||||
|
||||
protected SyntaxTreeNode parent;
|
||||
|
||||
@ -14,6 +25,8 @@ public abstract class SyntaxTreeNode {
|
||||
* Erfüllt folgenden Aufgaben:
|
||||
* 1. Füllt fehlende Typangaben mit TPHs auf.
|
||||
* 2. Verknüpft die Knoten des Syntaxbaums. (setzt Parent)
|
||||
* 3. Wechselt RefTypes gegebenenfalls mit GenericTypeVars aus.
|
||||
* 4. Führt einen Teil des Syntaxckecks durch.
|
||||
*
|
||||
*/
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
@ -25,14 +38,76 @@ public abstract class SyntaxTreeNode {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public Vector<SyntaxTreeNode> getChildren(){
|
||||
return new Vector<SyntaxTreeNode>();
|
||||
}
|
||||
public abstract Vector<SyntaxTreeNode> getChildren();
|
||||
|
||||
public Class getParentClass(){
|
||||
SyntaxTreeNode parent = this.getParent();
|
||||
if(parent instanceof Class)return (Class)parent;
|
||||
if(parent == null)throw new TypinferenzException("Das Wurzelelement eines Syntaxbaumes muss Class sein");
|
||||
if(parent == null)
|
||||
throw new DebugException("Das Wurzelelement eines Syntaxbaumes muss Class sein");
|
||||
return parent.getParentClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Beschreibung/Name des SyntaxTree-Nodes
|
||||
* @return
|
||||
*/
|
||||
public String getDescription(){
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object){
|
||||
if(!(object instanceof SyntaxTreeNode))return false;
|
||||
SyntaxTreeNode equal = (SyntaxTreeNode)object;
|
||||
if(!equal.getDescription().equals(this.getDescription()))return false;
|
||||
if(this.getParent()!=null)
|
||||
if(!this.getParent().equals(equal.getParent()))return false; //auch das Elternelement überprüfen.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zur Generierung der TypeInsertPoints
|
||||
* @param insertSet - Generierte InsertPoints werden dem insertSet angefügt
|
||||
* @param result - Das ResultSet auf dessen Basis die InsertPoints generiert werden
|
||||
*/
|
||||
public void addTypeInsertPoints(TypeInsertSet insertSet,ResultSet result) {
|
||||
for(SyntaxTreeNode node : this.getChildren()){
|
||||
node.addTypeInsertPoints(insertSet, result);
|
||||
}
|
||||
|
||||
TypeInsertPoint tip = null; //Der TypInsertPoint für diesen Knoten
|
||||
//Fall der Knoten ein TypeInsertable ist, kann direkt der TypeInsertPoint generiert werden.
|
||||
if(this instanceof TypeInsertable){
|
||||
TypeInsertable that = (TypeInsertable)this;
|
||||
Type t = that.getType();
|
||||
if(t instanceof TypePlaceholder){
|
||||
tip = that.createTypeInsertPoint((TypePlaceholder) t, result);
|
||||
insertSet.add(tip);//ret.addAll(((TypePlaceholder)t).getTypeInsertPoints(result));
|
||||
}
|
||||
|
||||
//Für den Fall, dass dieser Knoten Generische Variablen halten kann.
|
||||
if(that instanceof Generic && that.getOffset()>=0){
|
||||
//Alle unresolvedTPHs ermitteln und GenericTypeVarInsertPoints bilden:
|
||||
Vector<TypePlaceholder> uTPHs = insertSet.getUnresolvedTPHs();
|
||||
/*
|
||||
for(TypePlaceholder tph : uTPHs){//GenericInsertPoints für diese TPHs bilden:
|
||||
GenericTypeInsertPoint genericTIP = new GenericTypeInsertPoint(that,tph,result);
|
||||
insertSet.add(genericTIP);
|
||||
}
|
||||
*/
|
||||
if(uTPHs.size()>0){//Nur wenn es auch unresolvedTPHs gibt:
|
||||
Vector<Pair> gPairs = result.getConstraintsFor(uTPHs);
|
||||
if(gPairs.size()>0){
|
||||
GenericTypeInsertPoint genericTIP = new GenericTypeInsertPoint(that,gPairs,result);
|
||||
insertSet.add(genericTIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,15 @@ package mycompiler.mybytecode;
|
||||
// ino.module.Attribute.8529.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.Attribute.21446.declaration
|
||||
public abstract class Attribute
|
||||
public abstract class Attribute implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.Attribute.21446.body
|
||||
{
|
||||
@ -44,7 +47,8 @@ public abstract class Attribute
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21461.declaration
|
||||
public abstract void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public abstract void codegen(ClassFile classfile, OutputStream f)
|
||||
throws JVMCodeException, IOException;
|
||||
// ino.end
|
||||
|
||||
|
@ -4,8 +4,10 @@ package mycompiler.mybytecode;
|
||||
|
||||
// ino.module.AttributeInfo.8530.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
// ino.end
|
||||
|
||||
@ -70,7 +72,8 @@ public class AttributeInfo extends Attribute
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21489.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws JVMCodeException, java.io.IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21489.body
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CONSTANT_Class_info.8533.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CONSTANT_Class_info.21763.declaration
|
||||
@ -35,7 +36,8 @@ public class CONSTANT_Class_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21776.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21776.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_Double_info.21782.declaration
|
||||
public class CONSTANT_Double_info extends CPInfo
|
||||
@ -46,7 +47,8 @@ public class CONSTANT_Double_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21804.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21804.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_Fieldref_info.21810.declaration
|
||||
public class CONSTANT_Fieldref_info extends CPInfo
|
||||
@ -57,7 +58,8 @@ public class CONSTANT_Fieldref_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21832.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21832.body
|
||||
|
@ -2,9 +2,9 @@
|
||||
package mycompiler.mybytecode;
|
||||
// ino.end
|
||||
// ino.module.CONSTANT_Float_info.8536.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_Float_info.21838.declaration
|
||||
public class CONSTANT_Float_info extends CPInfo
|
||||
@ -29,7 +29,8 @@ public class CONSTANT_Float_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21851.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21851.body
|
||||
|
@ -4,6 +4,7 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CONSTANT_Integer_info.8537.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
// ino.end
|
||||
|
||||
|
||||
@ -32,7 +33,8 @@ public class CONSTANT_Integer_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21870.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21870.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_InterfaceMethodref_info.21876.declaration
|
||||
public class CONSTANT_InterfaceMethodref_info extends CPInfo
|
||||
@ -57,7 +58,8 @@ public class CONSTANT_InterfaceMethodref_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21898.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21898.body
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CONSTANT_Long_info.8539.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CONSTANT_Long_info.21904.declaration
|
||||
@ -57,7 +58,8 @@ public class CONSTANT_Long_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21926.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21926.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_Methodref_info.21932.declaration
|
||||
public class CONSTANT_Methodref_info extends CPInfo
|
||||
@ -57,7 +58,8 @@ public class CONSTANT_Methodref_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21954.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21954.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_NameAndType_info.21960.declaration
|
||||
public class CONSTANT_NameAndType_info extends CPInfo
|
||||
@ -57,7 +58,8 @@ public class CONSTANT_NameAndType_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.21982.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.21982.body
|
||||
|
@ -6,6 +6,7 @@ package mycompiler.mybytecode;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
// ino.end
|
||||
import java.io.OutputStream;
|
||||
|
||||
// ino.class.CONSTANT_String_info.21988.declaration
|
||||
public class CONSTANT_String_info extends CPInfo
|
||||
@ -35,7 +36,8 @@ public class CONSTANT_String_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22001.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.22001.body
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CONSTANT_Utf8_info.8543.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
// ino.end
|
||||
|
||||
@ -36,7 +37,8 @@ public class CONSTANT_Utf8_info extends CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22020.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.22020.body
|
||||
|
@ -5,11 +5,13 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CPInfo.8544.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CPInfo.22026.declaration
|
||||
public abstract class CPInfo
|
||||
public abstract class CPInfo implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.CPInfo.22026.body
|
||||
{
|
||||
@ -43,7 +45,8 @@ public abstract class CPInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22041.declaration
|
||||
public abstract void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public abstract void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException;
|
||||
// ino.end
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//key_vector funktioniert nicht PL 14-03-21
|
||||
//muss angeschaut werden
|
||||
|
||||
|
||||
// ino.module.ClassFile.8531.package
|
||||
package mycompiler.mybytecode;
|
||||
// ino.end
|
||||
@ -5,8 +9,10 @@ package mycompiler.mybytecode;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.myclass.ParameterList;
|
||||
import mycompiler.myclass.UsedId;
|
||||
import mycompiler.MyCompiler;
|
||||
@ -16,6 +22,7 @@ import mycompiler.mystatement.Assign;
|
||||
import mycompiler.mystatement.Block;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.SourceFile;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
@ -50,10 +57,10 @@ public class ClassFile
|
||||
private static int magic = 0xcafebabe;
|
||||
// ino.end
|
||||
// ino.attribute.minor_version.21501.declaration
|
||||
private static short minor_version = 0;
|
||||
public static short minor_version = 0;
|
||||
// ino.end
|
||||
// ino.attribute.major_version.21504.declaration
|
||||
private static short major_version = 0x31;
|
||||
public static short major_version = 0x31;
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.constant_pool.21507.declaration
|
||||
@ -87,7 +94,7 @@ public class ClassFile
|
||||
private Vector<Assign> class_block = new Vector<Assign>();
|
||||
// ino.end
|
||||
// ino.attribute.class_name.21537.declaration
|
||||
private String class_name = new String();
|
||||
private String class_name = new String("OUTPUT");//DEFAULTWERT PL 14-03-21 eingefuegt
|
||||
// ino.end
|
||||
// ino.attribute.super_class_name.21540.declaration
|
||||
private String super_class_name = new String();
|
||||
@ -633,6 +640,11 @@ public class ClassFile
|
||||
// ino.method.set_attributes.21624.body
|
||||
{ this.attributes = t; }
|
||||
// ino.end
|
||||
|
||||
public void set_class_name(String cn) {
|
||||
this.class_name = cn;
|
||||
}
|
||||
|
||||
// ino.method.set_constructor_founded.21627.definition
|
||||
public void set_constructor_founded(boolean t)
|
||||
// ino.end
|
||||
@ -724,7 +736,8 @@ public class ClassFile
|
||||
codegenlog.info("Generieren der Klasse: " + class_name);
|
||||
|
||||
// Datei vorbereiten
|
||||
File file = new File(MyCompiler.getAPI().getOutputDir()
|
||||
//File file = new File(MyCompiler.getAPI().getOutputDir()
|
||||
File file = new File ("/Users/pl/forschung/PIZZA+/JVM_Generics/Testfiles/"
|
||||
+ class_name + ".class");
|
||||
FileOutputStream f = new FileOutputStream(file);
|
||||
|
||||
@ -794,7 +807,7 @@ public class ClassFile
|
||||
// ino.end
|
||||
|
||||
// ino.method.writeInt.21669.definition
|
||||
public void writeInt(FileOutputStream f, int i)
|
||||
public void writeInt(OutputStream f, int i)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.writeInt.21669.body
|
||||
@ -807,7 +820,7 @@ public class ClassFile
|
||||
// ino.end
|
||||
|
||||
// ino.method.writeShort.21672.definition
|
||||
public void writeShort(FileOutputStream f, short i)
|
||||
public void writeShort(OutputStream f, short i)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.writeShort.21672.body
|
||||
@ -818,7 +831,7 @@ public class ClassFile
|
||||
// ino.end
|
||||
|
||||
// ino.method.writeByte.21675.definition
|
||||
public void writeByte(FileOutputStream f, byte i)
|
||||
public void writeByte(OutputStream f, byte i)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.writeByte.21675.body
|
||||
@ -828,7 +841,7 @@ public class ClassFile
|
||||
// ino.end
|
||||
|
||||
// ino.method.writeByteArray.21678.definition
|
||||
public void writeByteArray(FileOutputStream f, byte[] b)
|
||||
public void writeByteArray(OutputStream f, byte[] b)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.writeByteArray.21678.body
|
||||
|
10
src/mycompiler/mybytecode/ClassFileMember.java
Normal file
10
src/mycompiler/mybytecode/ClassFileMember.java
Normal file
@ -0,0 +1,10 @@
|
||||
package mycompiler.mybytecode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
|
||||
public interface ClassFileMember {
|
||||
public void codegen(ClassFile cf, OutputStream out) throws JVMCodeException, IOException;
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
//PL 14-03-21: calculate_max_stack() duerfte nicht stimmen
|
||||
//vorübergehend max_stack und set_max_stack eingeführt
|
||||
//in codegen "short max_stack = calculate_max_stack();" auskommentiert
|
||||
//muss wieder einkommentiert werden
|
||||
|
||||
// ino.module.CodeAttribute.8532.package
|
||||
package mycompiler.mybytecode;
|
||||
// ino.end
|
||||
@ -5,8 +10,11 @@ package mycompiler.mybytecode;
|
||||
// ino.module.CodeAttribute.8532.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Vector;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mytype.Type;
|
||||
// ino.end
|
||||
@ -31,7 +39,13 @@ public class CodeAttribute extends Attribute
|
||||
// ino.attribute.local_type_vector.21697.declaration
|
||||
private Vector<Type> local_type_vector = new Vector<Type>();
|
||||
// ino.end
|
||||
|
||||
short max_stack;
|
||||
|
||||
public CodeAttribute() {
|
||||
super();
|
||||
}
|
||||
|
||||
// ino.method.CodeAttribute.21700.definition
|
||||
public CodeAttribute(String class_name, short acc_flags)
|
||||
// ino.end
|
||||
@ -202,9 +216,11 @@ public class CodeAttribute extends Attribute
|
||||
// ino.end
|
||||
// ino.method.get_attributes_length.21748.body
|
||||
{
|
||||
int ret = 12;
|
||||
int ret = 8;//2(max_stack)+2(max_locals)+4(code_length)
|
||||
ret += code_vector.size();
|
||||
ret += 2; //exception table length
|
||||
ret += (exception_tables.size() * 8);
|
||||
ret += 2; //Attribute_count
|
||||
for (int i = 0; i < attributes.size(); i++)
|
||||
ret += attributes.elementAt(i)
|
||||
.get_attributes_length();
|
||||
@ -230,6 +246,11 @@ public class CodeAttribute extends Attribute
|
||||
}
|
||||
// ino.end
|
||||
|
||||
public void set_max_stack(short ms) {
|
||||
max_stack = ms;
|
||||
}
|
||||
|
||||
|
||||
// ino.method.codegen.21757.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
throws JVMCodeException, IOException
|
||||
@ -237,7 +258,8 @@ public class CodeAttribute extends Attribute
|
||||
// ino.method.codegen.21757.body
|
||||
{
|
||||
int attributes_length = this.get_attributes_length();
|
||||
short max_stack = calculate_max_stack();
|
||||
//PL 14-03-21: muss wieder einkommentiert werden
|
||||
//short max_stack = calculate_max_stack();
|
||||
classfile.writeShort(f, get_attribute_name_index());
|
||||
classfile.writeInt(f, attributes_length);
|
||||
classfile.writeShort(f, max_stack);
|
||||
@ -278,6 +300,7 @@ public class CodeAttribute extends Attribute
|
||||
// ino.end
|
||||
|
||||
// ino.method.calculate_max_stack.21760.definition
|
||||
//PL 14-03-21: Diese Methode duerfte nicht stimmen
|
||||
private short calculate_max_stack()
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
@ -1067,5 +1090,11 @@ public class CodeAttribute extends Attribute
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws JVMCodeException, IOException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,11 +5,13 @@ package mycompiler.mybytecode;
|
||||
// ino.module.ExceptionTable.8545.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.ExceptionTable.22047.declaration
|
||||
public class ExceptionTable
|
||||
public class ExceptionTable implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.ExceptionTable.22047.body
|
||||
{
|
||||
@ -36,7 +38,8 @@ public class ExceptionTable
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22065.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.22065.body
|
||||
|
@ -5,13 +5,16 @@ package mycompiler.mybytecode;
|
||||
// ino.module.FieldInfo.8546.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.FieldInfo.22068.declaration
|
||||
public class FieldInfo
|
||||
public class FieldInfo implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.FieldInfo.22068.body
|
||||
{
|
||||
@ -177,7 +180,8 @@ public class FieldInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22137.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws IOException, JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.22137.body
|
||||
|
@ -4,11 +4,13 @@ package mycompiler.mybytecode;
|
||||
|
||||
// ino.module.Key.8548.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.Key.22890.declaration
|
||||
public class Key
|
||||
public class Key implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.Key.22890.body
|
||||
{
|
||||
@ -87,7 +89,8 @@ public class Key
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22920.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
// ino.end
|
||||
// ino.method.codegen.22920.body
|
||||
{
|
||||
|
@ -5,13 +5,16 @@ package mycompiler.mybytecode;
|
||||
// ino.module.MethodInfo.8549.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.MethodInfo.22923.declaration
|
||||
public class MethodInfo
|
||||
public class MethodInfo implements ClassFileMember
|
||||
// ino.end
|
||||
// ino.class.MethodInfo.22923.body
|
||||
{
|
||||
@ -111,7 +114,7 @@ public class MethodInfo
|
||||
// ino.end
|
||||
|
||||
// ino.method.codegen.22965.definition
|
||||
public void codegen(ClassFile classfile, FileOutputStream f)
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws JVMCodeException, IOException
|
||||
// ino.end
|
||||
// ino.method.codegen.22965.body
|
||||
|
@ -5,7 +5,9 @@ package mycompiler.mybytecode;
|
||||
// ino.module.SignatureInfo.8550.import
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.myclass.ParameterList;
|
||||
import mycompiler.myclass.UsedId;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
@ -13,9 +15,12 @@ import mycompiler.mytype.BoundedGenericTypeVar;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
// ino.class.SignatureInfo.22968.description type=javadoc
|
||||
/**
|
||||
* Generiert die Attribute eines Fields, einer Methode oder einer Klasse/Interface
|
||||
@ -43,6 +48,9 @@ public class SignatureInfo extends Attribute
|
||||
// ino.end
|
||||
|
||||
|
||||
public SignatureInfo(short sid) {
|
||||
signatureID = sid;
|
||||
}
|
||||
// ino.method.SignatureInfo.22978.defdescription type=javadoc
|
||||
/**
|
||||
* Konstruktor fuer die Signatur einer Klasse bzw. eines Interfaces.
|
||||
@ -254,6 +262,12 @@ public class SignatureInfo extends Attribute
|
||||
return 2;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, OutputStream f)
|
||||
throws JVMCodeException, IOException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -10,6 +10,7 @@ import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.AClassOrInterface;
|
||||
import mycompiler.IItemWithOffset;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
@ -57,20 +58,29 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.assumptions.ClassAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
import typinferenz.*;
|
||||
|
||||
|
||||
// ino.class.Class.23010.declaration
|
||||
public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWithOffset, Generic
|
||||
// ino.end
|
||||
// ino.class.Class.23010.body
|
||||
{
|
||||
@ -247,14 +257,8 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
*/
|
||||
public void addField(Field i)
|
||||
{
|
||||
Field tempField = i;
|
||||
if(i instanceof Method){
|
||||
Method method = (Method)i;
|
||||
if(method.get_Method_Name().equals(this.getName()) ){
|
||||
tempField = new Constructor(method);
|
||||
}
|
||||
}
|
||||
fielddecl.addElement(tempField);
|
||||
|
||||
fielddecl.addElement(i);
|
||||
}
|
||||
|
||||
// ino.method.getUsedIdsToCheck.23050.definition
|
||||
@ -305,8 +309,14 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generiert die ClassFile für diese Klasse.
|
||||
* @param typeinferenceResult - Das ResultSet einer Typinferierung oder null, falls alle Typen eindeutig feststehen.
|
||||
* @return
|
||||
* @throws JVMCodeException
|
||||
*/
|
||||
// ino.method.codegen.23071.definition
|
||||
public void codegen(SourceFile sf)
|
||||
public ClassFile codegen(ResultSet typeinferenceResult)
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.23071.body
|
||||
@ -322,12 +332,15 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
}
|
||||
|
||||
// Handling der Package
|
||||
String pkgName = "";
|
||||
if (sf.getPackageName() != null) {
|
||||
pkgName = sf.getPackageName().get_codegen_UsedId() + "/";
|
||||
}
|
||||
//String pkgName = "";
|
||||
//if (sf.getPackageName() != null) {
|
||||
// pkgName = sf.getPackageName().get_codegen_UsedId() + "/";
|
||||
//}
|
||||
|
||||
classfile.add_class(getName(), pkgName, superClass, getAccessFlags());
|
||||
//geändert von Andreas Stadelmeier: pkgName wird nicht mehr aus dem SourceFile ausgelesen:
|
||||
String packageName = "";
|
||||
if(pkgName != null) packageName = pkgName.get_Name_1Element();
|
||||
classfile.add_class(getName(), packageName, superClass, getAccessFlags());
|
||||
|
||||
// Handling fuer Superinterfaces
|
||||
classfile.addSuperInterfaces(getSuperInterfaces());
|
||||
@ -346,9 +359,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
classfile.add_method("<init>", "()V", null, null, null, (short)0, this.paralist, false);
|
||||
}
|
||||
|
||||
classfile.codegen();
|
||||
//classfile.codegen();
|
||||
|
||||
codegenlog.info("Compilierung erfolgreich abgeschlossen, "+ getName() + ".class erstellt.");
|
||||
return classfile;
|
||||
}
|
||||
|
||||
public void codegen(ClassFile classfile, Vector paralist)
|
||||
@ -398,7 +412,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
* -Rückgabetyp der Methode/Konstruktors ist der Typ der Klasse
|
||||
* -Ein Konstruktor kann nicht aufgerufen werden (nur mit new)
|
||||
*/
|
||||
if(m.get_Method_Name().equals("<init>"))throw new TypinferenzException("<init> ist kein gültiger Methodenname");
|
||||
if(m.get_Method_Name().equals("<init>"))throw new TypeinferenceException("<init> ist kein gültiger Methodenname", m);
|
||||
if((m.get_Method_Name().equals(this.getName()))) {
|
||||
Constructor constructor = new Constructor(m);
|
||||
tempFields.add(constructor); //Den Konstruktor anstatt der Methode anfügen
|
||||
@ -470,7 +484,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_ParaList.23101.definition
|
||||
public Vector get_ParaList()
|
||||
public Vector<Type> get_ParaList()
|
||||
// ino.end
|
||||
// ino.method.get_ParaList.23101.body
|
||||
{
|
||||
@ -635,10 +649,17 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
// @author A10023 - Andreas Stadelmeier:
|
||||
//////////////////////////////
|
||||
//Erzeuge Assumptions:
|
||||
TypeAssumptions assumptions = this.getTypeAssumptions();
|
||||
//--
|
||||
TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
|
||||
//Globale Assumptions anfügen:
|
||||
assumptions.add(globalAssumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
for(Type gparam : this.paralist){
|
||||
if(gparam instanceof GenericTypeVar)oderConstraints.add(((GenericTypeVar)gparam).TYPE(assumptions)); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen
|
||||
}
|
||||
|
||||
typinferenzLog.debug("Erstellte Assumptions: "+assumptions);
|
||||
/*
|
||||
//Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden.
|
||||
Vector<Expr> fieldInitializers = new Vector<Expr>();
|
||||
@ -653,7 +674,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
|
||||
//ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
for(Field f:this.getFields()){
|
||||
oderConstraints.add(f.TYPE(assumptions));
|
||||
}
|
||||
@ -821,11 +842,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
*/
|
||||
|
||||
/**
|
||||
* Die Funktion ist erst nach dem Aufruf von getMethodList() nutzbar.
|
||||
* Ermittelt alle Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
|
||||
* Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
|
||||
* Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
|
||||
* @return Die erstellten TypeAssumptions
|
||||
*/
|
||||
private TypeAssumptions getTypeAssumptions() {
|
||||
private TypeAssumptions getPrivateFieldAssumptions() {
|
||||
if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
|
||||
TypeAssumptions assumptions = new TypeAssumptions(this.getName());
|
||||
//this.getMethodList(); //Diese Funktion muss zuerst ausgeführt werden.
|
||||
@ -834,7 +855,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
//assumptions.setThisV(thisAssumption);
|
||||
|
||||
for(Field field : this.getFields()){
|
||||
assumptions.add(field.createTypeAssumptions(this));
|
||||
if(!field.isPublic())assumptions.add(field.createTypeAssumptions(this));
|
||||
}
|
||||
|
||||
//Eine Assumption für den Standardkonstruktor:
|
||||
@ -844,9 +865,6 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
// assumptions.addMethodAssumption(new RefType(this.getName(),0), "<init>", new RefType(this.getName(),0), new Vector<CParaTypeAssumption>());
|
||||
//}
|
||||
|
||||
|
||||
typinferenzLog.debug("Erstellte Assumptions: "+assumptions);
|
||||
|
||||
this.typeAssumptions = assumptions; //Diese müssen anschließend nicht wieder generiert werden.
|
||||
return assumptions;
|
||||
}
|
||||
@ -948,8 +966,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.23128.body
|
||||
{
|
||||
|
||||
|
||||
for(Field f : this.getFields()){
|
||||
f.wandleRefTypeAttributes2GenericAttributes(paralist);
|
||||
}
|
||||
/*
|
||||
Vector fieldsAndMethods=this.getFields();
|
||||
|
||||
// Alle Methoden und Instanzvariablen durchgehen
|
||||
@ -960,7 +980,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
Method method=(Method)fieldsAndMethods.get(i);
|
||||
method.wandleRefTypeAttributes2GenericAttributes(paralist);
|
||||
}// Ist es eine InstanzVariable?
|
||||
/*
|
||||
*//*
|
||||
else if(fieldsAndMethods.get(i) instanceof InstVarDecl){
|
||||
InstVarDecl instVar=(InstVarDecl)fieldsAndMethods.get(i);
|
||||
Type type=instVar.getType();
|
||||
@ -971,8 +991,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
instVar.setType(pendant);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -1162,11 +1183,6 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
|
||||
JavaCodeResult classBodyCode = new JavaCodeResult();
|
||||
if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach(" ");
|
||||
|
||||
if(superclassid == null || superclassid.get_Name().size()<1){
|
||||
int superclassidOffset = superclassid == null ? 0 : superclassid.getOffset();
|
||||
superclassid = new UsedId("Object", superclassidOffset);
|
||||
}
|
||||
|
||||
classBodyCode.attach(this.name + " extends ").attach(superclassid.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach("\n");
|
||||
|
||||
@ -1201,10 +1217,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
* Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben.
|
||||
* @param tphs : Alle übriggebliebenen TypePLaceholder
|
||||
*/
|
||||
public void createGenericTypeVars(Vector<TypePlaceholder> tphs){
|
||||
private void createGenericTypeVars(Vector<TypePlaceholder> tphs){
|
||||
this.genericClassParameters = new Vector<GenericTypeVar>();
|
||||
for(TypePlaceholder tph : tphs){
|
||||
GenericTypeVar toAdd = new GenericTypeVar(tph);
|
||||
GenericTypeVar toAdd = new GenericTypeVar(tph,this.getOffset());
|
||||
if(!this.genericClassParameters.contains(toAdd))this.genericClassParameters.add(toAdd);
|
||||
}
|
||||
}
|
||||
@ -1213,40 +1229,45 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
* Errechnet die Generischen Parameter der Klasse für diese Klasse.
|
||||
* Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben.
|
||||
* @param reconstructionResult
|
||||
*/
|
||||
|
||||
public void createGenericTypeVars(TypeinferenceResultSet reconstructionResult){
|
||||
this.genericClassParameters = new Vector<GenericTypeVar>();
|
||||
for(Pair pair : reconstructionResult.getUnifiedConstraints()){
|
||||
if(pair.TA2 instanceof TypePlaceholder && pair.TA1 instanceof TypePlaceholder){// if(pair.OperatorSmallerExtends() || pair.OperatorSmaller()){
|
||||
Type ta1=reconstructionResult.getUnifiedConstraints().getTypeEqualTo(pair.TA1);
|
||||
Type ta2=reconstructionResult.getUnifiedConstraints().getTypeEqualTo(pair.TA2);
|
||||
this.genericClassParameters.add(new GenericTypeVar(new Pair(ta1,ta2)));
|
||||
this.genericClassParameters.add(new GenericTypeVar(new Pair(ta1,ta2),this.getOffset()));
|
||||
}
|
||||
/*
|
||||
// Auf SuperWildcardTypes überprüfen:
|
||||
ArrayList<SuperWildcardType> wildcardTypes = pair.TA2.getSuperWildcardTypes();
|
||||
wildcardTypes.addAll(pair.TA1.getSuperWildcardTypes());
|
||||
for(SuperWildcardType wildcardType : wildcardTypes){
|
||||
this.genericClassParameters.add(new GenericTypeVar(new Pair(TypePlaceholder.fresh(), wildcardType.getContainedType())));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
for(Pair pair : reconstructionResult.getConstraints()){
|
||||
if( ! reconstructionResult.getUnifiedConstraints().contains(pair.TA1)){
|
||||
this.genericClassParameters.add(new GenericTypeVar(pair.TA1));
|
||||
this.genericClassParameters.add(new GenericTypeVar(pair.TA1,this.getOffset()));
|
||||
}
|
||||
if( ! reconstructionResult.getUnifiedConstraints().contains(pair.TA2)){
|
||||
this.genericClassParameters.add(new GenericTypeVar(pair.TA2));
|
||||
this.genericClassParameters.add(new GenericTypeVar(pair.TA2, this.getOffset()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public int getOffset(){
|
||||
//TODO: richtiges Offset:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen RefType, welcher auf diese Klasse verweist
|
||||
* Ersetzt alle Generischen Variablen in der Parameterliste mit TPH
|
||||
* @return
|
||||
*/
|
||||
public RefType getType() {
|
||||
/*
|
||||
Vector<Type> parameter = new Vector<Type>();
|
||||
for(Type param : this.get_ParaList()){
|
||||
parameter.add(((GenericTypeVar)param).getTypePlaceHolder());//(TypePlaceholder.fresh()); //Hier ist kein ReplacementListener notwendig. Der Typ soll nie eingesetzt werden. Der TPH wird nur gebraucht, damit das Unifizieren funktioniert.
|
||||
}
|
||||
*/
|
||||
return new RefType(this.getName(), this.get_ParaList(), 0);
|
||||
}
|
||||
|
||||
@ -1257,13 +1278,40 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
* @return
|
||||
*/
|
||||
public TypeAssumptions getPublicFieldAssumptions() {
|
||||
TypeAssumptions ret = this.getTypeAssumptions();
|
||||
TypeAssumptions ret = new TypeAssumptions();//this.getPrivateFieldAssumptions();
|
||||
ret.addClassAssumption(new ClassAssumption(this));
|
||||
for(Field f : this.getFields()){
|
||||
if(f.isPublic())ret.add(f.createTypeAssumptions(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
|
||||
//Wenn keine Superklasse, dann erbt die Klasse zwangsweise von Object:
|
||||
if(superclassid == null || superclassid.get_Name().size()<1){
|
||||
int superclassidOffset = superclassid == null ? 0 : superclassid.getOffset();
|
||||
superclassid = new UsedId("Object", superclassidOffset);
|
||||
}
|
||||
|
||||
//Alle Methoden auf Konstruktoren durchsuchen und diese umwandeln:
|
||||
Vector<Field> tempFields = new Vector<Field>();
|
||||
for(Field f : this.getFields()){
|
||||
if(f instanceof Method && !(f instanceof Constructor)){
|
||||
Method method = (Method)f;
|
||||
if(method.get_Method_Name().equals(this.getName()) ){
|
||||
tempFields.add(new Constructor(method));
|
||||
}else{
|
||||
tempFields.add(f);
|
||||
}
|
||||
}else{
|
||||
tempFields.add(f);
|
||||
}
|
||||
}
|
||||
this.fielddecl = tempFields;
|
||||
|
||||
//Prüfen ob ein Konstruktor vorhanden ist:
|
||||
boolean constructorVorhanden = false;
|
||||
for(Field f : this.getFields()){
|
||||
@ -1273,13 +1321,15 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
}
|
||||
}
|
||||
if(!constructorVorhanden){//Falls kein Konstruktor vorhanden ist, muss noch der Standardkonstruktor angefügt werden:
|
||||
|
||||
|
||||
Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName(), this));
|
||||
this.addField(standardKonstruktor);
|
||||
}
|
||||
|
||||
//TODO: Umwandlung zu RefTypes funktioniert noch nicht richtig. (siehe LambdaTest2)
|
||||
//Als RefType geparste Generische Variablen umwandeln:
|
||||
this.wandleRefTypeAttributes2GenericAttributes();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SyntaxTreeNode getParent() {
|
||||
return this;
|
||||
@ -1302,5 +1352,20 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return "class "+this.getName();
|
||||
}
|
||||
@Override
|
||||
public int getVariableLength() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
||||
this.genericClassParameters = params;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -27,6 +27,7 @@ public class ClassHelper
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.findGenericType.23209.definition
|
||||
@Deprecated
|
||||
public static GenericTypeVar findGenericType(Type type, Vector<Type> paralist, Vector<GenericTypeVar> methodParaList)
|
||||
// ino.end
|
||||
// ino.method.findGenericType.23209.body
|
||||
|
@ -50,10 +50,12 @@ public class Constant extends Method
|
||||
// ino.end
|
||||
|
||||
// ino.method.Constant.23228.definition
|
||||
@Deprecated
|
||||
public Constant(String name, Modifiers mod)
|
||||
// ino.end
|
||||
// ino.method.Constant.23228.body
|
||||
{
|
||||
super(0); //Nur ein Workaraound. Da Constant = Deprecated
|
||||
this.name = name;
|
||||
this.mod = mod;
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.assumptions.ConstructorAssumption;
|
||||
import typinferenz.assumptions.MethodAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
public class Constructor extends Method {
|
||||
private Method methode;
|
||||
@ -25,10 +28,13 @@ public class Constructor extends Method {
|
||||
* Diese Klasse beherbegt den als Methode geparsten Konstruktor und wandelt sein verhalten zu dem eines Konstruktors ab.
|
||||
*/
|
||||
public Constructor(Method methode){
|
||||
super(methode.getOffset());
|
||||
this.methode = methode;
|
||||
this.setDeclIdVector(methode.getDeclIdVector());
|
||||
this.methode.setType(this.methode.getParentClass().getType());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGenericMethodParameters(
|
||||
Vector<GenericTypeVar> genericMethodParameters) {
|
||||
@ -51,7 +57,7 @@ public class Constructor extends Method {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
|
||||
return this.methode.getTypeName();
|
||||
return this.getType().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,11 +66,7 @@ public class Constructor extends Method {
|
||||
return this.methode.get_Block();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReturnType(Type type) {
|
||||
|
||||
this.methode.setReturnType(type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set_Block(Block blo) {
|
||||
@ -120,12 +122,6 @@ public class Constructor extends Method {
|
||||
this.methode.setOverloadedID(overloadedID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getReturnType() {
|
||||
|
||||
return this.methode.getReturnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get_codegen_Param_Type(Vector paralist) {
|
||||
|
||||
@ -244,10 +240,17 @@ public class Constructor extends Method {
|
||||
|
||||
@Override
|
||||
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||
|
||||
return this.methode.createTypeAssumptions(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
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
|
||||
@ -262,14 +265,120 @@ public class Constructor extends Method {
|
||||
|
||||
@Override
|
||||
public void setType(Type t) {
|
||||
|
||||
this.methode.setType(t);
|
||||
throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
|
||||
//this.methode.setType(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return new RefType(this.methode.getParentClass().getName(),0);
|
||||
return this.methode.getType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this.methode.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set_DeclId(DeclId did) {
|
||||
this.methode.set_DeclId(did);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<DeclId> get_Name() {
|
||||
return this.methode.get_Name();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<DeclId> getDeclIdVector() {
|
||||
return this.methode.getDeclIdVector();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDeclIdVector(Vector<DeclId> vDeclId) {
|
||||
this.methode.setDeclIdVector(vDeclId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.methode.getIdentifier();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return this.methode.getDescription();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class getParentClass() {
|
||||
return this.methode.getParentClass();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// ino.class.Constructor.23267.declaration
|
||||
public class Constructor_Backup extends Method
|
||||
// ino.end
|
||||
// ino.class.Constructor.23267.body
|
||||
{
|
||||
// ino.method.Constructor.23271.definition
|
||||
public Constructor_Backup()
|
||||
// ino.end
|
||||
// ino.method.Constructor.23271.body
|
||||
{
|
||||
this.setParameterList(null);
|
||||
// #JB# 04.06.2005
|
||||
// ###########################################################
|
||||
DeclId decl = new DeclId();
|
||||
decl.set_Name("<init>");
|
||||
this.set_DeclId(decl);
|
||||
// ###########################################################
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_Param_Type.23274.definition
|
||||
public String get_codegen_Param_Type(Vector paralist)
|
||||
// ino.end
|
||||
// ino.method.get_codegen_Param_Type.23274.body
|
||||
{
|
||||
String ret = new String();
|
||||
if(this.getParameterList() == null)
|
||||
{
|
||||
ret += "()";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += this.getParameterList().get_codegen_ParameterList(paralist);
|
||||
}
|
||||
ret += "V";
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.codegen.23277.definition
|
||||
public void codegen(ClassFile classfile, Vector paralist)
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.23277.body
|
||||
{
|
||||
classfile.set_constructor_founded(true);
|
||||
classfile.add_method("<init>", this.get_codegen_Param_Type(paralist), this.getParameterList(), null, get_Block(), declid.firstElement().get_access_flags(), paralist, false);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
}
|
||||
*/
|
||||
|
@ -1,79 +0,0 @@
|
||||
// ino.module.Constructor.8557.package
|
||||
package mycompiler.myclass;
|
||||
// ino.end
|
||||
// ino.module.Constructor.8557.import
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
// ino.end
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.Constructor.23267.declaration
|
||||
public class Constructor_Backup extends Method
|
||||
// ino.end
|
||||
// ino.class.Constructor.23267.body
|
||||
{
|
||||
// ino.method.Constructor.23271.definition
|
||||
public Constructor_Backup()
|
||||
// ino.end
|
||||
// ino.method.Constructor.23271.body
|
||||
{
|
||||
this.setParameterList(null);
|
||||
// #JB# 04.06.2005
|
||||
// ###########################################################
|
||||
DeclId decl = new DeclId();
|
||||
decl.set_Name("<init>");
|
||||
this.set_DeclId(decl);
|
||||
// ###########################################################
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_Param_Type.23274.definition
|
||||
public String get_codegen_Param_Type(Vector paralist)
|
||||
// ino.end
|
||||
// ino.method.get_codegen_Param_Type.23274.body
|
||||
{
|
||||
String ret = new String();
|
||||
if(this.getParameterList() == null)
|
||||
{
|
||||
ret += "()";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += this.getParameterList().get_codegen_ParameterList(paralist);
|
||||
}
|
||||
ret += "V";
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.codegen.23277.definition
|
||||
public void codegen(ClassFile classfile, Vector paralist)
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.23277.body
|
||||
{
|
||||
classfile.set_constructor_founded(true);
|
||||
classfile.add_method("<init>", this.get_codegen_Param_Type(paralist), this.getParameterList(), null, get_Block(), declid.firstElement().get_access_flags(), paralist, false);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
}
|
||||
// ino.end
|
@ -5,7 +5,10 @@ import java.util.Vector;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
@ -13,8 +16,9 @@ import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
|
||||
public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Typeable{
|
||||
public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Typeable, Generic{
|
||||
|
||||
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
||||
|
||||
@ -22,6 +26,10 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
||||
|
||||
private int offset;
|
||||
|
||||
public Field(int offset){
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOffset(int offset){
|
||||
this.offset = offset;
|
||||
@ -86,4 +94,40 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
||||
public String getIdentifier() {
|
||||
return this.get_Name().firstElement().get_Name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return this.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||
ResultSet resultSet) {
|
||||
return new TypeInsertPoint(this, resultSet.getTypeEqualTo(tph), resultSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wird im Zuge des ParserPostProcessing aufgerufen.
|
||||
* Der Parser kann den Unterschied zwischen einem RefType und einer GTV nicht erkennen.
|
||||
* Diese Methode ersetzt die RefTypes gegebenenfalls durch eine GTV.
|
||||
* @param paralist
|
||||
*/
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist){
|
||||
// Zuerst Returntype untersuchen
|
||||
Type type=getType();
|
||||
Type pendantReturnType = null;
|
||||
if(type instanceof RefType)pendantReturnType = ((RefType)type).findGenericType(paralist, new Vector<GenericTypeVar>());//GenericTypeVar pendantReturnType=ClassHelper.findGenericType(type, paralist,new Vector<GenericTypeVar>());
|
||||
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
|
||||
setType(pendantReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
//TODO: momentan ist jedes Feld public!
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,95 +0,0 @@
|
||||
// ino.module.FieldDecl.8560.package
|
||||
package mycompiler.myclass;
|
||||
// ino.end
|
||||
// ino.module.FieldDecl.8560.import
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
// ino.end
|
||||
import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
||||
|
||||
@Deprecated
|
||||
// ino.class.FieldDecl.23367.declaration
|
||||
public abstract class FieldDecl implements TypeInsertable
|
||||
// ino.end
|
||||
// ino.class.FieldDecl.23367.body
|
||||
{
|
||||
// ino.attribute.declid.23370.declaration
|
||||
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
||||
|
||||
// ino.end
|
||||
// ino.method.getTypeName.23373.declaration
|
||||
public abstract String getTypeName();
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
}
|
||||
// ino.end
|
@ -7,11 +7,15 @@ import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.assumptions.FieldAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||
@ -26,6 +30,21 @@ public class FieldDeclaration extends Field{
|
||||
|
||||
private Expr wert;
|
||||
//private Type type;
|
||||
private Vector<GenericTypeVar> parameter;
|
||||
|
||||
/**
|
||||
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
|
||||
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
|
||||
*/
|
||||
public FieldDeclaration(String name, Type typ){
|
||||
super(0);//Dieser Deklarator wird nicht vom Parser aufgerufen. Dadurch gibt es auch keinen Offset
|
||||
this.setType(typ);
|
||||
this.set_DeclId(new DeclId(name));
|
||||
}
|
||||
|
||||
public FieldDeclaration(int offset){
|
||||
super(offset);
|
||||
}
|
||||
|
||||
public void setWert(Expr initialExpression){
|
||||
this.wert = initialExpression;
|
||||
@ -48,7 +67,8 @@ public class FieldDeclaration extends Field{
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "=" + getWert().toString();
|
||||
if(getWert()!=null)return super.toString() + "=" + getWert().toString();
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
|
||||
@ -68,18 +88,19 @@ public class FieldDeclaration extends Field{
|
||||
//////////////////////////////
|
||||
TypeAssumptions assumptions = new TypeAssumptions();
|
||||
/*
|
||||
* TODO: Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||
* Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||
* Wird das Feld mit einem Typ initialisiert so muss dieser auch in die Assumptions.
|
||||
*/
|
||||
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||
if(this.getType() == null)throw new TypeinferenceException("Der Typ eines Feldes darf nicht null sein", this);
|
||||
//assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
|
||||
|
||||
assumptions.addAssumption(new FieldAssumption(this,classmember));
|
||||
return assumptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent){
|
||||
super.parserPostProcessing(parent);
|
||||
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||
|
||||
}
|
||||
|
||||
@ -108,6 +129,24 @@ public class FieldDeclaration extends Field{
|
||||
@Override
|
||||
public ConstraintsSet TYPE(TypeAssumptions publicAssumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
/*
|
||||
if(this.getType() instanceof GenericTypeVar){
|
||||
//Falls Typ ein GTV ist muss er syntaktisch kontrolliert werden...
|
||||
GenericTypeVar gtv = (GenericTypeVar) this.getType();
|
||||
}
|
||||
*/
|
||||
|
||||
//TypeCheck, falls es sich um einen RefType handelt:
|
||||
this.getType().checkType(publicAssumptions, this);
|
||||
/*
|
||||
if(this.getType()!=null && (this.getType() instanceof RefType)){
|
||||
Type replaceType = null;
|
||||
replaceType = publicAssumptions.getTypeFor((RefType)this.getType());
|
||||
if(replaceType == null)throw new TypeinferenceException("Der Typ "+this.getType().getName()+" ist nicht korrekt",this);
|
||||
this.setType(replaceType);
|
||||
}
|
||||
*/
|
||||
|
||||
SingleConstraint c1 = new SingleConstraint(this.getType(), this.getType());
|
||||
ret.add(c1); //Damit die TypVariable des Felds in den Constraints auftaucht
|
||||
|
||||
@ -119,6 +158,15 @@ public class FieldDeclaration extends Field{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist){
|
||||
super.wandleRefTypeAttributes2GenericAttributes(paralist);
|
||||
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Vector<GenericTypeVar>()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
||||
this.parameter = params;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
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.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
|
||||
|
||||
@Deprecated
|
||||
public class FieldInitialization extends InstVarDecl {
|
||||
|
||||
|
||||
private Expr wert;
|
||||
//private Type type;
|
||||
|
||||
public void setWert(Expr initialExpression){
|
||||
this.wert = initialExpression;
|
||||
}
|
||||
public Expr getWert(){
|
||||
return this.wert;
|
||||
}
|
||||
|
||||
public String getIdentifier(){
|
||||
return this.getIdentifier().elementAt(0).name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void codegen(ClassFile classfile, Vector paralist)
|
||||
throws JVMCodeException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/*
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "=" + getWert().toString();
|
||||
}
|
||||
|
||||
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
ret.attach(this.getType().printJavaCode(resultSet)).attach( " ").attach( this.getName()+" = ").attach(this.getWert().printJavaCode(resultSet) ).attach( ";");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||
//////////////////////////////
|
||||
//Felder:
|
||||
//////////////////////////////
|
||||
|
||||
TypeAssumptions assumptions = new TypeAssumptions();
|
||||
/*
|
||||
* TODO: Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||
* Wird das Feld mit einem Typ initialisiert so muss dieser auch in die Assumptions.
|
||||
*/
|
||||
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||
assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
|
||||
classmember.get_ClassBody().addField(this);
|
||||
return assumptions;
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,9 @@ package mycompiler.myclass;
|
||||
// ino.end
|
||||
|
||||
// ino.module.FormalParameter.8561.import
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mytype.Type;
|
||||
@ -16,14 +19,27 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
import typinferenz.typedeployment.TypeInsertSet;
|
||||
|
||||
// ino.class.FormalParameter.23391.declaration
|
||||
public class FormalParameter implements ITypeReplacementListener, Typeable, TypeInsertable
|
||||
public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementListener, Typeable, TypeInsertable
|
||||
// ino.end
|
||||
// ino.class.FormalParameter.23391.body
|
||||
{
|
||||
@ -37,9 +53,25 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
// ino.end
|
||||
|
||||
public FormalParameter(DeclId name){
|
||||
this.set_DeclId(name);
|
||||
}
|
||||
|
||||
|
||||
// ino.method.setType.23404.defdescription type=javadoc
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if(!super.equals(object))return false;
|
||||
if(!(object instanceof FormalParameter))return false;
|
||||
FormalParameter equals = (FormalParameter)object;
|
||||
if((this.type==null)!=(equals.type == null))return false;
|
||||
if(this.type != null){
|
||||
return this.type.equals(equals.type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ino.method.setType.23404.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
||||
* @param t
|
||||
@ -68,6 +100,7 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
|
||||
// ino.end
|
||||
// ino.method.set_DeclId.23407.body
|
||||
{
|
||||
if(did == null)throw new NullPointerException();
|
||||
this.declid = did;
|
||||
}
|
||||
// ino.end
|
||||
@ -100,7 +133,7 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
|
||||
public String getTypeName()
|
||||
// ino.end
|
||||
// ino.method.getTypeName.23416.body
|
||||
{
|
||||
{ if(this.getType() == null)return "";
|
||||
return this.getType().getName();
|
||||
}
|
||||
// ino.end
|
||||
@ -206,6 +239,8 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setOffset(int offset) {
|
||||
//Das Offset steht in declId
|
||||
@ -213,5 +248,50 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
return new Vector<SyntaxTreeNode>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
if(this.type==null)this.type = TypePlaceholder.fresh(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||
ResultSet resultSet) {
|
||||
if(this.getOffset()<=0)return null;
|
||||
Type t = resultSet.getTypeEqualTo(tph);
|
||||
return new TypeInsertPoint(this, t, resultSet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getVariableLength() {
|
||||
int ret = 0;
|
||||
ret += this.getTypeName().length();
|
||||
ret +=this.getIdentifier().length();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public DeclId getDeclId() {
|
||||
return this.declid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
String ret = "";
|
||||
if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){
|
||||
ret += this.getType().getName() + " ";
|
||||
}
|
||||
return ret+this.getIdentifier();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
15
src/mycompiler/myclass/Generic.java
Normal file
15
src/mycompiler/myclass/Generic.java
Normal file
@ -0,0 +1,15 @@
|
||||
package mycompiler.myclass;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
|
||||
/**
|
||||
* Wird von allen Klassen implementiert, welche generische Parameter halten können. (Class, Method und Field)
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public interface Generic {
|
||||
public void setGenericParameter(Vector<GenericTypeVar> params);
|
||||
//public int getGenericParameterOffset();
|
||||
}
|
@ -38,7 +38,10 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.MethodAssumption;
|
||||
import typinferenz.assumptions.ParameterAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
|
||||
|
||||
|
||||
@ -50,7 +53,7 @@ import typinferenz.assumptions.TypeAssumptions;
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class Method extends Field implements ITypeReplacementListener, IItemWithOffset, TypeInsertable
|
||||
public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
// ino.end
|
||||
// ino.class.Method.23482.body
|
||||
{
|
||||
@ -58,7 +61,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
private Block block;
|
||||
// ino.end
|
||||
// ino.attribute.parameterlist.23491.declaration
|
||||
public ParameterList parameterlist = null;
|
||||
public ParameterList parameterlist = new ParameterList();
|
||||
// ino.end
|
||||
// ino.attribute.exceptionlist.23494.declaration
|
||||
private ExceptionList exceptionlist;
|
||||
@ -99,6 +102,10 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
public Method(int offset){
|
||||
super(offset);
|
||||
}
|
||||
|
||||
// ino.method.setGenericMethodParameters.23521.definition
|
||||
public void setGenericMethodParameters(Vector<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
@ -168,10 +175,10 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
// ino.end
|
||||
// ino.method.getTypeName.23533.body
|
||||
{
|
||||
if( this.getReturnType() == null )
|
||||
if( this.getType() == null )
|
||||
return null;
|
||||
else
|
||||
return this.getReturnType().getName();
|
||||
return this.getType().getName();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -191,7 +198,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.setReturnType.23539.definition
|
||||
public void setReturnType(Type type)
|
||||
private void setReturnType(Type type)
|
||||
// ino.end
|
||||
// ino.method.setReturnType.23539.body
|
||||
{
|
||||
@ -301,20 +308,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/**
|
||||
* Liefert den Return Type der Methode.
|
||||
* Dieser entspricht dem Returntype des Methoden-Block's
|
||||
* @returnb
|
||||
*/
|
||||
// ino.method.getReturnType.23569.definition
|
||||
public Type getReturnType()
|
||||
// ino.end
|
||||
// ino.method.getReturnType.23569.body
|
||||
{
|
||||
return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023)
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_Param_Type.23572.definition
|
||||
@ -331,13 +325,13 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
{
|
||||
ret += this.getParameterList().get_codegen_ParameterList(paralist);
|
||||
}
|
||||
if(this.getReturnType() == null)
|
||||
if(this.getType() == null)
|
||||
{
|
||||
ret += "V";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += this.getReturnType().get_codegen_Type(paralist);
|
||||
ret += this.getType().get_codegen_Type(paralist);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -372,7 +366,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
// ino.end
|
||||
// ino.method.codegen.23581.body
|
||||
{
|
||||
classfile.add_method(declid.firstElement().get_Name(), this.get_codegen_Param_Type(paralist), this.getParameterList(), this.getReturnType(), block, declid.firstElement().get_access_flags(), paralist, isAbstract);
|
||||
classfile.add_method(declid.firstElement().get_Name(), this.get_codegen_Param_Type(paralist), this.getParameterList(), this.getType(), block, declid.firstElement().get_access_flags(), paralist, isAbstract);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -472,7 +466,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
// ino.end
|
||||
// ino.method.toString.23605.body
|
||||
{
|
||||
return this.getReturnType() + " " + block.toString();
|
||||
return this.getType() + " "+ this.get_Name() +( (block!=null)?block.toString():"");
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -504,15 +498,19 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
{
|
||||
return isAbstract;
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.23614.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.23614.body
|
||||
|
||||
@Override
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> classParalist)
|
||||
{
|
||||
Vector<Type> paralist = new Vector<Type>();//Mit den Generischen Typen der Methode
|
||||
paralist.addAll(classParalist);
|
||||
paralist.addAll(this.genericMethodParameters);
|
||||
|
||||
// Zuerst Returntype untersuchen
|
||||
Type returnType=getReturnType();
|
||||
GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
|
||||
Type returnType=getType();
|
||||
Type pendantReturnType = null;
|
||||
if(returnType instanceof RefType)pendantReturnType = ((RefType)returnType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
|
||||
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
|
||||
setReturnType(pendantReturnType);
|
||||
}
|
||||
@ -522,7 +520,9 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
FormalParameter fp=parameterlist.formalparameter.get(par);
|
||||
Type fpType=fp.getType();
|
||||
// Nur wenn es sich um ein RefType-Field handelt
|
||||
GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
Type pendantPara = null;
|
||||
if(fpType instanceof RefType)pendantPara = ((RefType)fpType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
|
||||
fp.setType(pendantPara);
|
||||
}
|
||||
@ -547,8 +547,42 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
|
||||
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.genericMethodParameters){
|
||||
ret.add(gtv.TYPE(localAss));
|
||||
}
|
||||
|
||||
ret.add(this.block.TYPEStmt(ass));
|
||||
//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);
|
||||
}
|
||||
*/
|
||||
|
||||
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(), this.returntype));
|
||||
return ret;
|
||||
@ -560,28 +594,31 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
*/
|
||||
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.getReturnType()+", 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.getReturnType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("()\n"); //TODO: hier müssen auch noch die Parameter ausgegeben werden!
|
||||
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 = this.getParentClass();
|
||||
TypeAssumptions ret = new TypeAssumptions();
|
||||
ret.addMethodAssumption(new MethodAssumption(this, parentClass));
|
||||
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("<init>")) && ((this.getReturnType().equals(new mycompiler.mytype.Void(0))) || this.getReturnType() instanceof TypePlaceholder)){
|
||||
//if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("<init>")) && ((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("<init>"))) {
|
||||
this.set_Method_Name("<init>");
|
||||
this.assumedType = new RefType(classmember.getName(),0);
|
||||
@ -609,7 +646,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
//methodList.addElement(method);
|
||||
|
||||
//F�r V_fields_methods:
|
||||
CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getReturnType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Vector<Integer>(),this.getGenericMethodParameters()); // Typannahme bauen...
|
||||
CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Vector<Integer>(),this.getGenericMethodParameters()); // Typannahme bauen...
|
||||
|
||||
|
||||
//Methode in V_Fields_methods ablegen
|
||||
@ -669,8 +706,11 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = super.getChildren();
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.block);
|
||||
for(FormalParameter param : this.parameterlist){
|
||||
ret.add(param);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -681,6 +721,9 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
this.returntype = t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Typ einer Methode ist ihr Returntype
|
||||
*/
|
||||
@Override
|
||||
public Type getType(){
|
||||
//Methode und Block teilen sich einen ReturnType:
|
||||
@ -688,17 +731,32 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
||||
}
|
||||
|
||||
public static Method createEmptyMethod(String withSignature, Class parent){
|
||||
Method ret = new Method();
|
||||
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));
|
||||
ret.set_Block(tempBlock);
|
||||
ret.setType(TypePlaceholder.fresh(ret));
|
||||
ret.parent = parent;
|
||||
ret.parserPostProcessing(parent);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
||||
this.genericMethodParameters = params;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,11 +3,13 @@ package mycompiler.myclass;
|
||||
// ino.end
|
||||
// ino.module.ParameterList.8565.import
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mytype.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
// ino.end
|
||||
@ -16,7 +18,7 @@ import java.util.Iterator;
|
||||
|
||||
|
||||
// ino.class.ParameterList.23620.declaration
|
||||
public class ParameterList
|
||||
public class ParameterList implements Iterable<FormalParameter>
|
||||
// ino.end
|
||||
// ino.class.ParameterList.23620.body
|
||||
{
|
||||
@ -37,7 +39,10 @@ public class ParameterList
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_ParameterList.23629.definition
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_ParameterList.23629.definition
|
||||
public String get_codegen_ParameterList(Vector paralist)
|
||||
// ino.end
|
||||
// ino.method.get_codegen_ParameterList.23629.body
|
||||
@ -146,5 +151,20 @@ public class ParameterList
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<FormalParameter> iterator() {
|
||||
return this.formalparameter.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof ParameterList))return false;
|
||||
ParameterList equals = (ParameterList)obj;
|
||||
if((this.formalparameter == null )!=(equals.formalparameter==null))return false;
|
||||
if(this.formalparameter!=null)return this.formalparameter.equals(equals.formalparameter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,7 +7,7 @@ import java.util.Vector;
|
||||
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.IItemWithOffset;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
import mycompiler.mytype.Type;
|
||||
@ -312,7 +312,7 @@ public class UsedId implements IItemWithOffset
|
||||
// ino.end
|
||||
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
if(this.name.size()>1)throw new TypinferenzException("Es kann maximal nur eine Superklasse pro Klasse geben");
|
||||
if(this.name.size()>1)throw new TypeinferenceException("Es kann maximal nur eine Superklasse pro Klasse geben", this);
|
||||
JavaCodeResult ret = new JavaCodeResult(this.getQualifiedName());
|
||||
if(this.paralist != null){
|
||||
ret.attach( "<" );
|
||||
|
@ -7,6 +7,7 @@ import java.util.Vector;
|
||||
|
||||
import mycompiler.AClassOrInterface;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.ClassHelper;
|
||||
import mycompiler.myclass.Constant;
|
||||
import mycompiler.myclass.FormalParameter;
|
||||
@ -27,12 +28,46 @@ import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
|
||||
import mycompiler.SourceFile;
|
||||
// ino.end
|
||||
|
||||
/**
|
||||
* Ein Interface ist eine abstrakte Klasse, erbt daher von Class
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class Interface extends Class {
|
||||
|
||||
public Interface(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
public Interface(String name, Modifiers modifiers) {
|
||||
super(name,modifiers);
|
||||
}
|
||||
|
||||
public Vector getParaList() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInterfaceBody(InterfaceBody interfaceBody) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setParaList(Vector<Type> paraVector) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ino.class.Interface.23932.description type=javadoc
|
||||
/**
|
||||
* Die Klasse stellt die Definition eines Interfaces dar.
|
||||
* @author SCJU
|
||||
*
|
||||
*/
|
||||
/*
|
||||
// ino.end
|
||||
// ino.class.Interface.23932.declaration
|
||||
public class Interface implements AClassOrInterface
|
||||
@ -85,23 +120,7 @@ public class Interface implements AClassOrInterface
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.getParaList.23954.defdescription type=block
|
||||
/*public Vector<Type> complete_paralist(boolean ext)
|
||||
{
|
||||
|
||||
Diese Funktion vervollt<EFBFBD>ndigt die Parameterliste f<EFBFBD>r vererbte Klassen
|
||||
Vector<Type> child = paralist;
|
||||
|
||||
paralist = (Vector<Type>)superclassid.get_ParaList();
|
||||
|
||||
for(Enumeration<Type> e = child.elements();e.hasMoreElements();){
|
||||
paralist.addElement(e.nextElement());
|
||||
}
|
||||
|
||||
return this.paralist;
|
||||
}*/
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
@ -209,12 +228,6 @@ public class Interface implements AClassOrInterface
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.23981.defdescription type=javadoc
|
||||
/**
|
||||
* Alle RefTypes, die hier im Interface definiert sind
|
||||
* bspw: E doSomething()
|
||||
* und eigentlich Generics sind werden zu generics gewandelt
|
||||
*
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.23981.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes()
|
||||
@ -255,3 +268,4 @@ public class Interface implements AClassOrInterface
|
||||
|
||||
}
|
||||
// ino.end
|
||||
*/
|
@ -9,7 +9,6 @@ import mycompiler.myclass.Field;
|
||||
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myclass.Constant;
|
||||
import mycompiler.myclass.FieldDecl;
|
||||
import mycompiler.myclass.Method;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mymodifier.Modifiers;
|
||||
|
@ -2,17 +2,25 @@
|
||||
package mycompiler.myoperator;
|
||||
// ino.end
|
||||
// ino.module.AddOp.8594.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mystatement.Binary;
|
||||
import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mytype.IntegerType;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.CTriple;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
@ -56,5 +64,17 @@ public abstract class AddOp extends Operator
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Type,Type> getReturnTypes(TypeAssumptions ass) {
|
||||
HashMap<Type,Type> ret = new HashMap<Type,Type>();
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Integer",-1)), ass.getTypeFor(new RefType("java.lang.Integer",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Double",-1)), ass.getTypeFor(new RefType("java.lang.Double",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Float",-1)), ass.getTypeFor(new RefType("java.lang.Float",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Long",-1)), ass.getTypeFor(new RefType("java.lang.Long",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.String",-1)), ass.getTypeFor(new RefType("java.lang.String",-1)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,5 +1,13 @@
|
||||
// ino.module.AndOp.8595.package
|
||||
package mycompiler.myoperator;
|
||||
|
||||
import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mytype.BooleanType;
|
||||
import mycompiler.mytype.IntegerType;
|
||||
import mycompiler.mytype.Type;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
// ino.end
|
||||
|
||||
// ino.class.AndOp.24101.declaration
|
||||
@ -16,5 +24,7 @@ public class AndOp extends LogOp
|
||||
super(offset,variableLength);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -2,9 +2,15 @@
|
||||
package mycompiler.myoperator;
|
||||
// ino.end
|
||||
// ino.module.LogOp.8602.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -15,8 +21,10 @@ import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mystatement.NotExpr;
|
||||
import mycompiler.mystatement.Null;
|
||||
import mycompiler.mystatement.Statement;
|
||||
import mycompiler.mytype.BooleanType;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.CTriple;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
@ -226,6 +234,13 @@ public abstract class LogOp extends Operator
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<Type,Type> getReturnTypes(TypeAssumptions ass) {
|
||||
HashMap<Type,Type> ret = new HashMap<Type,Type>();
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1)), ass.getTypeFor(new RefType("java.lang.Boolean",-1)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,13 +3,18 @@ package mycompiler.myoperator;
|
||||
// ino.end
|
||||
|
||||
// ino.module.MulOp.8605.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.mystatement.Binary;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.CTriple;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
@ -36,13 +41,20 @@ public abstract class MulOp extends Operator
|
||||
protected Hashtable<RefType, RefType> getOperatorTypes() {
|
||||
Hashtable<RefType, RefType> types = new Hashtable<RefType, RefType>();
|
||||
|
||||
types.put(new RefType("java.lang.Integer",-1), new RefType("java.lang.Integer",-1));
|
||||
types.put(new RefType("java.lang.Double",-1), new RefType("java.lang.Double",-1));
|
||||
types.put(new RefType("java.lang.Float",-1), new RefType("java.lang.Float",-1));
|
||||
types.put(new RefType("java.lang.Long",-1), new RefType("java.lang.Long",-1));
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Type,Type> getReturnTypes(TypeAssumptions ass) {
|
||||
HashMap<Type,Type> ret = new HashMap<Type,Type>();
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Integer",-1)), ass.getTypeFor(new RefType("java.lang.Integer",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Double",-1)), ass.getTypeFor(new RefType("java.lang.Double",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Float",-1)), ass.getTypeFor(new RefType("java.lang.Float",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Long",-1)), ass.getTypeFor(new RefType("java.lang.Long",-1)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,17 @@
|
||||
package mycompiler.myoperator;
|
||||
// ino.end
|
||||
// ino.module.Operator.8607.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.IItemWithOffset;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
@ -15,6 +23,8 @@ import mycompiler.mystatement.Binary;
|
||||
import mycompiler.mystatement.Expr;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.CTriple;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
@ -111,5 +121,13 @@ public abstract class Operator implements IItemWithOffset
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
/**
|
||||
* Liefert eine HashMap der Form: HashMap<ResultType, InputType>
|
||||
* @param ass
|
||||
* @return
|
||||
*/
|
||||
public abstract HashMap<Type,Type> getReturnTypes(TypeAssumptions ass);
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,9 +3,13 @@ package mycompiler.myoperator;
|
||||
// ino.end
|
||||
|
||||
// ino.module.RelOp.8610.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.DebugException;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
@ -13,6 +17,7 @@ import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.mystatement.Binary;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.CTriple;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
@ -52,6 +57,17 @@ public abstract class RelOp extends Operator
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Type,Type> getReturnTypes(TypeAssumptions ass) {
|
||||
HashMap<Type,Type> ret = new HashMap<Type,Type>();
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1)), ass.getTypeFor(new RefType("java.lang.Integer",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1)), ass.getTypeFor(new RefType("java.lang.Double",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1)), ass.getTypeFor(new RefType("java.lang.Float",-1)));
|
||||
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1)), ass.getTypeFor(new RefType("java.lang.Long",-1)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -313,7 +313,8 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
||||
%type <Statement> explicitconstructorinvocation
|
||||
%type <Method> staticinitializer
|
||||
%type <CastExpr> castexpression
|
||||
%type <ParaList> paralist parameter
|
||||
%type <ParaList> paralist
|
||||
%type <Vector> typelist parameter
|
||||
%type <WildcardType> wildcardparameter
|
||||
%left ','
|
||||
%%
|
||||
@ -322,7 +323,7 @@ compilationunit : typedeclarations
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
/* |importdeclarations typedeclarations
|
||||
|importdeclarations typedeclarations
|
||||
{
|
||||
$2.addImports($1);
|
||||
$$=$2;
|
||||
@ -345,7 +346,7 @@ compilationunit : typedeclarations
|
||||
this.testPair.add(new Pair($1,$2));
|
||||
$$=$3;
|
||||
}
|
||||
*/
|
||||
|
||||
packagedeclaration : PACKAGE name ';' ;
|
||||
{
|
||||
// SCJU: Package
|
||||
@ -394,12 +395,12 @@ typedeclaration :classdeclaration
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
/* | interfacedeclaration
|
||||
| interfacedeclaration
|
||||
{
|
||||
// SCJU: Interface
|
||||
$$=$1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
qualifiedname : name '.' IDENTIFIER
|
||||
{
|
||||
@ -785,21 +786,34 @@ classbodydeclaration : classmemberdeclaration
|
||||
classorinterfacetype : simplename parameter
|
||||
{
|
||||
if ($2 != null) {
|
||||
$1.set_ParaList($2.get_ParaList());
|
||||
|
||||
//$1.set_ParaList($2.get_ParaList());
|
||||
$1.set_ParaList($2);//Änderung von Andreas Stadelmeier. Type statt GenericVarType
|
||||
/* otth: originale (also diese) Parameterliste retten */
|
||||
((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
//((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
}
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
typelist : type
|
||||
{
|
||||
Vector<Type> tl = new Vector<Type>();
|
||||
tl.add($1);
|
||||
$$ = tl;
|
||||
}
|
||||
| typelist ',' type
|
||||
{
|
||||
$1.add($3);
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
/* PL 05-07-28 erg�nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */
|
||||
//TODO: Das hier ist möglicherweise falsch. Ein Typ hat keine parameterliste, nur eine Liste von RefTypes
|
||||
parameter : { $$ = null; }
|
||||
| '<'paralist'>'
|
||||
| '<'typelist'>'//'<'paralist'>'//typelist statt
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
|
||||
interfacememberdeclaration : constantdeclaration
|
||||
{
|
||||
// SCJU: Interfaces, Spezialform Konstantendef.
|
||||
@ -821,7 +835,7 @@ classmemberdeclaration : fielddeclaration
|
||||
|
||||
staticinitializer : STATIC block
|
||||
{
|
||||
Method STAT = new Method();
|
||||
Method STAT = new Method($1.getOffset());
|
||||
DeclId DST = new DeclId();
|
||||
DST.set_Name($1.getLexem());
|
||||
STAT.set_DeclId(DST);
|
||||
@ -867,9 +881,21 @@ Beispiel: var = 2;
|
||||
Bei einer lokalen Variable lässt sich hier nicht ermitteln ob die Variable deklariert werden soll oder bereits deklariert wurde und ihr nur ein Wert zugewiesen werden soll.
|
||||
Dieses Problem ist bei Feldern nicht der Fall.
|
||||
*/
|
||||
fielddeclarator : variabledeclarator '=' expression
|
||||
fielddeclarator :
|
||||
/*
|
||||
type variabledeclarator '=' expression
|
||||
{
|
||||
FieldDeclaration ret = new FieldDeclaration();
|
||||
FieldDeclaration ret = new FieldDeclaration($2.getOffset());
|
||||
ret.setType($1);
|
||||
ret.set_DeclId($2);
|
||||
ret.setWert($4);
|
||||
$$=ret;
|
||||
}
|
||||
|
|
||||
*/
|
||||
variabledeclarator '=' expression
|
||||
{
|
||||
FieldDeclaration ret = new FieldDeclaration($1.getOffset());
|
||||
ret.set_DeclId($1);
|
||||
ret.setWert($3);
|
||||
$$=ret;
|
||||
@ -879,11 +905,17 @@ fielddeclaration : fielddeclarator ';'
|
||||
{
|
||||
$$=$1;
|
||||
}
|
||||
| type fielddeclarator
|
||||
| type fielddeclarator ';'
|
||||
{
|
||||
$2.setType($1);
|
||||
$$=$2;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' type fielddeclarator ';'
|
||||
{//angefügt von Andreas Stadelmeier
|
||||
$5.setType($4);
|
||||
$5.setGenericParameter($2);
|
||||
$$=$5;
|
||||
}
|
||||
|
|
||||
variabledeclarators ';'
|
||||
{
|
||||
@ -1000,8 +1032,8 @@ boundedMethodParameter : IDENTIFIER
|
||||
}
|
||||
| IDENTIFIER EXTENDS boundedclassidentifierlist
|
||||
{
|
||||
BoundedGenericTypeVar gtv=new BoundedGenericTypeVar($1.getLexem(),$1.getOffset());
|
||||
gtv.setBounds($3);
|
||||
BoundedGenericTypeVar gtv=new BoundedGenericTypeVar($1.getLexem(),$3,$1.getOffset());
|
||||
//gtv.setBounds($3);
|
||||
$$=gtv;
|
||||
}
|
||||
// returns Vector<Type>
|
||||
@ -1035,45 +1067,45 @@ boundedMethodParameters : boundedMethodParameter
|
||||
// returns Method
|
||||
methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$5.setReturnType($4);
|
||||
$5.setType($4);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
}
|
||||
| type methoddeclarator
|
||||
{
|
||||
$2.setReturnType($1);
|
||||
$2.setType($1);
|
||||
$$=$2;
|
||||
}
|
||||
| modifiers type methoddeclarator
|
||||
{
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType($2);
|
||||
$3.setType($2);
|
||||
$$=$3;
|
||||
}
|
||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$6.set_Modifiers($1);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$6.setReturnType($5);
|
||||
$6.setType($5);
|
||||
$$=$6;
|
||||
}
|
||||
| type methoddeclarator throws
|
||||
{
|
||||
$2.setReturnType($1);
|
||||
$2.setType($1);
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' type methoddeclarator throws
|
||||
{
|
||||
$5.setGenericMethodParameters($2);
|
||||
$5.setReturnType($4);
|
||||
$5.setType($4);
|
||||
$5.set_ExceptionList($6);
|
||||
$$=$5;
|
||||
}
|
||||
| modifiers type methoddeclarator throws
|
||||
{
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType($2);
|
||||
$3.setType($2);
|
||||
$3.set_ExceptionList($4);
|
||||
$$=$3;
|
||||
}
|
||||
@ -1081,27 +1113,27 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
$6.set_Modifiers($1);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$6.setReturnType($5);
|
||||
$6.setType($5);
|
||||
$6.set_ExceptionList($7);
|
||||
$$=$6;
|
||||
}
|
||||
| VOID methoddeclarator
|
||||
{
|
||||
Void Voit = new Void($1.getOffset());
|
||||
$2.setReturnType(Voit);
|
||||
$2.setType(Voit);
|
||||
$$=$2;
|
||||
}
|
||||
| modifiers VOID methoddeclarator
|
||||
{
|
||||
Void voit = new Void($2.getOffset());
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType(voit);
|
||||
$3.setType(voit);
|
||||
$$=$3;
|
||||
}
|
||||
| VOID methoddeclarator throws
|
||||
{
|
||||
Void voyt = new Void($1.getOffset());
|
||||
$2.setReturnType(voyt);
|
||||
$2.setType(voyt);
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
@ -1109,14 +1141,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voyd = new Void($2.getOffset());
|
||||
$3.set_Modifiers($1);
|
||||
$3.setReturnType(voyd);
|
||||
$3.setType(voyd);
|
||||
$3.set_ExceptionList($4);
|
||||
$$=$3;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' VOID methoddeclarator
|
||||
{
|
||||
Void Voit = new Void($4.getOffset());
|
||||
$5.setReturnType(Voit);
|
||||
$5.setType(Voit);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
}
|
||||
@ -1124,14 +1156,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voit = new Void($5.getOffset());
|
||||
$6.set_Modifiers($1);
|
||||
$6.setReturnType(voit);
|
||||
$6.setType(voit);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$$=$6;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
||||
{
|
||||
Void voyt = new Void($4.getOffset());
|
||||
$5.setReturnType(voyt);
|
||||
$5.setType(voyt);
|
||||
$5.set_ExceptionList($6);
|
||||
$5.setGenericMethodParameters($2);
|
||||
$$=$5;
|
||||
@ -1140,7 +1172,7 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
{
|
||||
Void voyd = new Void($5.getOffset());
|
||||
$6.set_Modifiers($1);
|
||||
$6.setReturnType(voyd);
|
||||
$6.setType(voyd);
|
||||
$6.set_ExceptionList($7);
|
||||
$6.setGenericMethodParameters($3);
|
||||
$$=$6;
|
||||
@ -1148,12 +1180,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
|
||||
| methoddeclarator
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||
$$=$1;
|
||||
}
|
||||
| '<' boundedMethodParameters '>' methoddeclarator
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
||||
$4.setGenericMethodParameters($2);
|
||||
$$=$4;
|
||||
}
|
||||
@ -1161,19 +1193,19 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||||
| modifiers methoddeclarator
|
||||
{
|
||||
$2.set_Modifiers($1);
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||||
$$=$2;
|
||||
}
|
||||
| methoddeclarator throws
|
||||
{
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||
$1.set_ExceptionList($2);
|
||||
$$=$1;
|
||||
}
|
||||
| modifiers methoddeclarator throws
|
||||
{
|
||||
$2.set_Modifiers($1);
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||||
$2.set_ExceptionList($3);
|
||||
$$=$2;
|
||||
}
|
||||
@ -1197,8 +1229,9 @@ type : primitivetype
|
||||
}
|
||||
variabledeclarators : variabledeclarator
|
||||
{
|
||||
FieldDeclaration IVD = new FieldDeclaration();
|
||||
FieldDeclaration IVD = new FieldDeclaration($1.getOffset());
|
||||
IVD.getDeclIdVector().addElement( $1 );
|
||||
IVD.setOffset($1.getOffset());
|
||||
$$ = IVD;
|
||||
}
|
||||
| variabledeclarators ',' variabledeclarator
|
||||
@ -1267,7 +1300,7 @@ classtypelist : classtype
|
||||
|
||||
methoddeclarator :IDENTIFIER '(' ')'
|
||||
{
|
||||
Method met = new Method();
|
||||
Method met = new Method($1.getOffset());
|
||||
/* #JB# 10.04.2005 */
|
||||
/* ########################################################### */
|
||||
met.setLineNumber($1.getLineNumber());
|
||||
@ -1280,7 +1313,7 @@ methoddeclarator :IDENTIFIER '(' ')'
|
||||
}
|
||||
|IDENTIFIER '(' formalparameterlist ')'
|
||||
{
|
||||
Method met_para = new Method();
|
||||
Method met_para = new Method($1.getOffset());
|
||||
/* #JB# 10.04.2005 */
|
||||
/* ########################################################### */
|
||||
met_para.setLineNumber($1.getLineNumber());
|
||||
@ -1307,7 +1340,6 @@ primitivetype :BOOLEAN
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
|
||||
referencetype :classorinterfacetype
|
||||
{
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1);
|
||||
@ -1360,9 +1392,9 @@ blockstatement :localvariabledeclarationstatement
|
||||
|
||||
formalparameter : type variabledeclaratorid
|
||||
{
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($2);
|
||||
FP.setType($1);
|
||||
FP.set_DeclId($2);
|
||||
//FP.set_DeclId($2); //auskommentiert von Andreas Stadelmeier. DeclId wird nun dem Konstruktor von FormalParameter übergeben.
|
||||
$$=FP;
|
||||
}
|
||||
|
||||
@ -1374,9 +1406,9 @@ formalparameter : type variabledeclaratorid
|
||||
Parameterliste setzen
|
||||
$5.set_Paratyp($3.get_ParaList());
|
||||
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($5);
|
||||
FP.setType($1);
|
||||
FP.set_DeclId($5);
|
||||
//FP.set_DeclId($5);
|
||||
$$=FP;
|
||||
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("P->Polymorphes Methodenargument hinzugefuegt: Name = " + $5.get_Name() + " Typ = " + $1.getName());
|
||||
@ -1387,7 +1419,7 @@ formalparameter : type variabledeclaratorid
|
||||
{
|
||||
org.apache.log4j.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + $1.name);
|
||||
|
||||
FormalParameter FP = new FormalParameter();
|
||||
FormalParameter FP = new FormalParameter($1);
|
||||
|
||||
// #JB# 31.03.2005
|
||||
// ###########################################################
|
||||
@ -1397,7 +1429,7 @@ formalparameter : type variabledeclaratorid
|
||||
//org.apache.log4j.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName());
|
||||
|
||||
//auskommentiert von Andreas Stadelmeier (a10023) FP.setType( T );
|
||||
FP.set_DeclId($1);
|
||||
//FP.set_DeclId($1);
|
||||
|
||||
$$=FP;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -32,6 +33,7 @@ import mycompiler.mytypereconstruction.unify.Unify;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
// ino.end
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -259,5 +261,17 @@ public class Assign extends Expr
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr1);
|
||||
ret.add(this.expr2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,9 +3,11 @@ package mycompiler.mystatement;
|
||||
// ino.end
|
||||
// ino.module.Binary.8623.import
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -20,7 +22,10 @@ import mycompiler.myoperator.MulOp;
|
||||
import mycompiler.myoperator.Operator;
|
||||
import mycompiler.myoperator.RelOp;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||||
import mycompiler.mytypereconstruction.set.CTripleSet;
|
||||
@ -31,10 +36,18 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
|
||||
@ -253,7 +266,26 @@ public class Binary extends BinaryExpr
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
// TODO Implement Method stub
|
||||
ret.add(this.expr1.TYPEExpr(assumptions));
|
||||
ret.add(this.expr2.TYPEExpr(assumptions));
|
||||
/**
|
||||
* Berechnet die Constraints dieses Operators für die 2 gegebenen Parameter
|
||||
* Die Operatoren sind meistens überladen. Es entstehen mehrere Oder-Verknüpfte Constraints.
|
||||
* @param expr1
|
||||
* @param expr2
|
||||
* @return
|
||||
*/
|
||||
if(this.getType()==null)this.set_Type(TypePlaceholder.fresh(this));
|
||||
OderConstraint oderCons = new OderConstraint();
|
||||
HashMap<Type,Type> rMap = this.op.getReturnTypes(assumptions);
|
||||
for(Type rT : rMap.keySet()){
|
||||
UndConstraint c = new UndConstraint();
|
||||
c.addConstraint(this.getType(),rT);
|
||||
c.addConstraint(this.expr1.getType(), rMap.get(rT));
|
||||
c.addConstraint(this.expr2.getType(), rMap.get(rT));
|
||||
oderCons.addConstraint(c);
|
||||
}
|
||||
ret.add(oderCons);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -261,7 +293,21 @@ public class Binary extends BinaryExpr
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
throw new NotImplementedException();
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
ret.attach(this.expr1.printJavaCode(resultSet)).attach(" ");
|
||||
ret.attach(this.op.toString()+" ");
|
||||
ret.attach(this.expr2.printJavaCode(resultSet));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr1);
|
||||
ret.add(this.expr2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
// ino.module.BinaryExpr.8624.package
|
||||
package mycompiler.mystatement;
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
// ino.end
|
||||
|
||||
|
||||
@ -17,7 +20,8 @@ public abstract class BinaryExpr extends Expr
|
||||
super(offset,variableLength);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// abstract public void if_codegen(ClassFile classfile, Code_attribute code, boolean sw) throws jvmCode_Exception;
|
||||
// abstract public void not_codegen(ClassFile classfile, Code_attribute code) throws jvmCode_Exception;
|
||||
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
@ -30,14 +31,16 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -65,15 +68,7 @@ public class Block extends Statement
|
||||
// ino.attribute.statements.25047.declaration
|
||||
public Vector<Statement> statements = new Vector<Statement>();
|
||||
// ino.end
|
||||
// ino.attribute.HashTabelleKlasse.25050.declaration
|
||||
private Hashtable HashTabelleKlasse;
|
||||
// ino.end
|
||||
// ino.attribute.HashTabelleBlock.25053.declaration
|
||||
private Hashtable<String,String> HashTabelleBlock;
|
||||
// ino.end
|
||||
// ino.attribute.block_para.25056.declaration
|
||||
private Hashtable<String,Hashtable> block_para;
|
||||
// ino.end
|
||||
|
||||
|
||||
//private String sc_meth_ret_type;
|
||||
// ino.attribute.inferencelog.25059.decldescription type=javadoc
|
||||
@ -221,6 +216,7 @@ public class Block extends Statement
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
if(statements.size()==0)this.setType(new Void(0));
|
||||
/* this.setTypeVariable(TypePlaceholder.fresh(this)); */
|
||||
for(Statement stmt : statements){
|
||||
typinferenceLog.debug("Prozessing statement: "+stmt);
|
||||
@ -240,7 +236,7 @@ public class Block extends Statement
|
||||
if (!(stmt.getType() instanceof Void))
|
||||
if (this.getType() instanceof Void) {
|
||||
//this.setTypeVariable(stmt.getTypeVariable());
|
||||
throw new TypinferenzException("Falscher Return Type");
|
||||
throw new TypeinferenceException("Block besitzt falschen Rückgabetyp (fehlendes return-stmt)", this);
|
||||
}
|
||||
else {
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(this);
|
||||
@ -304,5 +300,19 @@ public class Block extends Statement
|
||||
return ret.attach("}");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
for(Statement st : this.get_Statement()){
|
||||
ret.add(st);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return "Block";
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -25,6 +26,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -178,7 +180,7 @@ public class BoolLiteral extends Literal
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
|
||||
this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",-1));
|
||||
return new ConstraintsSet();
|
||||
}
|
||||
|
||||
@ -190,6 +192,14 @@ public class BoolLiteral extends Literal
|
||||
return new JavaCodeResult("false");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -149,6 +151,15 @@ public class CastExpr extends UnaryExpr
|
||||
return new JavaCodeResult("(("+this.usedid+")").attach(this.expr.printJavaCode(resultSet)).attach(")");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -26,6 +27,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -181,6 +183,10 @@ public class CharLiteral extends Literal
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult("'"+String.valueOf(this.Char)+"'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -204,15 +205,20 @@ public class DoubleLiteral extends Literal
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
this.setType(assumptions.getTypeFor(new RefType("Double",this.getOffset())));
|
||||
return new ConstraintsSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
ret.attach(""+this.Double);
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
@ -23,6 +24,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
@ -111,5 +113,11 @@ public class EmptyStmt extends Statement
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
return new Vector<SyntaxTreeNode>();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
@ -207,6 +208,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -131,4 +132,18 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
if(this.body_Loop_block!=null)ret.add(this.body_Loop_block);
|
||||
if(this.head_Condition!=null)ret.add(this.head_Condition);
|
||||
if(this.head_Condition_1!=null)ret.add(this.head_Condition_1);
|
||||
if(this.head_Initializer!=null)ret.add(this.head_Initializer);
|
||||
if(this.head_Initializer_1!=null)ret.add(this.head_Initializer_1);
|
||||
if(this.head_Loop_expr!=null)ret.add(this.head_Loop_expr);
|
||||
if(this.head_Loop_expr_1!=null)ret.add(this.head_Loop_expr_1);
|
||||
//throw new NotImplementedException();
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -40,6 +41,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -414,5 +416,16 @@ public class IfStmt extends Statement
|
||||
ret.attach("\n}");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
if(this.expr!=null)ret.add(this.expr);
|
||||
if(this.else_block!=null)ret.add(this.else_block);
|
||||
if(this.then_block!=null)ret.add(this.then_block);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -34,10 +35,17 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.FieldAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
|
||||
@ -101,19 +109,25 @@ public class InstVar extends Expr
|
||||
super(offset,variableLength);
|
||||
Iterator namen = ui.get_Name().iterator();
|
||||
LocalOrFieldVar innerLOFV = new LocalOrFieldVar((String)namen.next(),getOffset());
|
||||
innerLOFV.setType(TypePlaceholder.fresh(this));
|
||||
//innerLOFV.setType(TypePlaceholder.fresh(this));
|
||||
InstVar INSTVA = new InstVar(innerLOFV, (String)namen.next(),offset);
|
||||
INSTVA.setType(TypePlaceholder.fresh(this));
|
||||
//INSTVA.setType(TypePlaceholder.fresh(this));
|
||||
while(namen.hasNext()) {
|
||||
INSTVA = new InstVar(INSTVA, (String)namen.next(),offset);
|
||||
INSTVA.setType(TypePlaceholder.fresh(this));
|
||||
//INSTVA.setType(TypePlaceholder.fresh(this));
|
||||
}
|
||||
expr = INSTVA.expr;
|
||||
usedid = INSTVA.usedid;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.sc_check.25417.definition
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
if(this.getType()==null)this.set_Type(TypePlaceholder.fresh(this));
|
||||
}
|
||||
|
||||
// ino.method.sc_check.25417.definition
|
||||
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
||||
// ino.end
|
||||
// ino.method.sc_check.25417.body
|
||||
@ -150,7 +164,7 @@ public class InstVar extends Expr
|
||||
// ino.end
|
||||
// ino.method.get_Name.25420.body
|
||||
{
|
||||
return null;
|
||||
return this.usedid.get_Name_1Element();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -265,14 +279,34 @@ public class InstVar extends Expr
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
if(this.expr == null){
|
||||
this.expr = new This(0, 0);
|
||||
}
|
||||
ret.add(expr.TYPEExpr(assumptions));
|
||||
this.setType(TypePlaceholder.fresh(this));
|
||||
return null;
|
||||
OderConstraint oderConstraint = new OderConstraint();
|
||||
for(FieldAssumption fa : assumptions.getFieldVars(this.get_Name())){
|
||||
UndConstraint undConstraint = new UndConstraint();
|
||||
undConstraint.addConstraint(fa.getAssumedType(),this.getType());
|
||||
undConstraint.addConstraint(this.expr.getType(),fa.getParentClass().getType());
|
||||
oderConstraint.addConstraint(undConstraint);
|
||||
}
|
||||
ret.add(oderConstraint);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult().attach(this.expr.printJavaCode(resultSet)).attach("."+this.usedid.get_Name_1Element());
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
if(this.expr != null)ret.attach(this.expr.printJavaCode(resultSet)).attach(".");
|
||||
return ret.attach(this.usedid.get_Name_1Element());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -150,6 +152,13 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -26,6 +27,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
@ -204,7 +206,8 @@ public class IntLiteral extends Literal
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
this.setType(new IntegerType());
|
||||
//this.setType(new IntegerType());
|
||||
this.set_Type(assumptions.getTypeFor(new RefType("java.lang.Integer",-1)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -212,6 +215,10 @@ public class IntLiteral extends Literal
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult(String.valueOf(this.Int));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -10,12 +10,14 @@ import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.ParameterAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.ClassHelper;
|
||||
import mycompiler.myclass.FormalParameter;
|
||||
import mycompiler.myclass.Method;
|
||||
import mycompiler.myclass.ParameterList;
|
||||
@ -24,6 +26,7 @@ import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.myexception.SCStatementException;
|
||||
import mycompiler.mytype.DoubleType;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.CSupportData;
|
||||
@ -64,7 +67,11 @@ public class LambdaExpression extends Expr{
|
||||
}
|
||||
|
||||
public void setParameterList(ParameterList params){
|
||||
this.params = params;
|
||||
ParameterList lambdaParameter = new ParameterList();
|
||||
for(FormalParameter fp : params){
|
||||
lambdaParameter.formalparameter.add(new LambdaParameter(fp));
|
||||
}
|
||||
this.params = lambdaParameter;
|
||||
}
|
||||
|
||||
|
||||
@ -80,8 +87,34 @@ public class LambdaExpression extends Expr{
|
||||
public void wandleRefTypeAttributes2GenericAttributes(
|
||||
Vector<Type> paralist,
|
||||
Vector<GenericTypeVar> genericMethodParameters) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Block block = this.method_body;
|
||||
// Zuerst Returntype untersuchen
|
||||
Type returnType=getType();
|
||||
Type pendantReturnType = null;
|
||||
if(returnType instanceof RefType)
|
||||
pendantReturnType = ((RefType)returnType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
|
||||
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
|
||||
setType(pendantReturnType);
|
||||
}
|
||||
|
||||
// Dann parameterlist untersuchen
|
||||
for(FormalParameter fp : params){
|
||||
Type fpType=fp.getType();
|
||||
// Nur wenn es sich um ein RefType-Field handelt
|
||||
Type pendantPara = null;
|
||||
if(fpType instanceof RefType)
|
||||
pendantPara = ((RefType)fpType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,14 +156,14 @@ public class LambdaExpression extends Expr{
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//Die Assumptions für die Parameter der LambdaExpression
|
||||
TypeAssumptions ArgumentAssumptions = new TypeAssumptions(assumptions.getThisValue().getName());
|
||||
TypeAssumptions ArgumentAssumptions = new TypeAssumptions(this.getParentClass().getName());
|
||||
Vector<Type> paramTypes = new Vector<Type>();
|
||||
|
||||
for(FormalParameter param : params.formalparameter){
|
||||
if(param.getType()==null)param.setType(TypePlaceholder.fresh(this));
|
||||
int offset = 0;
|
||||
//Jeder Parameter der LambdaExpression wird als CParaTypeAssumption der Assumption liste hinzugefügt:
|
||||
ArgumentAssumptions.addParameterAssumption(new ParameterAssumption(param));
|
||||
ArgumentAssumptions.addAssumption(new ParameterAssumption(param));
|
||||
paramTypes.add(param.getType());
|
||||
}
|
||||
this.setType(TypePlaceholder.fresh(this));
|
||||
@ -142,7 +175,7 @@ public class LambdaExpression extends Expr{
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions ass){
|
||||
throw new TypinferenzException("Eine LambdaExpression darf nicht als Statement verwendet werden.");
|
||||
throw new TypeinferenceException("Eine LambdaExpression darf nicht als Statement verwendet werden.", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -164,4 +197,12 @@ public class LambdaExpression extends Expr{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.method_body);
|
||||
for(FormalParameter fp : this.params)ret.add(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
30
src/mycompiler/mystatement/LambdaParameter.java
Normal file
30
src/mycompiler/mystatement/LambdaParameter.java
Normal file
@ -0,0 +1,30 @@
|
||||
package mycompiler.mystatement;
|
||||
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
import mycompiler.myclass.DeclId;
|
||||
import mycompiler.myclass.FormalParameter;
|
||||
import mycompiler.mytype.Type;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
|
||||
/**
|
||||
* Der FormalParameter einer LambdaExpression hat gesonderte Eigenschaften.
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class LambdaParameter extends FormalParameter {
|
||||
|
||||
public LambdaParameter(FormalParameter fp) {
|
||||
super(fp.getDeclId());
|
||||
this.setType(fp.getType());
|
||||
this.parent = fp.getParent();
|
||||
this.inferencelog = fp.inferencelog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||
ResultSet resultSet) {
|
||||
return null;//Ein LambdaParameter darf keine Typen einsetzen.
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -32,6 +33,8 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -39,6 +42,7 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -204,7 +208,8 @@ public class LocalOrFieldVar extends Expr
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//gibt es eine Assumption für den die LocalOrFieldVar-Variablen, dann folgendes ausführen:
|
||||
Type thisTypeAssumption = assumptions.getVarType(this.get_Name());
|
||||
Type thisTypeAssumption = assumptions.getVarType(this.get_Name(), this.getParentClass());
|
||||
if(thisTypeAssumption == null)throw new TypeinferenceException("Eine Variable "+this.get_Name()+" ist in den Assumptions nicht vorhanden",this);
|
||||
this.setType(thisTypeAssumption);
|
||||
//ret.add(new Constraint(thisTypeAssumption, this.getTypeVariable()));
|
||||
return ret;
|
||||
@ -220,5 +225,11 @@ public class LocalOrFieldVar extends Expr
|
||||
return new JavaCodeResult(this.get_Name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -12,6 +12,7 @@ import mycompiler.myclass.Class;
|
||||
import mycompiler.myclass.ClassHelper;
|
||||
import mycompiler.myclass.DeclId;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.myexception.SCExcept;
|
||||
import mycompiler.myexception.SCStatementException;
|
||||
@ -37,6 +38,10 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.JavaCodeResult;
|
||||
@ -44,6 +49,8 @@ import typinferenz.ResultSet;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.LocalVarAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
|
||||
|
||||
|
||||
@ -65,9 +72,6 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
// ino.attribute.declid.25548.declaration
|
||||
private Vector<DeclId> declid = new Vector<DeclId>();
|
||||
// ino.end
|
||||
// ino.attribute.type.25551.declaration
|
||||
private Type declType;
|
||||
// ino.end
|
||||
// ino.attribute.paralist.25554.declaration
|
||||
private Vector paralist = null;
|
||||
// ino.end
|
||||
@ -84,33 +88,6 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
public Block block;
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.setType.25569.definition
|
||||
public void setDeclType(Type t)
|
||||
// ino.end
|
||||
// ino.method.setType.25569.body
|
||||
{
|
||||
if(this.declType instanceof TypePlaceholder){
|
||||
((TypePlaceholder)this.declType).removeReplacementListener(this);
|
||||
}
|
||||
|
||||
if(t instanceof TypePlaceholder){
|
||||
((TypePlaceholder)t).addReplacementListener(this);
|
||||
}
|
||||
this.declType=t;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getType.25572.definition
|
||||
public Type getDeclType()
|
||||
// ino.end
|
||||
// ino.method.getType.25572.body
|
||||
{
|
||||
return this.declType;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.set_DeclId.25575.definition
|
||||
public void set_DeclId(DeclId did)
|
||||
// ino.end
|
||||
@ -297,7 +274,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
{
|
||||
if(declid != null)
|
||||
for(int i = 0; i < declid.size(); i++)
|
||||
declid.elementAt(i).codegen_LocalVarDecl(classfile, code, this.getDeclType(), paralist);
|
||||
declid.elementAt(i).codegen_LocalVarDecl(classfile, code, this.getType(), paralist);
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.getDeclidVector.25596.definition
|
||||
@ -374,12 +351,12 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
}
|
||||
this.setType(e.getNewType());
|
||||
}
|
||||
if(e.getOldType().equals(this.getDeclType())){
|
||||
if(e.getOldType().equals(this.getType())){
|
||||
inferencelog.debug("Ersetze Typ in LocalVarDecl \""+this.get_Name()+"\"\n");
|
||||
if(declType instanceof TypePlaceholder){
|
||||
((TypePlaceholder)declType).removeReplacementListener(this);
|
||||
if(this.getType() instanceof TypePlaceholder){
|
||||
((TypePlaceholder)this.getType()).removeReplacementListener(this);
|
||||
}
|
||||
this.setDeclType(e.getNewType());
|
||||
this.setType(e.getNewType());
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
@ -417,7 +394,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
CTripleSet resultSet = new CTripleSet();
|
||||
V = V.shallowCopy();
|
||||
CTypeAssumptionSet localSet = new CTypeAssumptionSet();
|
||||
CLocalVarTypeAssumption varAssum = new CLocalVarTypeAssumption(supportData.getCurrentClass(), supportData.getCurrentMethod(), supportData.getCurrentMethodParaCount(), supportData.getCurrentMethodOverloadedID(), supportData.getCurrentBlockId(), this.get_Name() ,this.getDeclType(), this.getLineNumber(),this.getOffset(),new Vector<Integer>());
|
||||
CLocalVarTypeAssumption varAssum = new CLocalVarTypeAssumption(supportData.getCurrentClass(), supportData.getCurrentMethod(), supportData.getCurrentMethodParaCount(), supportData.getCurrentMethodOverloadedID(), supportData.getCurrentBlockId(), this.get_Name() ,this.getType(), this.getLineNumber(),this.getOffset(),new Vector<Integer>());
|
||||
Class.isFirstLocalVarDecl=true;
|
||||
|
||||
if(this.block != null)
|
||||
@ -441,8 +418,8 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
// ino.end
|
||||
// ino.method.toString.25617.body
|
||||
{
|
||||
if(declType == null)return "no type " + declid.toString();
|
||||
return declType.toString() + " " + declid.toString();
|
||||
if(this.getType() == null)return "no type " + declid.toString();
|
||||
return this.getType().toString() + " " + declid.toString();
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25620.definition
|
||||
@ -451,9 +428,12 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25620.body
|
||||
{
|
||||
|
||||
Type fpType=getDeclType();
|
||||
Type fpType=getType();
|
||||
// Nur wenn es sich um ein RefType-Field handelt
|
||||
GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
Type pendantPara = null;
|
||||
if(fpType instanceof RefType)
|
||||
pendantPara = ((RefType)fpType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
|
||||
setType(pendantPara);
|
||||
}
|
||||
@ -486,25 +466,39 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
if(this.getDeclType()==null || this.getDeclType() instanceof TypePlaceholder)this.setDeclType(TypePlaceholder.fresh(this));
|
||||
assumptions.addLocalVarAssumption(new LocalVarAssumption(this));
|
||||
if((this.getType() instanceof RefType)){
|
||||
Type replaceType = null;
|
||||
replaceType = assumptions.getTypeFor((RefType)this.getType());
|
||||
if(replaceType == null)
|
||||
throw new TypeinferenceException("Der Typ "+this.getType().getName()+" ist nicht korrekt",this);
|
||||
this.setType(replaceType);
|
||||
}
|
||||
assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird.
|
||||
//assumptions.remove(null); // falls Variable mit diesem Namen bereits vorhanden.
|
||||
this.setType(new Void(0)); //Return typ einer Variablendeklaration ist Void
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
if(this.getType()==null || this.getType() instanceof TypePlaceholder)this.setType(TypePlaceholder.fresh(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeInformation(){
|
||||
String ret = "VarDeclaration ";
|
||||
if(this.getDeclType()!=null)ret+= this.getDeclType().toString()+" ";
|
||||
if(this.getType()!=null)ret+= this.getType().toString()+" ";
|
||||
ret+=this.get_Name();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult().attach(getDeclType().printJavaCode(resultSet)) .attach( " "+this.get_Name()+";");
|
||||
}
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
if(this.getType()!=null)ret.attach(getType().printJavaCode(resultSet)).attach(" ");
|
||||
ret.attach(this.get_Name()+";");
|
||||
return ret;}
|
||||
|
||||
@Override
|
||||
public void setOffset(int offset) {
|
||||
@ -516,5 +510,16 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
return this.get_Name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||
ResultSet resultSet) {
|
||||
return new TypeInsertPoint(this, resultSet.getTypeEqualTo(tph),resultSet);
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -212,6 +213,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -50,6 +51,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
@ -93,15 +95,13 @@ public class MethodCall extends Expr
|
||||
private Receiver receiver;
|
||||
// ino.end
|
||||
// ino.attribute.arglist.25642.declaration
|
||||
private ArgumentList arglist=null;
|
||||
private ArgumentList arglist=new ArgumentList();
|
||||
// ino.end
|
||||
private Vector<String> exprtypes=new Vector<String>(); //hier werden die Typen der �bergabewerten von sc_check eingetragen.
|
||||
// ino.attribute.class_name.25645.declaration
|
||||
private String class_name; //hier steht in welcher Klasse die Methode deklariert ist.
|
||||
// ino.end
|
||||
// ino.attribute.called_method.25648.declaration
|
||||
private Method called_method=null; //hier steht nach Ende von sc_check die aufgerufene Methode.
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.uebernachdurch.25651.declaration
|
||||
private Hashtable<String,Method> uebernachdurch;
|
||||
// ino.end
|
||||
@ -231,17 +231,17 @@ public class MethodCall extends Expr
|
||||
}
|
||||
Vector<CParaTypeAssumption> paraAssumptions=assumption.getParaAssumptions();
|
||||
Type returnType=assumption.getAssumedType();
|
||||
Method meth=new Method();
|
||||
Method meth=new Method(0);
|
||||
Vector<FormalParameter> parameterVector=new Vector<FormalParameter>();
|
||||
ParameterList pl=new ParameterList();
|
||||
for(int i=0;i<paraAssumptions.size();i++){
|
||||
CParaTypeAssumption paraassumtion=paraAssumptions.elementAt(i);
|
||||
FormalParameter fp=new FormalParameter();
|
||||
FormalParameter fp=new FormalParameter(new DeclId());
|
||||
fp.setType(paraassumtion.getAssumedType());
|
||||
parameterVector.addElement(fp);
|
||||
}
|
||||
pl.formalparameter=parameterVector;
|
||||
meth.setReturnType(returnType);
|
||||
meth.setType(returnType);
|
||||
meth.setParameterList(pl);
|
||||
meth.set_DeclId(new DeclId(assumption.getIdentifier()));
|
||||
return(meth);
|
||||
@ -268,7 +268,7 @@ public class MethodCall extends Expr
|
||||
String receiverClassName=((RefType)receiver.get_Expr().getType()).getTypeName();
|
||||
|
||||
// Die richtige Methode wird gesucht und gesetzt
|
||||
called_method=getMethodFittingMethodCallAndClassname(receiverClassName);
|
||||
Method called_method=getMethodFittingMethodCallAndClassname(receiverClassName);
|
||||
|
||||
|
||||
Vector name_vector = get_Name_Vector();
|
||||
@ -664,14 +664,13 @@ public class MethodCall extends Expr
|
||||
*/
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
//TODO hier muss unterschieden werden zwischen einem Konstruktor und einer Methode.
|
||||
//Hier der Ablauf für einen Methodenaufruf:
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//Der Return-Type des MEthodenaufrufs ist zunächst unbekannt:
|
||||
this.setType(TypePlaceholder.fresh(this));
|
||||
//Berechne die Constraints des Receivers
|
||||
if(receiver == null){
|
||||
receiver = new Receiver(new This(0,0));
|
||||
receiver = new Receiver(new This(this));
|
||||
}
|
||||
ret.add(receiver.get_Expr().TYPEExpr(assumptions));
|
||||
|
||||
@ -709,6 +708,21 @@ public class MethodCall extends Expr
|
||||
return ret.attach(";");
|
||||
|
||||
}
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
for(Expr e : this.arglist.expr){
|
||||
ret.add(e);
|
||||
}
|
||||
if(this.receiver!=null)ret.add(this.receiver.get_Expr());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
@ -30,6 +31,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -139,10 +141,17 @@ public class NegativeExpr extends UnaryExpr
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -23,6 +24,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -202,5 +204,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.addAll(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -35,6 +36,11 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.Overloading;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -42,7 +48,10 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.ConstructorAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -223,8 +232,7 @@ public class NewClass extends Expr
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
//TODO: Das hier noch vervollständigen
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
|
||||
this.set_Type(TypePlaceholder.fresh(this));
|
||||
UndConstraint callConstraints = new UndConstraint();
|
||||
//Die Auskommentierten Zeilen gehören zu MethodRefNew
|
||||
//Vector<Type> argumentTypeList = new Vector<Type>();
|
||||
//for(Expr expr : this.arglist.expr){
|
||||
@ -234,19 +242,31 @@ public class NewClass extends Expr
|
||||
|
||||
//Constraint newClassTypeConstraint = new Constraint(null,null);
|
||||
//ret.add(newClassTypeConstraint);
|
||||
int numArgs = 0;
|
||||
if(this.arglist != null)numArgs = this.arglist.size();
|
||||
ConstructorAssumption cA = assumptions.getConstructorAssumption(this.get_Name(), numArgs);
|
||||
if(cA == null)throw new TypeinferenceException("Der Konstruktor "+this.get_Name()+" mit "+numArgs+" Parametern ist nicht vorhanden.", this);
|
||||
|
||||
if(this.arglist != null && this.arglist.expr != null)for(Expr arg : this.arglist.expr){
|
||||
ret.add(arg.TYPEExpr(assumptions));
|
||||
for(int i=0; i<cA.getParaCount();i++){
|
||||
ret.add(this.arglist.expr.elementAt(i).TYPEExpr(assumptions));
|
||||
callConstraints.addConstraint( this.arglist.expr.elementAt(i).getType(), cA.getParameterType(i));
|
||||
}
|
||||
//if(this.arglist != null && this.arglist.expr != null)for(Expr arg : this.arglist.expr){
|
||||
// ret.add(arg.TYPEExpr(assumptions));
|
||||
//}
|
||||
|
||||
this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),0)));
|
||||
|
||||
|
||||
/*
|
||||
//Ein new-Aufruf ist nichts anderes als ein MethodCall der Methode <init>
|
||||
MethodCall newAufruf = new MethodCall(0,0);
|
||||
this.setType(new RefType(this.get_Name(),0));
|
||||
newAufruf.type = new RefType(this.get_Name(),0);
|
||||
this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),0)));
|
||||
newAufruf.type = this.getType();
|
||||
newAufruf.set_Name("<init>");
|
||||
newAufruf.set_Receiver(null);
|
||||
ret.add(new Overloading(assumptions, newAufruf, this.getType()).generateConsstraints());
|
||||
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -259,14 +279,14 @@ public class NewClass extends Expr
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){
|
||||
ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen
|
||||
this.set_Type(new Void(0)); //Typ des Statments auf Void setzen.
|
||||
this.setType(new Void(0)); //Typ des Statments auf Void setzen.
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
JavaCodeResult ret = new JavaCodeResult("new ");
|
||||
ret.attach(this.getType().printJavaCode(resultSet));
|
||||
ret.attach(this.get_Name());
|
||||
ret.attach("(");
|
||||
if(this.arglist!=null && this.arglist.expr != null){
|
||||
Iterator<Expr> it = this.arglist.expr.iterator();
|
||||
@ -281,5 +301,15 @@ public class NewClass extends Expr
|
||||
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
if(this.arglist!=null)for(Expr e : this.arglist.expr){
|
||||
ret.add(e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,12 +6,14 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
import mycompiler.myexception.SCStatementException;
|
||||
import mycompiler.mytype.BooleanType;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
@ -29,8 +31,12 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
@ -153,8 +159,11 @@ public class NotExpr extends UnaryExpr
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
OderConstraint constraint = new OderConstraint();
|
||||
constraint.addConstraint(new Pair(this.getType(), new BooleanType()));
|
||||
ret.add(constraint);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,5 +172,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -25,6 +26,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -120,5 +122,10 @@ public class Null extends Literal
|
||||
return new JavaCodeResult("null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
return new Vector<SyntaxTreeNode>();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.myclass.Class;
|
||||
@ -22,6 +23,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -143,5 +145,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -182,5 +184,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -182,5 +184,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -175,10 +177,16 @@ public class PreDecExpr extends UnaryExpr
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -183,5 +185,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -142,6 +144,13 @@ public class Return extends Statement
|
||||
ret.attach(this.retexpr.printJavaCode(resultSet));
|
||||
return ret.attach(";");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.retexpr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -50,7 +50,6 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
|
||||
// ino.end
|
||||
|
||||
protected Type type;
|
||||
private SyntaxTreeNode parent;
|
||||
|
||||
// ino.method.Statement.26194.definition
|
||||
public Statement(int offset, int variableLength)
|
||||
@ -145,5 +144,10 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
|
||||
|
||||
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return this.printJavaCode(new ResultSet(new Vector<Pair>())).toString();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -25,10 +26,13 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -135,7 +139,8 @@ public class StringLiteral extends Literal
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
this.set_Type(new RefType("String",0));
|
||||
this.set_Type(assumptions.getTypeFor(new RefType("String",0)));
|
||||
if(this.getType() == null)throw new TypeinferenceException("java.lang.String nicht importiert",this);
|
||||
return new ConstraintsSet();
|
||||
}
|
||||
|
||||
@ -143,7 +148,12 @@ public class StringLiteral extends Literal
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult("\""+this.string+"\"");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,7 @@ package mycompiler.mystatement;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
@ -48,6 +50,11 @@ public class This extends Expr
|
||||
}
|
||||
// ino.end
|
||||
|
||||
public This(SyntaxTreeNode parent){
|
||||
this(0,0);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
// ino.attribute.arglist.26268.declaration
|
||||
public ArgumentList arglist;
|
||||
// ino.end
|
||||
@ -168,7 +175,8 @@ public class This extends Expr
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//this.set_Type(new);
|
||||
this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen.
|
||||
//this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen.
|
||||
this.setType(this.getParentClass().getType());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -185,5 +193,11 @@ public class This extends Expr
|
||||
return new JavaCodeResult("this");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -7,6 +7,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
@ -36,6 +37,7 @@ import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
@ -200,5 +202,13 @@ public class WhileStmt extends Statement
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult().attach("while(").attach(this.expr.printJavaCode(resultSet)).attach(")").attach(this.loop_block.printJavaCode(resultSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<SyntaxTreeNode> getChildren() {
|
||||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||
ret.add(this.expr);
|
||||
ret.add(this.loop_block);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,58 +0,0 @@
|
||||
// ino.module.CByteCodeTest.8661.package
|
||||
package mycompiler.mytest;
|
||||
// ino.end
|
||||
|
||||
// ino.module.CByteCodeTest.8661.import
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytypereconstruction.CSubstitution;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CByteCodeTest.26367.description type=javadoc
|
||||
/**
|
||||
* Testklasse zum Generieren des ByteCode.
|
||||
* @author scju
|
||||
*/
|
||||
// ino.end
|
||||
// ino.class.CByteCodeTest.26367.declaration
|
||||
public class CByteCodeTest
|
||||
// ino.end
|
||||
// ino.class.CByteCodeTest.26367.body
|
||||
{
|
||||
|
||||
// ino.method.main.26370.definition
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.main.26370.body
|
||||
{
|
||||
MyCompilerAPI compiler = MyCompiler.getAPI();
|
||||
|
||||
// Ausgabeverzeichnis festlegen
|
||||
compiler.setOutputDir("Bytecode/");
|
||||
|
||||
// Parsen der Klasse
|
||||
compiler.parse(new File(args[0]));
|
||||
|
||||
// Typ-Rekonstruktion
|
||||
Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
|
||||
if ((resultSet != null) && (resultSet.size() > 0)) {
|
||||
TypeinferenceResultSet onePossibility = resultSet.firstElement();
|
||||
Iterator substIt = onePossibility.getSubstitutions().getIterator();
|
||||
while(substIt.hasNext()){
|
||||
CSubstitution subst = (CSubstitution)substIt.next();
|
||||
// Substition machen
|
||||
subst.execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Code generieren
|
||||
compiler.codeGeneration();
|
||||
}
|
||||
// ino.end
|
||||
}
|
||||
// ino.end
|
@ -1,103 +0,0 @@
|
||||
// ino.module.CInferenceTest.8662.package
|
||||
package mycompiler.mytest;
|
||||
// ino.end
|
||||
|
||||
// ino.module.CInferenceTest.8662.import
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.mytypereconstruction.CSubstitution;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CInferenceTest.26373.description type=javadoc
|
||||
/**
|
||||
* Testklasse fr die Typinferenz
|
||||
* @author Timo Holzherr
|
||||
*/
|
||||
// ino.end
|
||||
// ino.class.CInferenceTest.26373.declaration
|
||||
public class CInferenceTest
|
||||
// ino.end
|
||||
// ino.class.CInferenceTest.26373.body
|
||||
{
|
||||
|
||||
// ino.attribute.inferencelog.26376.declaration
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
// ino.end
|
||||
|
||||
// ino.method.main.26379.definition
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.main.26379.body
|
||||
{
|
||||
MyCompilerAPI compiler = MyCompiler.getAPI();
|
||||
try{
|
||||
|
||||
/////////////////////////
|
||||
// Parsen:
|
||||
/////////////////////////
|
||||
|
||||
//1. Argument: zu kompilierende Datei
|
||||
compiler.parse(new File(args[0]));
|
||||
|
||||
MyCompiler.getAPI().setOutputDir("Bytecode/");
|
||||
|
||||
//compiler.semanticCheck();
|
||||
|
||||
/////////////////////////
|
||||
// Typrekonstruktion:
|
||||
/////////////////////////
|
||||
Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
|
||||
/////////////////////////
|
||||
// Ausgabe:
|
||||
/////////////////////////
|
||||
|
||||
|
||||
if(resultSet==null||resultSet.size()==0){
|
||||
inferencelog.error("Das Resultset ist leer!!!");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// if(true)System.exit(0);
|
||||
TypeinferenceResultSet onePossibility = resultSet.firstElement();
|
||||
Iterator substIt = onePossibility.getSubstitutions().getIterator();
|
||||
while(substIt.hasNext()){
|
||||
CSubstitution subst = (CSubstitution)substIt.next();
|
||||
/*Vector<Integer> lineNumbers = ((TypePlaceholder)subst.getTypeVar()).getLineNumbers();
|
||||
String s = new String();
|
||||
for(int l=0; l<lineNumbers.size(); l++){
|
||||
s+=(lineNumbers.elementAt(l)+", ");
|
||||
}
|
||||
if(s.length()==0){
|
||||
inferencelog.debug("Fr TypePlaceholder \""+subst.getTypeVar().getName()+"\" sind keine Liniennummern "+s+" registriert.");
|
||||
}
|
||||
else {
|
||||
s = s.substring(0, s.length()-2);
|
||||
inferencelog.debug("TypePlaceholder \""+subst.getTypeVar().getName()+"\" kommt im Quellcode in den Linien "+s+" vor.");
|
||||
}*/
|
||||
/////////////////////////
|
||||
// Substitution durchf<EFBFBD>hren:
|
||||
/////////////////////////
|
||||
subst.execute();
|
||||
|
||||
}
|
||||
inferencelog.debug("========FERTIG========");
|
||||
|
||||
//compiler.codeGeneration();
|
||||
|
||||
|
||||
}catch(CTypeReconstructionException tre){
|
||||
tre.printStackTrace();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
}
|
||||
// ino.end
|
@ -1,90 +0,0 @@
|
||||
// ino.module.CSimpleTest.8664.package
|
||||
package mycompiler.mytest;
|
||||
// ino.end
|
||||
|
||||
// ino.module.CSimpleTest.8664.import
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
import mycompiler.mytypereconstruction.CSubstitution;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
import org.apache.log4j.Logger;
|
||||
// ino.end
|
||||
|
||||
// ino.class.CSimpleTest.26416.description type=javadoc
|
||||
/**
|
||||
* Testklasse f<EFBFBD>r die Compiler-API
|
||||
* @author J<EFBFBD>rg B<EFBFBD>uerle
|
||||
* @version $Date: 2006/06/13 10:37:32 $
|
||||
*/
|
||||
// ino.end
|
||||
// ino.class.CSimpleTest.26416.declaration
|
||||
public class CSimpleTest
|
||||
// ino.end
|
||||
// ino.class.CSimpleTest.26416.body
|
||||
{
|
||||
|
||||
// ino.attribute.inferencelog.26419.declaration
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
// ino.end
|
||||
|
||||
// ino.method.main.26422.definition
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.main.26422.body
|
||||
{
|
||||
MyCompilerAPI compiler = MyCompiler.getAPI();
|
||||
try{
|
||||
/////////////////////////
|
||||
// Parsen:
|
||||
/////////////////////////
|
||||
compiler.parse(new File(args[0]));
|
||||
//SourceFile tree = compiler.getSyntaxTree();
|
||||
|
||||
/////////////////////////
|
||||
// Typrekonstruktion:
|
||||
/////////////////////////
|
||||
Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
|
||||
/////////////////////////
|
||||
// Ausgabe:
|
||||
/////////////////////////
|
||||
TypeinferenceResultSet onePossibility = resultSet.firstElement();
|
||||
Iterator substIt = onePossibility.getSubstitutions().getIterator();
|
||||
while(substIt.hasNext()){
|
||||
CSubstitution subst = (CSubstitution)substIt.next();
|
||||
Vector<Integer> lineNumbers = ((TypePlaceholder)subst.getTypeVar()).getLineNumbers();
|
||||
String s = new String();
|
||||
for(int l=0; l<lineNumbers.size(); l++){
|
||||
s+=(lineNumbers.elementAt(l)+", ");
|
||||
}
|
||||
if(s.length()==0){
|
||||
inferencelog.debug("F<EFBFBD>r TypePlaceholders \""+subst.getTypeVar().getName()+"\" sind keine Liniennummern "+s+" registriert.");
|
||||
}
|
||||
else {
|
||||
s = s.substring(0, s.length()-2);
|
||||
inferencelog.debug("TypePlaceholders \""+subst.getTypeVar().getName()+"\" kommt im Quellcode in den Linien "+s+" vor.");
|
||||
}
|
||||
/////////////////////////
|
||||
// Substitution durchf<EFBFBD>hren:
|
||||
/////////////////////////
|
||||
subst.execute();
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// Code erzeugen:
|
||||
/////////////////////////
|
||||
//compiler.codeGeneration();
|
||||
/////////////////////////
|
||||
System.out.println("Fertig");
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
}
|
||||
// ino.end
|
@ -1,92 +0,0 @@
|
||||
|
||||
package mycompiler.mytest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.SourceFile;
|
||||
import mycompiler.mytype.*;
|
||||
import mycompiler.myexception.CTypeReconstructionException;
|
||||
import mycompiler.mytypereconstruction.CSubstitution;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
import mycompiler.mytypereconstruction.unify.FC_TTO;
|
||||
import mycompiler.mytypereconstruction.unify.Unify;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Testklasse fr die Wildcard Algorithmus uns Parser
|
||||
* @author Arne Lüdtke
|
||||
*/
|
||||
public class CWildcardTest
|
||||
{
|
||||
|
||||
// protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
{
|
||||
MyCompilerAPI compiler = MyCompiler.getAPI();
|
||||
try{
|
||||
|
||||
/////////////////////////
|
||||
// Parsen:
|
||||
/////////////////////////
|
||||
compiler.parse(new File(args[0]));
|
||||
|
||||
MyCompiler.getAPI().setOutputDir("Bytecode/");
|
||||
|
||||
//compiler.semanticCheck();
|
||||
|
||||
/////////////////////////
|
||||
// Typrekonstruktion:
|
||||
/////////////////////////
|
||||
//Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction();
|
||||
/////////////////////////
|
||||
// Ausgabe:
|
||||
/////////////////////////
|
||||
|
||||
//test
|
||||
SourceFile file = compiler.getSyntaxTree();
|
||||
FC_TTO fc_tto = file.makeFC();
|
||||
for(Pair p : fc_tto.getFC())
|
||||
{
|
||||
if(p.TA1 instanceof RefType && ((RefType)p.TA1).get_ParaList() != null)
|
||||
MyCompiler.wandleGeneric2RefType(((RefType)p.TA1).get_ParaList(),fc_tto.getClasses());
|
||||
|
||||
if(p.TA2 instanceof RefType && ((RefType)p.TA2).get_ParaList() != null)
|
||||
MyCompiler.wandleGeneric2RefType(((RefType)p.TA2).get_ParaList(),fc_tto.getClasses());
|
||||
}
|
||||
for(Pair p : ((MyCompiler)compiler).testPair)
|
||||
{
|
||||
RefType TA1 = (RefType)p.TA1;
|
||||
RefType TA2 = (RefType)p.TA2;
|
||||
MyCompiler.wandleGeneric2RefType(TA1.get_ParaList(),fc_tto.getClasses());
|
||||
MyCompiler.wandleGeneric2RefType(TA2.get_ParaList(),fc_tto.getClasses());
|
||||
|
||||
//Vector<Type> smallers = Unify.smaller(TA2,fc_tto);
|
||||
//Vector<Type> greaters = Unify.greater(TA2,fc_tto);
|
||||
MyCompiler.makeGenericTypeVars2TypePlaceHolders(TA2);
|
||||
MyCompiler.makeGenericTypeVars2TypePlaceHolders(TA1);
|
||||
}
|
||||
Vector<Vector<Pair>> unifyers = Unify.unify(((MyCompiler)compiler).testPair,fc_tto);
|
||||
|
||||
//Vector<Vector<Pair>> testUni = Unify.unify(TypePlaceholder.fresh(),TypePlaceholder.fresh(),fc_tto);
|
||||
/*
|
||||
if(resultSet==null||resultSet.size()==0){
|
||||
//inferencelog.error("Das Resultset ist leer!!!");
|
||||
System.exit(1);
|
||||
}*/
|
||||
|
||||
// inferencelog.debug("========FERTIG========");
|
||||
|
||||
compiler.codeGeneration();
|
||||
|
||||
|
||||
}catch(CTypeReconstructionException tre){
|
||||
tre.printStackTrace();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
// ino.module.CompilerTestCase.8663.package
|
||||
package mycompiler.mytest;
|
||||
// ino.end
|
||||
|
||||
// ino.module.CompilerTestCase.8663.import
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import junit.framework.TestCase;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytypereconstruction.CSubstitution;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.class.CompilerTestCase.26382.description type=javadoc
|
||||
/**
|
||||
* Testet den Compiler mit dem angegebenen JAV-File.
|
||||
* @author SCJU
|
||||
*
|
||||
*/
|
||||
// ino.end
|
||||
// ino.class.CompilerTestCase.26382.declaration
|
||||
public class CompilerTestCase extends TestCase
|
||||
// ino.end
|
||||
// ino.class.CompilerTestCase.26382.body
|
||||
{
|
||||
|
||||
// ino.attribute.javFile.26386.declaration
|
||||
protected File javFile;
|
||||
// ino.end
|
||||
// ino.attribute.compiler.26389.declaration
|
||||
protected MyCompilerAPI compiler = MyCompiler.getAPI();
|
||||
// ino.end
|
||||
|
||||
// ino.method.CompilerTestCase.26392.definition
|
||||
public CompilerTestCase(String javFile, String name)
|
||||
// ino.end
|
||||
// ino.method.CompilerTestCase.26392.body
|
||||
{
|
||||
this.javFile = new File(javFile);
|
||||
setName(name);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.CompilerTestCase.26395.definition
|
||||
public CompilerTestCase(String javFile)
|
||||
// ino.end
|
||||
// ino.method.CompilerTestCase.26395.body
|
||||
{
|
||||
this.javFile = new File(javFile);
|
||||
setName(this.javFile.getName());
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.runTest.26398.definition
|
||||
protected void runTest()
|
||||
throws Throwable
|
||||
// ino.end
|
||||
// ino.method.runTest.26398.body
|
||||
{
|
||||
// Testablauf. Tritt eine Exception auf,
|
||||
// schlaegt der Test fehl.
|
||||
parseFile();
|
||||
typeReconstruction();
|
||||
codeGeneration();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.parseFile.26401.definition
|
||||
protected void parseFile()
|
||||
throws Throwable
|
||||
// ino.end
|
||||
// ino.method.parseFile.26401.body
|
||||
{
|
||||
// Parsen der Klasse
|
||||
compiler.parse(javFile);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.typeReconstruction.26404.definition
|
||||
protected void typeReconstruction()
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.typeReconstruction.26404.body
|
||||
{
|
||||
// Typ-Rekonstruktion
|
||||
Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
|
||||
// Keine Typ-Rekonstruktion erforderlich
|
||||
if (resultSet == null || resultSet.size() == 0) throw new Exception("Typrekonstruktion nicht durchfuehrbar!");
|
||||
TypeinferenceResultSet onePossibility = resultSet.firstElement();
|
||||
Iterator substIt = onePossibility.getSubstitutions().getIterator();
|
||||
while(substIt.hasNext()){
|
||||
CSubstitution subst = (CSubstitution)substIt.next();
|
||||
// Substition machen
|
||||
subst.execute();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.codeGeneration.26407.definition
|
||||
protected void codeGeneration()
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.codeGeneration.26407.body
|
||||
{
|
||||
// Code generieren
|
||||
compiler.codeGeneration();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setUp.26410.definition
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
// ino.end
|
||||
// ino.method.setUp.26410.body
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
// Setup fuer Log4J
|
||||
// Logfiles werden im Ordner testResults gespeichert
|
||||
// Der Dateiname ist der Klassename plus .log
|
||||
String logFile = "testResults/"+ javFile.getName() + ".log";
|
||||
|
||||
File f = new File(logFile); // Altes Logfile loeschen
|
||||
f.delete();
|
||||
|
||||
// Ausgabeoptionen fuer die Logger
|
||||
PatternLayout pl = new PatternLayout("%-15C{1} %-5p [%-9c] %m%n");
|
||||
FileAppender fa = new FileAppender(pl, logFile);
|
||||
|
||||
// Die Einstellungen jedes Loggers veraendern
|
||||
ModifyLogger("parser", Level.ALL, fa);
|
||||
ModifyLogger("inference", Level.INFO, fa);
|
||||
ModifyLogger("codegen", Level.ALL, fa);
|
||||
ModifyLogger("bytecode", Level.ALL, fa);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.ModifyLogger.26413.defdescription type=line
|
||||
// Veraendert die Ausgabeoptionen des angegebenen Loggers
|
||||
// ino.end
|
||||
// ino.method.ModifyLogger.26413.definition
|
||||
protected void ModifyLogger(String strlogger, Level lv, FileAppender fa)
|
||||
// ino.end
|
||||
// ino.method.ModifyLogger.26413.body
|
||||
{
|
||||
Logger lg = Logger.getLogger(strlogger);
|
||||
|
||||
lg.setLevel(lv);
|
||||
lg.removeAllAppenders();
|
||||
lg.addAppender(fa);
|
||||
}
|
||||
// ino.end
|
||||
}
|
||||
// ino.end
|
@ -1,98 +0,0 @@
|
||||
// ino.module.JUnitTests.8665.package
|
||||
package mycompiler.mytest;
|
||||
// ino.end
|
||||
|
||||
// ino.module.JUnitTests.8665.import
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import mycompiler.MyCompiler;
|
||||
// ino.end
|
||||
|
||||
// ino.class.JUnitTests.26425.description type=javadoc
|
||||
/**
|
||||
* Erstellt eine JUnit-Testsuite, die saemtliche Testcases enthaelt und
|
||||
* ausfuehrt.
|
||||
* @author SCJU
|
||||
*
|
||||
*/
|
||||
// ino.end
|
||||
// ino.class.JUnitTests.26425.declaration
|
||||
public class JUnitTests
|
||||
// ino.end
|
||||
// ino.class.JUnitTests.26425.body
|
||||
{
|
||||
|
||||
|
||||
// ino.method.main.26428.defdescription type=line
|
||||
// Aufruf ist auch als normale Anwendung moeglich.
|
||||
// In Eclipse bietet sich allerdings eine Run-Config
|
||||
// als JUnit-Test an!
|
||||
// ino.end
|
||||
// ino.method.main.26428.definition
|
||||
public static void main(String[] args)
|
||||
// ino.end
|
||||
// ino.method.main.26428.body
|
||||
{
|
||||
junit.textui.TestRunner.run(JUnitTests.suite());
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.suite.26431.definition
|
||||
public static Test suite()
|
||||
// ino.end
|
||||
// ino.method.suite.26431.body
|
||||
{
|
||||
TestSuite suite = new TestSuite("Teste Usecases for Compiler ...");
|
||||
//$JUnit-BEGIN$
|
||||
|
||||
|
||||
MyCompiler.getAPI().setOutputDir("Bytecode/");
|
||||
|
||||
|
||||
|
||||
// DER WICHTIGSTE
|
||||
suite.addTest(new CompilerTestCase("examples/bajo1_usecases/Matrix.jav"));
|
||||
|
||||
// Usecases PL
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseOne_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseTwo_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseThree_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseFour_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseFive_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseSix_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseSeven_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseEight_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseNine_pl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/pl_usecases/UsecaseTen_pl.jav"));
|
||||
|
||||
|
||||
// Usecases HOTI
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Constr.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Generic.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/GenericsTest.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/ImplClass.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Import.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Intf.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Multiclass.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Overl.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Simple.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Simple2.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Test.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Test2.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/Test3.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/hoti/VererbProb.jav"));
|
||||
|
||||
// Usecases SCJU
|
||||
suite.addTest(new CompilerTestCase("examples/scju/ClassGenerics.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/scju/FieldGenerics.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/scju/MethodGenerics.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/scju/ClassKonstanten.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/scju/InterfaceTest.jav"));
|
||||
suite.addTest(new CompilerTestCase("examples/scju/testPackage/Test.jav"));
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
}
|
||||
// ino.end
|
@ -15,8 +15,8 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.apache.log4j.SimpleLayout;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypeinferenceException;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytype.Type;
|
||||
@ -98,7 +98,7 @@ public class LambdaTest {
|
||||
TypeAssumptions assumptions = result1.getInterferedClass().getPublicFieldAssumptions();// TypeAssumptions.getAssumptionsFor(classname);
|
||||
assertTrue("Fehler in Methode TypeAssumptions.getAssumptionsFor", assumptions!=null);
|
||||
for(String variable : variableTypeAssumptions.keySet()){
|
||||
Type assumedType = assumptions.getVarType(variable);
|
||||
Type assumedType = assumptions.getVarType(variable, result1.getInterferedClass());
|
||||
assertTrue("Der Variable muss ein TPH zugewiesen sein.", assumedType!=null && assumedType instanceof TypePlaceholder);
|
||||
//AssumedType auflösen:
|
||||
|
||||
@ -145,7 +145,7 @@ public class LambdaTest {
|
||||
/////////////////////////
|
||||
try{
|
||||
resultSet = compiler.typeReconstruction();
|
||||
}catch(TypinferenzException texc){
|
||||
}catch(TypeinferenceException texc){
|
||||
texc.printStackTrace();
|
||||
fail("Fehler bei Typinferenzalgorithmus. Message: "+texc.getMessage());
|
||||
}
|
||||
@ -189,6 +189,7 @@ public class LambdaTest {
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
assertNotNull("Fehler bei Typinferenzalgorithmus. Message: "+e.getMessage(), resultSet);
|
||||
fail();
|
||||
}
|
||||
return resultSet;
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
// ino.module.BaseType.8667.package
|
||||
package mycompiler.mytype;
|
||||
|
||||
import mycompiler.IItemWithOffset;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
// ino.end
|
||||
// ino.class.BaseType.26435.declaration
|
||||
public abstract class BaseType extends Type
|
||||
@ -76,5 +80,12 @@ public abstract class BaseType extends Type
|
||||
public void setArray(boolean IsArray) {
|
||||
this.IsArray = IsArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type checkType(TypeAssumptions ass, IItemWithOffset parent) {
|
||||
return this; //Die Base-Types müssen nicht nachgeschlagen werden.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -5,6 +5,8 @@ package mycompiler.mytype;
|
||||
|
||||
// ino.module.BoundedGenericTypeVar.8669.import
|
||||
import java.util.Vector;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
// ino.end
|
||||
|
||||
// ino.class.BoundedGenericTypeVar.26464.description type=javadoc
|
||||
@ -34,11 +36,12 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
||||
// ino.end
|
||||
|
||||
// ino.method.BoundedGenericTypeVar.26471.definition
|
||||
public BoundedGenericTypeVar(String s, int offset)
|
||||
public BoundedGenericTypeVar(String s, int offset, Vector<Type> t)
|
||||
// ino.end
|
||||
// ino.method.BoundedGenericTypeVar.26471.body
|
||||
{
|
||||
super(s, offset);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -48,6 +51,10 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
||||
// ino.method.BoundedGenericTypeVar.29409.body
|
||||
{
|
||||
super(s, offset);
|
||||
if(bounds != null)for(Type t : bounds){
|
||||
if(t!=null)this.extendVars.add(t);
|
||||
}
|
||||
this.genericTypeVar = new RefType(s,offset);
|
||||
this.bounds = bounds;
|
||||
}
|
||||
// ino.end
|
||||
@ -66,6 +73,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
||||
// ino.end
|
||||
// ino.method.setBounds.26477.body
|
||||
{
|
||||
|
||||
this.bounds=types;
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,18 +3,35 @@ package mycompiler.mytype;
|
||||
// ino.end
|
||||
|
||||
// ino.module.GenericTypeVar.8671.import
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||
import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListener;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.typedeployment.TypeInsertPoint;
|
||||
|
||||
|
||||
// ino.class.GenericTypeVar.26505.description type=javadoc
|
||||
/**
|
||||
*
|
||||
* TODO: Diese Klasse überarbeiten. Pair genericTypeVar ist nicht implementiert.
|
||||
* @author J<EFBFBD>rg B<EFBFBD>uerle
|
||||
* @version $Date: 2013/09/22 20:12:53 $
|
||||
*/
|
||||
@ -24,8 +41,10 @@ public class GenericTypeVar extends Type
|
||||
// ino.end
|
||||
// ino.class.GenericTypeVar.26505.body
|
||||
{
|
||||
Pair genericTypeVar;
|
||||
/**
|
||||
Type genericTypeVar;
|
||||
Vector<Type> extendVars = new Vector<Type>();
|
||||
protected Pair genericConstraint;
|
||||
/**
|
||||
* Eine Registry f<EFBFBD>r alle Generic-Instanzen, die vor der Bytecode-Generierung durch
|
||||
* Ihre Superklasse ersetzt werden m<EFBFBD>ssen. Siehe "Type Erasure" in Sun Spezifikation.
|
||||
* <br/>Autor: J<EFBFBD>rg B<EFBFBD>uerle
|
||||
@ -33,14 +52,19 @@ public class GenericTypeVar extends Type
|
||||
// ino.method.GenericTypeVar.26509.defdescription type=line
|
||||
// private Hashtable<String, Vector<GenericTypeVar>> m_TypeErasureList;
|
||||
// ino.end
|
||||
private static HashMap<GenericTypeVar,TypePlaceholder> tph = new HashMap<GenericTypeVar,TypePlaceholder>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param genericTypeVarExtendsVar
|
||||
*/
|
||||
public GenericTypeVar(Pair genericTypeVarExtendsVar){
|
||||
super(0);
|
||||
genericTypeVar = genericTypeVarExtendsVar;
|
||||
public GenericTypeVar(Pair genericTypeVarExtendsVar, int offset){
|
||||
super(offset);
|
||||
genericTypeVar = genericTypeVarExtendsVar.TA1;
|
||||
if(genericTypeVarExtendsVar.TA2!=null)this.extendVars.add(genericTypeVarExtendsVar.TA2);
|
||||
else{
|
||||
this.genericConstraint = genericTypeVarExtendsVar;
|
||||
}
|
||||
this.name = genericTypeVar.toString();
|
||||
}
|
||||
|
||||
@ -54,8 +78,8 @@ public class GenericTypeVar extends Type
|
||||
}
|
||||
// ino.end
|
||||
|
||||
public GenericTypeVar(Type tA1) {
|
||||
this(new Pair(tA1,null));
|
||||
public GenericTypeVar(Type tA1, int offset) {
|
||||
this(new Pair(tA1,null),offset);
|
||||
}
|
||||
|
||||
// ino.method.clone.26512.defdescription type=javadoc
|
||||
@ -73,7 +97,8 @@ public class GenericTypeVar extends Type
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.equals.26515.defdescription type=javadoc
|
||||
|
||||
// ino.method.equals.26515.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
||||
* @param obj
|
||||
@ -89,6 +114,8 @@ public class GenericTypeVar extends Type
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.toString.26518.definition
|
||||
public String toString()
|
||||
// ino.end
|
||||
@ -98,7 +125,12 @@ public class GenericTypeVar extends Type
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_codegen_Type.26521.defdescription type=javadoc
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
// ino.method.get_codegen_Type.26521.defdescription type=javadoc
|
||||
/**
|
||||
* hoti 4.5.06
|
||||
* Generische Typen werden im Bytecode
|
||||
@ -127,14 +159,52 @@ public class GenericTypeVar extends Type
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
if(this.genericTypeVar!=null){
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
ret.attach(this.genericTypeVar.TA1.printJavaCode(resultSet));
|
||||
if(this.genericTypeVar.TA2!=null)ret.attach(" extends ").attach(this.genericTypeVar.TA2.printJavaCode(resultSet));
|
||||
ret.attach(this.genericTypeVar.printJavaCode(resultSet));
|
||||
if(this.extendVars.size()>0){
|
||||
ret.attach(" extends ");
|
||||
Iterator<Type> it = this.extendVars.iterator();
|
||||
while(it.hasNext()){
|
||||
Type extend = it.next();
|
||||
ret.attach(extend.printJavaCode(resultSet));
|
||||
if(it.hasNext())ret.attach(", ");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return new JavaCodeResult(this.name);
|
||||
}
|
||||
|
||||
public TypePlaceholder getTypePlaceHolder() {
|
||||
if(!GenericTypeVar.tph.containsKey(this)){
|
||||
GenericTypeVar.tph.put(this, TypePlaceholder.fresh());
|
||||
}
|
||||
return GenericTypeVar.tph.get(this);
|
||||
//if(this.tph == null)this.tph = TypePlaceholder.fresh();
|
||||
//return this.tph;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get_Name() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public ConstraintsSet TYPE(TypeAssumptions ass){
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
ass.addGenericVarAssumption(this);
|
||||
//if(this.genericConstraint != null)ret.add(new SingleConstraint(this.genericConstraint.TA1, this.genericConstraint.TA2));
|
||||
if(this.extendVars != null){
|
||||
for(Type ev : this.extendVars){
|
||||
ret.add(new SingleConstraint(ass.getTypeFor(this), ass.getTypeFor(ev)));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user