public ReplInterpreter( @NotNull Disposable disposable, @NotNull CompilerConfiguration configuration) { jetCoreEnvironment = JetCoreEnvironment.createForProduction(disposable, configuration); Project project = jetCoreEnvironment.getProject(); trace = new BindingTraceContext(); module = AnalyzerFacadeForJVM.createJavaModule("<repl>"); TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.createForLocalDeclarations( new LockBasedStorageManager(), new ExceptionTracker(), // dummy Predicates.<PsiFile>alwaysTrue()); injector = new InjectorForTopDownAnalyzerForJvm( project, topDownAnalysisParameters, trace, module, MemberFilter.ALWAYS_TRUE); topDownAnalysisContext = new TopDownAnalysisContext(topDownAnalysisParameters); module.addFragmentProvider(SOURCES, injector.getTopDownAnalyzer().getPackageFragmentProvider()); module.addFragmentProvider( BUILT_INS, KotlinBuiltIns.getInstance().getBuiltInsModule().getPackageFragmentProvider()); module.addFragmentProvider( BINARIES, injector.getJavaDescriptorResolver().getPackageFragmentProvider()); List<URL> classpath = Lists.newArrayList(); for (File file : configuration.getList(JVMConfigurationKeys.CLASSPATH_KEY)) { try { classpath.add(file.toURI().toURL()); } catch (MalformedURLException e) { throw UtilsPackage.rethrow(e); } } classLoader = new ReplClassLoader(new URLClassLoader(classpath.toArray(new URL[0]))); }
/** * Creates new instance of {@link JetCoreEnvironment} instance using the arguments specified. * * @param stdlib path to "kotlin-runtime.jar", only used if not null and not empty * @param classpath compilation classpath, only used if not null and not empty * @param sourceRoots * @param enableInline * @param enableOptimization * @return compile environment instance */ private JetCoreEnvironment env( String stdlib, String[] classpath, String[] externalAnnotationsPath, String[] sourceRoots, boolean enableInline, boolean enableOptimization) { CompilerConfiguration configuration = createConfiguration( stdlib, classpath, externalAnnotationsPath, sourceRoots, enableInline, enableOptimization); return JetCoreEnvironment.createForProduction(Disposer.newDisposable(), configuration); }