Initial design for the TypeInfo class
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
namespace jet.lang
|
namespace jet
|
||||||
|
|
||||||
|
class TypeInfo<T> {
|
||||||
|
fun isSubtypeOf(other : TypeInfo<*>) : Boolean
|
||||||
|
fun isInstance(obj : Any?) : Boolean
|
||||||
|
}
|
||||||
|
|
||||||
class Iterator<out T> {
|
class Iterator<out T> {
|
||||||
fun next() : T
|
fun next() : T
|
||||||
@@ -63,7 +63,7 @@ public class JetStandardLibrary {
|
|||||||
|
|
||||||
private JetStandardLibrary(@NotNull Project project) {
|
private JetStandardLibrary(@NotNull Project project) {
|
||||||
// TODO : review
|
// TODO : review
|
||||||
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/lang/Library.jet");
|
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/Library.jet");
|
||||||
try {
|
try {
|
||||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||||
JetFile file = (JetFile) PsiFileFactory.getInstance(project).createFileFromText("Library.jet",
|
JetFile file = (JetFile) PsiFileFactory.getInstance(project).createFileFromText("Library.jet",
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package jet;
|
||||||
|
|
||||||
|
import jet.typeinfo.TypeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface JetObject {
|
||||||
|
TypeInfo<?> getTypeInfo();
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package jet.typeinfo;
|
||||||
|
|
||||||
|
import jet.JetObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class TypeInfo<T> implements JetObject {
|
||||||
|
|
||||||
|
private TypeInfo<?> typeInfo;
|
||||||
|
private final TypeInfo<?> typeArgument;
|
||||||
|
|
||||||
|
private TypeInfo(TypeInfo<?> typeArgument) {
|
||||||
|
this.typeArgument = typeArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInstance(Object obj) {
|
||||||
|
throw new UnsupportedOperationException(); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSubtypeOf(TypeInfo<?> other) {
|
||||||
|
throw new UnsupportedOperationException(); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user