getting rid of TypeInfo
This commit is contained in:
@@ -3,12 +3,9 @@ package std
|
||||
import java.lang.Class
|
||||
import java.lang.Object
|
||||
|
||||
val <erased T> T.javaClass : Class<T>
|
||||
get() = jet.runtime.Intrinsics.getJavaClass(this) as Class<T>
|
||||
import jet.runtime.intrinsic
|
||||
|
||||
fun <T> javaClass() : Class<T> = (typeinfo<T>() as org.jetbrains.jet.rt.TypeInfoImpl<T>).getJavaClass().sure()
|
||||
val <T> T.javaClass : Class<T>
|
||||
[intrinsic("std.javaClass.property")] get() = (this as java.lang.Object).getClass() as Class<T>
|
||||
|
||||
val <erased T> TypeInfo<T>.javaClassForType : Class<T>
|
||||
get() {
|
||||
return (this as org.jetbrains.jet.rt.TypeInfoImpl<T>).getJavaClass().sure()
|
||||
}
|
||||
[intrinsic("std.javaClass.function")] fun <T> javaClass() : Class<T> = null as Class<T>
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class BooleanIterator implements Iterator<Boolean> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(BooleanIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Boolean next() {
|
||||
return nextBoolean();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class ByteIterator implements Iterator<Byte> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ByteIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Byte next() {
|
||||
return nextByte();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(ByteRange.class, false);
|
||||
|
||||
private final byte start;
|
||||
private final int count;
|
||||
|
||||
@@ -74,11 +72,6 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
|
||||
return new MyIterator(start, count, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -89,8 +82,6 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
|
||||
}
|
||||
|
||||
private static class MyIterator extends ByteIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private byte cur;
|
||||
private int step;
|
||||
private int count;
|
||||
@@ -129,11 +120,6 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class CharIterator implements Iterator<Character> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(CharIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Character next() {
|
||||
return nextChar();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class CharRange implements Range<Character>, CharIterable, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(CharRange.class, false);
|
||||
|
||||
private final char start;
|
||||
private final int count;
|
||||
|
||||
@@ -74,11 +72,6 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
|
||||
return new MyIterator(start, count, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -89,8 +82,6 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
|
||||
}
|
||||
|
||||
private static class MyIterator extends CharIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private char cur;
|
||||
private int step;
|
||||
private int count;
|
||||
@@ -129,11 +120,6 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,24 +20,9 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class DefaultJetObject implements JetObject {
|
||||
private TypeInfo<?> typeInfo;
|
||||
|
||||
protected DefaultJetObject() {
|
||||
}
|
||||
|
||||
protected DefaultJetObject(TypeInfo<?> typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
protected final void $setTypeInfo(TypeInfo typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class DoubleIterator implements Iterator<Double> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(DoubleIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Double next() {
|
||||
return nextDouble();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class DoubleRange implements Range<Double>, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(DoubleRange.class, false);
|
||||
|
||||
private final double start;
|
||||
private final double size;
|
||||
|
||||
@@ -63,11 +61,6 @@ public final class DoubleRange implements Range<Double>, JetObject {
|
||||
return new DoubleRange(getEnd(), -size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -78,8 +71,6 @@ public final class DoubleRange implements Range<Double>, JetObject {
|
||||
}
|
||||
|
||||
private static class MyIterator extends DoubleIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private double cur;
|
||||
private double step;
|
||||
private final double end;
|
||||
@@ -120,11 +111,6 @@ public final class DoubleRange implements Range<Double>, JetObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction0<E, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction0(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction1<E, D1, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction1(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction10<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction10(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction10() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction11<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction11(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction11() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction12<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction12(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction12() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction13<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction13(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction13() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction14<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction14(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction14() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction15<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction15(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction15() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction16<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction16(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction16() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction17<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction17(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction17() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction18<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction18(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction18() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction19<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction19(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction19() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction2<E, D1, D2, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction2(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction20<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction20(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction20() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction21<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction21(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction21() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction22<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction22(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction22() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21, D22 d22);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction3<E, D1, D2, D3, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction3(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction4<E, D1, D2, D3, D4, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction4(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction4() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction5<E, D1, D2, D3, D4, D5, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction5(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction5() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction6<E, D1, D2, D3, D4, D5, D6, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction6(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction6() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction7<E, D1, D2, D3, D4, D5, D6, D7, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction7(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction7() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction8<E, D1, D2, D3, D4, D5, D6, D7, D8, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction8(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction8() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package jet;
|
||||
|
||||
public abstract class ExtensionFunction9<E, D1, D2, D3, D4, D5, D6, D7, D8, D9, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction9(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
protected ExtensionFunction9() {
|
||||
super();
|
||||
}
|
||||
|
||||
public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9);
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class FloatIterator implements Iterator<Float> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(FloatIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Float next() {
|
||||
return nextFloat();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class FloatRange implements Range<Float>, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(FloatRange.class, false);
|
||||
|
||||
private final float start;
|
||||
private final float size;
|
||||
|
||||
@@ -63,10 +61,6 @@ public final class FloatRange implements Range<Float>, JetObject {
|
||||
return new FloatRange(getEnd(), -size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
@@ -78,8 +72,6 @@ public final class FloatRange implements Range<Float>, JetObject {
|
||||
}
|
||||
|
||||
private static class MyIterator extends FloatIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private float cur;
|
||||
private float step;
|
||||
private final float end;
|
||||
@@ -120,11 +112,6 @@ public final class FloatRange implements Range<Float>, JetObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function0<R> extends DefaultJetObject {
|
||||
protected Function0(TypeInfo typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function1<D1, R> extends DefaultJetObject {
|
||||
protected Function1(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function10<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, R> extends DefaultJetObject {
|
||||
protected Function10(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function11<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, R> extends DefaultJetObject {
|
||||
protected Function11(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function12<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, R> extends DefaultJetObject {
|
||||
protected Function12(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function13<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, R> extends DefaultJetObject {
|
||||
protected Function13(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function14<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, R> extends DefaultJetObject {
|
||||
protected Function14(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function15<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, R> extends DefaultJetObject {
|
||||
protected Function15(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function16<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, R> extends DefaultJetObject {
|
||||
protected Function16(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function17<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, R> extends DefaultJetObject {
|
||||
protected Function17(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function18<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, R> extends DefaultJetObject {
|
||||
protected Function18(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function19<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, R> extends DefaultJetObject {
|
||||
protected Function19(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function2<D1, D2, R> extends DefaultJetObject {
|
||||
protected Function2(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function20<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, R> extends DefaultJetObject {
|
||||
protected Function20(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function21<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, R> extends DefaultJetObject {
|
||||
protected Function21(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function22<D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, R> extends DefaultJetObject {
|
||||
protected Function22(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21, D22 d22);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function3<D1, D2, D3, R> extends DefaultJetObject {
|
||||
protected Function3(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function4<D1, D2, D3, D4, R> extends DefaultJetObject {
|
||||
protected Function4(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function5<D1, D2, D3, D4, D5, R> extends DefaultJetObject {
|
||||
protected Function5(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function6<D1, D2, D3, D4, D5, D6, R> extends DefaultJetObject {
|
||||
protected Function6(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6);
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function7<D1, D2, D3, D4, D5, D6, D7, R> extends DefaultJetObject {
|
||||
protected Function7(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function8<D1, D2, D3, D4, D5, D6, D7, D8, R> extends DefaultJetObject {
|
||||
protected Function8(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
package jet;
|
||||
|
||||
public abstract class Function9<D1, D2, D3, D4, D5, D6, D7, D8, D9, R> extends DefaultJetObject {
|
||||
protected Function9(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class IntIterator implements Iterator<Integer> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(IntIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Integer next() {
|
||||
return nextInt();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class IntRange implements Range<Integer>, IntIterable, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(IntRange.class, false);
|
||||
|
||||
private final int start;
|
||||
private final int count;
|
||||
|
||||
@@ -74,11 +72,6 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
|
||||
return new MyIterator(start, count, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -89,8 +82,6 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
|
||||
}
|
||||
|
||||
private static class MyIterator extends IntIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private int cur;
|
||||
private int step;
|
||||
private int count;
|
||||
@@ -129,11 +120,6 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -21,6 +21,5 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public interface JetObject {
|
||||
TypeInfo<?> getTypeInfo();
|
||||
JetObject getOuterObject();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class LongIterator implements Iterator<Long> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(LongIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Long next() {
|
||||
return nextLong();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class LongRange implements Range<Long>, LongIterable, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(IntRange.class, false);
|
||||
|
||||
private final long start;
|
||||
private final long count;
|
||||
|
||||
@@ -74,11 +72,6 @@ public final class LongRange implements Range<Long>, LongIterable, JetObject {
|
||||
return new MyIterator(start, count, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -89,8 +82,6 @@ public final class LongRange implements Range<Long>, LongIterable, JetObject {
|
||||
}
|
||||
|
||||
private static class MyIterator extends LongIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private long cur;
|
||||
private long step;
|
||||
private long count;
|
||||
@@ -129,11 +120,6 @@ public final class LongRange implements Range<Long>, LongIterable, JetObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -20,12 +20,6 @@ package jet;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class ShortIterator implements Iterator<Short> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ShortIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Short next() {
|
||||
return nextShort();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package jet;
|
||||
|
||||
public final class ShortRange implements Range<Short>, ShortIterable, JetObject {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(ShortRange.class, false);
|
||||
|
||||
private final short start;
|
||||
private final int count;
|
||||
|
||||
@@ -74,11 +72,6 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
|
||||
return new MyIterator(start, count, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -89,8 +82,6 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
|
||||
}
|
||||
|
||||
private static class MyIterator extends ShortIterator {
|
||||
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
|
||||
|
||||
private short cur;
|
||||
private int step;
|
||||
private int count;
|
||||
@@ -129,11 +120,6 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -21,7 +21,6 @@ package jet;
|
||||
*/
|
||||
public class Tuple0 implements JetObject {
|
||||
public static final Tuple0 INSTANCE = new Tuple0();
|
||||
private static final TypeInfo<?> typeInfo = TypeInfo.getTypeInfo(Tuple0.class, false);
|
||||
|
||||
private Tuple0() {
|
||||
}
|
||||
@@ -41,11 +40,6 @@ public class Tuple0 implements JetObject {
|
||||
return 239;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -19,8 +19,7 @@ package jet;
|
||||
public class Tuple1<T1> extends DefaultJetObject {
|
||||
public final T1 _1;
|
||||
|
||||
public Tuple1(TypeInfo typeInfo, T1 t1) {
|
||||
super(typeInfo);
|
||||
public Tuple1(T1 t1) {
|
||||
_1 = t1;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,7 @@ public class Tuple10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends DefaultJet
|
||||
public final T9 _9;
|
||||
public final T10 _10;
|
||||
|
||||
public Tuple10(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) {
|
||||
super(typeInfo);
|
||||
public Tuple10(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -29,8 +29,7 @@ public class Tuple11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> extends Defau
|
||||
public final T10 _10;
|
||||
public final T11 _11;
|
||||
|
||||
public Tuple11(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) {
|
||||
super(typeInfo);
|
||||
public Tuple11(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -30,8 +30,7 @@ public class Tuple12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> extends
|
||||
public final T11 _11;
|
||||
public final T12 _12;
|
||||
|
||||
public Tuple12(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) {
|
||||
super(typeInfo);
|
||||
public Tuple12(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -31,8 +31,7 @@ public class Tuple13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> ext
|
||||
public final T12 _12;
|
||||
public final T13 _13;
|
||||
|
||||
public Tuple13(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) {
|
||||
super(typeInfo);
|
||||
public Tuple13(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -32,8 +32,7 @@ public class Tuple14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T13 _13;
|
||||
public final T14 _14;
|
||||
|
||||
public Tuple14(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14) {
|
||||
super(typeInfo);
|
||||
public Tuple14(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -33,8 +33,7 @@ public class Tuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T14 _14;
|
||||
public final T15 _15;
|
||||
|
||||
public Tuple15(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15) {
|
||||
super(typeInfo);
|
||||
public Tuple15(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -34,8 +34,7 @@ public class Tuple16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T15 _15;
|
||||
public final T16 _16;
|
||||
|
||||
public Tuple16(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16) {
|
||||
super(typeInfo);
|
||||
public Tuple16(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -35,8 +35,7 @@ public class Tuple17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T16 _16;
|
||||
public final T17 _17;
|
||||
|
||||
public Tuple17(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17) {
|
||||
super(typeInfo);
|
||||
public Tuple17(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -36,8 +36,7 @@ public class Tuple18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T17 _17;
|
||||
public final T18 _18;
|
||||
|
||||
public Tuple18(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18) {
|
||||
super(typeInfo);
|
||||
public Tuple18(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -37,8 +37,7 @@ public class Tuple19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T18 _18;
|
||||
public final T19 _19;
|
||||
|
||||
public Tuple19(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19) {
|
||||
super(typeInfo);
|
||||
public Tuple19(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -20,8 +20,7 @@ public class Tuple2<T1, T2> extends DefaultJetObject {
|
||||
public final T1 _1;
|
||||
public final T2 _2;
|
||||
|
||||
public Tuple2(TypeInfo typeInfo, T1 t1, T2 t2) {
|
||||
super(typeInfo);
|
||||
public Tuple2(T1 t1, T2 t2) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ public class Tuple20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T19 _19;
|
||||
public final T20 _20;
|
||||
|
||||
public Tuple20(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20) {
|
||||
super(typeInfo);
|
||||
public Tuple20(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -39,8 +39,7 @@ public class Tuple21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T20 _20;
|
||||
public final T21 _21;
|
||||
|
||||
public Tuple21(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21) {
|
||||
super(typeInfo);
|
||||
public Tuple21(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -40,8 +40,7 @@ public class Tuple22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
|
||||
public final T21 _21;
|
||||
public final T22 _22;
|
||||
|
||||
public Tuple22(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21, T22 t22) {
|
||||
super(typeInfo);
|
||||
public Tuple22(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21, T22 t22) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -21,8 +21,7 @@ public class Tuple3<T1, T2, T3> extends DefaultJetObject {
|
||||
public final T2 _2;
|
||||
public final T3 _3;
|
||||
|
||||
public Tuple3(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3) {
|
||||
super(typeInfo);
|
||||
public Tuple3(T1 t1, T2 t2, T3 t3) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -22,8 +22,7 @@ public class Tuple4<T1, T2, T3, T4> extends DefaultJetObject {
|
||||
public final T3 _3;
|
||||
public final T4 _4;
|
||||
|
||||
public Tuple4(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4) {
|
||||
super(typeInfo);
|
||||
public Tuple4(T1 t1, T2 t2, T3 t3, T4 t4) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -23,8 +23,7 @@ public class Tuple5<T1, T2, T3, T4, T5> extends DefaultJetObject {
|
||||
public final T4 _4;
|
||||
public final T5 _5;
|
||||
|
||||
public Tuple5(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
|
||||
super(typeInfo);
|
||||
public Tuple5(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -24,8 +24,7 @@ public class Tuple6<T1, T2, T3, T4, T5, T6> extends DefaultJetObject {
|
||||
public final T5 _5;
|
||||
public final T6 _6;
|
||||
|
||||
public Tuple6(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
|
||||
super(typeInfo);
|
||||
public Tuple6(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -25,8 +25,7 @@ public class Tuple7<T1, T2, T3, T4, T5, T6, T7> extends DefaultJetObject {
|
||||
public final T6 _6;
|
||||
public final T7 _7;
|
||||
|
||||
public Tuple7(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) {
|
||||
super(typeInfo);
|
||||
public Tuple7(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -26,8 +26,7 @@ public class Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> extends DefaultJetObject {
|
||||
public final T7 _7;
|
||||
public final T8 _8;
|
||||
|
||||
public Tuple8(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) {
|
||||
super(typeInfo);
|
||||
public Tuple8(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -27,8 +27,7 @@ public class Tuple9<T1, T2, T3, T4, T5, T6, T7, T8, T9> extends DefaultJetObject
|
||||
public final T8 _8;
|
||||
public final T9 _9;
|
||||
|
||||
public Tuple9(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) {
|
||||
super(typeInfo);
|
||||
public Tuple9(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) {
|
||||
_1 = t1;
|
||||
_2 = t2;
|
||||
_3 = t3;
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
import org.jetbrains.jet.rt.TypeInfoImpl;
|
||||
import org.jetbrains.jet.rt.TypeInfoProjectionImpl;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class TypeInfo<T> implements JetObject {
|
||||
|
||||
public static final TypeInfo<Object> ANY_TYPE_INFO = getTypeInfo(Object.class, false);
|
||||
public static final TypeInfo<Byte> BYTE_TYPE_INFO = getTypeInfo(Byte.class, false);
|
||||
public static final TypeInfo<Short> SHORT_TYPE_INFO = getTypeInfo(Short.class, false);
|
||||
public static final TypeInfo<Integer> INT_TYPE_INFO = getTypeInfo(Integer.class, false);
|
||||
public static final TypeInfo<Long> LONG_TYPE_INFO = getTypeInfo(Long.class, false);
|
||||
public static final TypeInfo<Character> CHAR_TYPE_INFO = getTypeInfo(Character.class, false);
|
||||
public static final TypeInfo<Boolean> BOOLEAN_TYPE_INFO = getTypeInfo(Boolean.class, false);
|
||||
public static final TypeInfo<Float> FLOAT_TYPE_INFO = getTypeInfo(Float.class, false);
|
||||
public static final TypeInfo<Double> DOUBLE_TYPE_INFO = getTypeInfo(Double.class, false);
|
||||
|
||||
public static final TypeInfo<byte[]> BYTE_ARRAY_TYPE_INFO = getTypeInfo(byte[].class, false);
|
||||
public static final TypeInfo<short[]> SHORT_ARRAY_TYPE_INFO = getTypeInfo(short[].class, false);
|
||||
public static final TypeInfo<int[]> INT_ARRAY_TYPE_INFO = getTypeInfo(int[].class, false);
|
||||
public static final TypeInfo<long[]> LONG_ARRAY_TYPE_INFO = getTypeInfo(long[].class, false);
|
||||
public static final TypeInfo<char[]> CHAR_ARRAY_TYPE_INFO = getTypeInfo(char[].class, false);
|
||||
public static final TypeInfo<boolean[]> BOOL_ARRAY_TYPE_INFO = getTypeInfo(boolean[].class, false);
|
||||
public static final TypeInfo<float[]> FLOAT_ARRAY_TYPE_INFO = getTypeInfo(float[].class, false);
|
||||
public static final TypeInfo<double[]> DOUBLE_ARRAY_TYPE_INFO = getTypeInfo(double[].class, false);
|
||||
|
||||
public static final TypeInfo<String> STRING_TYPE_INFO = getTypeInfo(String.class, false);
|
||||
public static final TypeInfo<Tuple0> TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, false);
|
||||
|
||||
public static final TypeInfo<Object> NULLABLE_ANY_TYPE_INFO = getTypeInfo(Object.class, true);
|
||||
public static final TypeInfo<Byte> NULLABLE_BYTE_TYPE_INFO = getTypeInfo(Byte.class, true);
|
||||
public static final TypeInfo<Short> NULLABLE_SHORT_TYPE_INFO = getTypeInfo(Short.class, true);
|
||||
public static final TypeInfo<Integer> NULLABLE_INT_TYPE_INFO = getTypeInfo(Integer.class, true);
|
||||
public static final TypeInfo<Long> NULLABLE_LONG_TYPE_INFO = getTypeInfo(Long.class, true);
|
||||
public static final TypeInfo<Character> NULLABLE_CHAR_TYPE_INFO = getTypeInfo(Character.class, true);
|
||||
public static final TypeInfo<Boolean> NULLABLE_BOOL_TYPE_INFO = getTypeInfo(Boolean.class, true);
|
||||
public static final TypeInfo<Float> NULLABLE_FLOAT_TYPE_INFO = getTypeInfo(Float.class, true);
|
||||
public static final TypeInfo<Double> NULLABLE_DOUBLE_TYPE_INFO = getTypeInfo(Double.class, true);
|
||||
public static final TypeInfo<String> NULLABLE_STRING_TYPE_INFO = getTypeInfo(String.class, true);
|
||||
public static final TypeInfo<Tuple0> NULLABLE_TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, true);
|
||||
|
||||
public abstract Object [] newArray(int length);
|
||||
|
||||
public static <T> TypeInfoProjection invariantProjection(final TypeInfo<T> typeInfo) {
|
||||
return (TypeInfoProjection) typeInfo;
|
||||
}
|
||||
|
||||
public static <T> TypeInfoProjection inProjection(TypeInfo<T> typeInfo) {
|
||||
return new TypeInfoProjectionImpl(typeInfo) {
|
||||
// @NotNull
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return TypeInfoVariance.IN;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T> TypeInfoProjection outProjection(TypeInfo<T> typeInfo) {
|
||||
return new TypeInfoProjectionImpl(typeInfo) {
|
||||
// @NotNull
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return TypeInfoVariance.OUT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static <T> TypeInfoProjection projection(TypeInfo<T> typeInfo, TypeInfoVariance variance) {
|
||||
switch (variance) {
|
||||
case IN: return inProjection(typeInfo);
|
||||
case OUT: return outProjection(typeInfo);
|
||||
case INVARIANT: return invariantProjection(typeInfo);
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable) {
|
||||
return new TypeInfoImpl<T>(klazz, nullable);
|
||||
}
|
||||
|
||||
public static <T> TypeInfo<T> getTypeInfo(Class<T> klazz, boolean nullable, TypeInfoProjection[] projections) {
|
||||
return new TypeInfoImpl<T>(klazz, nullable, projections);
|
||||
}
|
||||
|
||||
public abstract Class<T> getJavaClass();
|
||||
|
||||
public abstract Object getClassObject();
|
||||
|
||||
public abstract boolean isInstance(Object obj);
|
||||
|
||||
public abstract int getProjectionCount();
|
||||
|
||||
public abstract TypeInfoProjection getProjection(int index);
|
||||
|
||||
public abstract TypeInfo getArgumentType(Class klass, int index);
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package jet.runtime;
|
||||
|
||||
import jet.*;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
@@ -37,12 +36,10 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class GenericIterator<T> extends ArrayIterator<T> {
|
||||
private final T[] array;
|
||||
private final TypeInfo elementTypeInfo;
|
||||
|
||||
private GenericIterator(T[] array, TypeInfo elementTypeInfo) {
|
||||
private GenericIterator(T[] array) {
|
||||
super(array.length);
|
||||
this.array = array;
|
||||
this.elementTypeInfo = elementTypeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,24 +47,17 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return TypeInfo.getTypeInfo(GenericIterator.class, false, new TypeInfoProjection[] {(TypeInfoProjection) elementTypeInfo});
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Iterator<T> iterator(T[] array, TypeInfo elementTypeInfo) {
|
||||
return new GenericIterator<T>(array, elementTypeInfo);
|
||||
public static <T> Iterator<T> iterator(T[] array) {
|
||||
return new GenericIterator<T>(array);
|
||||
}
|
||||
|
||||
private static class ArrayByteIterator extends ByteIterator {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayByteIterator.class, false);
|
||||
|
||||
private final byte[] array;
|
||||
private int index;
|
||||
|
||||
@@ -85,11 +75,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -102,7 +87,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayShortIterator extends ShortIterator {
|
||||
private final short[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayShortIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -120,11 +104,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -137,7 +116,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayIntegerIterator extends IntIterator {
|
||||
private final int[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayIntegerIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -155,11 +133,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -172,7 +145,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayLongIterator extends LongIterator {
|
||||
private final long[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayLongIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -190,11 +162,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -207,7 +174,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayFloatIterator extends FloatIterator {
|
||||
private final float[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayFloatIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -225,11 +191,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -242,7 +203,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayDoubleIterator extends DoubleIterator {
|
||||
private final double[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayDoubleIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -260,11 +220,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -277,7 +232,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayCharacterIterator extends CharIterator {
|
||||
private final char[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayCharacterIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -295,11 +249,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
@@ -312,7 +261,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
|
||||
private static class ArrayBooleanIterator extends BooleanIterator {
|
||||
private final boolean[] array;
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayBooleanIterator.class, false);
|
||||
|
||||
private int index;
|
||||
|
||||
@@ -330,11 +278,6 @@ public abstract class ArrayIterator<T> implements Iterator<T>, JetObject {
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package jet.runtime.typeinfo;
|
||||
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
@@ -29,7 +28,6 @@ public @interface JetTypeDescriptor{
|
||||
//
|
||||
String varName() default "";
|
||||
boolean reified () default true;
|
||||
TypeInfoVariance variance() default TypeInfoVariance.INVARIANT;
|
||||
int [] upperBounds() default {};
|
||||
|
||||
//
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package jet.runtime.typeinfo;
|
||||
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -28,10 +26,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface JetTypeProjection {
|
||||
/**
|
||||
* @return variance of the type
|
||||
*/
|
||||
TypeInfoVariance variance();
|
||||
|
||||
/**
|
||||
* @return index of the class in the per class table of JetTypeDescriptor
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jet.typeinfo;
|
||||
|
||||
import jet.TypeInfo;
|
||||
|
||||
/**
|
||||
* This class represents how type info of super class should be matched against type parameters of subclass.
|
||||
*
|
||||
* For each subclass we create such pattern for subclass itself and all it super classes either during
|
||||
* static initialization(or maybe when needed).
|
||||
*
|
||||
* For each instance of parametrized type we keep it type info, which can be understood as binding of type parameter variables.
|
||||
*
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public interface TypeInfoPattern {
|
||||
TypeInfo substitute(TypeInfo[] variables);
|
||||
|
||||
class Var implements TypeInfoPattern {
|
||||
public final int index;
|
||||
|
||||
public Var(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo substitute(TypeInfo[] variables) {
|
||||
return variables[index];
|
||||
}
|
||||
}
|
||||
|
||||
class Const implements TypeInfoPattern {
|
||||
private final TypeInfo typeInfo;
|
||||
|
||||
public Const(TypeInfo typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo substitute(TypeInfo[] variables) {
|
||||
return typeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
class Pattern implements TypeInfoPattern {
|
||||
public static final TypeInfoPatternProjection[] EMPTY = new TypeInfoPatternProjection[0];
|
||||
public final Class klazz;
|
||||
public final boolean nullable;
|
||||
public final TypeInfoPatternProjection [] patterns;
|
||||
|
||||
public Pattern(Class klazz, boolean nullable, TypeInfoPatternProjection[] patterns) {
|
||||
this.klazz = klazz;
|
||||
this.nullable = nullable;
|
||||
this.patterns = patterns;
|
||||
}
|
||||
|
||||
public Pattern(Class klazz, boolean nullable) {
|
||||
this.klazz = klazz;
|
||||
this.nullable = nullable;
|
||||
this.patterns = EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo substitute(TypeInfo[] variables) {
|
||||
return TypeInfo.getTypeInfo(klazz, nullable, TypeInfoPatternProjection.substitute(patterns, variables));
|
||||
}
|
||||
}
|
||||
|
||||
class TypeInfoPatternProjection {
|
||||
public final TypeInfoVariance variance;
|
||||
|
||||
public final TypeInfoPattern pattern;
|
||||
|
||||
public TypeInfoPatternProjection(TypeInfoVariance variance, TypeInfoPattern pattern) {
|
||||
this.variance = variance;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public TypeInfoProjection substitute(final TypeInfo[] variables) {
|
||||
return new TypeInfoProjection() {
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return variance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return pattern.substitute(variables);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeInfoProjection[] substitute(TypeInfoPatternProjection[] patterns, TypeInfo[] variables) {
|
||||
if(patterns.length == 0)
|
||||
return TypeInfoProjection.EMPTY_ARRAY;
|
||||
TypeInfoProjection [] projections = new TypeInfoProjection[patterns.length];
|
||||
for (int i = 0; i < projections.length; i++) {
|
||||
projections[i] = patterns[i].substitute(variables);
|
||||
}
|
||||
return projections;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jet.typeinfo;
|
||||
|
||||
import jet.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public interface TypeInfoProjection {
|
||||
TypeInfoProjection[] EMPTY_ARRAY = new TypeInfoProjection[0];
|
||||
|
||||
TypeInfoVariance getVariance();
|
||||
|
||||
TypeInfo getType();
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.TypeInfo;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
class Signature {
|
||||
|
||||
// TODO: make all these fields private
|
||||
|
||||
final Class klazz;
|
||||
|
||||
List<TypeInfoProjection> variables;
|
||||
Map<String,Integer> varNames;
|
||||
List<TypeInfo> superTypes;
|
||||
|
||||
HashMap<Class,TypeInfo> superSignatures = new HashMap<Class,TypeInfo>();
|
||||
|
||||
Signature(Class klazz) {
|
||||
this.klazz = klazz;
|
||||
}
|
||||
|
||||
void afterParse() {
|
||||
List<TypeInfo> myVars = variables == null ? Collections.<TypeInfo>emptyList() : new LinkedList<TypeInfo>();
|
||||
if(variables != null)
|
||||
for(int i = 0; i != variables.size(); ++i)
|
||||
myVars.add(new TypeInfoVar(this, false, i));
|
||||
|
||||
for(TypeInfo superType : superTypes) {
|
||||
if(superType instanceof TypeInfoImpl) {
|
||||
TypeInfoImpl type = (TypeInfoImpl) superType;
|
||||
Signature superSignature = TypeInfoParser.parse(type.signature.klazz);
|
||||
|
||||
TypeInfo substituted = TypeInfoUtils.substitute(type, myVars);
|
||||
superSignatures.put(type.signature.klazz, substituted);
|
||||
|
||||
List<TypeInfo> vars = Collections.emptyList();
|
||||
if(superType.getProjectionCount() != 0) {
|
||||
vars = new LinkedList<TypeInfo>();
|
||||
for(int i=0; i != superType.getProjectionCount(); ++i) {
|
||||
TypeInfo substitute = TypeInfoUtils.substitute(superType.getProjection(i).getType(), myVars);
|
||||
vars.add(substitute);
|
||||
}
|
||||
}
|
||||
|
||||
for(Map.Entry<Class,TypeInfo> entry : superSignature.superSignatures.entrySet()) {
|
||||
superSignatures.put(entry.getKey(), TypeInfoUtils.substitute(entry.getValue(), vars));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.JetObject;
|
||||
import jet.TypeInfo;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class TypeInfoImpl<T> extends TypeInfo<T> implements TypeInfoProjection {
|
||||
private final static TypeInfoProjection[] EMPTY = new TypeInfoProjection[0];
|
||||
|
||||
private TypeInfo<?> typeInfo;
|
||||
public final Signature signature;
|
||||
private final boolean nullable;
|
||||
private final TypeInfoProjection[] projections;
|
||||
|
||||
public TypeInfoImpl(Class<T> theClass, boolean nullable) {
|
||||
this(theClass, nullable, EMPTY);
|
||||
}
|
||||
|
||||
public TypeInfoImpl(Class<T> theClass, boolean nullable, TypeInfoProjection[] projections) {
|
||||
this.signature = TypeInfoParser.parse(theClass);
|
||||
this.nullable = nullable;
|
||||
this.projections = projections;
|
||||
if(signature.variables.size() != projections.length)
|
||||
throw new IllegalStateException("Wrong signature " + theClass.getName());
|
||||
}
|
||||
|
||||
public final TypeInfoProjection getProjection(int index) {
|
||||
return projections[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] newArray(int length) {
|
||||
return (Object[]) Array.newInstance(signature.klazz, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getJavaClass() {
|
||||
return signature.klazz;
|
||||
}
|
||||
|
||||
public final Object getClassObject() {
|
||||
try {
|
||||
final Class implClass = signature.klazz.getClassLoader().loadClass(signature.klazz.getCanonicalName());
|
||||
final Field classobj = implClass.getField("$classobj");
|
||||
return classobj.get(null);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
TypeInfo getSuperTypeInfo(Class klass) {
|
||||
return signature.superSignatures.get(klass);
|
||||
}
|
||||
|
||||
public final TypeInfo getArgumentType(Class klass, int index) {
|
||||
if(klass == this.signature.klazz)
|
||||
return projections[index].getType();
|
||||
else {
|
||||
return TypeInfoUtils.substitute(getSuperTypeInfo(klass), projections).getArgumentType(klass, index);
|
||||
}
|
||||
}
|
||||
|
||||
TypeInfo substitute(final List<TypeInfo> myVars) {
|
||||
if(projections.length == 0)
|
||||
return new TypeInfoImpl(this.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 = TypeInfoUtils.substitute(projections[finalI].getType(), myVars);
|
||||
proj[i] = new TypeInfoProjection(){
|
||||
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return projections[finalI].getVariance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getVariance().toString() + " " + substitute;
|
||||
}
|
||||
};
|
||||
}
|
||||
return new TypeInfoImpl(this.signature.klazz, nullable, proj);
|
||||
}
|
||||
}
|
||||
|
||||
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 = TypeInfoUtils.substitute(projections[finalI].getType(), prj);
|
||||
proj[i] = new TypeInfoProjection(){
|
||||
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return projections[finalI].getVariance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getVariance().toString() + " " + substitute;
|
||||
}
|
||||
};
|
||||
}
|
||||
return new TypeInfoImpl(signature.klazz, nullable, proj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TypeInfoImpl typeInfo = (TypeInfoImpl) o;
|
||||
|
||||
if (!signature.klazz.equals(typeInfo.signature.klazz)) return false;
|
||||
if (nullable != typeInfo.nullable) return false;
|
||||
if (!Arrays.equals(projections, typeInfo.projections)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return TypeInfoVariance.INVARIANT;
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return 31 * signature.klazz.hashCode() + Arrays.hashCode(projections);
|
||||
}
|
||||
|
||||
public final boolean isInstance(Object obj) {
|
||||
if (obj == null) return nullable;
|
||||
|
||||
if (obj instanceof JetObject) {
|
||||
return ((TypeInfoImpl)((JetObject) obj).getTypeInfo()).isSubtypeOf(this);
|
||||
}
|
||||
|
||||
return signature.klazz.isAssignableFrom(obj.getClass()); // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProjectionCount() {
|
||||
return projections.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder sb = new StringBuilder().append(signature.klazz.getName());
|
||||
if (projections.length != 0) {
|
||||
sb.append("<");
|
||||
for (int i = 0; i != projections.length - 1; ++i) {
|
||||
sb.append(projections[i].toString()).append(",");
|
||||
}
|
||||
sb.append(projections[projections.length - 1].toString()).append(">");
|
||||
}
|
||||
if (nullable)
|
||||
sb.append("?");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TypeInfo<?> getTypeInfo() {
|
||||
if (typeInfo == null) {
|
||||
// TODO: Implementation must be lazy, otherwise the result would be of an infinite size
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final boolean isSubtypeOf(TypeInfoImpl<?> superType) {
|
||||
if (nullable && !superType.nullable) {
|
||||
return false;
|
||||
}
|
||||
if (!superType.signature.klazz.isAssignableFrom(signature.klazz)) {
|
||||
return false;
|
||||
}
|
||||
if (superType.projections == null || superType.projections.length != projections.length) {
|
||||
throw new IllegalArgumentException("inconsistent type info for the same class");
|
||||
}
|
||||
for (int i = 0; i < projections.length; i++) {
|
||||
// TODO handle variance here
|
||||
if (!projections[i].getType().equals(superType.projections[i].getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,298 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.TypeInfo;
|
||||
import jet.runtime.typeinfo.JetClass;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureReader;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureVariance;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureVisitor;
|
||||
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
class TypeInfoParser {
|
||||
static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
static final WeakHashMap<Class,Signature> map = new WeakHashMap<Class,Signature>();
|
||||
|
||||
public static Signature parse(Class klass) {
|
||||
if(klass == null)
|
||||
return null;
|
||||
|
||||
// lock.readLock().lock();
|
||||
Signature sig = map.get(klass);
|
||||
// lock.readLock().unlock();
|
||||
if (sig == null) {
|
||||
// lock.writeLock().lock();
|
||||
|
||||
sig = map.get(klass);
|
||||
if (sig == null) {
|
||||
sig = internalParse(klass);
|
||||
}
|
||||
|
||||
// lock.writeLock().unlock();
|
||||
}
|
||||
return sig;
|
||||
}
|
||||
|
||||
private static Signature internalParse(Class klass) {
|
||||
if(klass.isArray() && !klass.getComponentType().isPrimitive()) {
|
||||
Signature signature = new ArraySignature(klass);
|
||||
map.put(klass, signature);
|
||||
return signature;
|
||||
}
|
||||
|
||||
JetClass annotation = (JetClass) klass.getAnnotation(JetClass.class);
|
||||
if(annotation != null) {
|
||||
String value = annotation.signature();
|
||||
if(value != null) {
|
||||
Class enclosingClass = klass.getEnclosingClass();
|
||||
Signature signature = new Signature(klass);
|
||||
map.put(klass, signature);
|
||||
parse(value, signature);
|
||||
signature.afterParse();
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
return getGenericSignature(klass);
|
||||
}
|
||||
|
||||
private static void parse(String annotationValue, final Signature signature) {
|
||||
signature.variables = new ArrayList<TypeInfoProjection>();
|
||||
signature.varNames = new HashMap<String, Integer>();
|
||||
signature.superTypes = new ArrayList<TypeInfo>();
|
||||
new JetSignatureReader(annotationValue).accept(new JetSignatureExceptionsAdapter() {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance, boolean reified) {
|
||||
|
||||
// TODO: nullability
|
||||
|
||||
return new JetSignatureExceptionsAdapter() {
|
||||
@Override
|
||||
public JetSignatureVisitor visitClassBound() {
|
||||
return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) {
|
||||
@Override
|
||||
protected void done(TypeInfo typeInfo) {
|
||||
// TODO
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitInterfaceBound() {
|
||||
return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) {
|
||||
@Override
|
||||
protected void done(TypeInfo typeInfo) {
|
||||
// TODO
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFormalTypeParameterEnd() {
|
||||
final TypeInfoVar typeInfoVar = new TypeInfoVar(signature, signature.variables.size());
|
||||
|
||||
signature.varNames.put(name, signature.variables.size());
|
||||
TypeInfoProjection typeInfoProjection = new TypeInfoProjection() {
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return variance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return typeInfoVar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return typeInfoVar.toString();
|
||||
}
|
||||
};
|
||||
|
||||
signature.variables.add(typeInfoProjection);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitSuperclass() {
|
||||
return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) {
|
||||
@Override
|
||||
protected void done(TypeInfo typeInfo) {
|
||||
signature.superTypes.add(typeInfo);
|
||||
signature.superSignatures.put(typeInfo.getJavaClass(), typeInfo);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitInterface() {
|
||||
return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) {
|
||||
@Override
|
||||
protected void done(TypeInfo typeInfo) {
|
||||
signature.superTypes.add(typeInfo);
|
||||
signature.superSignatures.put(typeInfo.getJavaClass(), typeInfo);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static abstract class SignatureParserJetSignatureAdapter extends JetSignatureExceptionsAdapter {
|
||||
private final ClassLoader classLoader;
|
||||
private final Signature signature;
|
||||
|
||||
protected SignatureParserJetSignatureAdapter(ClassLoader classLoader, Signature signature) {
|
||||
this.classLoader = classLoader;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
protected abstract void done(TypeInfo typeInfo);
|
||||
|
||||
private Class<?> klass;
|
||||
private boolean nullable;
|
||||
private List<TypeInfoProjection> projections;
|
||||
|
||||
@Override
|
||||
public void visitClassType(String name, boolean nullable, boolean forceReal) {
|
||||
try {
|
||||
// TODO: real flag
|
||||
klass = classLoader.loadClass(name.replace('/', '.'));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
this.nullable = nullable;
|
||||
this.projections = new ArrayList<TypeInfoProjection>();
|
||||
}
|
||||
|
||||
private static TypeInfoVariance parseVariance(JetSignatureVariance variance) {
|
||||
switch (variance) {
|
||||
case INVARIANT: return TypeInfoVariance.INVARIANT;
|
||||
case OUT: return TypeInfoVariance.OUT;
|
||||
case IN: return TypeInfoVariance.IN;
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitTypeArgument(final JetSignatureVariance wildcard) {
|
||||
final TypeInfoVariance variance = parseVariance(wildcard);
|
||||
return new SignatureParserJetSignatureAdapter(classLoader, signature) {
|
||||
@Override
|
||||
protected void done(TypeInfo typeInfo) {
|
||||
projections.add(new TypeInfoProjectionImpl(typeInfo) {
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return variance;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeVariable(String name, boolean nullable) {
|
||||
Integer varIndex = signature.varNames.get(name);
|
||||
if (varIndex == null) {
|
||||
throw new IllegalStateException("unresolved type variable: " + name);
|
||||
}
|
||||
TypeInfoVar typeInfo = new TypeInfoVar(signature, nullable, varIndex);
|
||||
done(typeInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
done(new TypeInfoImpl(klass, nullable, projections.toArray(new TypeInfoProjection[0])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Signature getGenericSignature(Class klass) {
|
||||
// todo complete impl
|
||||
|
||||
java.lang.reflect.Type genericSuperclass = klass.getGenericSuperclass();
|
||||
Signature signature = new Signature(klass);
|
||||
|
||||
TypeVariable[] typeParameters = klass.getTypeParameters();
|
||||
if(typeParameters == null || typeParameters.length == 0) {
|
||||
signature.varNames = Collections.emptyMap();
|
||||
signature.variables = Collections.emptyList();
|
||||
}
|
||||
else {
|
||||
signature.varNames = new HashMap<String, Integer>();
|
||||
signature.variables = new LinkedList<TypeInfoProjection>();
|
||||
}
|
||||
|
||||
if (typeParameters != null && typeParameters.length != 0) {
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
TypeVariable typeParameter = typeParameters[i];
|
||||
signature.varNames.put(typeParameter.getName(), i);
|
||||
final TypeInfoVar typeInfoVar = new TypeInfoVar(signature, false, i);
|
||||
signature.variables.add(new TypeInfoProjection(){
|
||||
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return TypeInfoVariance.INVARIANT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return typeInfoVar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return typeInfoVar.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
private static class ArraySignature extends Signature {
|
||||
public ArraySignature(Class klass) {
|
||||
super(klass);
|
||||
variables = new LinkedList<TypeInfoProjection>();
|
||||
varNames = new HashMap<String, Integer>();
|
||||
varNames.put("T", 0);
|
||||
final TypeInfoVar typeInfoVar = new TypeInfoVar(this, 0);
|
||||
variables.add(new TypeInfoProjection() {
|
||||
@Override
|
||||
public TypeInfoVariance getVariance() {
|
||||
return TypeInfoVariance.INVARIANT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getType() {
|
||||
return typeInfoVar;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.TypeInfo;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
import jet.typeinfo.TypeInfoVariance;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public abstract class TypeInfoProjectionImpl implements TypeInfoProjection {
|
||||
private final TypeInfo type;
|
||||
|
||||
public TypeInfoProjectionImpl(TypeInfo typeInfo) {
|
||||
this.type = typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TypeInfo getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TypeInfoProjectionImpl that = (TypeInfoProjectionImpl) o;
|
||||
// no need to compare variance as we compared classes already
|
||||
return type.equals(that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
int result = type.hashCode();
|
||||
result = 31 * result + (getVariance().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return (getVariance() == TypeInfoVariance.INVARIANT ? "" : getVariance().toString() + " ") + type;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.TypeInfo;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
class TypeInfoUtils {
|
||||
|
||||
static TypeInfo<?> substitute(TypeInfo<?> typeInfo, TypeInfoProjection[] projections) {
|
||||
if (typeInfo instanceof TypeInfoImpl<?>) {
|
||||
TypeInfoImpl<?> typeInfoImpl = (TypeInfoImpl<?>) typeInfo;
|
||||
return typeInfoImpl.substitute(projections);
|
||||
} else if (typeInfo instanceof TypeInfoVar<?>) {
|
||||
TypeInfoVar<?> typeInfoVar = (TypeInfoVar<?>) typeInfo;
|
||||
return typeInfoVar.substitute(projections);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
static TypeInfo<?> substitute(TypeInfo<?> typeInfo, List<TypeInfo> myVars) {
|
||||
if (typeInfo instanceof TypeInfoImpl<?>) {
|
||||
TypeInfoImpl<?> typeInfoImpl = (TypeInfoImpl<?>) typeInfo;
|
||||
return typeInfoImpl.substitute(myVars);
|
||||
} else if (typeInfo instanceof TypeInfoVar<?>) {
|
||||
TypeInfoVar<?> typeInfoVar = (TypeInfoVar<?>) typeInfo;
|
||||
return typeInfoVar.substitute(myVars);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.rt;
|
||||
|
||||
import jet.JetObject;
|
||||
import jet.TypeInfo;
|
||||
import jet.typeinfo.TypeInfoProjection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
class TypeInfoVar<T> extends TypeInfo<T> {
|
||||
final int varIndex;
|
||||
final Signature signature;
|
||||
final boolean nullable;
|
||||
|
||||
public TypeInfoVar(Signature signature, Integer varIndex) {
|
||||
this.signature = signature;
|
||||
this.varIndex = varIndex;
|
||||
nullable = false;
|
||||
}
|
||||
|
||||
public TypeInfoVar(Signature signature, boolean nullable, int varIndex) {
|
||||
this.signature = signature;
|
||||
this.nullable = nullable;
|
||||
this.varIndex = varIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] newArray(int length) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getJavaClass() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClassObject() {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(Object obj) {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProjectionCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfoProjection getProjection(int index) {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getArgumentType(Class klass, int index) {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
}
|
||||
|
||||
TypeInfo substitute(List<TypeInfo> myVars) {
|
||||
return myVars.get(varIndex);
|
||||
}
|
||||
|
||||
TypeInfo substitute(TypeInfoProjection[] projections) {
|
||||
return projections[varIndex].getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo<?> getTypeInfo() {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObject getOuterObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "T:" + signature.klazz.getName() + ":" + varIndex;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user