From 5d44ecd2ca05bd6b9ce90c2381e933f3eb469572 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Thu, 15 Sep 2016 17:30:33 +0300 Subject: [PATCH] fix source passing to frontend :) and binding from analyzing result, dumping ir compiler:) --- .../org/jetbrains/kotlin/cli/student/K2StudentLlvm.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/experiments/student-backend/src/org/jetbrains/kotlin/cli/student/K2StudentLlvm.kt b/experiments/student-backend/src/org/jetbrains/kotlin/cli/student/K2StudentLlvm.kt index 75f8494e51a..869d7e00bb7 100644 --- a/experiments/student-backend/src/org/jetbrains/kotlin/cli/student/K2StudentLlvm.kt +++ b/experiments/student-backend/src/org/jetbrains/kotlin/cli/student/K2StudentLlvm.kt @@ -13,11 +13,16 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.config.addKotlinSourceRoot +import org.jetbrains.kotlin.ir.util.DumpIrTreeVisitor +import org.jetbrains.kotlin.ir.util.RenderIrElementVisitor import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi2ir.Psi2IrConfiguration import org.jetbrains.kotlin.psi2ir.Psi2IrTranslator import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM +import org.jetbrains.kotlin.utils.Printer +import java.lang.System.out /** * Created by minamoto on 14/09/16. @@ -28,6 +33,7 @@ class K2StudentLlvm : CLICompiler() { override fun doExecute(arguments: K2StudentLlvmArguments, configuration: CompilerConfiguration, rootDisposable: Disposable): ExitCode { configuration.put(CommonConfigurationKeys.MODULE_NAME, /*arguments.moduleName ?: */ JvmAbi.DEFAULT_MODULE_NAME) + configuration.addKotlinSourceRoot(arguments.freeArgs.get(0)) val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, emptyList()) val collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector) @@ -55,7 +61,9 @@ class K2StudentLlvm : CLICompiler() { val translator = Psi2IrTranslator(Psi2IrConfiguration(false)) val module = translator.generateModule(analyzerWithCompilerReport.analysisResult.moduleDescriptor, environment.getSourceFiles(), - BindingContext.EMPTY) + analyzerWithCompilerReport.analysisResult.bindingContext) + + module.accept(DumpIrTreeVisitor(out), "") return ExitCode.OK }