Search in sources :

Example 1 with KtWhenEntry

use of org.jetbrains.kotlin.psi.KtWhenEntry in project kotlin by JetBrains.

the class SwitchCodegen method generateEntries.

protected void generateEntries() {
    // resolving entries' entryLabels and generating entries' code
    Iterator<Label> entryLabelsIterator = entryLabels.iterator();
    for (KtWhenEntry entry : expression.getEntries()) {
        v.visitLabel(entryLabelsIterator.next());
        FrameMap.Mark mark = codegen.myFrameMap.mark();
        codegen.gen(entry.getExpression(), resultType);
        mark.dropTo();
        if (!entry.isElse()) {
            v.goTo(endLabel);
        }
    }
}
Also used : KtWhenEntry(org.jetbrains.kotlin.psi.KtWhenEntry) FrameMap(org.jetbrains.kotlin.codegen.FrameMap) Label(org.jetbrains.org.objectweb.asm.Label)

Example 2 with KtWhenEntry

use of org.jetbrains.kotlin.psi.KtWhenEntry in project kotlin by JetBrains.

the class SwitchCodegen method prepareConfiguration.

/**
     * Sets up transitionsTable and maybe something else needed in a special case
     * Behaviour may be changed by overriding processConstant
     */
private void prepareConfiguration() {
    for (KtWhenEntry entry : expression.getEntries()) {
        Label entryLabel = new Label();
        for (ConstantValue<?> constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext, codegen.getState().getShouldInlineConstVals())) {
            if (constant instanceof NullValue)
                continue;
            processConstant(constant, entryLabel);
        }
        if (entry.isElse()) {
            elseLabel = entryLabel;
        }
        entryLabels.add(entryLabel);
    }
}
Also used : KtWhenEntry(org.jetbrains.kotlin.psi.KtWhenEntry) NullValue(org.jetbrains.kotlin.resolve.constants.NullValue) Label(org.jetbrains.org.objectweb.asm.Label)

Aggregations

KtWhenEntry (org.jetbrains.kotlin.psi.KtWhenEntry)2 Label (org.jetbrains.org.objectweb.asm.Label)2 FrameMap (org.jetbrains.kotlin.codegen.FrameMap)1 NullValue (org.jetbrains.kotlin.resolve.constants.NullValue)1