Java Code Examples for org.objectweb.asm.Label

The following examples show how to use org.objectweb.asm.Label. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pitest   Source File: RemoveConditionalMutator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void visitJumpInsn(final int opcode, final Label label) {

  if (canMutate(opcode)) {
    final MutationIdentifier newId = this.context.registerMutation(
        this.factory, this.description);

    if (this.context.shouldMutate(newId)) {
      emptyStack(opcode);
      if (!RemoveConditionalMutator.this.replaceWith) {
        super.visitJumpInsn(Opcodes.GOTO, label);
      }
    } else {
      this.mv.visitJumpInsn(opcode, label);
    }
  } else {
    this.mv.visitJumpInsn(opcode, label);
  }

}
 
Example 2
Source Project: JReFrameworker   Source File: CheckMethodAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public void visitLocalVariable(
    final String name,
    final String descriptor,
    final String signature,
    final Label start,
    final Label end,
    final int index) {
  checkVisitCodeCalled();
  checkVisitMaxsNotCalled();
  checkUnqualifiedName(version, name, "name");
  checkDescriptor(version, descriptor, false);
  checkLabel(start, true, START_LABEL);
  checkLabel(end, true, END_LABEL);
  checkUnsignedShort(index, INVALID_LOCAL_VARIABLE_INDEX);
  int startInsnIndex = labelInsnIndices.get(start).intValue();
  int endInsnIndex = labelInsnIndices.get(end).intValue();
  if (endInsnIndex < startInsnIndex) {
    throw new IllegalArgumentException(
        "Invalid start and end labels (end must be greater than start)");
  }
  super.visitLocalVariable(name, descriptor, signature, start, end, index);
}
 
Example 3
Source Project: groovy   Source File: BinaryIntExpressionHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * writes a std compare. This involves the tokens IF_ICMPEQ, IF_ICMPNE, 
 * IF_ICMPEQ, IF_ICMPNE, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE and IF_ICMPLT
 * @param type the token type
 * @return true if a successful std compare write
 */
protected boolean writeStdCompare(int type, boolean simulate) {
    type = type-COMPARE_NOT_EQUAL;
    // look if really compare
    if (type<0||type>7) return false;

    if (!simulate) {
        MethodVisitor mv = getController().getMethodVisitor();
        OperandStack operandStack = getController().getOperandStack();
        // operands are on the stack already
        int bytecode = stdCompareCodes[type];
        Label l1 = new Label();
        mv.visitJumpInsn(bytecode,l1);
        mv.visitInsn(ICONST_1);
        Label l2 = new Label();
        mv.visitJumpInsn(GOTO, l2);
        mv.visitLabel(l1);
        mv.visitInsn(ICONST_0);
        mv.visitLabel(l2);
        operandStack.replace(ClassHelper.boolean_TYPE, 2);
    }
    return true;
}
 
Example 4
Source Project: yql-plus   Source File: ArrayIndexAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public BytecodeExpression length(final BytecodeExpression inputExpr) {
    return new BaseTypeExpression(BaseTypeAdapter.INT32) {
        @Override
        public void generate(CodeEmitter code) {
            Label done = new Label();
            Label isNull = new Label();
            MethodVisitor mv = code.getMethodVisitor();
            code.exec(inputExpr);
            boolean nullable = code.nullTest(inputExpr.getType(), isNull);
            mv.visitInsn(Opcodes.ARRAYLENGTH);
            if (nullable) {
                mv.visitJumpInsn(Opcodes.GOTO, done);
                mv.visitLabel(isNull);
                mv.visitInsn(Opcodes.ICONST_0);
                mv.visitLabel(done);
            }
        }
    };
}
 
Example 5
Source Project: Despector   Source File: MethodTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testStaticInvoke() {
    TestMethodBuilder builder = new TestMethodBuilder("test_mth", "()V");
    MethodVisitor mv = builder.getGenerator();
    Label start = new Label();
    Label end = new Label();
    mv.visitLabel(start);
    mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
    mv.visitLdcInsn("Hello World!");
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
    mv.visitLabel(end);
    mv.visitInsn(RETURN);

    String insn = TestHelper.getAsString(builder.finish(), "test_mth");
    String good = "System.out.println(\"Hello World!\");";
    Assert.assertEquals(good, insn);
}
 
Example 6
Source Project: jaxrs-analyzer   Source File: InstructionBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public static Instruction buildFieldInstruction(final int opcode, final String ownerClass, final String name, final String desc, final Label label) {
    // TODO remove
    if (org.objectweb.asm.Type.getObjectType(ownerClass).getClassName().equals(ownerClass.replace('.', '/')))
        throw new AssertionError("!");

    final String opcodeName = OPCODES[opcode];

    switch (opcode) {
        case GETSTATIC:
            final Object value = getStaticValue(name, ownerClass);
            return new GetStaticInstruction(ownerClass, name, desc, value, label);
        case PUTSTATIC:
            return new SizeChangingInstruction(opcodeName, 0, 1, label);
        case GETFIELD:
            return new GetFieldInstruction(ownerClass, name, desc, label);
        case PUTFIELD:
            return new SizeChangingInstruction(opcodeName, 0, 2, label);
        default:
            throw new IllegalArgumentException("Opcode " + opcode + " not a field instruction");
    }
}
 
Example 7
Source Project: Despector   Source File: OperatorTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testDiv() {
    TestMethodBuilder builder = new TestMethodBuilder("test_mth", "(III)V");
    MethodVisitor mv = builder.getGenerator();
    Label start = new Label();
    mv.visitLabel(start);
    Label end = new Label();
    mv.visitIntInsn(ILOAD, 1);
    mv.visitIntInsn(ILOAD, 2);
    mv.visitInsn(IDIV);
    mv.visitIntInsn(ISTORE, 0);
    mv.visitLabel(end);
    mv.visitInsn(RETURN);
    mv.visitLocalVariable("i", "I", null, start, end, 0);
    mv.visitLocalVariable("a", "I", null, start, end, 1);
    mv.visitLocalVariable("b", "I", null, start, end, 2);

    String insn = TestHelper.getAsString(builder.finish(), "test_mth");
    String good = "i = a / b;";
    Assert.assertEquals(good, insn);
}
 
Example 8
Source Project: cglib   Source File: EmitUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Process an array on the stack. Assumes the top item on the stack
 * is an array of the specified type. For each element in the array,
 * puts the element on the stack and triggers the callback.
 * @param type the type of the array (type.isArray() must be true)
 * @param callback the callback triggered for each element
 */
public static void process_array(CodeEmitter e, Type type, ProcessArrayCallback callback) {
    Type componentType = TypeUtils.getComponentType(type);
    Local array = e.make_local();
    Local loopvar = e.make_local(Type.INT_TYPE);
    Label loopbody = e.make_label();
    Label checkloop = e.make_label();
    e.store_local(array);
    e.push(0);
    e.store_local(loopvar);
    e.goTo(checkloop);
    
    e.mark(loopbody);
    e.load_local(array);
    e.load_local(loopvar);
    e.array_load(componentType);
    callback.processElement(componentType);
    e.iinc(loopvar, 1);
    
    e.mark(checkloop);
    e.load_local(loopvar);
    e.load_local(array);
    e.arraylength();
    e.if_icmp(e.LT, loopbody);
}
 
Example 9
Source Project: Despector   Source File: OperatorTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testTypeConstant() {
    TestMethodBuilder builder = new TestMethodBuilder("test_mth", "(I)V");
    MethodVisitor mv = builder.getGenerator();
    Label start = new Label();
    mv.visitLabel(start);
    Label end = new Label();
    mv.visitLdcInsn(Type.getType("Ljava/lang/String;"));
    mv.visitIntInsn(ASTORE, 0);
    mv.visitLabel(end);
    mv.visitInsn(RETURN);
    mv.visitLocalVariable("i", "Ljava/lang/Class;", null, start, end, 0);

    String insn = TestHelper.getAsString(builder.finish(), "test_mth");
    String good = "i = String.class;";
    Assert.assertEquals(good, insn);
}
 
Example 10
public void visitInsnList(InsnList list) {
	text.clear();
	if (labelNames == null) {
		labelNames = new HashMap<Label, String>();
	} else {
		labelNames.clear();
	}

	buildingLabelMap = true;
	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn.getType() == 8) {
			visitLabel(((LabelNode) insn).getLabel());
		}
	}

	text.clear();
	buildingLabelMap = false;

	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		_visitInsn(insn);
	}
}
 
Example 11
@Override
public void visitCode()
{
	System.out.println("EntityPlayerVisitor.JumpVisitor.visitCode()");
	
	super.visitCode();
	mv.visitVarInsn(Opcodes.ALOAD, 0);
	mv.visitMethodInsn(Opcodes.INVOKESTATIC,
		"net/wurstclient/forge/compatibility/WEventFactory",
		"entityPlayerJump",
		"(Lnet/minecraft/entity/player/EntityPlayer;)Z", false);
	Label l1 = new Label();
	mv.visitJumpInsn(Opcodes.IFNE, l1);
	mv.visitInsn(Opcodes.RETURN);
	mv.visitLabel(l1);
	mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}
 
Example 12
Source Project: Despector   Source File: IfTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testNestedIf3Optimized() {
    TestMethodBuilder builder = new TestMethodBuilder("test_mth", "(ZZZ)V");
    MethodVisitor mv = builder.getGenerator();
    Label start = new Label();
    mv.visitLabel(start);
    Label end = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitVarInsn(ILOAD, 0);
    mv.visitJumpInsn(IFEQ, end);
    mv.visitVarInsn(ILOAD, 1);
    mv.visitJumpInsn(IFEQ, l1);
    mv.visitVarInsn(ILOAD, 2);
    mv.visitJumpInsn(IFEQ, l2);
    mv.visitMethodInsn(INVOKESTATIC, THIS_TYPE.getInternalName(), "body", "()V", false);
    mv.visitJumpInsn(GOTO, l1);
    mv.visitLabel(l2);
    mv.visitMethodInsn(INVOKESTATIC, THIS_TYPE.getInternalName(), "body", "()V", false);
    mv.visitLabel(l1);
    mv.visitMethodInsn(INVOKESTATIC, THIS_TYPE.getInternalName(), "body", "()V", false);
    mv.visitLabel(end);
    mv.visitInsn(RETURN);
    mv.visitLocalVariable("a", "Z", null, start, end, 0);
    mv.visitLocalVariable("b", "Z", null, start, end, 1);
    mv.visitLocalVariable("c", "Z", null, start, end, 2);

    String insn = TestHelper.getAsString(builder.finish(), "test_mth");
    String good = "if (a) {\n"
            + "    if (b) {\n"
            + "        if (c) {\n"
            + "            org.spongepowered.test.decompile.IfTests.body();\n"
            + "        } else {\n"
            + "            org.spongepowered.test.decompile.IfTests.body();\n"
            + "        }\n"
            + "    }\n\n"
            + "    org.spongepowered.test.decompile.IfTests.body();\n"
            + "}";
    Assert.assertEquals(good, insn);
}
 
Example 13
Source Project: dacapobench   Source File: ClinitInstrument.java    License: Apache License 2.0 5 votes vote down vote up
protected void onMethodEnter() {
	Label target = super.newLabel();
	// invoke the logger, note that we may not know about the Log class yet so we must catch and ignore the
	// exception here.
	super.visitLdcInsn(className);
	Label start = super.mark();
	super.visitMethodInsn(Opcodes.INVOKESTATIC, LOG_INTERNAL, LOG_METHOD_NAME, LOG_METHOD_SIGNATURE);
	Label end = super.mark();
	super.visitJumpInsn(Opcodes.GOTO,target);
	// catch the exception, discard the exception
	super.catchException(start,end,JAVA_LANG_THROWABLE_TYPE);
	super.pop();
	super.mark(target);
	// remainder of the <clinit>
}
 
Example 14
Source Project: JReFrameworker   Source File: AnalyzerAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public void visitJumpInsn(final int opcode, final Label label) {
  super.visitJumpInsn(opcode, label);
  execute(opcode, 0, null);
  if (opcode == Opcodes.GOTO) {
    this.locals = null;
    this.stack = null;
  }
}
 
Example 15
Source Project: JReFrameworker   Source File: ASMifier.java    License: MIT License 5 votes vote down vote up
/**
 * Calls {@link #declareLabel} for each label in the given stack map frame types.
 *
 * @param numTypes the number of stack map frame types in 'frameTypes'.
 * @param frameTypes an array of stack map frame types, in the format described in {@link
 *     org.objectweb.asm.MethodVisitor#visitFrame}.
 */
private void declareFrameTypes(final int numTypes, final Object[] frameTypes) {
  for (int i = 0; i < numTypes; ++i) {
    if (frameTypes[i] instanceof Label) {
      declareLabel((Label) frameTypes[i]);
    }
  }
}
 
Example 16
Source Project: Concurnas   Source File: TraceMethodVisitor.java    License: MIT License 5 votes vote down vote up
@Override
public void visitLocalVariable(
    final String name,
    final String descriptor,
    final String signature,
    final Label start,
    final Label end,
    final int index) {
  p.visitLocalVariable(name, descriptor, signature, start, end, index);
  super.visitLocalVariable(name, descriptor, signature, start, end, index);
}
 
Example 17
Source Project: yql-plus   Source File: ExpressionHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BytecodeExpression list(Location loc, final List<BytecodeExpression> args) {
    List<TypeWidget> types = Lists.newArrayList();
    for (BytecodeExpression e : args) {
        types.add(e.getType());
    }
    final TypeWidget unified = unify(types).boxed();
    final ListTypeWidget out = new ListTypeWidget(NotNullableTypeWidget.create(unified));
    return new BaseTypeExpression(out) {
        @Override
        public void generate(CodeEmitter code) {
            MethodVisitor mv = code.getMethodVisitor();
            code.exec(out.construct(constant(args.size())));
            for (BytecodeExpression expr : args) {
                Label skip = new Label();
                mv.visitInsn(Opcodes.DUP);
                code.exec(expr);
                final TypeWidget type = expr.getType();
                boolean nullable = code.cast(unified, type, skip);
                mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, Type.getInternalName(Collection.class), "add", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getType(Object.class)), true);
                if (nullable) {
                    // we're either going to POP the DUPed List OR the result of add
                    mv.visitLabel(skip);
                }
                mv.visitInsn(Opcodes.POP);
            }
        }
    };
}
 
Example 18
Source Project: Despector   Source File: WhileTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testWhileDirectBreak() {
    // if the break is the only thing in a condition it will sometimes be
    // optimized so that the inverse of the condition targets the outside of
    // the loop rather than having a goto inside the condition
    TestMethodBuilder builder = new TestMethodBuilder("test_mth", "(IZ)V");
    MethodVisitor mv = builder.getGenerator();
    Label start = new Label();
    mv.visitLabel(start);
    Label end = new Label();
    Label l1 = new Label();
    mv.visitLabel(l1);
    mv.visitVarInsn(ILOAD, 0);
    mv.visitInsn(ICONST_5);
    mv.visitJumpInsn(IF_ICMPGE, end);
    mv.visitMethodInsn(INVOKESTATIC, THIS_TYPE.getInternalName(), "body", "()V", false);
    mv.visitVarInsn(ILOAD, 1);
    mv.visitJumpInsn(IFNE, end);
    mv.visitJumpInsn(GOTO, l1);
    mv.visitLabel(end);
    mv.visitInsn(RETURN);
    mv.visitLocalVariable("i", "I", null, start, end, 0);
    mv.visitLocalVariable("a", "Z", null, start, end, 1);

    String insn = TestHelper.getAsString(builder.finish(), "test_mth");
    String good = "while (i < 5) {\n"
            + "    org.spongepowered.test.decompile.WhileTests.body();\n"
            + "    if (a) {\n"
            + "        break;\n"
            + "    }\n"
            + "}";
    Assert.assertEquals(good, insn);
}
 
Example 19
@Override
public void visitMaxs(int maxStack, int maxLocals) {
    Label endFinallyLabel = new Label();
    super.visitTryCatchBlock(startFinallyLabel, endFinallyLabel, endFinallyLabel, null);
    super.visitLabel(endFinallyLabel);
    onFinally(ATHROW);
    super.visitInsn(ATHROW);
    super.visitMaxs(maxStack, maxLocals);
}
 
Example 20
Source Project: bazel   Source File: DepsCheckerClassVisitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AnnotationVisitor visitLocalVariableAnnotation(
    int typeRef,
    TypePath typePath,
    Label[] start,
    Label[] end,
    int[] index,
    String desc,
    boolean visible) {
  checkDescriptor(desc);
  return defaultAnnotationChecker;
}
 
Example 21
@Override
public final void begin(final String element, final Attributes attrs) {
  String name = attrs.getValue("name");
  String desc = attrs.getValue("desc");
  String signature = attrs.getValue("signature");
  Label start = getLabel(attrs.getValue("start"));
  Label end = getLabel(attrs.getValue("end"));
  int var = Integer.parseInt(attrs.getValue("var"));
  getCodeVisitor().visitLocalVariable(name, desc, signature, start, end, var);
}
 
Example 22
public void visitInsn(AbstractInsnNode insn) {
	text.clear();
	if (labelNames == null) {
		labelNames = new HashMap<Label, String>();
	} else {
		labelNames.clear();
	}

	_visitInsn(insn);
}
 
Example 23
Source Project: AVM   Source File: LoopingExceptionStrippingVisitorTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testLoopingFinally() throws Exception {
    String testClassName = "TestClass";
    ClassWriter writer = new ClassWriter(0);
    TryCatchCountingVisitor counter = new TryCatchCountingVisitor(writer);
    LoopingExceptionStrippingVisitor visitor = new LoopingExceptionStrippingVisitor();
    visitor.setDelegate(counter);
    visitor.visit(Opcodes.V10, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, testClassName, null, "java/lang/Object", null);
    
    // Create our labels.
    Label start = new Label();
    Label end = new Label();
    Label handler = new Label();
    String type = null;
    
    // Write a target method.
    MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_STATIC, "targetMethod", "()V", null, null);
    methodVisitor.visitCode();
    methodVisitor.visitInsn(Opcodes.ACONST_NULL);
    methodVisitor.visitInsn(Opcodes.POP);
    methodVisitor.visitLabel(start);
    methodVisitor.visitInsn(Opcodes.ACONST_NULL);
    methodVisitor.visitLabel(handler);
    methodVisitor.visitInsn(Opcodes.POP);
    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitLabel(end);
    methodVisitor.visitTryCatchBlock(start, end, handler, type);
    methodVisitor.visitMaxs(1, 0);
    methodVisitor.visitEnd();
    
    // Finish.
    visitor.visitEnd();
    
    Assert.assertEquals(0, counter.counter);
}
 
Example 24
Source Project: Concurnas   Source File: ASMifier.java    License: MIT License 5 votes vote down vote up
@Override
public void visitJumpInsn(final int opcode, final Label label) {
  stringBuilder.setLength(0);
  declareLabel(label);
  stringBuilder.append(name).append(".visitJumpInsn(").append(OPCODES[opcode]).append(", ");
  appendLabel(label);
  stringBuilder.append(");\n");
  text.add(stringBuilder.toString());
}
 
Example 25
Source Project: JReFrameworker   Source File: ModuleHashesAttribute.java    License: MIT License 5 votes vote down vote up
@Override
protected Attribute read(
    final ClassReader classReader,
    final int offset,
    final int length,
    final char[] charBuffer,
    final int codeAttributeOffset,
    final Label[] labels) {
  int currentOffset = offset;

  String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
  currentOffset += 2;

  int numModules = classReader.readUnsignedShort(currentOffset);
  currentOffset += 2;

  ArrayList<String> moduleList = new ArrayList<String>(numModules);
  ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules);

  for (int i = 0; i < numModules; ++i) {
    String module = classReader.readModule(currentOffset, charBuffer);
    currentOffset += 2;
    moduleList.add(module);

    int hashLength = classReader.readUnsignedShort(currentOffset);
    currentOffset += 2;
    byte[] hash = new byte[hashLength];
    for (int j = 0; j < hashLength; ++j) {
      hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
      currentOffset += 1;
    }
    hashList.add(hash);
  }
  return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
}
 
Example 26
Source Project: jaxrs-analyzer   Source File: SizeChangingInstruction.java    License: Apache License 2.0 5 votes vote down vote up
public SizeChangingInstruction(final String description, final int numberOfPushes, final int numberOfPops, final Label label) {
    super(description, label);

    if (numberOfPushes < 0 || numberOfPops < 0)
        throw new IllegalArgumentException("Number of pushes and pops cannot be negative");

    this.numberOfPushes = numberOfPushes;
    this.numberOfPops = numberOfPops;
}
 
Example 27
Source Project: AVM   Source File: ConstructorThisInterpreterTest.java    License: MIT License 5 votes vote down vote up
private MethodNode buildTestConstructor() {
    MethodNode methodVisitor = new MethodNode(Opcodes.ACC_PUBLIC, "<init>", "(Lorg/aion/avm/core/persistence/ConstructorThisInterpreterTest;I)V", null, null);
    methodVisitor.visitCode();
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
    methodVisitor.visitInsn(Opcodes.ICONST_5);
    methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
    Label label2 = new Label();
    methodVisitor.visitJumpInsn(Opcodes.IF_ICMPNE, label2);
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    Label label3 = new Label();
    methodVisitor.visitJumpInsn(Opcodes.GOTO, label3);
    methodVisitor.visitLabel(label2);
    methodVisitor.visitFrame(Opcodes.F_FULL, 3, new Object[] {"org/aion/avm/core/persistence/ConstructorThisInterpreterTest", "org/aion/avm/core/persistence/ConstructorThisInterpreterTest", Opcodes.INTEGER}, 0, new Object[] {});
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 1);
    methodVisitor.visitLabel(label3);
    methodVisitor.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"org/aion/avm/core/persistence/ConstructorThisInterpreterTest"});
    methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
    methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, "org/aion/avm/core/persistence/ConstructorThisInterpreterTest", "bar", "I");
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitInsn(Opcodes.ICONST_1);
    methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, "org/aion/avm/core/persistence/ConstructorThisInterpreterTest", "bar", "I");
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 1);
    methodVisitor.visitInsn(Opcodes.ICONST_2);
    methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, "org/aion/avm/core/persistence/ConstructorThisInterpreterTest", "bar", "I");
    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitMaxs(2, 3);
    methodVisitor.visitEnd();
    return methodVisitor;
}
 
Example 28
Source Project: copper-engine   Source File: BuildStackInfoAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public LocalVariable(String name, String declaredDescriptor, Label from, Label to, int index) {
    this.name = name;
    this.fromLine = getLineNumber(from);
    this.toLine = getLineNumber(to);
    if (this.toLine[0] == -1)
        this.toLine[0] = Integer.MAX_VALUE;
    this.index = index;
    this.declaredDescriptor = declaredDescriptor;
}
 
Example 29
@Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
    sawBranchTo(dflt);
    for (Label lbl : labels) {
        sawBranchTo(lbl);
    }
    identityState = IdentityMethodState.NOT;
    super.visitTableSwitchInsn(min, max, dflt, labels);
}
 
Example 30
Source Project: pitest   Source File: AvoidStringSwitchedMethodAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitLineNumber(int line, Label start) {
  super.visitLineNumber(line, start);
  // if compiler emits a line number switch statement (probably) contains user
  // generated code
  enableMutation();
}