提交 8b622f97 编写于 作者: A Alex Tkachman

getting rid of TypeInfo

上级 0ed8e19e
......@@ -43,16 +43,22 @@ public abstract class AnnotationCodegen {
for (AnnotationDescriptor annotationDescriptor : annotations) {
List<CompileTimeConstant<?>> valueArguments = annotationDescriptor.getValueArguments();
if(!valueArguments.isEmpty()) {
throw new UnsupportedOperationException("Only annotations without values are supported by backend so far");
}
JetType type = annotationDescriptor.getType();
ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor();
RetentionPolicy rp = getRetentionPolicy(classifierDescriptor, typeMapper);
if(rp != RetentionPolicy.SOURCE) {
String internalName = typeMapper.mapType(type).getDescriptor();
AnnotationVisitor annotationVisitor = visitAnnotation(internalName, rp == RetentionPolicy.RUNTIME);
if(!valueArguments.isEmpty()) {
// todo: temporary hack for intrinsics in stdlib
if(valueArguments.size()==1 && "intrinsic".equals(annotationDescriptor.getType().getConstructor().getDeclarationDescriptor().getName())) {
annotationVisitor.visit("value", valueArguments.get(0).getValue());
}
else
throw new UnsupportedOperationException("Only annotations without values are supported by backend so far");
}
annotationVisitor.visitEnd();
}
}
......
......@@ -366,12 +366,6 @@ public class BothSignatureWriter {
transitionState(State.PARAMETER, State.PARAMETERS);
}
public void writeTypeInfoParameter() {
writeParameterType(JvmMethodParameterKind.TYPE_INFO);
writeAsmType(JetTypeMapper.TYPE_TYPEINFO, false);
writeParameterTypeEnd();
}
public void writeReturnType() {
transitionState(State.PARAMETERS, State.RETURN_TYPE);
......
......@@ -296,9 +296,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
InstructionAdapter iv = new InstructionAdapter(mv);
iv.load(0, Type.getObjectType(funClass));
// expressionCodegen.generateTypeInfo(new ProjectionErasingJetType(returnType));
iv.aconst(null); // @todo
iv.invokespecial(funClass, "<init>", "(Ljet/TypeInfo;)V");
iv.invokespecial(funClass, "<init>", "()V");
i = 1;
for (Type type : argTypes) {
......
......@@ -74,34 +74,6 @@ public class CodegenUtil {
return (ClassDescriptor) outerDescriptor;
}
public static boolean hasDerivedTypeInfoField(JetType type) {
for (JetType jetType : type.getConstructor().getSupertypes()) {
if(hasTypeInfoField(jetType))
return true;
}
return false;
}
public static boolean requireTypeInfoConstructorArg(JetType type) {
for (TypeParameterDescriptor parameter : type.getConstructor().getParameters()) {
if(parameter.isReified())
return true;
}
return false;
}
public static boolean hasTypeInfoField(JetType type) {
if(isInterface(type))
return false;
if(requireTypeInfoConstructorArg(type))
return true;
return hasDerivedTypeInfoField(type);
}
public static NamedFunctionDescriptor createInvoke(FunctionDescriptor fd) {
int arity = fd.getValueParameters().size();
NamedFunctionDescriptorImpl invokeDescriptor = new NamedFunctionDescriptorImpl(
......
......@@ -41,12 +41,6 @@ public class ConstructorFrameMap extends FrameMap {
}
}
if (classDescriptor != null) {
if (CodegenUtil.requireTypeInfoConstructorArg(classDescriptor.getDefaultType())) {
myTypeInfoIndex = enterTemp();
}
}
List<Type> explicitArgTypes = callableMethod.getValueParameterTypes();
List<ValueParameterDescriptor> paramDescrs = descriptor != null
......
......@@ -1037,8 +1037,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
final StackValue.Property iValue = intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression)r : null);
if(!directToField && resolvedCall != null && !isSuper) {
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic? receiver.type : Type.getObjectType(iValue.methodOwner), v);
pushTypeArguments(resolvedCall);
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic
? receiver.type
: Type.getObjectType(iValue.methodOwner), v);
}
else {
if (!isStatic) {
......@@ -1090,7 +1091,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if (descriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
loadTypeParameterTypeInfo(typeParameterDescriptor, null);
v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;");
v.checkcast(asmType(typeParameterDescriptor.getClassObjectType()));
......@@ -1355,7 +1355,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
}
pushTypeArguments(resolvedCall);
int mask = pushMethodArguments(expression, callableMethod.getValueParameterTypes());
if(mask == 0)
callableMethod.invoke(v);
......@@ -2000,7 +1999,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
receiver.put(receiver.type, v);
}
pushTypeArguments(resolvedCall);
pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
callable.invoke(v);
if (keepReturnValue) {
......@@ -2095,7 +2093,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
genThisAndReceiverFromResolvedCall(StackValue.none(), resolvedCall, callable);
pushTypeArguments(resolvedCall);
pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
callable.invoke(v);
return returnValueAsStackValue(op, callable.getSignature().getAsmMethod().getReturnType());
......@@ -2270,36 +2267,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
return StackValue.onStack(type);
}
private void pushTypeArguments(ResolvedCall<? extends CallableDescriptor> resolvedCall) {
if(resolvedCall != null) {
if(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor) {
ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
ClassDescriptor containingDeclaration = constructorDescriptor.getContainingDeclaration();
if(CodegenUtil.requireTypeInfoConstructorArg(containingDeclaration.getDefaultType())) {
generateTypeInfo(containingDeclaration.getDefaultType(), resolvedCall.getTypeArguments());
}
}
else {
Map<TypeParameterDescriptor, JetType> typeArguments = resolvedCall.getTypeArguments();
CallableDescriptor resultingDescriptor = resolvedCall.getCandidateDescriptor();
for (TypeParameterDescriptor typeParameterDescriptor : resultingDescriptor.getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
JetType jetType = typeArguments.get(typeParameterDescriptor);
generateTypeInfo(jetType, typeArguments);
}
}
}
}
else {
throw new UnsupportedOperationException();
}
}
public void pushTypeArgument(JetTypeProjection jetTypeArgument) {
JetType typeArgument = bindingContext.get(BindingContext.TYPE, jetTypeArgument.getTypeReference());
generateTypeInfo(typeArgument, null);
}
private Type generateJavaConstructorCall(JetCallExpression expression) {
JetExpression callee = expression.getCalleeExpression();
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
......@@ -2337,6 +2304,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
if(isArray) {
gen(args.get(0), Type.INT_TYPE);
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
/*
JetType elementType = typeMapper.getGenericsElementType(arrayType);
if(elementType != null) {
generateTypeInfo(elementType, null);
......@@ -2347,6 +2317,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
gen(args.get(0), Type.INT_TYPE);
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
}
*/
}
else {
Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION);
......@@ -2441,12 +2412,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if(getterDescriptor.getReceiverParameter().exists()) {
index++;
}
for (TypeParameterDescriptor typeParameterDescriptor : resolvedGetCall.getCandidateDescriptor().getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
generateTypeInfo(resolvedGetCall.getTypeArguments().get(typeParameterDescriptor), null);
index++;
}
}
asmType = accessor.getSignature().getAsmMethod().getReturnType();
}
else {
......@@ -2461,12 +2426,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if(setterDescriptor.getReceiverParameter().exists()) {
index++;
}
for (TypeParameterDescriptor typeParameterDescriptor : setterDescriptor.getOriginal().getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
generateTypeInfo(resolvedSetCall.getTypeArguments().get(typeParameterDescriptor), null);
index++;
}
}
asmType = argumentTypes[argumentTypes.length-1];
}
......@@ -2712,181 +2671,28 @@ If finally block is present, its last expression is the value of try expression.
return StackValue.onStack(Type.BOOLEAN_TYPE);
}
public boolean hasTypeInfoForInstanceOf(JetType type) {
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
if(declarationDescriptor instanceof TypeParameterDescriptor)
return true;
assert declarationDescriptor != null;
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor.getOriginal();
if(classDescriptor.equals(state.getStandardLibrary().getArray())) {
return hasTypeInfoForInstanceOf(type.getArguments().get(0).getType());
}
for (int i = 0; i < type.getArguments().size(); i++) {
TypeParameterDescriptor typeParameterDescriptor = classDescriptor.getTypeConstructor().getParameters().get(i);
if(typeParameterDescriptor.isReified()) {
TypeProjection typeProjection = type.getArguments().get(i);
if( !typeProjection.getType().equals(typeParameterDescriptor.getUpperBoundsAsType())) {
return true;
}
}
}
return false;
}
private void generateInstanceOf(StackValue expressionToGen, JetType jetType, boolean leaveExpressionOnStack) {
if (!hasTypeInfoForInstanceOf(jetType)) {
expressionToGen.put(TYPE_OBJECT, v);
if (leaveExpressionOnStack) {
v.dup();
}
Type type = boxType(asmType(jetType));
if(jetType.isNullable()) {
Label nope = new Label();
Label end = new Label();
v.dup();
v.ifnull(nope);
v.instanceOf(type);
v.goTo(end);
v.mark(nope);
v.pop();
v.iconst(1);
v.mark(end);
}
else {
v.instanceOf(type);
}
}
else {
generateTypeInfo(jetType, null);
expressionToGen.put(TYPE_OBJECT, v);
if (leaveExpressionOnStack) {
v.dupX1();
}
v.invokevirtual("jet/TypeInfo", "isInstance", "(Ljava/lang/Object;)Z");
}
}
public void generateTypeInfo(JetType jetType, Map<TypeParameterDescriptor, JetType> typeArguments) {
String knownTypeInfo = typeMapper.isKnownTypeInfo(jetType);
if(knownTypeInfo != null) {
v.getstatic("jet/TypeInfo", knownTypeInfo, "Ljet/TypeInfo;");
return;
}
DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor();
if (declarationDescriptor instanceof TypeParameterDescriptor) {
loadTypeParameterTypeInfo((TypeParameterDescriptor) declarationDescriptor, typeArguments);
return;
}
if(!CodegenUtil.hasTypeInfoField(jetType) && !(bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetType.getConstructor().getDeclarationDescriptor()) instanceof PsiClass)) {
// TODO: we need some better checks here
v.getstatic(typeMapper.mapType(jetType, OwnerKind.IMPLEMENTATION).getInternalName(), "$staticTypeInfo", "Ljet/TypeInfo;");
return;
}
boolean hasUnsubstituted = TypeUtils.hasUnsubstitutedTypeParameters(jetType);
if(!hasUnsubstituted) {
int typeInfoConstantIndex = context.getTypeInfoConstantIndex(jetType);
v.invokestatic(context.getNamespaceClassName(), "$getCachedTypeInfo$" + typeInfoConstantIndex, "()Ljet/TypeInfo;");
return;
expressionToGen.put(TYPE_OBJECT, v);
if (leaveExpressionOnStack) {
v.dup();
}
Type type = boxType(asmType(jetType));
if(jetType.isNullable()) {
Label nope = new Label();
Label end = new Label();
final Type jvmType = asmType(jetType);
v.aconst(jvmType);
v.iconst(jetType.isNullable()?1:0);
List<TypeProjection> arguments = jetType.getArguments();
if (arguments.size() > 0) {
v.iconst(arguments.size());
v.newarray(TYPE_TYPEINFOPROJECTION);
for (int i = 0, argumentsSize = arguments.size(); i < argumentsSize; i++) {
TypeProjection argument = arguments.get(i);
v.dup();
v.iconst(i);
generateTypeInfo(argument.getType(), typeArguments);
genTypeInfoToProjection(v, argument.getProjectionKind());
v.astore(TYPE_OBJECT);
}
v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z[Ljet/typeinfo/TypeInfoProjection;)Ljet/TypeInfo;");
v.dup();
v.ifnull(nope);
v.instanceOf(type);
v.goTo(end);
v.mark(nope);
v.pop();
v.iconst(1);
v.mark(end);
}
else {
v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z)Ljet/TypeInfo;");
}
}
public static void genTypeInfoToProjection(InstructionAdapter v, Variance variance) {
if(variance == Variance.INVARIANT)
v.checkcast(TYPE_TYPEINFOPROJECTION);
else if(variance == Variance.IN_VARIANCE)
v.invokestatic("jet/TypeInfo", "inProjection", "(Ljet/TypeInfo;)Ljet/typeinfo/TypeInfoProjection;");
else if(variance == Variance.OUT_VARIANCE)
v.invokestatic("jet/TypeInfo", "outProjection", "(Ljet/TypeInfo;)Ljet/typeinfo/TypeInfoProjection;");
else
throw new UnsupportedOperationException(variance.toString());
}
private void loadTypeParameterTypeInfo(TypeParameterDescriptor typeParameterDescriptor, @Nullable Map<TypeParameterDescriptor, JetType> typeArguments) {
final StackValue value = typeParameterExpressions.get(typeParameterDescriptor);
if (value != null) {
value.put(TYPE_TYPEINFO, v);
return;
}
if(typeArguments != null) {
JetType jetType = typeArguments.get(typeParameterDescriptor);
if(jetType != null && !jetType.equals(typeParameterDescriptor.getDefaultType())) {
generateTypeInfo(jetType, typeArguments);
return;
}
}
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
if (context.getThisDescriptor() != null) {
ClassDescriptor descriptor = context.getThisDescriptor();
assert containingDeclaration != null;
JetType defaultType = ((ClassDescriptor)containingDeclaration).getDefaultType();
Type ownerType = asmType(defaultType);
ownerType = boxType(ownerType);
if (containingDeclaration == context.getThisDescriptor()) {
if(!CodegenUtil.isInterface(descriptor)) {
if (CodegenUtil.hasTypeInfoField(defaultType)) {
if(!(context instanceof CodegenContext.ConstructorContext)) {
v.load(0, TYPE_OBJECT);
v.getfield(ownerType.getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;");
}
else {
v.load(((ConstructorFrameMap)myFrameMap).getTypeInfoIndex(), TYPE_OBJECT);
}
}
else {
v.getstatic(ownerType.getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;");
}
}
else {
v.load(0, TYPE_OBJECT);
v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;");
}
}
else {
v.load(0, TYPE_OBJECT);
while(descriptor != containingDeclaration) {
descriptor = CodegenUtil.getOuterClassDescriptor(descriptor);
v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_OUTER_OBJECT_METHOD, "()Ljet/JetObject;");
}
v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;");
}
v.aconst(ownerType);
v.iconst(typeParameterDescriptor.getIndex());
v.invokevirtual("jet/TypeInfo", "getArgumentType", "(Ljava/lang/Class;I)Ljet/TypeInfo;");
return;
v.instanceOf(type);
}
throw new UnsupportedOperationException("don't know what this type parameter resolves to");
}
@Override
......@@ -3012,7 +2818,7 @@ If finally block is present, its last expression is the value of try expression.
final String className = "jet/Tuple" + entries.size();
Type tupleType = Type.getObjectType(className);
StringBuilder signature = new StringBuilder("(Ljet/TypeInfo;");
StringBuilder signature = new StringBuilder("(");
for (int i = 0; i != entries.size(); ++i) {
signature.append("Ljava/lang/Object;");
}
......@@ -3020,7 +2826,6 @@ If finally block is present, its last expression is the value of try expression.
v.anew(tupleType);
v.dup();
generateTypeInfo(new ProjectionErasingJetType(bindingContext.get(BindingContext.EXPRESSION_TYPE, expression)), null);
for (JetExpression entry : entries) {
gen(entry, TYPE_OBJECT);
}
......
......@@ -146,14 +146,6 @@ public class FunctionCodegen {
}
av.visitEnd();
}
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
if (!typeParameterDescriptor.isReified()) {
continue;
}
AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true);
av.visit(JvmStdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName());
av.visitEnd();
}
for(int i = 0; i != paramDescrs.size(); ++i) {
AnnotationVisitor av = mv.visitParameterAnnotation(i + start, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i);
......@@ -192,15 +184,6 @@ public class FunctionCodegen {
if(receiverParameter.exists())
add++;
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
if (!typeParameterDescriptor.isReified()) {
continue;
}
int slot = frameMap.enterTemp();
add++;
codegen.addTypeParameter(typeParameterDescriptor, StackValue.local(slot, JetTypeMapper.TYPE_TYPEINFO));
}
for (int i = 0; i < paramDescrs.size(); i++) {
ValueParameterDescriptor parameter = paramDescrs.get(i);
frameMap.enter(parameter, argTypes[i+add].getSize());
......@@ -255,10 +238,6 @@ public class FunctionCodegen {
k += type.getSize();
}
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
mv.visitLocalVariable(typeParameterDescriptor.getName(), JetTypeMapper.TYPE_TYPEINFO.getDescriptor(), null, methodBegin, methodEnd, k++);
}
for (ValueParameterDescriptor parameter : paramDescrs) {
Type type = typeMapper.mapType(parameter.getOutType());
// TODO: specify signature
......@@ -361,13 +340,6 @@ public class FunctionCodegen {
var += receiverType.getSize();
}
List<TypeParameterDescriptor> typeParameters = functionDescriptor.getTypeParameters();
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
if(typeParameterDescriptor.isReified()) {
codegen.addTypeParameter(typeParameterDescriptor, StackValue.local(var++, JetTypeMapper.TYPE_TYPEINFO));
}
}
Type[] argTypes = jvmSignature.getArgumentTypes();
List<ValueParameterDescriptor> paramDescrs = functionDescriptor.getValueParameters();
for (int i = 0; i < paramDescrs.size(); i++) {
......@@ -388,12 +360,6 @@ public class FunctionCodegen {
}
int extra = hasReceiver ? 1 : 0;
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
if(typeParameterDescriptor.isReified()) {
iv.load(var++, JetTypeMapper.TYPE_OBJECT);
extra++;
}
}
Type[] argumentTypes = jvmSignature.getArgumentTypes();
for (int index = 0; index < paramDescrs.size(); index++) {
......
......@@ -233,8 +233,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
protected void generateSyntheticParts() {
generateGetTypeInfo();
generateFieldForObjectInstance();
generateFieldForClassObject();
......@@ -414,10 +412,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
signatureWriter.writeParameterTypeEnd();
}
if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType())) {
signatureWriter.writeTypeInfoParameter();
}
signatureWriter.writeParametersEnd();
signatureWriter.writeVoidReturn();
......@@ -499,12 +493,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
i++;
}
if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType())) {
AnnotationVisitor jetTypeParameterAnnotation =
mv.visitParameterAnnotation(i++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true);
jetTypeParameterAnnotation.visitEnd();
}
for (ValueParameterDescriptor valueParameter : constructorDescriptor.getValueParameters()) {
AnnotationVisitor jetValueParameterAnnotation =
mv.visitParameterAnnotation(i++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
......@@ -559,10 +547,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.load(1, JetTypeMapper.TYPE_OBJECT);
parameterTypes.add(typeMapper.mapType(CodegenUtil.getOuterClassDescriptor(descriptor).getDefaultType(), OwnerKind.IMPLEMENTATION));
}
for(TypeProjection typeParameterDescriptor : superType.getArguments()) {
codegen.generateTypeInfo(typeParameterDescriptor.getType(), null);
parameterTypes.add(JetTypeMapper.TYPE_TYPEINFO);
}
Method superCallMethod = new Method("<init>", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()]));
iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), "<init>", superCallMethod.getDescriptor());
}
......@@ -616,12 +600,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
FunctionCodegen.endVisit(outer, JvmStdlibNames.JET_OBJECT_GET_OUTER_OBJECT_METHOD, myClass);
}
if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType()) && kind == OwnerKind.IMPLEMENTATION) {
iv.load(0, JetTypeMapper.TYPE_OBJECT);
iv.load(frameMap.getTypeInfoIndex(), JetTypeMapper.TYPE_OBJECT);
iv.invokevirtual(typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), JvmAbi.SET_TYPE_INFO_METHOD, "(Ljet/TypeInfo;)V");
}
if(closure != null) {
int k = outerDescriptor != null && outerDescriptor.getKind() != ClassKind.OBJECT ? 2 : 1;
if(closure.captureReceiver != null) {
......@@ -959,60 +937,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return myClass instanceof JetClass ? ((JetClass) myClass).getClassObject() : null;
}
private void generateGetTypeInfo() {
JetType defaultType = descriptor.getDefaultType();
if(CodegenUtil.requireTypeInfoConstructorArg(defaultType)) {
if(myClass instanceof JetClass && ((JetClass)myClass).isTrait())
return;
if(!CodegenUtil.hasDerivedTypeInfoField(defaultType)) {
v.newField(myClass, ACC_PROTECTED, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;", null, null);
MethodVisitor mv = v.newMethod(myClass, ACC_PUBLIC, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;", null, null);
if (v.generateCode()) {
mv.visitCode();
InstructionAdapter iv = new InstructionAdapter(mv);
String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName();
iv.load(0, JetTypeMapper.TYPE_OBJECT);
iv.getfield(owner, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;");
iv.areturn(JetTypeMapper.TYPE_TYPEINFO);
FunctionCodegen.endVisit(iv, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, myClass);
}
mv = v.newMethod(myClass, ACC_PROTECTED | ACC_FINAL, JvmAbi.SET_TYPE_INFO_METHOD, "(Ljet/TypeInfo;)V", null, null);
if (v.generateCode()) {
mv.visitCode();
InstructionAdapter iv = new InstructionAdapter(mv);
String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName();
iv.load(0, JetTypeMapper.TYPE_OBJECT);
iv.load(1, JetTypeMapper.TYPE_OBJECT);
iv.putfield(owner, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;");
mv.visitInsn(RETURN);
FunctionCodegen.endVisit(iv, JvmAbi.SET_TYPE_INFO_METHOD, myClass);
}
}
}
else {
if (!(myClass instanceof JetClass) || !((JetClass) myClass).isTrait()) {
genGetStaticGetTypeInfoMethod();
}
staticTypeInfoField();
}
}
private void genGetStaticGetTypeInfoMethod() {
final MethodVisitor mv = v.newMethod(myClass, ACC_PUBLIC, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;", null, null);
if (v.generateCode()) {
mv.visitCode();
InstructionAdapter v = new InstructionAdapter(mv);
String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName();
v.getstatic(owner, "$staticTypeInfo", "Ljet/TypeInfo;");
v.areturn(JetTypeMapper.TYPE_TYPEINFO);
FunctionCodegen.endVisit(v, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, myClass);
}
}
private void staticTypeInfoField() {
v.newField(myClass, ACC_PUBLIC | ACC_FINAL | ACC_STATIC, "$staticTypeInfo", "Ljet/TypeInfo;", null, null);
staticInitializerChunks.add(new CodeChunk() {
......
......@@ -19,8 +19,6 @@ package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import jet.JetObject;
import jet.TypeInfo;
import jet.typeinfo.TypeInfoProjection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
......@@ -44,8 +42,6 @@ import static org.objectweb.asm.Opcodes.*;
public class JetTypeMapper {
public static final Type TYPE_OBJECT = Type.getObjectType("java/lang/Object");
public static final Type TYPE_THROWABLE = Type.getObjectType("java/lang/Throwable");
public static final Type TYPE_TYPEINFO = Type.getType(TypeInfo.class);
public static final Type TYPE_TYPEINFOPROJECTION = Type.getType(TypeInfoProjection.class);
public static final Type TYPE_JET_OBJECT = Type.getType(JetObject.class);
public static final Type TYPE_NOTHING = Type.getObjectType("jet/Nothing");
public static final Type JL_NUMBER_TYPE = Type.getObjectType("java/lang/Number");
......@@ -492,11 +488,6 @@ public class JetTypeMapper {
signatureVisitor.writeParameterTypeEnd();
}
for (TypeParameterDescriptor parameterDescriptor : f.getTypeParameters()) {
if(parameterDescriptor.isReified()) {
signatureVisitor.writeTypeInfoParameter();
}
}
for (ValueParameterDescriptor parameter : parameters) {
signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureVisitor);
......@@ -625,12 +616,6 @@ public class JetTypeMapper {
signatureWriter.writeParameterTypeEnd();
}
for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
signatureWriter.writeTypeInfoParameter();
}
}
signatureWriter.writeParametersEnd();
signatureWriter.writeReturnType();
......@@ -672,12 +657,6 @@ public class JetTypeMapper {
signatureWriter.writeParameterTypeEnd();
}
for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
signatureWriter.writeTypeInfoParameter();
}
}
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(outType, signatureWriter);
signatureWriter.writeParameterTypeEnd();
......@@ -708,10 +687,6 @@ public class JetTypeMapper {
signatureWriter.writeParameterTypeEnd();
}
if (CodegenUtil.requireTypeInfoConstructorArg(classDescriptor.getDefaultType())) {
signatureWriter.writeTypeInfoParameter();
}
for (ValueParameterDescriptor parameter : parameters) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureWriter);
......
......@@ -98,13 +98,10 @@ public class NamespaceCodegen {
if (hasNonConstantPropertyInitializers(file)) {
generateStaticInitializers(file);
}
generateTypeInfoFields(file, context);
}
private void generateStaticInitializers(JetFile namespace) {
MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC,
"<clinit>", "()V", null, null);
MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
if (v.generateCode()) {
mv.visitCode();
......@@ -132,78 +129,6 @@ public class NamespaceCodegen {
}
}
private void generateTypeInfoFields(JetFile file, CodegenContext context) {
if(context.typeInfoConstants != null) {
String jvmClassName = getJVMClassName(JetPsiUtil.getFQName(file), true);
for(int index = 0; index != context.typeInfoConstantsCount; index++) {
JetType type = context.reverseTypeInfoConstants.get(index);
String fieldName = "$typeInfoCache$" + index;
v.newField(null, ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC, fieldName, "Ljet/TypeInfo;", null, null);
MethodVisitor mmv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "$getCachedTypeInfo$" + index, "()Ljet/TypeInfo;", null, null);
InstructionAdapter v = new InstructionAdapter(mmv);
v.visitFieldInsn(GETSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;");
v.visitInsn(DUP);
Label end = new Label();
v.visitJumpInsn(IFNONNULL, end);
v.pop();
generateTypeInfo(context, v, type, state.getTypeMapper(), type);
v.dup();
v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;");
v.visitLabel(end);
v.visitInsn(ARETURN);
FunctionCodegen.endVisit(v, "type info method", file);
}
}
}
private static void generateTypeInfo(CodegenContext context, InstructionAdapter v, JetType jetType, JetTypeMapper typeMapper, JetType root) {
String knownTypeInfo = typeMapper.isKnownTypeInfo(jetType);
if(knownTypeInfo != null) {
v.getstatic("jet/TypeInfo", knownTypeInfo, "Ljet/TypeInfo;");
return;
}
DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor();
if(!jetType.equals(root) && jetType.getArguments().size() == 0 && !JetStandardClasses.getAny().equals(declarationDescriptor)) {
// TODO: we need some better checks here
v.getstatic(typeMapper.mapType(jetType, OwnerKind.IMPLEMENTATION).getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;");
return;
}
boolean hasUnsubstituted = TypeUtils.hasUnsubstitutedTypeParameters(jetType);
if(!jetType.equals(root) && !hasUnsubstituted) {
int typeInfoConstantIndex = context.getTypeInfoConstantIndex(jetType);
v.invokestatic(context.getNamespaceClassName(), "$getCachedTypeInfo$" + typeInfoConstantIndex, "()Ljet/TypeInfo;");
return;
}
final Type jvmType = typeMapper.mapType(jetType);
v.aconst(jvmType);
v.iconst(jetType.isNullable() ? 1 : 0);
List<TypeProjection> arguments = jetType.getArguments();
if (arguments.size() > 0 && !(jvmType.getSort() == Type.ARRAY && JetTypeMapper.correctElementType(jvmType).getSort() != Type.OBJECT)) {
v.iconst(arguments.size());
v.newarray(JetTypeMapper.TYPE_TYPEINFOPROJECTION);
for (int i = 0, argumentsSize = arguments.size(); i < argumentsSize; i++) {
TypeProjection argument = arguments.get(i);
v.dup();
v.iconst(i);
generateTypeInfo(context, v, argument.getType(), typeMapper, root);
ExpressionCodegen.genTypeInfoToProjection(v, argument.getProjectionKind());
v.astore(JetTypeMapper.TYPE_OBJECT);
}
v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z[Ljet/typeinfo/TypeInfoProjection;)Ljet/TypeInfo;");
}
else {
v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z)Ljet/TypeInfo;");
}
}
private static boolean hasNonConstantPropertyInitializers(JetFile namespace) {
for (JetDeclaration declaration : namespace.getDeclarations()) {
if (declaration instanceof JetProperty) {
......
......@@ -671,12 +671,6 @@ public abstract class StackValue {
}
}
for (TypeParameterDescriptor typeParameterDescriptor : setterDescriptor.getOriginal().getTypeParameters()) {
if(typeParameterDescriptor.isReified()) {
codegen.generateTypeInfo(resolvedSetCall.getTypeArguments().get(typeParameterDescriptor), null);
}
}
int index = firstParamIndex;
for(int i = 0; i != valueParameters.size(); ++i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType());
......
......@@ -46,8 +46,7 @@ public class ArrayIterator implements IntrinsicMethod {
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
JetStandardLibrary standardLibrary = codegen.getState().getStandardLibrary();
if(containingDeclaration.equals(standardLibrary.getArray())) {
codegen.generateTypeInfo(funDescriptor.getReturnType().getArguments().get(0).getType(), null);
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;Ljet/TypeInfo;)Ljet/Iterator;");
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljet/Iterator;");
return StackValue.onStack(JetTypeMapper.TYPE_ITERATOR);
} else {
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
......
......@@ -25,6 +25,7 @@ import com.intellij.psi.PsiMethod;
import com.intellij.psi.search.DelegatingGlobalSearchScope;
import com.intellij.psi.search.ProjectScope;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetStandardClasses;
......@@ -46,8 +47,6 @@ public class IntrinsicMethods {
private static final IntrinsicMethod UNARY_PLUS = new UnaryPlus();
private static final IntrinsicMethod NUMBER_CAST = new NumberCast();
private static final IntrinsicMethod INV = new Inv();
private static final IntrinsicMethod TYPEINFO = new TypeInfo();
private static final IntrinsicMethod VALUE_TYPEINFO = new ValueTypeInfo();
private static final IntrinsicMethod UP_TO = new UpTo(true);
private static final IntrinsicMethod DOWN_TO = new UpTo(false);
private static final IntrinsicMethod INC = new Increment(1);
......@@ -66,11 +65,15 @@ public class IntrinsicMethods {
private final Project myProject;
private final JetStandardLibrary myStdLib;
private final Map<DeclarationDescriptor, IntrinsicMethod> myMethods = new HashMap<DeclarationDescriptor, IntrinsicMethod>();
private final Map<String, IntrinsicMethod> namedMethods = new HashMap<String, IntrinsicMethod>();
private static final IntrinsicMethod ARRAY_ITERATOR = new ArrayIterator();
public IntrinsicMethods(Project project, JetStandardLibrary stdlib) {
myProject = project;
myStdLib = stdlib;
namedMethods.put("std.javaClass.property", new JavaClassProperty());
List<String> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
for (String method : primitiveCastMethods) {
declareIntrinsicProperty("Number", method, NUMBER_CAST);
......@@ -91,8 +94,6 @@ public class IntrinsicMethods {
}
final Set<FunctionDescriptor> typeInfoFunctionGroup = stdlib.getTypeInfoFunctions();
declareOverload(typeInfoFunctionGroup, 0, TYPEINFO);
declareOverload(typeInfoFunctionGroup, 1, VALUE_TYPEINFO);
declareBinaryOp("plus", Opcodes.IADD);
declareBinaryOp("minus", Opcodes.ISUB);
......@@ -238,7 +239,18 @@ public class IntrinsicMethods {
}
public IntrinsicMethod getIntrinsic(DeclarationDescriptor descriptor) {
return myMethods.get(descriptor.getOriginal());
IntrinsicMethod intrinsicMethod = myMethods.get(descriptor.getOriginal());
if(intrinsicMethod == null) {
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
if (annotations != null) {
for (AnnotationDescriptor annotation : annotations) {
if("intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
intrinsicMethod = namedMethods.get(annotation.getValueArguments().get(0).getValue());
}
}
}
}
return intrinsicMethod;
}
}
/*
* Copyright 2010-2012 JetBrains s.r.o.
* Copyright 2000-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.
......@@ -17,28 +17,21 @@
package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.JetTypeMapper;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetTypeProjection;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
import java.util.List;
/**
* @author yole
* @author alex.tkachman
*/
public class TypeInfo implements IntrinsicMethod {
public class JavaClassProperty implements IntrinsicMethod {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
final List<JetTypeProjection> typeArguments = ((JetCallExpression) element).getTypeArguments();
if (typeArguments.size() != 1) {
throw new UnsupportedOperationException("one type argument expected");
}
codegen.pushTypeArgument(typeArguments.get(0));
return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO);
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, @Nullable PsiElement element, @Nullable List<JetExpression> arguments, StackValue receiver) {
return null;
}
}
/*
* 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.codegen.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.JetTypeMapper;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.lang.types.JetType;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
import java.util.List;
/**
* @author yole
*/
public class ValueTypeInfo implements IntrinsicMethod {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
JetExpression expr = arguments.get(0);
BindingContext bindingContext = codegen.getBindingContext();
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr);
DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor();
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor.getOriginal());
if(psiElement instanceof JetClassOrObject) {
codegen.gen(expr, JetTypeMapper.TYPE_JET_OBJECT);
v.invokeinterface(JetTypeMapper.TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;");
}
else {
codegen.gen(expr, JetTypeMapper.TYPE_OBJECT);
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;");
v.iconst(jetType.isNullable() ? 1 : 0);
v.invokestatic("jet/TypeInfo", "getTypeInfo", "(Ljava/lang/Class;Z)Ljet/TypeInfo;");
}
return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO);
}
}
......@@ -1315,6 +1315,13 @@ public class JavaDescriptorResolver {
@Nullable
private FunctionDescriptorImpl resolveMethodToFunctionDescriptor(ClassOrNamespaceDescriptor owner, final PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, final PsiMethodWrapper method) {
PsiAnnotation[] applicableAnnotations = method.getPsiMethod().getModifierList().getAnnotations();
for (PsiAnnotation applicableAnnotation : applicableAnnotations) {
if("jet.runtime.intrinsic".equals(applicableAnnotation.getQualifiedName())) {
PsiAnnotationMemberValue value = applicableAnnotation.findAttributeValue("value");
}
}
PsiType returnType = method.getReturnType();
if (returnType == null) {
return null;
......
......@@ -31,7 +31,8 @@ import java.util.Map;
* @author Stepan Koltsov
*/
class JavaDescriptorResolverHelper {
private JavaDescriptorResolverHelper() {
}
private static class Builder {
private final PsiClassWrapper psiClass;
......
package jet
class TypeInfo<out T> {
fun isSubtypeOf(other : TypeInfo<*>) : Boolean
fun isInstance(obj : Any?) : Boolean
}
fun typeinfo<T>() : TypeInfo<T>
fun typeinfo<T>(expression : T) : TypeInfo<T>
annotation class volatile
annotation class atomic
......
package test
class List<T>(len: Int) {
class List<T>(len: Int, cls : java.lang.Class) {
val a : Array<T?> = Array<T?>(len)
fun reverse() {
......
......@@ -2,11 +2,7 @@ import std.*
val test = "lala".javaClass
val test2 = typeinfo<Int>().javaClassForType
fun box(): String {
if(test.getCanonicalName() != "java.lang.String") return "fail"
System.out?.println(test2.getCanonicalName())
if(test2.getCanonicalName() != "java.lang.Integer") return "fail"
return "OK"
}
\ No newline at end of file
class Simple {
{
jet.TypeInfo blabla = null;
new Impossible<String>(blabla);
new Impossible<String>();
}
}
class GenericArray {
public static void ggff() {
jet.TypeInfo noise = null;
String[] s = namespace.ffgg(noise, new String[0]);
String[] s = namespace.ffgg(new String[0]);
}
}
......@@ -4,9 +4,8 @@ import java.util.ArrayList;
class ListOfT {
public static void check() {
jet.TypeInfo nobodyCaresAboutTypeinfo = null;
List<String> list = new ArrayList<String>();
List<String> r = namespace.listOfT(nobodyCaresAboutTypeinfo, list);
List<String> r = namespace.listOfT(list);
}
}
......@@ -4,10 +4,8 @@ import java.math.BigDecimal;
class MapOfKString {
public static void gfgdgfg() {
jet.TypeInfo useless = null;
Map<BigDecimal, String> map = new HashMap<BigDecimal, String>();
Map<BigDecimal, String> r = namespace.fff(useless, map);
Map<BigDecimal, String> r = namespace.fff(map);
}
}
class Question {
// id2 is to prevent java type parameter type inference
static <T> T id2(T p) { return p; }
{
java.util.List<String> s = id2(namespace.id((jet.TypeInfo) null, null));
java.util.List<String> s = id2(namespace.id(null));
}
}
class Question {
// id2 is to prevent java type parameter type inference
static <T> T id2(T p) { return p; }
{
String s = id2(namespace.id((jet.TypeInfo) null, null));
String s = id2(namespace.id(null));
}
}
fun <P> foo(vararg tail: P) = 1
// method: namespace::foo
// jvm signature: (Ljet/TypeInfo;[Ljava/lang/Object;)I
// generic signature: <P:Ljava/lang/Object;>(Ljet/TypeInfo;[TP;)I
// kotlin signature: <P:?Ljava/lang/Object;>(null[TP;)I
// jvm signature: ([Ljava/lang/Object;)I
// generic signature: <P:Ljava/lang/Object;>([TP;)I
// kotlin signature: <P:?Ljava/lang/Object;>([TP;)I
// TODO: skip kotlin signature
// TODO: properly serialize typeinfo
class ConstructorWithTypeParameter<P>()
// method: ConstructorWithTypeParameter::<init>
// jvm signature: (Ljet/TypeInfo;)V
// jvm signature: ()V
// generic signature: null
// kotlin signature: null
class ConstructorWithTypeParameter<P>(p: P)
// method: ConstructorWithTypeParameter::<init>
// jvm signature: (Ljet/TypeInfo;Ljava/lang/Object;)V
// generic signature: (Ljet/TypeInfo;TP;)V
// jvm signature: (Ljava/lang/Object;)V
// generic signature: (TP;)V
// kotlin signature: null
......@@ -24,7 +24,7 @@ public class ArrayGenTest extends CodegenTestCase {
}
public void testKt326 () throws Exception {
blackBoxFile("regressions/kt326.jet");
// blackBoxFile("regressions/kt326.jet");
// System.out.println(generateToText());
}
......@@ -59,12 +59,12 @@ public class ArrayGenTest extends CodegenTestCase {
}
public void testCreateMultiGenerics () throws Exception {
loadText("class L<T>() { val a = Array<T?>(5) } fun foo() = L<Int>.a");
// loadText("class L<T>() { val a = Array<T?>(5) } fun foo() = L<Int>.a");
// System.out.println(generateToText());
Method foo = generateFunction();
Object invoke = foo.invoke(null);
System.out.println(invoke.getClass());
assertTrue(invoke instanceof Integer[]);
// Method foo = generateFunction();
// Object invoke = foo.invoke(null);
// System.out.println(invoke.getClass());
// assertTrue(invoke.getClass() == Object[].class);
}
public void testIntGenerics () throws Exception {
......@@ -78,7 +78,7 @@ public class ArrayGenTest extends CodegenTestCase {
public void testIterator () throws Exception {
loadText("fun box() { val x = Array<Int>(5, { it } ).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }");
// System.out.println(generateToText());
System.out.println(generateToText());
Method foo = generateFunction();
foo.invoke(null);
}
......
......@@ -33,7 +33,7 @@ public class ClassGenTest extends CodegenTestCase {
final Method[] methods = aClass.getDeclaredMethods();
// public int SimpleClass.foo()
// public jet.TypeInfo SimpleClass.getTypeInfo()
assertEquals(2, methods.length);
assertEquals(1, methods.length);
}
public void testArrayListInheritance() throws Exception {
......@@ -132,7 +132,8 @@ public class ClassGenTest extends CodegenTestCase {
}
public void testClassObjectMethod() throws Exception {
blackBoxFile("classes/classObjectMethod.jet");
// todo to be implemented after removal of type info
// blackBoxFile("classes/classObjectMethod.jet");
}
public void testClassObjectInterface() throws Exception {
......
......@@ -55,8 +55,9 @@ public class ForTestCompileStdlib {
File classesDir = new File(tmpDir, "classes");
compileKotlinPartOfStdlib(classesDir);
FileUtil.createParentDirs(new File(classesDir, "dummy"));
compileJavaPartOfStdlib(classesDir);
compileKotlinPartOfStdlib(classesDir);
FileOutputStream stdlibJar = new FileOutputStream(jarFile);
try {
......@@ -98,7 +99,7 @@ public class ForTestCompileStdlib {
private static void compileKotlinPartOfStdlib(File destdir) throws IOException {
// lame
KotlinCompiler.exec("-output", destdir.getPath(), "-src", "./stdlib/ktSrc");
KotlinCompiler.exec("-output", destdir.getPath(), "-src", "./stdlib/ktSrc", "-stdlib", destdir.getAbsolutePath());
}
private static List<File> javaFilesInDir(File dir) {
......
......@@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen;
import jet.IntRange;
import jet.Tuple2;
import jet.Tuple4;
import jet.TypeInfo;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
......@@ -513,7 +512,7 @@ public class NamespaceGenTest extends CodegenTestCase {
loadText("fun <E,D> E.foo(extra: java.util.List<D>) = #(1, \"foo\", this, extra)");
// System.out.println(generateToText());
final Method main = generateFunction();
Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO, Arrays.asList(10));
Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", Arrays.asList(10));
assertEquals(1, tuple4._1);
assertEquals("foo", tuple4._2);
assertEquals("aaa", tuple4._3);
......
......@@ -105,13 +105,13 @@ public class PatternMatchingTest extends CodegenTestCase {
Method foo = generateFunction();
final Object result;
try {
result = foo.invoke(null, new Tuple2<Integer, Integer>(null, 1, 2));
result = foo.invoke(null, new Tuple2<Integer, Integer>(1, 2));
} catch (Exception e) {
System.out.println(generateToText());
throw e;
}
assertEquals("one,two", result);
assertEquals("something", foo.invoke(null, new Tuple2<String, String>(null, "not", "tuple")));
assertEquals("something", foo.invoke(null, new Tuple2<String, String>("not", "tuple")));
}
// Commented for KT-621
......@@ -135,8 +135,8 @@ public class PatternMatchingTest extends CodegenTestCase {
public void testNames() throws Exception {
loadText("fun foo(x: #(Any, Any)) = when(x) { is #(val a is String, *) -> a; else -> \"something\" }");
Method foo = generateFunction();
assertEquals("JetBrains", foo.invoke(null, new Tuple2<String, String>(null, "JetBrains", "s.r.o.")));
assertEquals("something", foo.invoke(null, new Tuple2<Integer, Integer>(null, 1, 2)));
assertEquals("JetBrains", foo.invoke(null, new Tuple2<String, String>("JetBrains", "s.r.o.")));
assertEquals("something", foo.invoke(null, new Tuple2<Integer, Integer>(1, 2)));
}
public void testMultipleConditions() throws Exception {
......
......@@ -34,7 +34,7 @@ public class PropertyGenTest extends CodegenTestCase {
loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal");
final Field[] fields = aClass.getDeclaredFields();
assertEquals(2, fields.length); // $typeInfo, prop
assertEquals(1, fields.length); // prop
final Field field = fields[0];
assertEquals("prop", field.getName());
}
......
......@@ -19,6 +19,6 @@ package org.jetbrains.jet.codegen;
public class TupleGenTest extends CodegenTestCase {
public void testBasic() {
blackBoxFile("/tuples/basic.jet");
// System.out.println(generateToText());
System.out.println(generateToText());
}
}
......@@ -18,12 +18,12 @@ package org.jetbrains.jet.codegen;
import jet.JetObject;
import jet.TypeCastException;
import jet.TypeInfo;
import java.lang.reflect.Method;
/**
* @author yole
* @author alex.tkachman
*/
public class TypeInfoTest extends CodegenTestCase {
@Override
......@@ -31,28 +31,6 @@ public class TypeInfoTest extends CodegenTestCase {
return "typeInfo";
}
public void testGetTypeInfo() throws Exception {
loadFile();
Method foo = generateFunction();
JetObject jetObject = (JetObject) foo.invoke(null);
TypeInfo<?> typeInfo = jetObject.getTypeInfo();
assertNotNull(typeInfo);
}
public void testOneArgTypeinfo() throws Exception {
loadFile();
Method foo = generateFunction();
TypeInfo typeInfo = (TypeInfo) foo.invoke(null);
assertNotNull(typeInfo);
}
public void testNoArgTypeinfo() throws Exception {
loadText("fun foo() = typeinfo<Int>()");
Method foo = generateFunction();
TypeInfo typeInfo = (TypeInfo) foo.invoke(null);
assertSame(TypeInfo.INT_TYPE_INFO, typeInfo);
}
public void testAsSafeOperator() throws Exception {
loadText("fun foo(x: Any) = x as? Runnable");
Method foo = generateFunction();
......@@ -94,19 +72,22 @@ public class TypeInfoTest extends CodegenTestCase {
}
public void testIsWithGenericParameters() throws Exception {
loadFile();
Method foo = generateFunction();
assertFalse((Boolean) foo.invoke(null));
// todo: obsolete with typeinfo removal
// loadFile();
// Method foo = generateFunction();
// assertFalse((Boolean) foo.invoke(null));
}
public void testIsTypeParameter() throws Exception {
blackBoxFile("typeInfo/isTypeParameter.jet");
// todo: obsolete with typeinfo removal
// blackBoxFile("typeInfo/isTypeParameter.jet");
}
public void testAsSafeWithGenerics() throws Exception {
loadFile();
Method foo = generateFunction();
assertNull(foo.invoke(null));
// todo: obsolete with typeinfo removal
// loadFile();
// Method foo = generateFunction();
// assertNull(foo.invoke(null));
}
public void testAsInLoop() throws Exception {
......@@ -119,18 +100,22 @@ public class TypeInfoTest extends CodegenTestCase {
}
public void testNullability() throws Exception {
blackBoxFile("typeInfo/nullability.jet");
// todo: obsolete with typeinfo removal
// blackBoxFile("typeInfo/nullability.jet");
}
public void testGenericFunction() throws Exception {
blackBoxFile("typeInfo/genericFunction.jet");
// todo: obsolete with typeinfo removal
// blackBoxFile("typeInfo/genericFunction.jet");
}
public void testForwardTypeParameter() throws Exception {
blackBoxFile("typeInfo/forwardTypeParameter.jet");
// todo: obsolete with typeinfo removal
// blackBoxFile("typeInfo/forwardTypeParameter.jet");
}
public void testClassObjectInTypeInfo() throws Exception {
/*
loadFile();
// System.out.println(generateToText());
Method foo = generateFunction();
......@@ -139,6 +124,7 @@ public class TypeInfoTest extends CodegenTestCase {
final Object object = typeInfo.getClassObject();
final Method classObjFoo = object.getClass().getMethod("foo");
assertNotNull(classObjFoo);
*/
}
private Runnable newRunnable() {
......@@ -150,7 +136,8 @@ public class TypeInfoTest extends CodegenTestCase {
}
public void testKt259() throws Exception {
blackBoxFile("regressions/kt259.jet");
// todo: obsolete with typeinfo removal
// blackBoxFile("regressions/kt259.jet");
// System.out.println(generateToText());
}
......@@ -170,7 +157,8 @@ public class TypeInfoTest extends CodegenTestCase {
}
public void testkt1113() throws Exception {
blackBoxFile("regressions/kt1113.kt");
System.out.println(generateToText());
// todo: obsolete with typeinfo removal
// blackBoxFile("regressions/kt1113.kt");
// System.out.println(generateToText());
}
}
......@@ -78,7 +78,7 @@ public class VarArgTest extends CodegenTestCase {
public void testArrayT () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements");
// System.out.println(generateToText());
System.out.println(generateToText());
final Method main = generateFunction("test");
Object res = main.invoke(null);
assertTrue(((Integer[])res).length == 2);
......
......@@ -108,8 +108,9 @@ public class JetTypeCheckerTest extends JetLiteFixture {
}
public void testTypeInfo() throws Exception {
assertType("typeinfo<Int>", "TypeInfo<Int>");
assertType("typeinfo<TypeInfo<Int>>", "TypeInfo<TypeInfo<Int>>");
// todo: obsolete since removal of typeinfo
// assertType("typeinfo<Int>", "TypeInfo<Int>");
// assertType("typeinfo<TypeInfo<Int>>", "TypeInfo<TypeInfo<Int>>");
}
public void testJumps() throws Exception {
......
......@@ -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();
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册