Package org.objectweb.asm

Examples of org.objectweb.asm.Type


    public static MethodInfo getMethodInfo(Member member) {
        return getMethodInfo(member, member.getModifiers());
    }

    public static ClassInfo getClassInfo(final Class clazz) {
        final Type type = Type.getType(clazz);
        final Type sc = (clazz.getSuperclass() == null) ? null : Type.getType(clazz.getSuperclass());
        return new ClassInfo() {
            public Type getType() {
                return type;
            }
            public Type getSuperType() {
View Full Code Here


        e.dup();
        e.load_arg(0);
        EmitUtils.constructor_switch(e, constructors, new ObjectSwitchCallback() {
            public void processCase(Object key, Label end) {
                MethodInfo constructor = (MethodInfo)key;
                Type types[] = constructor.getSignature().getArgumentTypes();
                for (int i = 0; i < types.length; i++) {
                    e.load_arg(1);
                    e.push(i);
                    e.aaload();
                    e.unbox(types[i]);
View Full Code Here

                    // have had a bridge doing an invokespecial.
                    // If it isn't true, we would need to checkcast each argument
                    // against the target's argument types
                    e.invoke_virtual_this(bridgeTarget);
                   
                    Type retType = method.getSignature().getReturnType();                   
                    // Not necessary to cast if the target & bridge have
                    // the same return type.
                    // (This conveniently includes void and primitive types,
                    // which would fail if casted.  It's not possible to
                    // covariant from boxed to unbox (or vice versa), so no having
                    // to box/unbox for bridges).
                    // TODO: It also isn't necessary to checkcast if the return is
                    // assignable from the target.  (This would happen if a subclass
                    // used covariant returns to narrow the return type within a bridge
                    // method.)
                    if (!retType.equals(bridgeTarget.getReturnType())) {
                        e.checkcast(retType);
                    }
                } else {
                    e.super_invoke(method.getSignature());
                }
View Full Code Here

//
//                    this.visitVarInsn(ALOAD, 2);
//                    this.visitLabel(l2);
//                    this.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
                } else {
                    Type rtn = method.getReturnType();

                    if (rtn == Type.VOID_TYPE) {
                        this.visitLdcInsn(_className);
                        this.visitLdcInsn(method.toString());
                        this.visitMethodInsn(INVOKESTATIC,
View Full Code Here

    } else if (value instanceof EnumConstValue) {
      EnumConstValue e = (EnumConstValue) value;
      return "new Annotation.EnumConstValue(\""+e.typeName+"\", \""+e.constName+"\")";

    } else if (value instanceof Type) {
      Type t = (Type)value;
      return "Type.getType(\""+t.getDescriptor()+"\")";

    } else if (value instanceof Annotation) {
      return asmify((Annotation)value, buf, valName);

    } else if (value instanceof Object[]) {
View Full Code Here

    Frame current = newFrame(m.maxLocals, m.maxStack);
    Frame handler = newFrame(m.maxLocals, m.maxStack);
    Type[] args = Type.getArgumentTypes(m.desc);
    int local = 0;
    if ((m.access & ACC_STATIC) == 0) {
      Type ctype = Type.getType("L" + c.name + ";");
      current.setLocal(local++, interpreter.newValue(ctype));
    }
    for (int i = 0; i < args.length; ++i) {
      current.setLocal(local++, interpreter.newValue(args[i]));
      if (args[i].getSize() == 2) {
        current.setLocal(local++, interpreter.newValue(null));
      }
    }
    while (local < m.maxLocals) {
      current.setLocal(local++, interpreter.newValue(null));
    }
    merge(0, current, null);

    // control flow analysis
    while (top > 0) {
      int insn = queue[--top];
      Frame f = frames[insn];
      Subroutine subroutine = subroutines[insn];
      queued[insn] = false;

      try {
        Object o = m.instructions.get(insn);
       
        if (o instanceof Label) {
          merge(insn + 1, f, subroutine);
        } else {
          AbstractInsnNode insnNode = (AbstractInsnNode)o;
          int insnOpcode = insnNode.getOpcode();
         
          current.init(f).execute(insnNode, interpreter);
          subroutine = subroutine == null ? null : subroutine.copy();
         
          if (insnNode instanceof JumpInsnNode) {
            JumpInsnNode j = (JumpInsnNode)insnNode;
            if (insnOpcode != GOTO && insnOpcode != JSR) {
              merge(insn + 1, current, subroutine);
            }
            if (insnOpcode == JSR) {
              subroutine = new Subroutine(j.label, m.maxLocals, j);
            }
            merge(indexes.get(j.label), current, subroutine);
          } else if (insnNode instanceof LookupSwitchInsnNode) {
            LookupSwitchInsnNode lsi = (LookupSwitchInsnNode)insnNode;
            merge(indexes.get(lsi.dflt), current, subroutine);
            for (int j = 0; j < lsi.labels.size(); ++j) {
              Label label = (Label)lsi.labels.get(j);
              merge(indexes.get(label), current, subroutine);
            }
          } else if (insnNode instanceof TableSwitchInsnNode) {
            TableSwitchInsnNode tsi = (TableSwitchInsnNode)insnNode;
            merge(indexes.get(tsi.dflt), current, subroutine);
            for (int j = 0; j < tsi.labels.size(); ++j) {
              Label label = (Label)tsi.labels.get(j);
              merge(indexes.get(label), current, subroutine);
            }
          } else if (insnOpcode == RET) {
            if (subroutine == null) {
              throw new AnalyzerException(
                "RET instruction outside of a sub routine");
            } else {
              for (int i = 0; i < subroutine.callers.size(); ++i) {
                int caller = indexes.get(subroutine.callers.get(i));
                merge(caller + 1, frames[caller], current, subroutine.access);
              }
            }
          } else if (insnOpcode != ATHROW && (insnOpcode < IRETURN || insnOpcode > RETURN)) {
            if (subroutine != null) {
              if (insnNode instanceof VarInsnNode) {
                int var = ((VarInsnNode)insnNode).var;
                subroutine.access[var] = true;
                if (insnOpcode == LLOAD ||
                    insnOpcode == DLOAD ||
                    insnOpcode == LSTORE ||
                    insnOpcode == DSTORE)
                {
                  subroutine.access[var + 1] = true;
                }
              } else if (insnNode instanceof IincInsnNode) {
                int var = ((IincInsnNode)insnNode).var;
                subroutine.access[var] = true;
              }
            }
            merge(insn + 1, current, subroutine);
          }
        }
       
        List insnHandlers = handlers[insn];
        if (insnHandlers != null) {
          for (int i = 0; i < insnHandlers.size(); ++i) {
            TryCatchBlockNode tcb = (TryCatchBlockNode)insnHandlers.get(i);
            Type type;
            if (tcb.type == null) {
              type = Type.getType("Ljava/lang/Throwable;");
            } else {
              type = Type.getType("L" + tcb.type + ";");
            }
View Full Code Here

      case DMUL:
      case DDIV:
      case DREM:
        return BasicValue.DOUBLE_VALUE;
      case AALOAD:
        Type t = ((BasicValue)value1).getType();
        if (t != null && t.getSort() == Type.ARRAY) {
          return newValue(t.getElementType());
        } else {
          return BasicValue.REFERENCE_VALUE;
        }
      case LCMP:
      case FCMPL:
View Full Code Here

    }
    return v;
  }
 
  protected boolean isArrayValue (final Value value) {
    Type t = ((BasicValue)value).getType();
    if (t != null) {
      return t.getDescriptor().equals("Lnull;") || t.getSort() == Type.ARRAY;
    }
    return false;
  }
View Full Code Here

  }
     
  protected Value getElementValue (final Value objectArrayValue)
    throws AnalyzerException
  {
    Type arrayType = ((BasicValue)objectArrayValue).getType();
    if (arrayType != null) {
      if (arrayType.getSort() == Type.ARRAY) {
        return newValue(Type.getType(arrayType.getDescriptor().substring(1)));
      } else if (arrayType.getDescriptor().equals("Lnull;")) {
        return objectArrayValue;
      }
    }
    throw new AnalyzerException("Not an array type");
  }
View Full Code Here

    }
    throw new AnalyzerException("Not an array type");
  }
   
  protected boolean isSubTypeOf (final Value value, final Value expected) {
    Type expectedType = ((BasicValue)expected).getType();
    Type type = ((BasicValue)value).getType();
    if (expectedType == null) {
      return type == null;
    } else {
      switch (expectedType.getSort()) {
        case Type.INT:
        case Type.FLOAT:
        case Type.LONG:
        case Type.DOUBLE:
          return type == expectedType;
        case Type.ARRAY:
        case Type.OBJECT:
          if (expectedType.getDescriptor().equals("Lnull;")) {
            return type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY;
          }
          Class expectedClass = getClass(expectedType);
          if (type.getDescriptor().equals("Lnull;")) {
            return !expectedClass.isPrimitive();
          } else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
            Class actualClass = getClass(type);
            return expectedClass.isAssignableFrom(actualClass);
          } else {
            return false;
          }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.