Java Code Examples for org.objectweb.asm.Type#getArgumentsAndReturnSizes()

The following examples show how to use org.objectweb.asm.Type#getArgumentsAndReturnSizes() . 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 File: BytecodeTypeInference.java    From bazel with Apache License 2.0 6 votes vote down vote up
private void popDescriptor(String desc) {
  char c = desc.charAt(0);
  switch (c) {
    case '(':
      int argumentSize = (Type.getArgumentsAndReturnSizes(desc) >> 2) - 1;
      if (argumentSize > 0) {
        pop(argumentSize);
      }
      break;
    case 'J':
    case 'D':
      pop(2);
      break;
    default:
      pop(1);
      break;
  }
}
 
Example 2
Source File: BytecodeTypeInference.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
  if (opcode == Opcodes.INVOKESPECIAL && "<init>".equals(name)) {
    int argumentSize = (Type.getArgumentsAndReturnSizes(desc) >> 2);
    InferredType receiverType = getTypeOfOperandFromTop(argumentSize - 1);
    if (receiverType.isUninitialized()) {
      InferredType realType = InferredType.create('L' + owner + ';');
      replaceUninitializedTypeInStack(receiverType, realType);
    }
  }
  switch (opcode) {
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEINTERFACE:
      popDescriptor(desc);
      if (opcode != Opcodes.INVOKESTATIC) {
        pop(); // Pop receiver.
      }
      pushDescriptor(desc);
      break;
    default:
      throw new RuntimeException(
          String.format(
              "Unhandled opcode %s, owner=%s, name=%s, desc=%s, itf=%s",
              opcode, owner, name, desc, itf));
  }
  super.visitMethodInsn(opcode, owner, name, desc, itf);
}
 
Example 3
Source File: Instrumenter.java    From dacapobench with Apache License 2.0 4 votes vote down vote up
protected static int getArgumentSizes(int access, String desc) {
	return 
		(((access & Opcodes.ACC_STATIC) == 0)?1:0) +		
		Type.getArgumentsAndReturnSizes(desc) >> 2; 
}