Example usage for org.objectweb.asm MethodVisitor visitIincInsn

List of usage examples for org.objectweb.asm MethodVisitor visitIincInsn

Introduction

In this page you can find the example usage for org.objectweb.asm MethodVisitor visitIincInsn.

Prototype

public void visitIincInsn(final int var, final int increment) 

Source Link

Document

Visits an IINC instruction.

Usage

From source file:org.teavm.flavour.regex.bytecode.MatcherClassBuilder.java

License:Apache License

private void generateTransition(MethodVisitor mv, DfaState source, DfaState target) {
    if (source.isTerminal() && source != target) {
        mv.visitVarInsn(Opcodes.ALOAD, 0);
        mv.visitInsn(Opcodes.ICONST_M1);
        mv.visitFieldInsn(Opcodes.PUTFIELD, className, "domain", "I");
    }/*from w  w w. jav a 2  s.c o m*/
    mv.visitIntInsn(Opcodes.SIPUSH, target.getIndex());
    mv.visitVarInsn(Opcodes.ISTORE, 5);
    if (target.isTerminal() && source != target) {
        mv.visitVarInsn(Opcodes.ALOAD, 0);
        mv.visitIntInsn(Opcodes.SIPUSH, target.getDomains()[0]);
        mv.visitFieldInsn(Opcodes.PUTFIELD, className, "domain", "I");
    }

    debug(mv, "DFA: " + source.getIndex() + " -> " + target.getIndex() + " "
            + Arrays.toString(target.getDomains()));
    if (target.isTerminal()) {
        Label noReluctant = new Label();
        mv.visitVarInsn(Opcodes.ILOAD, 4);
        mv.visitJumpInsn(Opcodes.IFEQ, noReluctant);
        mv.visitIincInsn(2, 1);
        debug(mv, "DFA reached terminal state");
        mv.visitJumpInsn(Opcodes.GOTO, saveLabel);
        mv.visitLabel(noReluctant);
    }
    if (source.getIndex() + 1 == target.getIndex()) {
        mv.visitIincInsn(2, 1);
        generateLengthGuard(mv);
        mv.visitJumpInsn(Opcodes.GOTO, stateLabels[target.getIndex()]);
    } else {
        mv.visitJumpInsn(Opcodes.GOTO, continueLabel);
    }
}