Update after rebase on master.

This commit is contained in:
Dmitry Petrov
2016-10-11 13:21:12 +03:00
parent 6c9b8792c7
commit 703110c0e2
4 changed files with 133 additions and 19 deletions
@@ -27,10 +27,6 @@ import org.jetbrains.kotlin.psi.KtFile
object JvmIrCodegenFactory : CodegenFactory {
override fun createPackageCodegen(state: GenerationState, files: Collection<KtFile>, fqName: FqName, registry: PackagePartRegistry): PackageCodegen {
val impl = PackageCodegenImpl(state, files, fqName, registry)
// val psi2ir = Psi2IrTranslator()
// val psi2irContext = psi2ir.createGeneratorContext(state.module, state.bindingContext)
// val jvmBackendContext = JvmBackendFacade.createJvmBackendContext(psi2ir, state)
return object : PackageCodegen {
override fun generate(errorHandler: CompilationErrorHandler) {
@@ -38,7 +34,7 @@ object JvmIrCodegenFactory : CodegenFactory {
}
override fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: PackageContext) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
TODO()
}
override fun getPackageFragment(): PackageFragmentDescriptor {
@@ -48,6 +44,6 @@ object JvmIrCodegenFactory : CodegenFactory {
}
override fun createMultifileClassCodegen(state: GenerationState, files: Collection<KtFile>, fqName: FqName, registry: PackagePartRegistry): MultifileClassCodegen {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
TODO()
}
}
@@ -100,8 +100,8 @@ class LoopExpressionGenerator(statementGenerator: StatementGenerator) : Statemen
fun generateForLoop(ktFor: KtForExpression): IrExpression {
val ktLoopParameter = ktFor.loopParameter
val ktLoopDestructuringParameter = ktFor.destructuringParameter
if (ktLoopParameter == null && ktLoopDestructuringParameter == null) {
val ktLoopDestructuringDeclaration = ktFor.destructuringDeclaration
if (ktLoopParameter == null && ktLoopDestructuringDeclaration == null) {
throw AssertionError("Either loopParameter or destructuringParameter should be present:\n${ktFor.text}")
}
@@ -137,18 +137,19 @@ class LoopExpressionGenerator(statementGenerator: StatementGenerator) : Statemen
val nextCall = statementGenerator.pregenerateCall(nextResolvedCall)
nextCall.setExplicitReceiverValue(iteratorValue)
val irNextCall = callGenerator.generateCall(ktLoopRange, nextCall, IrStatementOrigin.FOR_LOOP_NEXT)
val irLoopParameter = if (ktLoopParameter != null) {
val loopParameterDescriptor = getOrFail(BindingContext.VALUE_PARAMETER, ktLoopParameter)
IrVariableImpl(ktLoopParameter.startOffset, ktLoopParameter.endOffset, IrDeclarationOrigin.DEFINED,
loopParameterDescriptor, irNextCall)
}
else {
scope.createTemporaryVariable(irNextCall, "loop_parameter")
}
val irLoopParameter =
if (ktLoopParameter != null && ktLoopDestructuringDeclaration == null) {
val loopParameterDescriptor = getOrFail(BindingContext.VALUE_PARAMETER, ktLoopParameter)
IrVariableImpl(ktLoopParameter.startOffset, ktLoopParameter.endOffset, IrDeclarationOrigin.DEFINED,
loopParameterDescriptor, irNextCall)
}
else {
scope.createTemporaryVariable(irNextCall, "loop_parameter")
}
irInnerBody.statements.add(irLoopParameter)
if (ktLoopDestructuringParameter != null) {
statementGenerator.declareComponentVariablesInBlock(ktLoopDestructuringParameter, irInnerBody, VariableLValue(irLoopParameter))
if (ktLoopDestructuringDeclaration != null) {
statementGenerator.declareComponentVariablesInBlock(ktLoopDestructuringDeclaration, irInnerBody, VariableLValue(irLoopParameter))
}
if (ktForBody != null) {