當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.getSort方法代碼示例

本文整理匯總了Java中org.objectweb.asm.Type.getSort方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.getSort方法的具體用法?Java Type.getSort怎麽用?Java Type.getSort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.Type的用法示例。


在下文中一共展示了Type.getSort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mapType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:17,代碼來源:Remapper.java

示例2: box

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Generates the instructions to box the top stack value. This value is
 * replaced by its boxed equivalent on top of the stack.
 * 
 * @param type
 *            the type of the top stack value.
 */
public void box(final Type type) {
    if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
        return;
    }
    if (type == Type.VOID_TYPE) {
        push((String) null);
    } else {
        Type boxed = getBoxedType(type);
        newInstance(boxed);
        if (type.getSize() == 2) {
            // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
            dupX2();
            dupX2();
            pop();
        } else {
            // p -> po -> opo -> oop -> o
            dupX1();
            swap();
        }
        invokeConstructor(boxed, new Method("<init>", Type.VOID_TYPE,
                new Type[] { type }));
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:31,代碼來源:GeneratorAdapter.java

示例3: validate

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void validate(String value) {
    if (value.startsWith("$this") && method.equals("<init>")) {
        throwLabelInvalidException(value, "Cannot use $this in Constructor");
    }

    if (value.startsWith("$")) {
        if (!value.matches("\\$([0-9]+|this)([a-zA-Z.]+)*")) {
            throwLabelInvalidException(value, "Must match pattern \\\\$([0-9]+|this)([a-zA-Z.]+)* or start with $this");
        }

        if (!value.startsWith("$this")) {

            int index = LabelUtil.getLabelVarIndex(value);

            if (index >= argTypes.length) {
                throwLabelInvalidException(value, "It only has " + argTypes.length + " params");
            }

            Type argType = argTypes[index];
            if (argType.getSort() == Type.ARRAY) {
                throwLabelInvalidException(value, "ARRAY type is not allowed");
            }
        }
    }
}
 
開發者ID:willfleury,項目名稱:prometheus-metrics-agent,代碼行數:26,代碼來源:LabelValidator.java

示例4: getBoxedType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static Type getBoxedType(final Type type) {
    switch (type.getSort()) {
    case Type.BYTE:
        return BYTE_TYPE;
    case Type.BOOLEAN:
        return BOOLEAN_TYPE;
    case Type.SHORT:
        return SHORT_TYPE;
    case Type.CHAR:
        return CHARACTER_TYPE;
    case Type.INT:
        return INTEGER_TYPE;
    case Type.FLOAT:
        return FLOAT_TYPE;
    case Type.LONG:
        return LONG_TYPE;
    case Type.DOUBLE:
        return DOUBLE_TYPE;
    }
    return type;
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:22,代碼來源:GeneratorAdapter.java

示例5: moveType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static MoveType moveType(Type type) {
  switch (type.getSort()) {
    case Type.ARRAY:
    case Type.OBJECT:
      return MoveType.OBJECT;
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.SHORT:
    case Type.CHAR:
    case Type.INT:
    case Type.FLOAT:
      return MoveType.SINGLE;
    case Type.LONG:
    case Type.DOUBLE:
      return MoveType.WIDE;
    case Type.VOID:
      // Illegal. Throws in fallthrough.
    default:
      throw new Unreachable("Invalid type in moveType: " + type);
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:22,代碼來源:JarSourceCode.java

示例6: constType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static ConstType constType(Type type) {
  switch (type.getSort()) {
    case Type.ARRAY:
    case Type.OBJECT:
      return ConstType.OBJECT;
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.SHORT:
    case Type.CHAR:
    case Type.INT:
      return ConstType.INT;
    case Type.FLOAT:
      return ConstType.FLOAT;
    case Type.LONG:
      return ConstType.LONG;
    case Type.DOUBLE:
      return ConstType.DOUBLE;
    case Type.VOID:
      // Illegal. Throws in fallthrough.
    default:
      throw new Unreachable("Invalid type in constType: " + type);
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:24,代碼來源:JarSourceCode.java

示例7: newValue

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public BasicValue newValue(final Type type) {
    if (type == null) {
        return BasicValue.UNINITIALIZED_VALUE;
    }
    switch (type.getSort()) {
    case Type.VOID:
        return null;
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        return BasicValue.INT_VALUE;
    case Type.FLOAT:
        return BasicValue.FLOAT_VALUE;
    case Type.LONG:
        return BasicValue.LONG_VALUE;
    case Type.DOUBLE:
        return BasicValue.DOUBLE_VALUE;
    case Type.ARRAY:
    case Type.OBJECT:
        return BasicValue.REFERENCE_VALUE;
    default:
        throw new Error("Internal error");
    }
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:28,代碼來源:BasicInterpreter.java

示例8: getShortyDescriptor

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static String getShortyDescriptor(Type type) {
  switch (type.getSort()) {
    case Type.METHOD:
      throw new InternalCompilerError("Cannot produce a shorty decriptor for methods");
    case Type.ARRAY:
    case Type.OBJECT:
      return "L";
    default:
      return type.getDescriptor();
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:12,代碼來源:JarApplicationReader.java

示例9: isFieldInlineable

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private boolean isFieldInlineable(int access, String desc) {
	if ((access & OPCODE_FIELD_INLINEABLE) != 0) {
		final Type type = Type.getType(desc);
		return type.getSort() != Type.OBJECT || "java.lang.String".equals(type.getClassName());
	}
	return false;
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:8,代碼來源:CalledClassVisitor.java

示例10: newLocal

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Creates a new local variable of the given type.
 * 
 * @param type
 *            the type of the local variable to be created.
 * @return the identifier of the newly created local variable.
 */
public int newLocal(final Type type) {
    Object t;
    switch (type.getSort()) {
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        t = Opcodes.INTEGER;
        break;
    case Type.FLOAT:
        t = Opcodes.FLOAT;
        break;
    case Type.LONG:
        t = Opcodes.LONG;
        break;
    case Type.DOUBLE:
        t = Opcodes.DOUBLE;
        break;
    case Type.ARRAY:
        t = type.getDescriptor();
        break;
    // case Type.OBJECT:
    default:
        t = type.getInternalName();
        break;
    }
    int local = newLocalMapping(type);
    setLocalType(local, type);
    setFrameLocal(local, t);
    return local;
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:40,代碼來源:LocalVariablesSorter.java

示例11: isAssignableFrom

import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected boolean isAssignableFrom(final Type t, final Type u) {
    if (t.equals(u)) {
        return true;
    }
    if (currentClass != null && t.equals(currentClass)) {
        if (getSuperClass(u) == null) {
            return false;
        } else {
            if (isInterface) {
                return u.getSort() == Type.OBJECT
                        || u.getSort() == Type.ARRAY;
            }
            return isAssignableFrom(t, getSuperClass(u));
        }
    }
    if (currentClass != null && u.equals(currentClass)) {
        if (isAssignableFrom(t, currentSuperClass)) {
            return true;
        }
        if (currentClassInterfaces != null) {
            for (int i = 0; i < currentClassInterfaces.size(); ++i) {
                Type v = currentClassInterfaces.get(i);
                if (isAssignableFrom(t, v)) {
                    return true;
                }
            }
        }
        return false;
    }
    Class<?> tc = getClass(t);
    if (tc.isInterface()) {
        tc = Object.class;
    }
    return tc.isAssignableFrom(getClass(u));
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:36,代碼來源:SimpleVerifier.java

示例12: getElementValue

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
protected BasicValue getElementValue(final BasicValue objectArrayValue)
        throws AnalyzerException {
    Type arrayType = objectArrayValue.getType();
    if (arrayType != null) {
        if (arrayType.getSort() == Type.ARRAY) {
            return newValue(Type.getType(arrayType.getDescriptor()
                    .substring(1)));
        } else if ("Lnull;".equals(arrayType.getDescriptor())) {
            return objectArrayValue;
        }
    }
    throw new Error("Internal error");
}
 
開發者ID:ItzSomebody,項目名稱:BukkitPlugin-Message-Injector,代碼行數:15,代碼來源:SimpleVerifier.java

示例13: decodeBootstrapArgument

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private DexValue decodeBootstrapArgument(Object value) {
  if (value instanceof Integer) {
    return DexValue.DexValueInt.create((Integer) value);
  } else if (value instanceof Long) {
    return DexValue.DexValueLong.create((Long) value);
  } else if (value instanceof Float) {
    return DexValue.DexValueFloat.create((Float) value);
  } else if (value instanceof Double) {
    return DexValue.DexValueDouble.create((Double) value);
  } else if (value instanceof String) {
    return new DexValue.DexValueString(application.getString((String) value));

  } else if (value instanceof Type) {
    Type type = (Type) value;
    switch (type.getSort()) {
      case Type.OBJECT:
        return new DexValue.DexValueType(
            application.getTypeFromDescriptor(((Type) value).getDescriptor()));
      case Type.METHOD:
        return new DexValue.DexValueMethodType(
            application.getProto(((Type) value).getDescriptor()));
    }
    throw new Unreachable("Type sort is not supported: " + type.getSort());

  } else if (value instanceof Handle) {
    return new DexValue.DexValueMethodHandle(getMethodHandle(application, (Handle) value));
  } else {
    throw new Unreachable(
        "Unsupported bootstrap static argument of type " + value.getClass().getSimpleName());
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:32,代碼來源:JarSourceCode.java

示例14: processReferenceAnnotation

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static Collection<Reference<? extends Item>> processReferenceAnnotation(Item item, AnnotationNode node, Class<?> annotClass) throws ConstraintException {
    if (!annotClass.isAnnotation())
        throw new IllegalArgumentException("annotClass must be an annotation type");
    if (!("L" + annotClass.getName().replace('.', '/') + ";").equals(node.desc))
        throw new IllegalArgumentException("annot class mismatch");
    Map<Object, Object> map = processPairs(node.values);
    Object value = map.get("value");
    if (!(value instanceof List))
        throw new ConstraintException("value not given");
    Object weakBoxed = map.get("weakBoxed");
    if (weakBoxed == null) {
        try {
            weakBoxed = annotClass.getDeclaredMethod("weak").getDefaultValue();
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
    if (!(weakBoxed instanceof Boolean))
        throw new ConstraintException("Invalid or null weak property type");
    boolean isStrong = !(boolean) weakBoxed;
    Collection<Reference<? extends Item>> refs = new ArrayList<>();
    for (Object ref : (List<?>) value) {
        String id = null;
        if (ref instanceof String)
            id = ((String) ref).replace(".", "/");
        else if (ref instanceof Type) {
            Type typ = (Type) ref;
            if (typ.getSort() == Type.OBJECT) {
                id = typ.getInternalName();
                if (id == null) throw new NullPointerException();
            }
        }
        if (id == null)
            throw new ConstraintException("Invalid type specified in value: " + ref + " (" + ref.getClass() + ")");
        refs.add(new ReferenceProxy<>(item, id, isStrong)); // TODO use legitimate one
    }
    return refs;
}
 
開發者ID:iamahuman,項目名稱:IdentObf,代碼行數:39,代碼來源:AsmAnnotationAdapter.java

示例15: ifCmp

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Generates the instructions to jump to a label based on the comparison of
 * the top two stack values.
 * 
 * @param type
 *            the type of the top two stack values.
 * @param mode
 *            how these values must be compared. One of EQ, NE, LT, GE, GT,
 *            LE.
 * @param label
 *            where to jump if the comparison result is <tt>true</tt>.
 */
public void ifCmp(final Type type, final int mode, final Label label) {
    switch (type.getSort()) {
    case Type.LONG:
        mv.visitInsn(Opcodes.LCMP);
        break;
    case Type.DOUBLE:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL
                : Opcodes.DCMPG);
        break;
    case Type.FLOAT:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL
                : Opcodes.FCMPG);
        break;
    case Type.ARRAY:
    case Type.OBJECT:
        switch (mode) {
        case EQ:
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
            return;
        case NE:
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
            return;
        }
        throw new IllegalArgumentException("Bad comparison for type "
                + type);
    default:
        int intOp = -1;
        switch (mode) {
        case EQ:
            intOp = Opcodes.IF_ICMPEQ;
            break;
        case NE:
            intOp = Opcodes.IF_ICMPNE;
            break;
        case GE:
            intOp = Opcodes.IF_ICMPGE;
            break;
        case LT:
            intOp = Opcodes.IF_ICMPLT;
            break;
        case LE:
            intOp = Opcodes.IF_ICMPLE;
            break;
        case GT:
            intOp = Opcodes.IF_ICMPGT;
            break;
        }
        mv.visitJumpInsn(intOp, label);
        return;
    }
    mv.visitJumpInsn(mode, label);
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:65,代碼來源:GeneratorAdapter.java


注:本文中的org.objectweb.asm.Type.getSort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。