no outer type info
This commit is contained in:
@@ -2609,7 +2609,7 @@ If finally block is present, its last expression is the value of try expression.
|
|||||||
v.getfield(ownerType.getInternalName(), "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
v.getfield(ownerType.getInternalName(), "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v.load(1, TYPE_OBJECT);
|
v.load(((ConstructorFrameMap)myFrameMap).getTypeInfoIndex(), TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeInfo<?> getTypeInfo() {
|
public TypeInfo<?> getTypeInfo() {
|
||||||
return TypeInfo.getTypeInfo(GenericIterator.class, false, null, new TypeInfoProjection[] {(TypeInfoProjection) elementTypeInfo});
|
return TypeInfo.getTypeInfo(GenericIterator.class, false, new TypeInfoProjection[] {(TypeInfoProjection) elementTypeInfo});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -79,14 +79,6 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
return new TypeInfoImpl<T>(klazz, nullable);
|
return new TypeInfoImpl<T>(klazz, nullable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable, TypeInfo outerTypeInfo) {
|
|
||||||
return new TypeInfoImpl<T>(klazz, nullable, outerTypeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable, TypeInfo outerTypeInfo, TypeInfoProjection[] projections) {
|
|
||||||
return new TypeInfoImpl<T>(klazz, nullable, outerTypeInfo, projections);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable, TypeInfoProjection[] projections) {
|
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable, TypeInfoProjection[] projections) {
|
||||||
return new TypeInfoImpl<T>(klazz, nullable, projections);
|
return new TypeInfoImpl<T>(klazz, nullable, projections);
|
||||||
}
|
}
|
||||||
@@ -99,15 +91,13 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
|
|
||||||
public abstract int getProjectionCount();
|
public abstract int getProjectionCount();
|
||||||
|
|
||||||
public abstract TypeInfo getOuterTypeInfo();
|
|
||||||
|
|
||||||
public abstract TypeInfoProjection getProjection(int index);
|
public abstract TypeInfoProjection getProjection(int index);
|
||||||
|
|
||||||
public abstract TypeInfo getArgumentType(Class klass, int index);
|
public abstract TypeInfo getArgumentType(Class klass, int index);
|
||||||
|
|
||||||
protected abstract TypeInfo substitute(List<TypeInfo> myVars);
|
protected abstract TypeInfo substitute(List<TypeInfo> myVars);
|
||||||
|
|
||||||
protected abstract TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] projections);
|
protected abstract TypeInfo substitute(TypeInfoProjection[] projections);
|
||||||
|
|
||||||
private static class TypeInfoVar<T> extends TypeInfo<T> {
|
private static class TypeInfoVar<T> extends TypeInfo<T> {
|
||||||
final int varIndex;
|
final int varIndex;
|
||||||
@@ -151,11 +141,6 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeInfo getOuterTypeInfo() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeInfoProjection getProjection(int index) {
|
public TypeInfoProjection getProjection(int index) {
|
||||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||||
@@ -172,7 +157,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] projections) {
|
protected TypeInfo substitute(TypeInfoProjection[] projections) {
|
||||||
return projections[varIndex].getType();
|
return projections[varIndex].getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,22 +182,12 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
private final Signature signature;
|
private final Signature signature;
|
||||||
private final boolean nullable;
|
private final boolean nullable;
|
||||||
private final TypeInfoProjection[] projections;
|
private final TypeInfoProjection[] projections;
|
||||||
private final TypeInfo outerTypeInfo;
|
|
||||||
|
|
||||||
private TypeInfoImpl(Class<T> theClass, boolean nullable) {
|
private TypeInfoImpl(Class<T> theClass, boolean nullable) {
|
||||||
this(theClass, nullable, null, EMPTY);
|
this(theClass, nullable, EMPTY);
|
||||||
}
|
|
||||||
|
|
||||||
private TypeInfoImpl(Class<T> theClass, boolean nullable, TypeInfo outerTypeInfo) {
|
|
||||||
this(theClass, nullable, outerTypeInfo, EMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeInfoImpl(Class<T> theClass, boolean nullable, TypeInfoProjection[] projections) {
|
private TypeInfoImpl(Class<T> theClass, boolean nullable, TypeInfoProjection[] projections) {
|
||||||
this(theClass, nullable, null, projections);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TypeInfoImpl(Class<T> theClass, boolean nullable, TypeInfo outerTypeInfo, TypeInfoProjection[] projections) {
|
|
||||||
this.outerTypeInfo = outerTypeInfo;
|
|
||||||
this.signature = Parser.parse(theClass);
|
this.signature = Parser.parse(theClass);
|
||||||
this.nullable = nullable;
|
this.nullable = nullable;
|
||||||
this.projections = projections;
|
this.projections = projections;
|
||||||
@@ -252,7 +227,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
if(klass == this.signature.klazz)
|
if(klass == this.signature.klazz)
|
||||||
return projections[index].getType();
|
return projections[index].getType();
|
||||||
else {
|
else {
|
||||||
return getSuperTypeInfo(klass).substitute(outerTypeInfo, projections).getArgumentType(klass, index);
|
return getSuperTypeInfo(klass).substitute(projections).getArgumentType(klass, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,14 +263,14 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] prj) {
|
protected TypeInfo substitute(TypeInfoProjection[] prj) {
|
||||||
if(projections.length == 0)
|
if(projections.length == 0)
|
||||||
return new TypeInfoImpl(signature.klazz, nullable, EMPTY);
|
return new TypeInfoImpl(signature.klazz, nullable, EMPTY);
|
||||||
else {
|
else {
|
||||||
TypeInfoProjection [] proj = new TypeInfoProjection[projections.length];
|
TypeInfoProjection [] proj = new TypeInfoProjection[projections.length];
|
||||||
for(int i = 0; i != proj.length; ++i) {
|
for(int i = 0; i != proj.length; ++i) {
|
||||||
final int finalI = i;
|
final int finalI = i;
|
||||||
final TypeInfo substitute = projections[finalI].getType().substitute(outer, prj);
|
final TypeInfo substitute = projections[finalI].getType().substitute(prj);
|
||||||
proj[i] = new TypeInfoProjection(){
|
proj[i] = new TypeInfoProjection(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -364,11 +339,6 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
return projections.length;
|
return projections.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeInfo getOuterTypeInfo() {
|
|
||||||
return outerTypeInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuilder sb = new StringBuilder().append(signature.klazz.getName());
|
StringBuilder sb = new StringBuilder().append(signature.klazz.getName());
|
||||||
@@ -420,7 +390,6 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Signature {
|
public static class Signature {
|
||||||
final Signature outer;
|
|
||||||
final Class klazz;
|
final Class klazz;
|
||||||
|
|
||||||
List<TypeInfoProjection> variables;
|
List<TypeInfoProjection> variables;
|
||||||
@@ -429,8 +398,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
|
|
||||||
final HashMap<Class,TypeInfo> superSignatures = new HashMap<Class,TypeInfo>();
|
final HashMap<Class,TypeInfo> superSignatures = new HashMap<Class,TypeInfo>();
|
||||||
|
|
||||||
public Signature(Signature outer, Class klazz) {
|
public Signature(Class klazz) {
|
||||||
this.outer = outer;
|
|
||||||
this.klazz = klazz;
|
this.klazz = klazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +480,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
if(value != null) {
|
if(value != null) {
|
||||||
Parser parser = new Parser(value, klass.getClassLoader());
|
Parser parser = new Parser(value, klass.getClassLoader());
|
||||||
Class enclosingClass = klass.getEnclosingClass();
|
Class enclosingClass = klass.getEnclosingClass();
|
||||||
Signature signature = new Signature(parse(enclosingClass), klass);
|
Signature signature = new Signature(klass);
|
||||||
map.put(klass, signature);
|
map.put(klass, signature);
|
||||||
parser.parseVars(signature);
|
parser.parseVars(signature);
|
||||||
parser.parseTypes(signature);
|
parser.parseTypes(signature);
|
||||||
@@ -527,7 +495,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
// todo complete impl
|
// todo complete impl
|
||||||
|
|
||||||
java.lang.reflect.Type genericSuperclass = klass.getGenericSuperclass();
|
java.lang.reflect.Type genericSuperclass = klass.getGenericSuperclass();
|
||||||
Signature signature = new Signature(parse(klass.getEnclosingClass()), klass);
|
Signature signature = new Signature(klass);
|
||||||
|
|
||||||
TypeVariable[] typeParameters = klass.getTypeParameters();
|
TypeVariable[] typeParameters = klass.getTypeParameters();
|
||||||
if(typeParameters == null || typeParameters.length == 0) {
|
if(typeParameters == null || typeParameters.length == 0) {
|
||||||
@@ -692,14 +660,14 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
if(klazz.equals(signature.klazz.getName()))
|
if(klazz.equals(signature.klazz.getName()))
|
||||||
return new TypeInfoVar(signature, nullable, signature.varNames.get(name));
|
return new TypeInfoVar(signature, nullable, signature.varNames.get(name));
|
||||||
else {
|
else {
|
||||||
Signature sig = signature;
|
// Signature sig = signature;
|
||||||
while(!klazz.equals(sig.klazz.getName())) {
|
// while(!klazz.equals(sig.klazz.getName())) {
|
||||||
sig = sig.outer;
|
// sig = sig.outer;
|
||||||
if(sig == null)
|
// if(sig == null)
|
||||||
throw new IllegalStateException();
|
// throw new IllegalStateException();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return new TypeInfoVar(sig, nullable, sig.varNames.get(name));
|
throw new UnsupportedOperationException("outer type info does not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,7 +694,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
|
|
||||||
private static class ArraySignature extends Signature {
|
private static class ArraySignature extends Signature {
|
||||||
public ArraySignature(Class klass) {
|
public ArraySignature(Class klass) {
|
||||||
super(null, klass);
|
super(klass);
|
||||||
variables = new LinkedList<TypeInfoProjection>();
|
variables = new LinkedList<TypeInfoProjection>();
|
||||||
varNames = new HashMap<String, Integer>();
|
varNames = new HashMap<String, Integer>();
|
||||||
varNames.put("T", 0);
|
varNames.put("T", 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user