Search in sources :

Example 1 with ScriptContext

use of org.jetbrains.kotlin.codegen.context.ScriptContext in project kotlin by JetBrains.

the class ScriptCodegen method createScriptCodegen.

public static ScriptCodegen createScriptCodegen(@NotNull KtScript declaration, @NotNull GenerationState state, @NotNull CodegenContext parentContext) {
    BindingContext bindingContext = state.getBindingContext();
    ScriptDescriptor scriptDescriptor = bindingContext.get(BindingContext.SCRIPT, declaration);
    assert scriptDescriptor != null;
    Type classType = state.getTypeMapper().mapType(scriptDescriptor);
    ClassBuilder builder = state.getFactory().newVisitor(JvmDeclarationOriginKt.OtherOrigin(declaration, scriptDescriptor), classType, declaration.getContainingFile());
    List<ScriptDescriptor> earlierScripts = state.getReplSpecific().getEarlierScriptsForReplInterpreter();
    ScriptContext scriptContext = parentContext.intoScript(scriptDescriptor, earlierScripts == null ? Collections.<ScriptDescriptor>emptyList() : earlierScripts, scriptDescriptor, state.getTypeMapper());
    return new ScriptCodegen(declaration, state, scriptContext, builder);
}
Also used : Type(org.jetbrains.org.objectweb.asm.Type) ScriptContext(org.jetbrains.kotlin.codegen.context.ScriptContext) BindingContext(org.jetbrains.kotlin.resolve.BindingContext) ScriptDescriptor(org.jetbrains.kotlin.descriptors.ScriptDescriptor)

Aggregations

ScriptContext (org.jetbrains.kotlin.codegen.context.ScriptContext)1 ScriptDescriptor (org.jetbrains.kotlin.descriptors.ScriptDescriptor)1 BindingContext (org.jetbrains.kotlin.resolve.BindingContext)1 Type (org.jetbrains.org.objectweb.asm.Type)1