GenerationState is constructed with BindingContext, not full AnalyzeExhaust

This commit is contained in:
Andrey Breslav
2012-12-17 17:37:34 +04:00
parent 39b6c53ef3
commit b5aa44ae49
7 changed files with 15 additions and 15 deletions
@@ -18,7 +18,6 @@ package org.jetbrains.jet.codegen.state;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.codegen.*;
import org.jetbrains.jet.codegen.binding.CodegenBinding; import org.jetbrains.jet.codegen.binding.CodegenBinding;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
@@ -67,15 +66,15 @@ public class GenerationState {
private final boolean generateNotNullParamAssertions; private final boolean generateNotNullParamAssertions;
public GenerationState(Project project, ClassBuilderFactory builderFactory, AnalyzeExhaust analyzeExhaust, List<JetFile> files) { public GenerationState(Project project, ClassBuilderFactory builderFactory, BindingContext bindingContext, List<JetFile> files) {
this(project, builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED, true, false); this(project, builderFactory, Progress.DEAF, bindingContext, files, BuiltinToJavaTypesMapping.ENABLED, true, false);
} }
public GenerationState( public GenerationState(
@NotNull Project project, @NotNull Project project,
ClassBuilderFactory builderFactory, ClassBuilderFactory builderFactory,
@NotNull Progress progress, @NotNull Progress progress,
@NotNull AnalyzeExhaust exhaust, @NotNull BindingContext bindingContext,
@NotNull List<JetFile> files, @NotNull List<JetFile> files,
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping, @NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
boolean generateNotNullAssertions, boolean generateNotNullAssertions,
@@ -86,8 +85,8 @@ public class GenerationState {
this.files = files; this.files = files;
this.classBuilderMode = builderFactory.getClassBuilderMode(); this.classBuilderMode = builderFactory.getClassBuilderMode();
bindingTrace = new DelegatingBindingTrace(exhaust.getBindingContext(), "trace in GenerationState"); bindingTrace = new DelegatingBindingTrace(bindingContext, "trace in GenerationState");
bindingContext = bindingTrace.getBindingContext(); this.bindingContext = bindingTrace.getBindingContext();
this.typeMapper = new JetTypeMapper(bindingTrace, builtinToJavaTypesMapping == BuiltinToJavaTypesMapping.ENABLED, classBuilderMode); this.typeMapper = new JetTypeMapper(bindingTrace, builtinToJavaTypesMapping == BuiltinToJavaTypesMapping.ENABLED, classBuilderMode);
@@ -346,7 +346,7 @@ public class KotlinToJVMBytecodeCompiler {
} }
}; };
GenerationState generationState = new GenerationState( GenerationState generationState = new GenerationState(
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust, environment.getSourceFiles(), project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED), configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false), configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false) configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false)
@@ -224,8 +224,9 @@ public class ReplInterpreter {
earierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassName())); earierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassName()));
} }
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), injector.getModuleConfiguration()).getBindingContext();
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false),
AnalyzeExhaust.success(trace.getBindingContext(), injector.getModuleConfiguration()), Collections.singletonList(psiFile)); bindingContext, Collections.singletonList(psiFile));
generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassName, earierScripts, generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassName, earierScripts,
CompilationErrorHandler.THROW_EXCEPTION); CompilationErrorHandler.THROW_EXCEPTION);
@@ -216,7 +216,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
} }
try { try {
GenerationState state = new GenerationState(project, builderFactory, exhaust, Collections.singletonList(file)); GenerationState state = new GenerationState(project, builderFactory, exhaust.getBindingContext(), Collections.singletonList(file));
GenerationStrategy strategy = new LightClassGenerationStrategy(this, stubStack, answer); GenerationStrategy strategy = new LightClassGenerationStrategy(this, stubStack, answer);
strategy.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); strategy.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
@@ -358,7 +358,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext()); AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
CompilerConfiguration configuration = environment.getConfiguration(); CompilerConfiguration configuration = environment.getConfiguration();
GenerationState state = new GenerationState( GenerationState state = new GenerationState(
environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust, files.getPsiFiles(), environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust.getBindingContext(), files.getPsiFiles(),
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED), configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true), configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true) configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true)
@@ -58,7 +58,7 @@ public class GenerationUtils {
@NotNull @NotNull
public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) { public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) {
analyzeExhaust.throwIfError(); analyzeExhaust.throwIfError();
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust, files); GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust.getBindingContext(), files);
GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
return state; return state;
} }
@@ -87,11 +87,11 @@ public class BytecodeToolwindow extends JPanel implements Disposable {
GenerationState state; GenerationState state;
try { try {
AnalyzeExhaust binding = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile); AnalyzeExhaust exhaust = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
if (binding.isError()) { if (exhaust.isError()) {
return printStackTraceToString(binding.getError()); return printStackTraceToString(exhaust.getError());
} }
state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEXT, binding, Collections.singletonList(jetFile)); state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEXT, exhaust.getBindingContext(), Collections.singletonList(jetFile));
GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
} }
catch (ProcessCanceledException e) { catch (ProcessCanceledException e) {