Ranges support. (#73)
This commit is contained in:
+8
-2
@@ -224,6 +224,11 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitConstructor(constructorDeclaration: IrConstructor) {
|
||||
if (constructorDeclaration.descriptor.containingDeclaration.isIntrinsic) {
|
||||
// Do not generate any ctors for intrinsic classes.
|
||||
return
|
||||
}
|
||||
|
||||
codegen.prologue(constructorDeclaration)
|
||||
val constructorDescriptor = constructorDeclaration.descriptor
|
||||
val classDescriptor = DescriptorUtils.getContainingClass(constructorDescriptor)
|
||||
@@ -389,8 +394,9 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
return
|
||||
}
|
||||
|
||||
if (declaration.descriptor.isIntrinsic) {
|
||||
// do not generate any code for intrinsic classes as they require special handling
|
||||
if (KotlinBuiltIns.isUnit(declaration.descriptor.defaultType)) {
|
||||
// Do not generate any code for Unit.
|
||||
// TODO: Unit has toString() operation, which we may want to support.
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -574,3 +574,8 @@ task unreachable1(type: RunKonanTest) {
|
||||
goldValue = "1\n"
|
||||
source = "codegen/controlflow/unreachable1.kt"
|
||||
}
|
||||
|
||||
task range0(type: RunKonanTest) {
|
||||
goldValue = "123\nabcd\n"
|
||||
source = "runtime/collections/range0.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun main(args : Array<String>) {
|
||||
for (i in 1..3) print(i)
|
||||
println()
|
||||
for (i in 'a'..'d') print(i)
|
||||
println()
|
||||
}
|
||||
Reference in New Issue
Block a user