array code gen rewrite and work in progress on outer type info

This commit is contained in:
Alex Tkachman
2011-09-29 12:55:35 +03:00
parent b40b7ada4d
commit ea9e1bee85
31 changed files with 1035 additions and 232 deletions
+12 -8
View File
@@ -8,18 +8,22 @@ trait javaUtilIterator<T> : java.util.Iterator<T> {
}
}
class MyIterator<T>(val array : ReadOnlyArray<T>) : javaUtilIterator<T> {
private var index = 0
override fun hasNext() : Boolean = index < array.size
override fun next() : T = array.get(index++)
}
trait ReadOnlyArray<out T> : ISized, java.lang.Iterable<T> {
fun get(index : Int) : T
class MyIterator() : javaUtilIterator<T> {
private var index = 0
override fun hasNext() : Boolean = index < size
override fun next() : T = get(index++)
class Default {
fun check(v: Any) = v is T
}
override fun iterator() : java.util.Iterator<T> = MyIterator()
override fun iterator() : java.util.Iterator<T> = MyIterator<T>(this)
}
trait WriteOnlyArray<in T> : ISized {
@@ -53,4 +57,4 @@ fun box() : String {
System.out?.println(el)
}
return "OK"
}
}