forked from JavaTX/JavaCompilerCore
Einsetzen von generischen Variablen verbessern
This commit is contained in:
parent
694899e73f
commit
f059e0b9b8
@ -134,7 +134,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%token CASE
|
%token CASE
|
||||||
%token CATCH
|
%token CATCH
|
||||||
%token <Token> CHAR
|
%token <Token> CHAR
|
||||||
%token CLASS
|
%token <Token> CLASS
|
||||||
%token CONTINUE
|
%token CONTINUE
|
||||||
%token DEFAULT
|
%token DEFAULT
|
||||||
%token DO
|
%token DO
|
||||||
@ -152,7 +152,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%token <Token> PUBLIC
|
%token <Token> PUBLIC
|
||||||
%token PACKAGE
|
%token PACKAGE
|
||||||
%token IMPORT
|
%token IMPORT
|
||||||
%token INTERFACE
|
%token <Token> INTERFACE
|
||||||
%token IMPLEMENTS
|
%token IMPLEMENTS
|
||||||
%token RETURN
|
%token RETURN
|
||||||
%token <Token> STATIC
|
%token <Token> STATIC
|
||||||
@ -447,50 +447,50 @@ classdeclaration : CLASS classidentifier classbody
|
|||||||
// Vector<UsedId> SuperInterfaces,
|
// Vector<UsedId> SuperInterfaces,
|
||||||
// Vector<Type> Parameterliste
|
// Vector<Type> Parameterliste
|
||||||
|
|
||||||
$$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector());
|
$$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier classbody
|
| modifiers CLASS classidentifier classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| CLASS classidentifier super classbody
|
| CLASS classidentifier super classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector());
|
$$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier super classbody
|
| modifiers CLASS classidentifier super classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
///* auskommentiert von Andreas Stadelmeier A10023
|
///* auskommentiert von Andreas Stadelmeier A10023
|
||||||
| CLASS classidentifier interfaces classbody
|
| CLASS classidentifier interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector());
|
$$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier interfaces classbody
|
| modifiers CLASS classidentifier interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| CLASS classidentifier super interfaces classbody
|
| CLASS classidentifier super interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector());
|
$$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier super interfaces classbody
|
| modifiers CLASS classidentifier super interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -520,7 +520,7 @@ classidentifier : IDENTIFIER
|
|||||||
interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
||||||
{
|
{
|
||||||
// SCJU: Interface
|
// SCJU: Interface
|
||||||
Interface ic = new Interface($2.getName());
|
Interface ic = new Interface($2.getName(), $1.getOffset());
|
||||||
ic.setParaList($2.getParaVector());
|
ic.setParaList($2.getParaVector());
|
||||||
ic.setInterfaceBody($3);
|
ic.setInterfaceBody($3);
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -529,7 +529,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| modifiers INTERFACE interfaceidentifier interfacebody
|
| modifiers INTERFACE interfaceidentifier interfacebody
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($3.getName(), $1);
|
Interface ic = new Interface($3.getName(), $1, $2.getOffset());
|
||||||
ic.setInterfaceBody($4);
|
ic.setInterfaceBody($4);
|
||||||
ic.setParaList($3.getParaVector());
|
ic.setParaList($3.getParaVector());
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -538,7 +538,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| INTERFACE interfaceidentifier extendsinterfaces interfacebody
|
| INTERFACE interfaceidentifier extendsinterfaces interfacebody
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($2.getName());
|
Interface ic = new Interface($2.getName(), $1.getOffset());
|
||||||
ic.setParaList($2.getParaVector());
|
ic.setParaList($2.getParaVector());
|
||||||
ic.setSuperInterfaces($3.getVector());
|
ic.setSuperInterfaces($3.getVector());
|
||||||
ic.setInterfaceBody($4);
|
ic.setInterfaceBody($4);
|
||||||
@ -548,7 +548,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| modifiers INTERFACE interfaceidentifier extendsinterfaces interfacebody ;
|
| modifiers INTERFACE interfaceidentifier extendsinterfaces interfacebody ;
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($3.getName(), $1);
|
Interface ic = new Interface($3.getName(), $1, $2.getOffset());
|
||||||
ic.setParaList($3.getParaVector());
|
ic.setParaList($3.getParaVector());
|
||||||
ic.setSuperInterfaces($4.getVector());
|
ic.setSuperInterfaces($4.getVector());
|
||||||
ic.setInterfaceBody($5);
|
ic.setInterfaceBody($5);
|
||||||
|
@ -1128,7 +1128,7 @@ public class SourceFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
//BasicAssumptionClass myCl = new BasicAssumptionClass(className, mod);
|
//BasicAssumptionClass myCl = new BasicAssumptionClass(className, mod);
|
||||||
Class parentClass = new Class(className, mod);
|
Class parentClass = new Class(className, mod, 0);
|
||||||
|
|
||||||
if(typeGenPara.size()>0){
|
if(typeGenPara.size()>0){
|
||||||
//auskommentiert von Andreas Stadelmeier:
|
//auskommentiert von Andreas Stadelmeier:
|
||||||
|
@ -17,7 +17,7 @@ public class BasicAssumptionClass extends Class
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.BasicAssumptionClass.23004.body
|
// ino.method.BasicAssumptionClass.23004.body
|
||||||
{
|
{
|
||||||
super(name);
|
super(name, 0);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class BasicAssumptionClass extends Class
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.BasicAssumptionClass.23007.body
|
// ino.method.BasicAssumptionClass.23007.body
|
||||||
{
|
{
|
||||||
super(name,mod);
|
super(name,mod, 0);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@ -68,6 +68,8 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
@ -189,10 +191,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
private SyntaxTreeNode parent;
|
private SyntaxTreeNode parent;
|
||||||
private Vector<Field> fielddecl = new Vector<Field>();
|
private Vector<Field> fielddecl = new Vector<Field>();
|
||||||
private GenericDeclarationList genericClassParameters;
|
private GenericDeclarationList genericClassParameters;
|
||||||
|
private int offset;
|
||||||
|
|
||||||
|
|
||||||
// ino.method.Class.23041.definition
|
// ino.method.Class.23041.definition
|
||||||
public Class(String name)
|
public Class(String name, int offset)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23041.body
|
// ino.method.Class.23041.body
|
||||||
{
|
{
|
||||||
@ -200,11 +203,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
if(name.equals("java.lang.Object")){
|
if(name.equals("java.lang.Object")){
|
||||||
superclassid=null;
|
superclassid=null;
|
||||||
}
|
}
|
||||||
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.Class.23044.definition
|
// ino.method.Class.23044.definition
|
||||||
public Class(String name, Modifiers mod)
|
public Class(String name, Modifiers mod, int offset)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23044.body
|
// ino.method.Class.23044.body
|
||||||
{
|
{
|
||||||
@ -213,6 +217,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
if(name.equals("java.lang.Object")){
|
if(name.equals("java.lang.Object")){
|
||||||
superclassid=null;
|
superclassid=null;
|
||||||
}
|
}
|
||||||
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@ -224,7 +229,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23047.definition
|
// ino.method.Class.23047.definition
|
||||||
public Class(String name, Modifiers mod, ClassBody cb, Vector<Type> ct, Vector<UsedId> usedIdsToCheck,
|
public Class(String name, Modifiers mod, ClassBody cb, Vector<Type> ct, Vector<UsedId> usedIdsToCheck,
|
||||||
UsedId superclass, Vector<UsedId> superif, Vector<Type> paralist)
|
UsedId superclass, Vector<UsedId> superif, Vector<Type> paralist, int offset)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23047.body
|
// ino.method.Class.23047.body
|
||||||
{
|
{
|
||||||
@ -245,7 +250,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
}
|
}
|
||||||
|
|
||||||
parserlog.debug("Neue Klasse: " + name);
|
parserlog.debug("Neue Klasse: " + name);
|
||||||
|
this.offset = offset;
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -1258,8 +1263,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public int getOffset(){
|
public int getOffset(){
|
||||||
//TODO: richtiges Offset:
|
return this.offset;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1381,9 +1385,22 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGenericDeclOffset() {
|
public String getGenericVarDeclarationString(String genericVarDeclaration) {
|
||||||
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
if(this.genericClassParameters != null){
|
||||||
return this.getOffset();
|
return ", "+genericVarDeclaration;
|
||||||
|
}else{
|
||||||
|
return "<"+genericVarDeclaration+">";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGenericVarDeclarationOffset(){
|
||||||
|
// Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
|
if(this.genericClassParameters != null){
|
||||||
|
return this.genericClassParameters.getOffsetOfLastElement();
|
||||||
|
}else{
|
||||||
|
return this.offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,11 +134,23 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGenericVarDeclarationString(String genericVarDeclaration) {
|
||||||
|
if(this.genericParameters != null){
|
||||||
|
return ", "+genericVarDeclaration;
|
||||||
|
}else{
|
||||||
|
return "<"+genericVarDeclaration+">";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGenericDeclOffset() {
|
public int getGenericVarDeclarationOffset(){
|
||||||
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
// Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
return this.offset;
|
if(this.genericParameters != null){
|
||||||
|
return this.genericParameters.getOffsetOfLastElement();
|
||||||
|
}else{
|
||||||
|
return this.offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,12 +35,12 @@ import mycompiler.SourceFile;
|
|||||||
*/
|
*/
|
||||||
public class Interface extends Class {
|
public class Interface extends Class {
|
||||||
|
|
||||||
public Interface(String name){
|
public Interface(String name, int offset){
|
||||||
super(name);
|
super(name, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Interface(String name, Modifiers modifiers) {
|
public Interface(String name, Modifiers modifiers, int offset) {
|
||||||
super(name,modifiers);
|
super(name,modifiers, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getParaList() {
|
public Vector getParaList() {
|
||||||
|
@ -909,7 +909,7 @@ case 20:
|
|||||||
/* Vector<UsedId> SuperInterfaces, */
|
/* Vector<UsedId> SuperInterfaces, */
|
||||||
/* Vector<Type> Parameterliste*/
|
/* Vector<Type> Parameterliste*/
|
||||||
|
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -917,7 +917,7 @@ case 20:
|
|||||||
case 21:
|
case 21:
|
||||||
// line 455 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 455 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -925,7 +925,7 @@ case 21:
|
|||||||
case 22:
|
case 22:
|
||||||
// line 461 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 461 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -933,7 +933,7 @@ case 22:
|
|||||||
case 23:
|
case 23:
|
||||||
// line 467 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 467 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -941,7 +941,7 @@ case 23:
|
|||||||
case 24:
|
case 24:
|
||||||
// line 474 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 474 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -949,7 +949,7 @@ case 24:
|
|||||||
case 25:
|
case 25:
|
||||||
// line 480 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 480 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ case 25:
|
|||||||
case 26:
|
case 26:
|
||||||
// line 486 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 486 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -965,7 +965,7 @@ case 26:
|
|||||||
case 27:
|
case 27:
|
||||||
// line 492 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 492 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), ((Modifiers)yyVals[-5+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector());
|
yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), ((Modifiers)yyVals[-5+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -1002,7 +1002,7 @@ case 32:
|
|||||||
// line 521 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 521 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
/* SCJU: Interface*/
|
/* SCJU: Interface*/
|
||||||
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-1+yyTop]).getName());
|
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-1+yyTop]).getName(), ((Token)yyVals[-2+yyTop]).getOffset());
|
||||||
ic.setParaList(((InterfaceAndParameter)yyVals[-1+yyTop]).getParaVector());
|
ic.setParaList(((InterfaceAndParameter)yyVals[-1+yyTop]).getParaVector());
|
||||||
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -1013,7 +1013,7 @@ case 32:
|
|||||||
case 33:
|
case 33:
|
||||||
// line 531 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 531 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]));
|
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]), ((Token)yyVals[-2+yyTop]).getOffset());
|
||||||
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
||||||
ic.setParaList(((InterfaceAndParameter)yyVals[-1+yyTop]).getParaVector());
|
ic.setParaList(((InterfaceAndParameter)yyVals[-1+yyTop]).getParaVector());
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -1024,7 +1024,7 @@ case 33:
|
|||||||
case 34:
|
case 34:
|
||||||
// line 540 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 540 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-2+yyTop]).getName());
|
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-2+yyTop]).getName(), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
ic.setParaList(((InterfaceAndParameter)yyVals[-2+yyTop]).getParaVector());
|
ic.setParaList(((InterfaceAndParameter)yyVals[-2+yyTop]).getParaVector());
|
||||||
ic.setSuperInterfaces(((InterfaceList)yyVals[-1+yyTop]).getVector());
|
ic.setSuperInterfaces(((InterfaceList)yyVals[-1+yyTop]).getVector());
|
||||||
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
||||||
@ -1036,7 +1036,7 @@ case 34:
|
|||||||
case 35:
|
case 35:
|
||||||
// line 550 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 550 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]));
|
Interface ic = new Interface(((InterfaceAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((Token)yyVals[-3+yyTop]).getOffset());
|
||||||
ic.setParaList(((InterfaceAndParameter)yyVals[-2+yyTop]).getParaVector());
|
ic.setParaList(((InterfaceAndParameter)yyVals[-2+yyTop]).getParaVector());
|
||||||
ic.setSuperInterfaces(((InterfaceList)yyVals[-1+yyTop]).getVector());
|
ic.setSuperInterfaces(((InterfaceList)yyVals[-1+yyTop]).getVector());
|
||||||
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
ic.setInterfaceBody(((InterfaceBody)yyVals[0+yyTop]));
|
||||||
|
@ -134,7 +134,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%token CASE
|
%token CASE
|
||||||
%token CATCH
|
%token CATCH
|
||||||
%token <Token> CHAR
|
%token <Token> CHAR
|
||||||
%token CLASS
|
%token <Token> CLASS
|
||||||
%token CONTINUE
|
%token CONTINUE
|
||||||
%token DEFAULT
|
%token DEFAULT
|
||||||
%token DO
|
%token DO
|
||||||
@ -152,7 +152,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%token <Token> PUBLIC
|
%token <Token> PUBLIC
|
||||||
%token PACKAGE
|
%token PACKAGE
|
||||||
%token IMPORT
|
%token IMPORT
|
||||||
%token INTERFACE
|
%token <Token> INTERFACE
|
||||||
%token IMPLEMENTS
|
%token IMPLEMENTS
|
||||||
%token RETURN
|
%token RETURN
|
||||||
%token <Token> STATIC
|
%token <Token> STATIC
|
||||||
@ -447,50 +447,50 @@ classdeclaration : CLASS classidentifier classbody
|
|||||||
// Vector<UsedId> SuperInterfaces,
|
// Vector<UsedId> SuperInterfaces,
|
||||||
// Vector<Type> Parameterliste
|
// Vector<Type> Parameterliste
|
||||||
|
|
||||||
$$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector());
|
$$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier classbody
|
| modifiers CLASS classidentifier classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| CLASS classidentifier super classbody
|
| CLASS classidentifier super classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector());
|
$$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier super classbody
|
| modifiers CLASS classidentifier super classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
///* auskommentiert von Andreas Stadelmeier A10023
|
///* auskommentiert von Andreas Stadelmeier A10023
|
||||||
| CLASS classidentifier interfaces classbody
|
| CLASS classidentifier interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector());
|
$$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier interfaces classbody
|
| modifiers CLASS classidentifier interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| CLASS classidentifier super interfaces classbody
|
| CLASS classidentifier super interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector());
|
$$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector(), $1.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
| modifiers CLASS classidentifier super interfaces classbody
|
| modifiers CLASS classidentifier super interfaces classbody
|
||||||
{
|
{
|
||||||
$$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector());
|
$$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector(), $2.getOffset());
|
||||||
this.initContainedTypes();
|
this.initContainedTypes();
|
||||||
this.initUsedIdsToCheck();
|
this.initUsedIdsToCheck();
|
||||||
}
|
}
|
||||||
@ -520,7 +520,7 @@ classidentifier : IDENTIFIER
|
|||||||
interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
||||||
{
|
{
|
||||||
// SCJU: Interface
|
// SCJU: Interface
|
||||||
Interface ic = new Interface($2.getName());
|
Interface ic = new Interface($2.getName(), $1.getOffset());
|
||||||
ic.setParaList($2.getParaVector());
|
ic.setParaList($2.getParaVector());
|
||||||
ic.setInterfaceBody($3);
|
ic.setInterfaceBody($3);
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -529,7 +529,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| modifiers INTERFACE interfaceidentifier interfacebody
|
| modifiers INTERFACE interfaceidentifier interfacebody
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($3.getName(), $1);
|
Interface ic = new Interface($3.getName(), $1, $2.getOffset());
|
||||||
ic.setInterfaceBody($4);
|
ic.setInterfaceBody($4);
|
||||||
ic.setParaList($3.getParaVector());
|
ic.setParaList($3.getParaVector());
|
||||||
ic.setContainedTypes(containedTypes);
|
ic.setContainedTypes(containedTypes);
|
||||||
@ -538,7 +538,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| INTERFACE interfaceidentifier extendsinterfaces interfacebody
|
| INTERFACE interfaceidentifier extendsinterfaces interfacebody
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($2.getName());
|
Interface ic = new Interface($2.getName(), $1.getOffset());
|
||||||
ic.setParaList($2.getParaVector());
|
ic.setParaList($2.getParaVector());
|
||||||
ic.setSuperInterfaces($3.getVector());
|
ic.setSuperInterfaces($3.getVector());
|
||||||
ic.setInterfaceBody($4);
|
ic.setInterfaceBody($4);
|
||||||
@ -548,7 +548,7 @@ interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
|||||||
}
|
}
|
||||||
| modifiers INTERFACE interfaceidentifier extendsinterfaces interfacebody ;
|
| modifiers INTERFACE interfaceidentifier extendsinterfaces interfacebody ;
|
||||||
{
|
{
|
||||||
Interface ic = new Interface($3.getName(), $1);
|
Interface ic = new Interface($3.getName(), $1, $2.getOffset());
|
||||||
ic.setParaList($3.getParaVector());
|
ic.setParaList($3.getParaVector());
|
||||||
ic.setSuperInterfaces($4.getVector());
|
ic.setSuperInterfaces($4.getVector());
|
||||||
ic.setInterfaceBody($5);
|
ic.setInterfaceBody($5);
|
||||||
|
@ -22,7 +22,7 @@ public class FunNInterface extends Class{
|
|||||||
* @param N - Die Anzahl der Parameter der apply-Methode. Beispiel N = 1 ergibt <code>R apply(T1 par1);</code>
|
* @param N - Die Anzahl der Parameter der apply-Methode. Beispiel N = 1 ergibt <code>R apply(T1 par1);</code>
|
||||||
*/
|
*/
|
||||||
public FunNInterface(int N) {
|
public FunNInterface(int N) {
|
||||||
super("Fun"+N);
|
super("Fun"+N, 0);
|
||||||
Vector<Type> paralist = new Vector<Type>();
|
Vector<Type> paralist = new Vector<Type>();
|
||||||
paralist.add(new GenericTypeVar("R",0));
|
paralist.add(new GenericTypeVar("R",0));
|
||||||
//paralist.add(TypePlaceholder.fresh());
|
//paralist.add(TypePlaceholder.fresh());
|
||||||
|
@ -5,10 +5,8 @@ package typinferenz;
|
|||||||
*/
|
*/
|
||||||
public interface GenericTypeInsertable {
|
public interface GenericTypeInsertable {
|
||||||
|
|
||||||
/**
|
public String getGenericVarDeclarationString(String genericVarDeclaration);
|
||||||
* Gibt den Offset im Quellcode an, an dem neue Deklarationen von generischen Variablen eingesetzt werden können.
|
public int getGenericVarDeclarationOffset();
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getGenericDeclOffset();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,9 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
|
|
||||||
|
|
||||||
public String getTypeInsertString() {
|
public String getTypeInsertString() {
|
||||||
return this.patch.getInsertString(this.resultSet);
|
String genericVar = this.patch.getInsertString(this.resultSet);
|
||||||
|
if(genericVar.length()==0)return "";
|
||||||
|
return this.genericInsertPoint.getGenericVarDeclarationString(genericVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -122,6 +124,18 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
||||||
|
/*
|
||||||
|
int offset = additionalOffset;
|
||||||
|
String insertString = "";
|
||||||
|
if(this.genericParameters != null){
|
||||||
|
offset += this.genericParameters.getOffsetOfLastElement();
|
||||||
|
insertString = ", "+genericVarDecl;
|
||||||
|
}else{
|
||||||
|
offset += this.offset;
|
||||||
|
|
||||||
|
}
|
||||||
|
return sourceCode.substring(0,offset) + insertString + sourceCode.substring(offset);
|
||||||
|
*/
|
||||||
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
||||||
JavaCodeResult ret = new JavaCodeResult(fileContent.substring(0, this.getOffset()+additionalOffset));
|
JavaCodeResult ret = new JavaCodeResult(fileContent.substring(0, this.getOffset()+additionalOffset));
|
||||||
JavaCodeResult mitte = new JavaCodeResult(this.getTypeInsertString()).attach(fileContent.substring(this.getOffset()+additionalOffset));
|
JavaCodeResult mitte = new JavaCodeResult(this.getTypeInsertString()).attach(fileContent.substring(this.getOffset()+additionalOffset));
|
||||||
@ -147,7 +161,7 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
return genericInsertPoint.getGenericDeclOffset();
|
return genericInsertPoint.getGenericVarDeclarationOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +185,11 @@ class GenericVarPatch {
|
|||||||
|
|
||||||
public String getInsertString(ResultSet rs){
|
public String getInsertString(ResultSet rs){
|
||||||
String ret = "";
|
String ret = "";
|
||||||
for(GenericVarDeclarationPatch p : this.genericVarDeclarations){
|
Iterator<GenericVarDeclarationPatch> it = this.genericVarDeclarations.iterator();
|
||||||
ret += p.getInsertString(rs) + ", ";
|
while(it.hasNext()){
|
||||||
|
GenericVarDeclarationPatch p = it.next();
|
||||||
|
ret += p.getInsertString(rs);
|
||||||
|
if(it.hasNext())ret += ", ";
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user