Parsen von typisierten Felddeklarationen ist jetzt möglich.

This commit is contained in:
JanUlrich 2014-03-18 14:04:31 +01:00
parent 59106a7e7b
commit 2fb5413548
7 changed files with 7380 additions and 7150 deletions

View File

@ -867,7 +867,15 @@ 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($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);
@ -1361,9 +1369,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);
$$=FP;
}
@ -1375,9 +1383,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());
@ -1388,7 +1396,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
// ###########################################################
@ -1398,7 +1406,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;
}

View File

@ -21,11 +21,13 @@ 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.TypinferenzException;
// ino.class.FormalParameter.23391.declaration
public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementListener, Typeable, TypeInsertable
@ -42,6 +44,9 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL
protected static Logger inferencelog = Logger.getLogger("inference");
// ino.end
public FormalParameter(DeclId name){
this.set_DeclId(name);
}
// ino.method.setType.23404.defdescription type=javadoc
@ -73,6 +78,7 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL
// ino.end
// ino.method.set_DeclId.23407.body
{
if(did == null)throw new NullPointerException();
this.declid = did;
}
// ino.end

File diff suppressed because it is too large Load Diff

View File

@ -867,7 +867,15 @@ 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($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);
@ -1361,9 +1369,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);
$$=FP;
}
@ -1375,9 +1383,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());
@ -1388,7 +1396,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
// ###########################################################
@ -1398,7 +1406,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;
}

View File

@ -17,10 +17,10 @@ public class FunNMethod extends Method{
ParameterList pl = new ParameterList();
Vector<FormalParameter> fpList = new Vector<FormalParameter>();
for(int i = 0;i<N;i++){
FormalParameter parameter = new FormalParameter();
parameter.setType(TypePlaceholder.fresh(parameter));
DeclId paramName = new DeclId("T"+i);
parameter.set_DeclId(paramName);
FormalParameter parameter = new FormalParameter(paramName);
parameter.setType(TypePlaceholder.fresh(parameter));
//parameter.set_DeclId(paramName);
fpList.add(parameter);
}
pl.formalparameter = fpList;

View File

@ -1,165 +1,123 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: Klasse2Method Assumptions:
[MethodAssumption: TPH B null { [(var1 = NEW Klasse1), null Return null (var1.getVar1( [ ]))], MethodAssumption: Klasse2 null { []]
Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions:
[MethodAssumption: Matrix null { []]
FieldVar Assumptions:
[typinferenz.assumptions.FieldAssumption@3ea4e3ae]
[typinferenz.assumptions.FieldAssumption@15502c5e]
LocalVar Assumptions:
[]
Parameter Assumptions:
[]
Class DEBUG [Typeinference] Erstellte Assumptions: this: Klasse1Method Assumptions:
[MethodAssumption: int int { [null Return var1], MethodAssumption: Klasse1 null { []]
FieldVar Assumptions:
[typinferenz.assumptions.FieldAssumption@1799e2e2]
LocalVar Assumptions:
[]
Parameter Assumptions:
[]
Block DEBUG [Typeinference] Prozessing statement: (var1 = NEW Klasse1)
Block DEBUG [Typeinference] Prozessing statement: null Return null (var1.getVar1( [ ]))
Block DEBUG [Typeinference] Prozessing statement: TPH K Return TPH J (var1: TPH A.getVar1( [ ]))
Block DEBUG [Typeinference] Prozessing statement: void(var1: TPH A = NEW Klasse1)
Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ f, ]) -> null { [null Return null (f.apply( [ null (this(null)), m, ]))])
Block DEBUG [Typeinference] Prozessing statement: null Return null (f.apply( [ null (this(null)), m, ]))
Block DEBUG [Typeinference] Prozessing statement: TPH K Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ]))
Block DEBUG [Typeinference] Prozessing statement: TPH L Return TPH F (( [ TPH E f, ]) -> TPH K { [TPH K Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ]))])
Class DEBUG [Typeinference] Erstellte Constraints: TPH A < TPH A
[(Klasse1 <. Klasse1), (Klasse1 <. Klasse1), ]
Klasse1 < TPH A
TPH A < TPH I
[(int <. TPH J), (TPH A <. Klasse1), (int <. TPH J), (TPH A <. Klasse1), ]
TPH J < TPH K
TPH K < TPH B
[(TPH H <. TPH G), (Matrix <. TPH I), (TPH C <. TPH J), (TPH E <. FunN), ]
TPH G < TPH K
Fun1< TPH K, TPH E > < TPH F
TPH F < TPH L
Fun1< TPH L, TPH C > < TPH D
TPH D < TPH A
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (Klasse1 <. Klasse1), (Klasse1 <. TPH A), (TPH A <. TPH I), (int <. TPH J), (TPH A <. Klasse1), (TPH J <. TPH K), (TPH K <. TPH B)], [(TPH A <. TPH A), (Klasse1 <. Klasse1), (Klasse1 <. TPH A), (TPH A <. TPH I), (int <. TPH J), (TPH A <. Klasse1), (TPH J <. TPH K), (TPH K <. TPH B)], [(TPH A <. TPH A), (Klasse1 <. Klasse1), (Klasse1 <. TPH A), (TPH A <. TPH I), (int <. TPH J), (TPH A <. Klasse1), (TPH J <. TPH K), (TPH K <. TPH B)], [(TPH A <. TPH A), (Klasse1 <. Klasse1), (Klasse1 <. TPH A), (TPH A <. TPH I), (int <. TPH J), (TPH A <. Klasse1), (TPH J <. TPH K), (TPH K <. TPH B)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]]
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (TPH H <. TPH G), (Matrix <. TPH I), (TPH C <. TPH J), (TPH E <. FunN), (TPH G <. TPH K), (Fun1< TPH K, TPH E > <. TPH F), (TPH F <. TPH L), (Fun1< TPH L, TPH C > <. TPH D), (TPH D <. TPH A)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Matrix), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? super GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Matrix >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Matrix), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] class Klasse2 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
Klasse1 var1;
int testMethode()
{
var1 = new Klasse1();
return var1.getVar1();;
}
Klasse2 Klasse2()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]
SourceFile DEBUG [Typeinference] class Klasse2 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
Klasse1 var1;
int testMethode()
{
var1 = new Klasse1();
return var1.getVar1();;
}
Klasse2 Klasse2()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]
SourceFile DEBUG [Typeinference] class Klasse2 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
Klasse1 var1;
int testMethode()
{
var1 = new Klasse1();
return var1.getVar1();;
}
Klasse2 Klasse2()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH B = int), (TPH I = Klasse1), (TPH K = int), (TPH A = Klasse1), (TPH J = int)]
SourceFile DEBUG [Typeinference] class Klasse2 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
Klasse1 var1;
int testMethode()
{
var1 = new Klasse1();
return var1.getVar1();;
}
Klasse2 Klasse2()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
Block DEBUG [Typeinference] Prozessing statement: null Return var1
Block DEBUG [Typeinference] Prozessing statement: TPH L Return var1: TPH D
Class DEBUG [Typeinference] Erstellte Constraints: TPH D < TPH D
TPH D < TPH L
TPH L < int
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? super GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH D <. TPH D), (TPH D <. TPH L), (TPH L <. int)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH D = int), (TPH L = int)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH D = int), (TPH L = int)]
SourceFile DEBUG [Typeinference] class Klasse1 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
int var1;
int getVar1()
{
return var1;
}
Klasse1 Klasse1()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
Class DEBUG [Typeinference] Erstellte Assumptions: this: Klasse1Method Assumptions:
[MethodAssumption: int int { [null Return var1], MethodAssumption: Klasse1 null { []]
FieldVar Assumptions:
[typinferenz.assumptions.FieldAssumption@744578e0]
LocalVar Assumptions:
[]
Parameter Assumptions:
[]
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
Block DEBUG [Typeinference] Prozessing statement: null Return var1
Block DEBUG [Typeinference] Prozessing statement: TPH M Return var1: TPH F
Class DEBUG [Typeinference] Erstellte Constraints: TPH F < TPH F
TPH F < TPH M
TPH M < int
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH F <. TPH F), (TPH F <. TPH M), (TPH M <. int)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH F = int), (TPH M = int)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH F = int), (TPH M = int)]
SourceFile DEBUG [Typeinference] class Klasse1 extends Object
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
int var1;
int getVar1()
{
return var1;
}
Klasse1 Klasse1()
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Matrix >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}

File diff suppressed because it is too large Load Diff