From 6889a35fb892f314a78bec53b29bc82baff01a14 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Mon, 12 Dec 2011 13:21:47 +0200 Subject: [PATCH] no outer type info --- .../jet/codegen/ExpressionCodegen.java | 2 +- stdlib/src/jet/runtime/ArrayIterator.java | 2 +- stdlib/src/jet/typeinfo/TypeInfo.java | 66 +++++-------------- 3 files changed, 19 insertions(+), 51 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index d0644e6bd5a..9eef892f33e 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -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;"); } else { - v.load(1, TYPE_OBJECT); + v.load(((ConstructorFrameMap)myFrameMap).getTypeInfoIndex(), TYPE_OBJECT); } } else { diff --git a/stdlib/src/jet/runtime/ArrayIterator.java b/stdlib/src/jet/runtime/ArrayIterator.java index 7626820a6b6..0b05941e507 100644 --- a/stdlib/src/jet/runtime/ArrayIterator.java +++ b/stdlib/src/jet/runtime/ArrayIterator.java @@ -37,7 +37,7 @@ public abstract class ArrayIterator implements Iterator, JetObject { @Override 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 diff --git a/stdlib/src/jet/typeinfo/TypeInfo.java b/stdlib/src/jet/typeinfo/TypeInfo.java index 32db06ff044..a5ad5850ebe 100644 --- a/stdlib/src/jet/typeinfo/TypeInfo.java +++ b/stdlib/src/jet/typeinfo/TypeInfo.java @@ -79,14 +79,6 @@ public abstract class TypeInfo implements JetObject { return new TypeInfoImpl(klazz, nullable); } - public static TypeInfo getTypeInfo(Class klazz, boolean nullable, TypeInfo outerTypeInfo) { - return new TypeInfoImpl(klazz, nullable, outerTypeInfo); - } - - public static TypeInfo getTypeInfo(Class klazz, boolean nullable, TypeInfo outerTypeInfo, TypeInfoProjection[] projections) { - return new TypeInfoImpl(klazz, nullable, outerTypeInfo, projections); - } - public static TypeInfo getTypeInfo(Class klazz, boolean nullable, TypeInfoProjection[] projections) { return new TypeInfoImpl(klazz, nullable, projections); } @@ -99,15 +91,13 @@ public abstract class TypeInfo implements JetObject { public abstract int getProjectionCount(); - public abstract TypeInfo getOuterTypeInfo(); - public abstract TypeInfoProjection getProjection(int index); public abstract TypeInfo getArgumentType(Class klass, int index); protected abstract TypeInfo substitute(List myVars); - protected abstract TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] projections); + protected abstract TypeInfo substitute(TypeInfoProjection[] projections); private static class TypeInfoVar extends TypeInfo { final int varIndex; @@ -151,11 +141,6 @@ public abstract class TypeInfo implements JetObject { return 0; } - @Override - public TypeInfo getOuterTypeInfo() { - return null; - } - @Override public TypeInfoProjection getProjection(int index) { throw new UnsupportedOperationException("Abstract TypeInfo"); @@ -172,7 +157,7 @@ public abstract class TypeInfo implements JetObject { } @Override - protected TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] projections) { + protected TypeInfo substitute(TypeInfoProjection[] projections) { return projections[varIndex].getType(); } @@ -197,22 +182,12 @@ public abstract class TypeInfo implements JetObject { private final Signature signature; private final boolean nullable; private final TypeInfoProjection[] projections; - private final TypeInfo outerTypeInfo; private TypeInfoImpl(Class theClass, boolean nullable) { - this(theClass, nullable, null, EMPTY); - } - - private TypeInfoImpl(Class theClass, boolean nullable, TypeInfo outerTypeInfo) { - this(theClass, nullable, outerTypeInfo, EMPTY); + this(theClass, nullable, EMPTY); } private TypeInfoImpl(Class theClass, boolean nullable, TypeInfoProjection[] projections) { - this(theClass, nullable, null, projections); - } - - private TypeInfoImpl(Class theClass, boolean nullable, TypeInfo outerTypeInfo, TypeInfoProjection[] projections) { - this.outerTypeInfo = outerTypeInfo; this.signature = Parser.parse(theClass); this.nullable = nullable; this.projections = projections; @@ -252,7 +227,7 @@ public abstract class TypeInfo implements JetObject { if(klass == this.signature.klazz) return projections[index].getType(); 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 implements JetObject { } @Override - protected TypeInfo substitute(TypeInfo outer, TypeInfoProjection[] prj) { + protected TypeInfo substitute(TypeInfoProjection[] prj) { if(projections.length == 0) return new TypeInfoImpl(signature.klazz, nullable, EMPTY); else { TypeInfoProjection [] proj = new TypeInfoProjection[projections.length]; for(int i = 0; i != proj.length; ++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(){ @Override @@ -364,11 +339,6 @@ public abstract class TypeInfo implements JetObject { return projections.length; } - @Override - public TypeInfo getOuterTypeInfo() { - return outerTypeInfo; - } - @Override public final String toString() { StringBuilder sb = new StringBuilder().append(signature.klazz.getName()); @@ -420,7 +390,6 @@ public abstract class TypeInfo implements JetObject { } public static class Signature { - final Signature outer; final Class klazz; List variables; @@ -429,8 +398,7 @@ public abstract class TypeInfo implements JetObject { final HashMap superSignatures = new HashMap(); - public Signature(Signature outer, Class klazz) { - this.outer = outer; + public Signature(Class klazz) { this.klazz = klazz; } @@ -512,7 +480,7 @@ public abstract class TypeInfo implements JetObject { if(value != null) { Parser parser = new Parser(value, klass.getClassLoader()); Class enclosingClass = klass.getEnclosingClass(); - Signature signature = new Signature(parse(enclosingClass), klass); + Signature signature = new Signature(klass); map.put(klass, signature); parser.parseVars(signature); parser.parseTypes(signature); @@ -527,7 +495,7 @@ public abstract class TypeInfo implements JetObject { // todo complete impl java.lang.reflect.Type genericSuperclass = klass.getGenericSuperclass(); - Signature signature = new Signature(parse(klass.getEnclosingClass()), klass); + Signature signature = new Signature(klass); TypeVariable[] typeParameters = klass.getTypeParameters(); if(typeParameters == null || typeParameters.length == 0) { @@ -692,14 +660,14 @@ public abstract class TypeInfo implements JetObject { if(klazz.equals(signature.klazz.getName())) return new TypeInfoVar(signature, nullable, signature.varNames.get(name)); else { - Signature sig = signature; - while(!klazz.equals(sig.klazz.getName())) { - sig = sig.outer; - if(sig == null) - throw new IllegalStateException(); - } +// Signature sig = signature; +// while(!klazz.equals(sig.klazz.getName())) { +// sig = sig.outer; +// if(sig == null) +// 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 implements JetObject { private static class ArraySignature extends Signature { public ArraySignature(Class klass) { - super(null, klass); + super(klass); variables = new LinkedList(); varNames = new HashMap(); varNames.put("T", 0);