modified: ../../../main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java
Typen mit Argumenten korrgiert
This commit is contained in:
parent
411629279d
commit
850fe39426
@ -3,16 +3,18 @@ package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
|||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||||
|
import de.dhbwstuttgart.parser.antlr.Java8Parser.UnannClassType_lfno_unannClassOrInterfaceTypeContext;
|
||||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
||||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
@ -24,12 +26,14 @@ import java.util.regex.Pattern;
|
|||||||
public class TypeGenerator {
|
public class TypeGenerator {
|
||||||
|
|
||||||
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
||||||
Java8Parser.TypeArgumentsContext arguments;
|
Java8Parser.TypeArgumentsContext arguments=null;
|
||||||
|
/* PL 2019-03-19 auskommentiert ANFANG
|
||||||
if(unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType() != null){
|
if(unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType() != null){
|
||||||
arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||||
}else{// if(unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType() != null){
|
}else{// if(unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType() != null){
|
||||||
arguments = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
arguments = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||||
}
|
}
|
||||||
|
PL 2019-03-19 auskommentiert ENDE */
|
||||||
/**
|
/**
|
||||||
* Problem sind hier die verschachtelten Typen mit verschachtelten Typargumenten
|
* Problem sind hier die verschachtelten Typen mit verschachtelten Typargumenten
|
||||||
* Beispiel: Typ<String>.InnererTyp<Integer>
|
* Beispiel: Typ<String>.InnererTyp<Integer>
|
||||||
@ -37,6 +41,28 @@ public class TypeGenerator {
|
|||||||
String name = unannClassOrInterfaceTypeContext.getText();
|
String name = unannClassOrInterfaceTypeContext.getText();
|
||||||
if(name.contains("<")){
|
if(name.contains("<")){
|
||||||
name = name.split("<")[0]; //Der Typ ist alles vor den ersten Argumenten
|
name = name.split("<")[0]; //Der Typ ist alles vor den ersten Argumenten
|
||||||
|
/* Fuer Debug-Zwecke
|
||||||
|
unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType();
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().getText();
|
||||||
|
//unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||||
|
//UnannClassType_lfno_unannClassOrInterfaceTypeContext
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(0);
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(0).getText();
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(1);
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(1).getText();
|
||||||
|
unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().getText();
|
||||||
|
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType();
|
||||||
|
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType(0).getText();
|
||||||
|
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType(1).getText();
|
||||||
|
//unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().getText();
|
||||||
|
*/
|
||||||
|
int lastElement = new ArrayList<>(unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType()).size()-1;
|
||||||
|
if (lastElement >=0) {//qualifizierter Name z.B.: java.util.Vector
|
||||||
|
arguments = unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(lastElement).typeArguments();
|
||||||
|
}
|
||||||
|
else { //unqualifizierter Name z.B.: Vector
|
||||||
|
arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convertTypeName(name, arguments, unannClassOrInterfaceTypeContext.getStart(), reg, generics);
|
return convertTypeName(name, arguments, unannClassOrInterfaceTypeContext.getStart(), reg, generics);
|
||||||
}
|
}
|
||||||
@ -135,6 +161,18 @@ public class TypeGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.WildcardContext wildcardContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
||||||
|
if(wildcardContext.wildcardBounds() != null){
|
||||||
|
if(wildcardContext.wildcardBounds().getText().substring(0, 7).equals("extends")){
|
||||||
|
return new ExtendsWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart());
|
||||||
|
}else{
|
||||||
|
return new SuperWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException(); //Wildcard ohne Bound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static RefTypeOrTPHOrWildcardOrGeneric convertTypeName(String name, Token offset, JavaClassRegistry reg, GenericsRegistry generics){
|
public static RefTypeOrTPHOrWildcardOrGeneric convertTypeName(String name, Token offset, JavaClassRegistry reg, GenericsRegistry generics){
|
||||||
return convertTypeName(name, null, offset, reg, generics);
|
return convertTypeName(name, null, offset, reg, generics);
|
||||||
}
|
}
|
||||||
@ -169,7 +207,7 @@ public class TypeGenerator {
|
|||||||
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
||||||
for(Java8Parser.TypeArgumentContext arg : typeArguments.typeArgumentList().typeArgument()){
|
for(Java8Parser.TypeArgumentContext arg : typeArguments.typeArgumentList().typeArgument()){
|
||||||
if(arg.wildcard() != null){
|
if(arg.wildcard() != null){
|
||||||
throw new NotImplementedException();
|
ret.add(convert(arg.wildcard(), reg, generics));
|
||||||
}else{
|
}else{
|
||||||
ret.add(convert(arg.referenceType(), reg, generics));
|
ret.add(convert(arg.referenceType(), reg, generics));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class Matrix extends Vector<Vector<Integer>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mul(m) {
|
mul(java.util.Vector<? extends Vector<? extends java.lang.Integer>> m) {
|
||||||
var ret = new Matrix();
|
var ret = new Matrix();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while(i < size()) {
|
while(i < size()) {
|
||||||
|
@ -18,7 +18,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mul = (m1, m2) -> {
|
Fun2$$<java.util.Vector<? extends java.util.Vector<? extends java.lang.Integer>>, java.util.Vector<? extends java.util.Vector<? extends java.lang.Integer>>, MatrixOP> mul = (m1, m2) -> {
|
||||||
var ret = new MatrixOP();
|
var ret = new MatrixOP();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while(i < m1.size()) {
|
while(i < m1.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user