Package cn.wensiqun.asmsupport.clazz

Examples of cn.wensiqun.asmsupport.clazz.AClass


        }
       
        AClass[] potentialMethodArgs = entity.getArgClasses();
        int potenMtdArgLen = ArrayUtils.getLength(potentialMethodArgs);
        for(int i=0; i < potenMtdArgLen - 1 ; i++){
          AClass actuallyArg = argumentTypes[i];
          AClass potentialArg = potentialMethodArgs[i];
          if(!AClassUtils.isSubOrEqualType(actuallyArg, potentialArg) && !canBeConvertedByMethodInvocationConversion(actuallyArg, potentialArg))
            return;
        }
       
        int actMtdArgLen = ArrayUtils.getLength(argumentTypes);
        if(actMtdArgLen >= potenMtdArgLen){
          AClass varargType = ((ArrayClass)potentialMethodArgs[potenMtdArgLen - 1]).getRootComponentClass();
          for(int i = potenMtdArgLen - 1; i<actMtdArgLen ; i++){
            AClass actuallyArg = argumentTypes[i];
            if(!AClassUtils.isSubOrEqualType(actuallyArg, varargType) && !canBeConvertedByMethodInvocationConversion(actuallyArg, varargType))
              return;
          }
        }
       
View Full Code Here


        this.exp3 = expression3;
    }

    @Override
    protected void verifyArgument() {
        AClass expCls1 = exp1.getParamterizedType();
        AClass expCls2 = exp2.getParamterizedType();
        AClass expCls3 = exp3.getParamterizedType();
       
        if(!expCls1.equals(AClass.BOOLEAN_ACLASS) && !expCls1.equals(AClass.BOOLEAN_WRAP_ACLASS)){
            throw new ASMSupportException("the first expression type of ternary operator must by boolean or Boolean!");
        }
       
View Full Code Here

         exp2.asArgument();
         exp3.asArgument();
    }

    private boolean checkExpression(AClass expCls1, AClass expCls2){
        AClass expPrimCls1 = AClassUtils.getPrimitiveAClass(expCls1);
        AClass expPrimCls2 = AClassUtils.getPrimitiveAClass(expCls2);
       
        if(expPrimCls1.equals(expPrimCls2)){
            resultClass = expPrimCls1;
            return true;
        }else if(expPrimCls1.isPrimitive() && expPrimCls2.isPrimitive()){
            if(expPrimCls1.equals(AClass.BOOLEAN_ACLASS) || expPrimCls2.equals(AClass.BOOLEAN_ACLASS)){
                return false;
            }else{
                if(expPrimCls1.getCastOrder() > expPrimCls2.getCastOrder()){
                    resultClass = expPrimCls1;
                }else{
                    resultClass = expPrimCls2;
                }
                return true;
            }
        }else if(expPrimCls1.isChildOrEqual(expPrimCls2)){
            resultClass = expPrimCls2;
            return true;
        }else if(expPrimCls2.isChildOrEqual(expPrimCls1)){
            resultClass = expPrimCls1;
            return true;
        }
        return false;
    }
View Full Code Here

       
    }
   
    @Override
    protected void verifyArgument() {
        AClass fatCls = factor.getParamterizedType();
        if(!AClassUtils.arithmetical(fatCls)){
            throw new ArithmeticException("cannot execute arithmetic operator whit " + fatCls);
        }
    }
View Full Code Here

    }


    @Override
    protected void afterInitProperties() {
        AClass fatCls = factor.getParamterizedType();
        resultClass = AClassUtils.getPrimitiveAClass(fatCls);
    }
View Full Code Here

    }

    @Override
    public void executing() {
        orginal.loadToStack(block);
        AClass from = orginal.getParamterizedType();
        if(to.equals(from)){
            return;
        }
       
        if(from.isPrimitive() && to.isPrimitive()){
            log.debug("checkcast from " + from + " to " + to );
            if(from.getCastOrder() > to.getCastOrder() ||
               (from.equals(AClass.CHAR_ACLASS) && to.equals(AClass.SHORT_ACLASS)) ||
               (to.equals(AClass.CHAR_ACLASS) && from.equals(AClass.SHORT_ACLASS))){
                insnHelper.cast(from.getType(), to.getType());
                return;
            }
        }
        log.debug("checkcast from " + from + " to " + to );
        insnHelper.checkCast(to.getType());
View Full Code Here

   * @param clazz
   * @return
   * @throws IOException
   */
  public static List<MethodEntity> getAllMethod(Class<?> clazz, final String findName) throws IOException{
    final AClass owner = AClassFactory.getProductClass(clazz);
    InputStream classStream = ASMClassLoader.asmClassLoader.getResourceAsStream(clazz.getName().replace('.', '/') + ".class");
    ClassReader cr = new ClassReader(classStream);
    final List<MethodEntity> list = new ArrayList<MethodEntity>();
   
    cr.accept(new ClassAdapter(new EmptyVisitor()){

      @Override
      public MethodVisitor visitMethod(int access, String name,
          String desc, String signature, String[] exceptions) {
        if((StringUtils.isEmpty(findName) || name.equals(findName))){
         
          if(exceptions == null){
            exceptions = new String[0];
          }
         
          try {
           
            Type[] types = Type.getArgumentTypes(desc);
            AClass[] aclass = new AClass[types.length];
            String[] args = new String[types.length];
            for(int i=0; i<types.length; i++){
              aclass[i] = AClassFactory.getProductClass(forName(types[i].getDescriptor()));
              args[i] = "arg" + i;
            }
           
            AClass returnType = AClassFactory.getProductClass(
                forName(Type.getReturnType(desc).getDescriptor()));
           

            AClass[] exceptionArray = new AClass[exceptions.length];
            for(int i=0; i<exceptions.length; i++){
View Full Code Here

        trueLbl = new Label();
    }

    @Override
  protected void verifyArgument() {
      AClass ftrCls = factor.getParamterizedType();
        if(!(ftrCls.equals(AClass.BOOLEAN_ACLASS) && !ftrCls.equals(AClass.BOOLEAN_WRAP_ACLASS))){
            throw new ASMSupportException("the factor type must be boolean or Boolean for logical operator!");
        }
  }
View Full Code Here

   
   
    @Override
    protected void executingProcess() {
        MethodVisitor mv = insnHelper.getMv();
        AClass ftrCls1 = factor1.getParamterizedType();
        AClass ftrCls2 = factor2.getParamterizedType();
       
        factor1.loadToStack(block);
        insnHelper.unbox(ftrCls1.getType());
        mv.visitJumpInsn(Opcodes.IFEQ, falseLbl);
       
        factor2.loadToStack(block);
        insnHelper.unbox(ftrCls2.getType());
        mv.visitJumpInsn(Opcodes.IFEQ, falseLbl);
       

        mv.visitInsn(Opcodes.ICONST_1);
        mv.visitJumpInsn(Opcodes.GOTO, trueLbl);
View Full Code Here

        this.factor2 = factor2;
    }

  @Override
  protected void verifyArgument() {
    AClass ftrCls1 = factor1.getParamterizedType();
        AClass ftrCls2 = factor2.getParamterizedType();
       
        if(!((ftrCls1.equals(AClass.BOOLEAN_ACLASS) || ftrCls1.equals(AClass.BOOLEAN_WRAP_ACLASS)) &&
           (ftrCls2.equals(AClass.BOOLEAN_ACLASS) || ftrCls2.equals(AClass.BOOLEAN_WRAP_ACLASS)))){
            throw new ASMSupportException("the factor type must be boolean or Boolean for logical operator!");
        }
  }
View Full Code Here

TOP

Related Classes of cn.wensiqun.asmsupport.clazz.AClass

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.