work in progress on extra type info in bytecode

This commit is contained in:
Alex Tkachman
2011-12-06 09:25:59 +02:00
parent 627c2186e9
commit 36c0ab6642
11 changed files with 211 additions and 36 deletions
+27
View File
@@ -0,0 +1,27 @@
package jet.typeinfo;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for method
*
* The fact of receiver presence must be deducted from presence of 'this$receiver' parameter
*
* @author alex.tkachman
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface JetMethod {
/**
* @return type projections or empty
*/
JetTypeProjection[] returnTypeProjections() default {};
/**
* @return is this type returnTypeNullable
*/
boolean nullableReturnType() default false;
}
+35
View File
@@ -0,0 +1,35 @@
package jet.typeinfo;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for parameters
*
* @author alex.tkachman
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JetParameter {
/**
* @return name of parameter
*/
String name ();
/**
* @return type projections or empty
*/
JetTypeProjection[] typeProjections() default {};
/**
* @return is this type nullable
*/
boolean nullable () default false;
/**
* @return if this parameter has default value
*/
boolean hasDefaultValue () default false;
}
@@ -0,0 +1,20 @@
package jet.typeinfo;
/**
* @author alex.tkachman
*/
public @interface JetTypeDescriptor{
//
// case of type parameter
//
String varName() default "";
boolean reified () default true;
TypeInfoVariance variance() default TypeInfoVariance.INVARIANT;
int [] upperBounds() default {};
//
// case of real type
//
Class javaClass() default Object.class;
JetTypeProjection [] projections() default {};
}
@@ -6,10 +6,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for parameters
*
* @author alex.tkachman
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JetParameterName {
String value ();
public @interface JetTypeParameter {
/**
* @return name of parameter
*/
String name();
}
@@ -0,0 +1,20 @@
package jet.typeinfo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author alex.tkachman
*/
@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
*/
int typeDescriptorIndex();
}
+4 -4
View File
@@ -60,7 +60,7 @@ public abstract class TypeInfo<T> implements JetObject {
// @NotNull
@Override
public TypeInfoVariance getVariance() {
return TypeInfoVariance.IN_VARIANCE;
return TypeInfoVariance.IN;
}
};
}
@@ -70,7 +70,7 @@ public abstract class TypeInfo<T> implements JetObject {
// @NotNull
@Override
public TypeInfoVariance getVariance() {
return TypeInfoVariance.OUT_VARIANCE;
return TypeInfoVariance.OUT;
}
};
}
@@ -606,11 +606,11 @@ public abstract class TypeInfo<T> implements JetObject {
private TypeInfoVariance parseVariance() {
if(string[cur] == 'i' && string[cur+1] == 'n' && string[cur+2] == ' ' ) {
cur += 3;
return TypeInfoVariance.IN_VARIANCE;
return TypeInfoVariance.IN;
}
else if (string[cur] == 'o' && string[cur+1] == 'u' && string[cur+2] == 't' && string[cur+3] == ' ') {
cur += 4;
return TypeInfoVariance.OUT_VARIANCE;
return TypeInfoVariance.OUT;
}
else {
return TypeInfoVariance.INVARIANT;
@@ -5,8 +5,8 @@ package jet.typeinfo;
*/
public enum TypeInfoVariance {
INVARIANT("") ,
IN_VARIANCE("in"),
OUT_VARIANCE("out");
IN("in"),
OUT("out");
private final String label;