Package cn.wensiqun.asmsupport.definition.variable

Examples of cn.wensiqun.asmsupport.definition.variable.GlobalVariable


     * add
     * @param field
     */
    public void addGlobalVariableEntity(GlobalVariableEntity e) {
        if (ModifierUtils.isStatic(e.getModifiers())) {
          getGlobalVariables().add(new GlobalVariable(e.getOwner(), e));
        } else {
          getGlobalVariables().add(new GlobalVariable(getThisVariable(), e));
        }
    }
View Full Code Here


        return me;
    }*/

    @Override
    public GlobalVariable getGlobalVariable(String name) {
      GlobalVariable gv = super.getGlobalVariable(name);
      if(gv != null){
        return gv;
      }
     
        Class<?> fieldOwner = reallyClass;
        Field f = null;
        for(;fieldOwner!=null ;fieldOwner = fieldOwner.getSuperclass()){
            try {
                f = fieldOwner.getDeclaredField(name);
                break;
            } catch (NoSuchFieldException e) {
            }
        }
       
        if(f == null){
            throw new ASMSupportException("no such field exception : " + name);
        }
       
        if(!ModifierUtils.isStatic(f.getModifiers())){
            throw new ASMSupportException("the field \"" + f.getName() + "\" is non-static, cannot use current method!");
        }
       
        return new GlobalVariable(fieldOwner.equals(reallyClass) ? this : AClassFactory.getProductClass(fieldOwner),
            AClassFactory.getProductClass(f.getType()), f.getModifiers(), name);
    }
View Full Code Here

        return chooser.chooseMethod();
    }*/

    @Override
    public GlobalVariable getGlobalVariable(String name) {
      GlobalVariable gv = super.getGlobalVariable(name);
      if(gv != null){
          return gv;
        }
       
        Class<?> fieldOwner = superClass;
        Field f = null;
        for(;!fieldOwner.equals(Object.class;fieldOwner = fieldOwner.getSuperclass()){
            try {
                f = fieldOwner.getDeclaredField(name);
            } catch (NoSuchFieldException e) {
            }
        }
       
        if(f == null){
            throw new ASMSupportException("no such field exception : " + name);
        }
       
        return new GlobalVariable(AClassFactory.getProductClass(fieldOwner),
                new ProductClass(f.getType()), 0, name);
    }
View Full Code Here

  @Override
  public void newEnum(String name, Parameterized... argus){
        if(!ModifierUtils.isEnum(getMethodOwner().getModifiers())){
          throw new IllegalArgumentException("cannot create an enum constant cause by current class is not enum type");
        }
        GlobalVariable constant = getMethodOwner().getGlobalVariable(name);
        if(!ModifierUtils.isEnum(constant.getGlobalVariableEntity().getModifiers())){
          throw new IllegalArgumentException("cannot new an enum instant assign to non-enum type variable");
        }
        enumArgumentsList.add(new EnumConstructorInfo(name, argus));
    }
View Full Code Here

    if(getMethodOwner().getEnumNum() != enumArgumentsList.size()){
      throw new ASMSupportException("exist unassign enum constant!");
    }
   
    Parameterized[] values = new Parameterized[getMethodOwner().getEnumNum()];
    GlobalVariable enumConstant;
    int i = 0;
    for(EnumConstructorInfo enumArgu : enumArgumentsList){
      enumConstant = getMethodOwner().getGlobalVariable(enumArgu.name);
     
      values[i] = enumConstant;
      String enumName = enumArgu.name;
      Parameterized[] otherArgus = enumArgu.argus;
          Parameterized[] enumArgus = new Parameterized[otherArgus.length + 2];
          enumArgus[0] = Value.value(enumName);
          enumArgus[1] = Value.value(i);
          System.arraycopy(otherArgus, 0, enumArgus, 2, otherArgus.length);
         
          MethodInvoker mi = invokeConstructor(getMethodOwner(), enumArgus);
          assign(enumConstant, mi);
          i++;
    }
   
    GlobalVariable gv = getMethodOwner().getGlobalVariable("ENUM$VALUES");
   
    ArrayValue av = newArrayWithValue(AClassFactory.getArrayClass(getMethodOwner(), 1), values);
    assign(gv, av);
  }
View Full Code Here

TOP

Related Classes of cn.wensiqun.asmsupport.definition.variable.GlobalVariable

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.