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

The following examples show how to use org.objectweb.asm.Type#getDimensions() . 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: Remapper.java    From Concurnas with MIT License 6 votes vote down vote up
/**
 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
 * #mapMethodDesc(String)}.
 *
 * @param type a type, which can be a method type.
 * @return the given type, with its [array element type] internal name remapped with {@link
 *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
 *     is) or, of the type is a method type, with its descriptor remapped with {@link
 *     #mapMethodDesc(String)}.
 */
private Type mapType(final Type type) {
  switch (type.getSort()) {
    case Type.ARRAY:
      StringBuilder remappedDescriptor = new StringBuilder();
      for (int i = 0; i < type.getDimensions(); ++i) {
        remappedDescriptor.append('[');
      }
      remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
      return Type.getType(remappedDescriptor.toString());
    case Type.OBJECT:
      String remappedInternalName = map(type.getInternalName());
      return remappedInternalName != null ? Type.getObjectType(remappedInternalName) : type;
    case Type.METHOD:
      return Type.getMethodType(mapMethodDesc(type.getDescriptor()));
    default:
      return type;
  }
}
 
Example 2
Source File: HierarchyMethods.java    From maple-ir with GNU General Public License v3.0 6 votes vote down vote up
/**
 * returns true if::
 *  both types are primitives of the same
 *   race.
 * or
 *  the types are both objects.
 * or
 *  they are both array types and have the
 *  same number of dimensions and have
 *  loosely or strongly (T I G H T L Y)
 *  related element types.
 */
private boolean areTypesLooselyRelated(Type t1, Type t2) {
	/* getSort() returns V, Z, C, B, I, F, J, D, array or object */
	if(t1.getSort() == t2.getSort()) {
		if(t1.getSort() == Type.ARRAY) {
			/* both arrays */
			
			if(t1.getDimensions() != t2.getDimensions()) {
				return false;
			}
			
			return areTypesLooselyRelated(t1.getElementType(), t2.getElementType());
		}
		
		/* either strongly related (prims) or
		 * loosely (object types) */
		return true;
	} else {
		/* no chance m8 */
		return false;
	}
}
 
Example 3
Source File: Remapper.java    From bytecode-viewer with GNU General Public License v3.0 6 votes vote down vote up
public String mapDesc(String desc) {
    Type t = Type.getType(desc);
    switch (t.getSort()) {
        case Type.ARRAY:
            String s = mapDesc(t.getElementType().getDescriptor());
            for (int i = 0; i < t.getDimensions(); ++i) {
                s = '[' + s;
            }
            return s;
        case Type.OBJECT:
            String newType = map(t.getInternalName());
            if (newType != null) {
                return 'L' + newType + ';';
            }
    }
    return desc;
}
 
Example 4
Source File: Remapper.java    From JByteMod-Beta with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
 * #mapMethodDesc(String)}.
 *
 * @param type a type, which can be a method type.
 * @return the given type, with its [array element type] internal name remapped with {@link
 *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
 *     is) or, of the type is a method type, with its descriptor remapped with {@link
 *     #mapMethodDesc(String)}.
 */
private Type mapType(final Type type) {
  switch (type.getSort()) {
    case Type.ARRAY:
      StringBuilder remappedDescriptor = new StringBuilder();
      for (int i = 0; i < type.getDimensions(); ++i) {
        remappedDescriptor.append('[');
      }
      remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
      return Type.getType(remappedDescriptor.toString());
    case Type.OBJECT:
      String remappedInternalName = map(type.getInternalName());
      return remappedInternalName != null ? Type.getObjectType(remappedInternalName) : type;
    case Type.METHOD:
      return Type.getMethodType(mapMethodDesc(type.getDescriptor()));
    default:
      return type;
  }
}
 
Example 5
Source File: Remapper.java    From JReFrameworker with MIT License 6 votes vote down vote up
/**
 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
 * #mapMethodDesc(String)}.
 *
 * @param type a type, which can be a method type.
 * @return the given type, with its [array element type] internal name remapped with {@link
 *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
 *     is) or, of the type is a method type, with its descriptor remapped with {@link
 *     #mapMethodDesc(String)}.
 */
private Type mapType(final Type type) {
  switch (type.getSort()) {
    case Type.ARRAY:
      StringBuilder remappedDescriptor = new StringBuilder();
      for (int i = 0; i < type.getDimensions(); ++i) {
        remappedDescriptor.append('[');
      }
      remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
      return Type.getType(remappedDescriptor.toString());
    case Type.OBJECT:
      String remappedInternalName = map(type.getInternalName());
      return remappedInternalName != null ? Type.getObjectType(remappedInternalName) : type;
    case Type.METHOD:
      return Type.getMethodType(mapMethodDesc(type.getDescriptor()));
    default:
      return type;
  }
}
 
Example 6
Source File: SimpleVerifier.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
	if (type == null) {
		return BasicValue.UNINITIALIZED_VALUE;
	}

	boolean isArray = type.getSort() == Type.ARRAY;
	if (isArray) {
		switch (type.getElementType().getSort()) {
		case Type.BOOLEAN:
		case Type.CHAR:
		case Type.BYTE:
		case Type.SHORT:
			return new BasicValue(type);
		default:
			break;
		}
	}

	BasicValue value = super.newValue(type);
	if (BasicValue.REFERENCE_VALUE.equals(value)) {
		if (isArray) {
			value = newValue(type.getElementType());
			StringBuilder descriptor = new StringBuilder();
			for (int i = 0; i < type.getDimensions(); ++i) {
				descriptor.append('[');
			}
			descriptor.append(value.getType().getDescriptor());
			value = new BasicValue(Type.getType(descriptor.toString()));
		} else {
			value = new BasicValue(type);
		}
	}
	return value;
}
 
Example 7
Source File: SimpleVerifier.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
  if (type == null) {
    return BasicValue.UNINITIALIZED_VALUE;
  }

  boolean isArray = type.getSort() == Type.ARRAY;
  if (isArray) {
    switch (type.getElementType().getSort()) {
      case Type.BOOLEAN:
      case Type.CHAR:
      case Type.BYTE:
      case Type.SHORT:
        return new BasicValue(type);
      default:
        break;
    }
  }

  BasicValue value = super.newValue(type);
  if (BasicValue.REFERENCE_VALUE.equals(value)) {
    if (isArray) {
      value = newValue(type.getElementType());
      StringBuilder descriptor = new StringBuilder();
      for (int i = 0; i < type.getDimensions(); ++i) {
        descriptor.append('[');
      }
      descriptor.append(value.getType().getDescriptor());
      value = new BasicValue(Type.getType(descriptor.toString()));
    } else {
      value = new BasicValue(type);
    }
  }
  return value;
}
 
Example 8
Source File: FastClassVerifier.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isAssignableFrom(Type t, Type u) {
    if (t.equals(u)) {
        return true;
    }
    // Null is assignable to any reference type
    if ("Lnull;".equals(u.getDescriptor()) && t.getSort() >= Type.ARRAY) {
        return true;
    }
    Type et, eu;
    if (t.getSort() == Type.ARRAY) {
        if (u.getSort() != Type.ARRAY ) {
            return false;
        }
        et = t.getElementType();
        eu = u.getElementType();
        int dt = t.getDimensions();
        int du = u.getDimensions();
        boolean isObject = et.equals(BasicValue.REFERENCE_VALUE.getType());
        // u must be an array of equals dimension or bigger dimension if t is Object
        if (dt == du || dt < du && isObject) {
            // Ok
        } else {
            return false;
        }
    } else {
        et = t; 
        eu = u;
    }
    /*
    Type commonType = classHierarchy.getCommonSuperType(et, eu);
    */
    // isAssignableFrom(Number, Integer) => getCommonSuperType(Integer, Number) == Number        
    // Use ClassHierarchy.isSubclass biased behavior (for performance)
    Type commonType = classHierarchy.getCommonSuperType(eu, et);
    return commonType.equals(et);

}
 
Example 9
Source File: SimpleVerifier.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
  if (type == null) {
    return BasicValue.UNINITIALIZED_VALUE;
  }

  boolean isArray = type.getSort() == Type.ARRAY;
  if (isArray) {
    switch (type.getElementType().getSort()) {
      case Type.BOOLEAN:
      case Type.CHAR:
      case Type.BYTE:
      case Type.SHORT:
        return new BasicValue(type);
      default:
        break;
    }
  }

  BasicValue value = super.newValue(type);
  if (BasicValue.REFERENCE_VALUE.equals(value)) {
    if (isArray) {
      value = newValue(type.getElementType());
      StringBuilder descriptor = new StringBuilder();
      for (int i = 0; i < type.getDimensions(); ++i) {
        descriptor.append('[');
      }
      descriptor.append(value.getType().getDescriptor());
      value = new BasicValue(Type.getType(descriptor.toString()));
    } else {
      value = new BasicValue(type);
    }
  }
  return value;
}
 
Example 10
Source File: FastClassVerifier.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isAssignableFrom(Type t, Type u) {
    if (t.equals(u)) {
        return true;
    }
    // Null is assignable to any reference type
    if ("Lnull;".equals(u.getDescriptor()) && t.getSort() >= Type.ARRAY) {
        return true;
    }
    Type et, eu;
    if (t.getSort() == Type.ARRAY) {
        if (u.getSort() != Type.ARRAY ) {
            return false;
        }
        et = t.getElementType();
        eu = u.getElementType();
        int dt = t.getDimensions();
        int du = u.getDimensions();
        boolean isObject = et.equals(BasicValue.REFERENCE_VALUE.getType());
        // u must be an array of equals dimension or bigger dimension if t is Object
        if (dt == du || dt < du && isObject) {
            // Ok
        } else {
            return false;
        }
    } else {
        et = t; 
        eu = u;
    }
    /*
    Type commonType = classHierarchy.getCommonSuperType(et, eu);
    */
    // isAssignableFrom(Number, Integer) => getCommonSuperType(Integer, Number) == Number        
    // Use ClassHierarchy.isSubclass biased behavior (for performance)
    Type commonType = classHierarchy.getCommonSuperType(eu, et);
    return commonType.equals(et);

}
 
Example 11
Source File: BuildStackInfoAdapter.java    From copper-engine with Apache License 2.0 5 votes vote down vote up
private static Type getArrayElementType(Type arrayType) {
    int dim = arrayType.getDimensions();
    if(dim < 1) throw new IllegalArgumentException("Not an array type: " + arrayType);
    if(dim > 1) {
        String descr = arrayType.getDescriptor();
        return Type.getType(descr.substring(1));
    }
    return arrayType.getElementType();
}
 
Example 12
Source File: SimpleVerifier.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
  if (type == null) {
    return BasicValue.UNINITIALIZED_VALUE;
  }

  boolean isArray = type.getSort() == Type.ARRAY;
  if (isArray) {
    switch (type.getElementType().getSort()) {
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
      return new BasicValue(type);
    }
  }

  BasicValue v = super.newValue(type);
  if (BasicValue.REFERENCE_VALUE.equals(v)) {
    if (isArray) {
      v = newValue(type.getElementType());
      String desc = v.getType().getDescriptor();
      for (int i = 0; i < type.getDimensions(); ++i) {
        desc = '[' + desc;
      }
      v = new BasicValue(Type.getType(desc));
    } else {
      v = new BasicValue(type);
    }
  }
  return v;
}
 
Example 13
Source File: NameMapping.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
private Type fix(final Type t) {
  if (t.getSort() == Type.OBJECT) {
    return Type.getObjectType(map(t.getInternalName()));
  } else if (t.getSort() == Type.ARRAY) {
    String s = fix(t.getElementType()).getDescriptor();
    for (int i = 0; i < t.getDimensions(); ++i) {
      s = '[' + s;
    }
    return Type.getType(s);
  } else {
    return t;
  }
}
 
Example 14
Source File: FastClassVerifier.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isAssignableFrom(Type t, Type u) {
    if (t.equals(u)) {
        return true;
    }
    // Null is assignable to any reference type
    if ("Lnull;".equals(u.getDescriptor()) && t.getSort() >= Type.ARRAY) {
        return true;
    }
    Type et, eu;
    if (t.getSort() == Type.ARRAY) {
        if (u.getSort() != Type.ARRAY ) {
            return false;
        }
        et = t.getElementType();
        eu = u.getElementType();
        int dt = t.getDimensions();
        int du = u.getDimensions();
        boolean isObject = et.equals(((BasicValue)BasicValue.REFERENCE_VALUE).getType());
        // u must be an array of equals dimension or bigger dimension if t is Object
        if (dt == du || dt < du && isObject) {
            // Ok
        } else {
            return false;
        }
    } else {
        et = t; 
        eu = u;
    }
    /*
    Type commonType = classHierarchy.getCommonSuperType(et, eu);
    */
    // isAssignableFrom(Number, Integer) => getCommonSuperType(Integer, Number) == Number        
    // Use ClassHierarchy.isSubclass biased behavior (for performance)
    Type commonType = classHierarchy.getCommonSuperType(eu, et);
    return commonType.equals(et);

}
 
Example 15
Source File: SimpleVerifier.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override
public BasicValue merge(final BasicValue value1, final BasicValue value2) {
  if (!value1.equals(value2)) {
    Type type1 = value1.getType();
    Type type2 = value2.getType();
    if (type1 != null
        && (type1.getSort() == Type.OBJECT || type1.getSort() == Type.ARRAY)
        && type2 != null
        && (type2.getSort() == Type.OBJECT || type2.getSort() == Type.ARRAY)) {
      if (type1.equals(NULL_TYPE)) {
        return value2;
      }
      if (type2.equals(NULL_TYPE)) {
        return value1;
      }
      if (isAssignableFrom(type1, type2)) {
        return value1;
      }
      if (isAssignableFrom(type2, type1)) {
        return value2;
      }
      int numDimensions = 0;
      if (type1.getSort() == Type.ARRAY
          && type2.getSort() == Type.ARRAY
          && type1.getDimensions() == type2.getDimensions()
          && type1.getElementType().getSort() == Type.OBJECT
          && type2.getElementType().getSort() == Type.OBJECT) {
        numDimensions = type1.getDimensions();
        type1 = type1.getElementType();
        type2 = type2.getElementType();
      }
      do {
        if (type1 == null || isInterface(type1)) {
          return newArrayValue(Type.getObjectType("java/lang/Object"), numDimensions);
        }
        type1 = getSuperClass(type1);
        if (isAssignableFrom(type1, type2)) {
          return newArrayValue(type1, numDimensions);
        }
      } while (true);
    }
    return BasicValue.UNINITIALIZED_VALUE;
  }
  return value1;
}
 
Example 16
Source File: SignaturePrinter.java    From Mixin with MIT License 4 votes vote down vote up
private static StringBuilder appendArraySuffix(StringBuilder sb, Type type) {
    for (int i = 0; i < type.getDimensions(); i++) {
        sb.append("[]");
    }
    return sb;
}
 
Example 17
Source File: ABICompilerClassVisitor.java    From AVM with MIT License 4 votes vote down vote up
private boolean isArrayOfTypeAndDimensions(Type arrayType, Type expectedElementType, int expectedDimensions) {
    return arrayType.getSort() == Type.ARRAY && arrayType.getDimensions() == expectedDimensions && arrayType.getElementType() == expectedElementType;
}
 
Example 18
Source File: ABICompilerClassVisitor.java    From AVM with MIT License 4 votes vote down vote up
private void callTheDecoder(MethodVisitor methodVisitor, Type type) {
    if (type == Type.BYTE_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneByte", "()B", false);
    } else if (type == Type.BOOLEAN_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneBoolean", "()Z", false);
    } else if (type == Type.CHAR_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneCharacter", "()C", false);
    } else if (type == Type.SHORT_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneShort", "()S", false);
    } else if (type == Type.INT_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneInteger", "()I", false);
    } else if (type == Type.LONG_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneLong", "()J", false);
    } else if (type == Type.FLOAT_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneFloat", "()F", false);
    } else if (type == Type.DOUBLE_TYPE) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneDouble", "()D", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.BYTE_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneByteArray", "()[B", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.BOOLEAN_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneBooleanArray", "()[Z", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.CHAR_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneCharacterArray", "()[C", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.SHORT_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneShortArray", "()[S", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.INT_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneIntegerArray", "()[I", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.LONG_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneLongArray", "()[J", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.FLOAT_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneFloatArray", "()[F", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.DOUBLE_TYPE, 1)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneDoubleArray", "()[D", false);
    } else if (isString(type)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneString", "()Ljava/lang/String;", false);
    } else if (isAddress(type)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneAddress", "()Lavm/Address;", false);
    } else if(isBigInteger(type)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneBigInteger", "()Ljava/math/BigInteger;", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.BYTE_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DByteArray", "()[[B", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.BOOLEAN_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DBooleanArray", "()[[Z", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.CHAR_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DCharacterArray", "()[[C", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.SHORT_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DShortArray", "()[[S", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.INT_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DIntegerArray", "()[[I", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.LONG_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DLongArray", "()[[J", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.FLOAT_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DFloatArray", "()[[F", false);
    } else if (isArrayOfTypeAndDimensions(type, Type.DOUBLE_TYPE, 2)) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOne2DDoubleArray", "()[[D", false);
    } else if (type.getSort() == Type.ARRAY && type.getDimensions() == 1 && isString(type.getElementType())) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneStringArray", "()[Ljava/lang/String;", false);
    } else if (type.getSort() == Type.ARRAY && type.getDimensions() == 1 && isAddress(type.getElementType())) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneAddressArray", "()[Lavm/Address;", false);
    } else if(type.getSort() == Type.ARRAY && type.getDimensions() == 1 && isBigInteger(type.getElementType())) {
        methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "org/aion/avm/userlib/abi/ABIDecoder", "decodeOneBigIntegerArray", "()[Ljava/math/BigInteger;", false);
    } else {
        throw new ABICompilerException("Need to decode an unsupported ABI type");
    }
}
 
Example 19
Source File: SimpleVerifier.java    From Cafebabe with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BasicValue merge(final BasicValue value1, final BasicValue value2) {
	if (!value1.equals(value2)) {
		Type type1 = value1.getType();
		Type type2 = value2.getType();
		if (type1 != null && (type1.getSort() == Type.OBJECT || type1.getSort() == Type.ARRAY) && type2 != null
				&& (type2.getSort() == Type.OBJECT || type2.getSort() == Type.ARRAY)) {
			if (type1.equals(NULL_TYPE)) {
				return value2;
			}
			if (type2.equals(NULL_TYPE)) {
				return value1;
			}
			if (isAssignableFrom(type1, type2)) {
				return value1;
			}
			if (isAssignableFrom(type2, type1)) {
				return value2;
			}
			int numDimensions = 0;
			if (type1.getSort() == Type.ARRAY && type2.getSort() == Type.ARRAY
					&& type1.getDimensions() == type2.getDimensions() && type1.getElementType().getSort() == Type.OBJECT
					&& type2.getElementType().getSort() == Type.OBJECT) {
				numDimensions = type1.getDimensions();
				type1 = type1.getElementType();
				type2 = type2.getElementType();
			}
			do {
				if (type1 == null || isInterface(type1)) {
					return newArrayValue(Type.getObjectType("java/lang/Object"), numDimensions);
				}
				type1 = getSuperClass(type1);
				if (isAssignableFrom(type1, type2)) {
					return newArrayValue(type1, numDimensions);
				}
			} while (true);
		}
		return BasicValue.UNINITIALIZED_VALUE;
	}
	return value1;
}
 
Example 20
Source File: TypeUtil.java    From Recaf with MIT License 2 votes vote down vote up
/**
 * @param type
 * 		Some array type.
 *
 * @return Array depth.
 */
public static int getArrayDepth(Type type) {
	if (type.getSort() == Type.ARRAY)
		return type.getDimensions();
	return 0;
}