Example usage for org.objectweb.asm Opcodes IFNONNULL

List of usage examples for org.objectweb.asm Opcodes IFNONNULL

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes IFNONNULL.

Prototype

int IFNONNULL

To view the source code for org.objectweb.asm Opcodes IFNONNULL.

Click Source Link

Usage

From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInlinerTest.java

License:Open Source License

/**
 * Tests that constantIfInliner is working correctly.
 * /*from   ww  w  . ja  va  2  s  .  co m*/
 * Input is
 * 
 * <pre>
 * if(a==null)
 * ...
 * </pre>
 * 
 * where a is null
 * 
 * @throws JBOPClassException
 *           the jBOP class exception
 */
@Test
public void testConstantIfInlinerIFNONNULL() throws JBOPClassException {
    // INIT
    final LabelNode label = new LabelNode();
    builder.addInsn(new InsnNode(Opcodes.ACONST_NULL)).//
            addInsn(new JumpInsnNode(Opcodes.IFNONNULL, label)).//
            addInsn(new InsnNode(Opcodes.NOP)).//
            addInsn(label).//
            addInsn(new InsnNode(Opcodes.RETURN));

    // RUN
    assertEquals(5, method.instructions.size());
    final InsnList optimized = constantIfInliner.optimize(method.instructions, method);

    // ASSERT
    assertEquals(3, optimized.size());
    assertEquals(Opcodes.NOP, optimized.get(0).getOpcode());
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

License:Open Source License

/**
 * Returns true if node is an one-param-if-Statement.
 * /* w w w .  jav a2 s .c  o  m*/
 * @param node
 *          the node
 * @return true if node is one value if
 */
public static boolean isOneValueIf(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    if (node.getOpcode() == Opcodes.IFNULL) {
        return true;
    }
    if (node.getOpcode() == Opcodes.IFNONNULL) {
        return true;
    }
    if (node.getOpcode() >= Opcodes.IFEQ && node.getOpcode() <= Opcodes.IFLE) {
        return true;
    }
    return false;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction.java

License:Open Source License

@Override
public String toString() {
    String condition;/*from w w  w.  j  a  v  a  2 s. c om*/
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.label;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction2.java

License:Open Source License

@Override
public String toString() {
    String condition;/*w ww .j a  v  a  2 s.c om*/
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.target;
}

From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java

License:BSD License

@Override
public void visitJumpInsn(final int opcode, final Label label) {
    mv.visitJumpInsn(opcode, label);/*from   w w w.  j a v  a  2s.c om*/
    switch (opcode) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        this.stackFrame.pop();
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        this.stackFrame.pop();
        this.stackFrame.pop();
        break;
    case Opcodes.JSR:
        this.stackFrame.push(OTHER);
        break;
    }
    addBranch(label);
}

From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java

License:Open Source License

private void interpret(JumpInsnNode insn, FrameState frame, BBInfo block) {
    //All JumpInsnNodes have a target.  Find it.
    BBInfo target = blockByInsn(insn.label);
    assert target != null;

    if (insn.getOpcode() == Opcodes.GOTO) {
        block.block.instructions().add(new JumpInst(target.block));
        return;/*w  ww  .  j a  v a  2  s  .c  o  m*/
    } else if (insn.getOpcode() == Opcodes.JSR)
        throw new UnsupportedOperationException("jsr not supported; upgrade to Java 6-era class files");

    //Remaining opcodes are branches.
    BBInfo fallthrough = blocks.get(blocks.indexOf(block) + 1);
    BranchInst.Sense sense = OPCODE_TO_SENSE.get(insn.getOpcode());
    //The second operand may come from the stack or may be a constant 0 or null.
    Value right;
    switch (insn.getOpcode()) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        right = module.constants().getConstant(0);
        break;
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        right = module.constants().getNullConstant();
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        right = frame.stack.pop();
        break;
    default:
        throw new AssertionError("Can't happen! Branch opcode missing? " + insn.getOpcode());
    }
    //First operand always comes from the stack.
    Value left = frame.stack.pop();
    block.block.instructions().add(new BranchInst(left, sense, right, target.block, fallthrough.block));
}

From source file:edu.umd.cs.guitar.testcase.plugin.edg.ClassDBVisitor.java

License:Open Source License

@Override
public void visitJumpInsn(int opcode, Label label) {
    currentMethod.setEmpty(false);//from   ww w.ja  v a2  s.c o  m
    currentMethod.setEmpty(false);
    switch (opcode) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        //      case Opcodes.GOTO:
        //      case Opcodes.JSR:
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        // add all label reads/writes as condition reads/writes
        currentMethod.getConditionReads().addAll(labelReads);
        currentMethod.getConditionWrites().addAll(labelWrites);
        break;
    }
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

/**
 * Generate the required Java code to load one parameter for
 * the syscall function from the CPU registers.
 *
 * The following code is generated based on the parameter type:
 * Processor: parameterValue = RuntimeContext.processor
 * int:       parameterValue = cpu.gpr[paramIndex++]
 * float:     parameterValue = cpu.fpr[paramFloatIndex++]
 * long:      parameterValue = (cpu.gpr[paramIndex++] & 0xFFFFFFFFL) + ((long) cpu.gpr[paramIndex++]) << 32)
 * boolean:   parameterValue = cpu.gpr[paramIndex++]
 * TPointer,/*from w ww. j  av a 2s. c  om*/
 * TPointer8,
 * TPointer16,
 * TPointer32,
 * TPointer64,
 * TErrorPointer32:
 *            if (checkMemoryAccess()) {
 *                if (canBeNullParam && address == 0) {
 *                    goto addressGood;
 *                }
 *                if (RuntimeContext.checkMemoryPointer(address)) {
 *                    goto addressGood;
 *                }
 *                cpu.gpr[_v0] = SceKernelErrors.ERROR_INVALID_POINTER;
 *                pop all the parameters already prepared on the stack;
 *                goto afterSyscall;
 *                addressGood:
 *            }
 *            <parameterType> pointer = new <parameterType>(address);
 *            if (parameterType == TErrorPointer32.class) {
 *                parameterReader.setHasErrorPointer(true);
 *                localVar[LOCAL_ERROR_POINTER] = pointer;
 *            }
 *            parameterValue = pointer
 * HLEUidClass defined in annotation:
 *            <parameterType> uidObject = HLEUidObjectMapping.getObject("<parameterType>", uid);
 *            if (uidObject == null) {
 *                cpu.gpr[_v0] = errorValueOnNotFound;
 *                pop all the parameters already prepared on the stack;
 *                goto afterSyscall;
 *            }
 *            parameterValue = uidObject
 *
 * And then common for all the types:
 *            try {
 *                parameterValue = <module>.<methodToCheck>(parameterValue);
 *            } catch (SceKernelErrorException e) {
 *                goto catchSceKernelErrorException;
 *            }
 *            push parameterValue on stack
 *
 * @param parameterReader               the current parameter state
 * @param func                          the syscall function
 * @param parameterType                 the type of the parameter
 * @param afterSyscallLabel             the Label pointing after the call to the syscall function
 * @param catchSceKernelErrorException  the Label pointing to the SceKernelErrorException catch handler
 */
private void loadParameter(CompilerParameterReader parameterReader, HLEModuleFunction func,
        Class<?> parameterType, Annotation[] parameterAnnotations, Label afterSyscallLabel,
        Label catchSceKernelErrorException) {
    if (parameterType == Processor.class) {
        loadProcessor();
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == CpuState.class) {
        loadCpu();
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == int.class) {
        parameterReader.loadNextInt();
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == float.class) {
        parameterReader.loadNextFloat();
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == long.class) {
        parameterReader.loadNextLong();
        parameterReader.incrementCurrentStackSize(2);
    } else if (parameterType == boolean.class) {
        parameterReader.loadNextInt();
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == String.class) {
        parameterReader.loadNextInt();

        int maxLength = 16 * 1024;
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof StringInfo) {
                StringInfo stringInfo = ((StringInfo) parameterAnnotation);
                maxLength = stringInfo.maxLength();
                break;
            }
        }
        loadImm(maxLength);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "readStringNZ",
                "(II)" + Type.getDescriptor(String.class));
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == PspString.class) {
        parameterReader.loadNextInt();

        int maxLength = 16 * 1024;
        boolean canBeNull = false;
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof StringInfo) {
                StringInfo stringInfo = ((StringInfo) parameterAnnotation);
                maxLength = stringInfo.maxLength();
            }
            if (parameterAnnotation instanceof CanBeNull) {
                canBeNull = true;
            }
        }
        loadImm(maxLength);
        loadImm(canBeNull);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "readPspStringNZ",
                "(IIZ)" + Type.getDescriptor(PspString.class));
        parameterReader.incrementCurrentStackSize();
    } else if (parameterType == TPointer.class || parameterType == TPointer8.class
            || parameterType == TPointer16.class || parameterType == TPointer32.class
            || parameterType == TPointer64.class || parameterType == TErrorPointer32.class) {
        // if (checkMemoryAccess()) {
        //     if (canBeNullParam && address == 0) {
        //         goto addressGood;
        //     }
        //     if (RuntimeContext.checkMemoryPointer(address)) {
        //         goto addressGood;
        //     }
        //     cpu.gpr[_v0] = SceKernelErrors.ERROR_INVALID_POINTER;
        //     pop all the parameters already prepared on the stack;
        //     goto afterSyscall;
        //     addressGood:
        // }
        // <parameterType> pointer = new <parameterType>(address);
        // if (parameterType == TErrorPointer32.class) {
        //     parameterReader.setHasErrorPointer(true);
        //     localVar[LOCAL_ERROR_POINTER] = pointer;
        // }
        mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(parameterType));
        mv.visitInsn(Opcodes.DUP);
        loadMemory();
        parameterReader.loadNextInt();

        boolean canBeNull = false;
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof CanBeNull) {
                canBeNull = true;
                break;
            }
        }

        if (checkMemoryAccess() && afterSyscallLabel != null) {
            Label addressGood = new Label();
            if (canBeNull) {
                mv.visitInsn(Opcodes.DUP);
                mv.visitJumpInsn(Opcodes.IFEQ, addressGood);
            }
            mv.visitInsn(Opcodes.DUP);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "checkMemoryPointer", "(I)Z");
            mv.visitJumpInsn(Opcodes.IFNE, addressGood);
            storeRegister(_v0, SceKernelErrors.ERROR_INVALID_POINTER);
            parameterReader.popAllStack(4);
            mv.visitJumpInsn(Opcodes.GOTO, afterSyscallLabel);
            mv.visitLabel(addressGood);
        }
        if (parameterType == TPointer8.class || parameterType == TPointer16.class
                || parameterType == TPointer32.class || parameterType == TPointer64.class) {
            loadImm(canBeNull);
            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(parameterType), "<init>",
                    "(" + memoryDescriptor + "IZ)V");
        } else {
            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(parameterType), "<init>",
                    "(" + memoryDescriptor + "I)V");
        }
        if (parameterType == TErrorPointer32.class) {
            parameterReader.setHasErrorPointer(true);
            mv.visitInsn(Opcodes.DUP);
            mv.visitVarInsn(Opcodes.ASTORE, LOCAL_ERROR_POINTER);
        }
        parameterReader.incrementCurrentStackSize();
    } else if (pspAbstractMemoryMappedStructure.class.isAssignableFrom(parameterType)) {
        parameterReader.loadNextInt();

        boolean canBeNull = false;
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof CanBeNull) {
                canBeNull = true;
                break;
            }
        }

        if (checkMemoryAccess() && afterSyscallLabel != null) {
            Label addressGood = new Label();
            if (canBeNull) {
                mv.visitInsn(Opcodes.DUP);
                mv.visitJumpInsn(Opcodes.IFEQ, addressGood);
            }
            mv.visitInsn(Opcodes.DUP);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "checkMemoryPointer", "(I)Z");
            mv.visitJumpInsn(Opcodes.IFNE, addressGood);
            storeRegister(_v0, SceKernelErrors.ERROR_INVALID_POINTER);
            parameterReader.popAllStack(1);
            mv.visitJumpInsn(Opcodes.GOTO, afterSyscallLabel);
            mv.visitLabel(addressGood);
        }

        mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(parameterType));
        mv.visitInsn(Opcodes.DUP);
        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(parameterType), "<init>", "()V");
        mv.visitInsn(Opcodes.DUP_X1);
        mv.visitInsn(Opcodes.SWAP);
        loadMemory();
        mv.visitInsn(Opcodes.SWAP);
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(parameterType), "read",
                "(" + memoryDescriptor + "I)V");
        parameterReader.incrementCurrentStackSize();
    } else {
        HLEUidClass hleUidClass = parameterType.getAnnotation(HLEUidClass.class);
        if (hleUidClass != null) {
            int errorValueOnNotFound = hleUidClass.errorValueOnNotFound();

            // <parameterType> uidObject = HLEUidObjectMapping.getObject("<parameterType>", uid);
            // if (uidObject == null) {
            //     cpu.gpr[_v0] = errorValueOnNotFound;
            //     pop all the parameters already prepared on the stack;
            //     goto afterSyscall;
            // }
            mv.visitLdcInsn(parameterType.getName());
            // Load the UID
            parameterReader.loadNextInt();

            // Load the UID Object
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(HLEUidObjectMapping.class),
                    "getObject",
                    "(" + Type.getDescriptor(String.class) + "I)" + Type.getDescriptor(Object.class));
            if (afterSyscallLabel != null) {
                Label foundUid = new Label();
                mv.visitInsn(Opcodes.DUP);
                mv.visitJumpInsn(Opcodes.IFNONNULL, foundUid);
                storeRegister(_v0, errorValueOnNotFound);
                parameterReader.popAllStack(1);
                mv.visitJumpInsn(Opcodes.GOTO, afterSyscallLabel);
                mv.visitLabel(foundUid);
            }
            mv.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(parameterType));
            parameterReader.incrementCurrentStackSize();
        } else {
            log.error(String.format("Unsupported sycall parameter type '%s'", parameterType.getName()));
            Emulator.PauseEmuWithStatus(Emulator.EMU_STATUS_UNIMPLEMENTED);
        }
    }

    Method methodToCheck = null;
    if (afterSyscallLabel != null) {
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof CheckArgument) {
                CheckArgument checkArgument = (CheckArgument) parameterAnnotation;
                try {
                    methodToCheck = func.getHLEModule().getClass().getMethod(checkArgument.value(),
                            parameterType);
                } catch (Exception e) {
                    log.error(String.format("CheckArgument method '%s' not found in %s", checkArgument.value(),
                            func.getModuleName()), e);
                }
                break;
            }
        }
    }

    if (methodToCheck != null) {
        // try {
        //     parameterValue = <module>.<methodToCheck>(parameterValue);
        // } catch (SceKernelErrorException e) {
        //     goto catchSceKernelErrorException;
        // }
        loadModule(func.getModuleName());
        mv.visitInsn(Opcodes.SWAP);

        Label tryStart = new Label();
        Label tryEnd = new Label();
        mv.visitTryCatchBlock(tryStart, tryEnd, catchSceKernelErrorException,
                Type.getInternalName(SceKernelErrorException.class));

        mv.visitLabel(tryStart);
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(methodToCheck.getDeclaringClass()),
                methodToCheck.getName(),
                "(" + Type.getDescriptor(parameterType) + ")" + Type.getDescriptor(parameterType));
        mv.visitLabel(tryEnd);
    }

    parameterReader.incrementCurrentParameterIndex();
}

From source file:lucee.transformer.bytecode.op.OpElvis.java

License:Open Source License

/**
 *
 * @see lucee.transformer.bytecode.expression.ExpressionBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
 *///from   www  .j  a v  a 2s .  c om
public Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException {
    if (ASMUtil.hasOnlyDataMembers(left))
        return _writeOutPureDataMember(bc, mode);

    Label notNull = new Label();
    Label end = new Label();

    GeneratorAdapter ga = bc.getAdapter();

    int l = ga.newLocal(Types.OBJECT);
    ExpressionUtil.visitLine(bc, left.getStart());
    left.writeOut(bc, MODE_REF);
    ExpressionUtil.visitLine(bc, left.getEnd());
    ga.dup();
    ga.storeLocal(l);

    ga.visitJumpInsn(Opcodes.IFNONNULL, notNull);
    ExpressionUtil.visitLine(bc, right.getStart());
    right.writeOut(bc, MODE_REF);
    ExpressionUtil.visitLine(bc, right.getEnd());
    ga.visitJumpInsn(Opcodes.GOTO, end);
    ga.visitLabel(notNull);
    ga.loadLocal(l);
    ga.visitLabel(end);

    return Types.OBJECT;
}

From source file:lucee.transformer.bytecode.statement.tag.TagLoop.java

License:Open Source License

/**
 * write out list loop//from   ww w .  j  a  va2  s  .c  o m
 * @param adapter
 * @throws TemplateException
 */
private void writeOutTypeListArray(BytecodeContext bc, boolean isArray) throws BytecodeException {
    ForVisitor forVisitor = new ForVisitor();
    loopVisitor = forVisitor;
    GeneratorAdapter adapter = bc.getAdapter();

    //List.listToArrayRemoveEmpty("", 'c')
    int array = adapter.newLocal(Types.ARRAY);
    int len = adapter.newLocal(Types.INT_VALUE);

    if (isArray) {
        getAttribute("array").getValue().writeOut(bc, Expression.MODE_REF);
    } else {
        // array=List.listToArrayRemoveEmpty(list, delimter)
        getAttribute("list").getValue().writeOut(bc, Expression.MODE_REF);
        if (containsAttribute("delimiters")) {
            getAttribute("delimiters").getValue().writeOut(bc, Expression.MODE_REF);
            adapter.invokeStatic(Types.LIST_UTIL, LIST_TO_ARRAY_REMOVE_EMPTY_SS);
        } else {
            adapter.visitIntInsn(Opcodes.BIPUSH, 44);// ','
            //adapter.push(',');
            adapter.invokeStatic(Types.LIST_UTIL, LIST_TO_ARRAY_REMOVE_EMPTY_SC);
        }
    }
    adapter.storeLocal(array);

    // int len=array.size();
    adapter.loadLocal(array);
    adapter.invokeInterface(Types.ARRAY, SIZE);
    adapter.storeLocal(len);

    //VariableInterpreter.getVariableReference(pc,Caster.toString(index));
    Attribute attrIndex = getAttribute("index");
    int index = -1;
    if (attrIndex != null) {
        index = adapter.newLocal(Types.VARIABLE_REFERENCE);
        adapter.loadArg(0);
        attrIndex.getValue().writeOut(bc, Expression.MODE_REF);
        adapter.invokeStatic(Types.VARIABLE_INTERPRETER, GET_VARIABLE_REFERENCE);
        adapter.storeLocal(index);
    }

    //VariableInterpreter.getVariableReference(pc,Caster.toString(item));
    Attribute attrItem = getAttribute("item");
    int item = -1;
    if (attrItem != null) {
        item = adapter.newLocal(Types.VARIABLE_REFERENCE);
        adapter.loadArg(0);
        attrItem.getValue().writeOut(bc, Expression.MODE_REF);
        adapter.invokeStatic(Types.VARIABLE_INTERPRETER, GET_VARIABLE_REFERENCE);
        adapter.storeLocal(item);
    }

    int obj = 0;
    if (isArray)
        obj = adapter.newLocal(Types.OBJECT);

    // for(int i=1;i<=len;i++) {      
    int i = forVisitor.visitBegin(adapter, 1, false);
    // index.set(pc, list.get(i));

    if (isArray) {

        // value
        adapter.loadLocal(array);
        adapter.visitVarInsn(Opcodes.ILOAD, i);
        ASMConstants.NULL(adapter);
        adapter.invokeInterface(Types.ARRAY, GET);
        adapter.dup();
        adapter.storeLocal(obj);
        Label endIf = new Label();
        //adapter.loadLocal(obj);
        adapter.visitJumpInsn(Opcodes.IFNONNULL, endIf);
        adapter.goTo(forVisitor.getContinueLabel());
        adapter.visitLabel(endIf);

        if (item == -1)
            adapter.loadLocal(index);
        else
            adapter.loadLocal(item);

        adapter.loadArg(0);

        adapter.loadLocal(obj);

    } else {
        if (item == -1)
            adapter.loadLocal(index);
        else
            adapter.loadLocal(item);
        adapter.loadArg(0);
        adapter.loadLocal(array);
        adapter.visitVarInsn(Opcodes.ILOAD, i);
        adapter.invokeInterface(Types.ARRAY, GETE);

    }
    adapter.invokeVirtual(Types.VARIABLE_REFERENCE, SET);
    adapter.pop();

    // key
    if (index != -1 && item != -1) {
        adapter.loadLocal(index);
        adapter.loadArg(0);
        adapter.visitVarInsn(Opcodes.ILOAD, i);
        adapter.cast(Types.INT_VALUE, Types.DOUBLE_VALUE);
        adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_DOUBLE[Methods_Caster.DOUBLE]);
        adapter.invokeVirtual(Types.VARIABLE_REFERENCE, SET);
        adapter.pop();
    }

    getBody().writeOut(bc);
    forVisitor.visitEnd(bc, len, true, getStart());
}