Package net.sf.rej.java.constantpool

Examples of net.sf.rej.java.constantpool.ConstantPoolInfo


 
  public ConstantPoolInfo getConstant() {
    ConstantValueAttribute attr = this.attributes.getConstantValueAttribute();
    if (attr != null) {
      int index = attr.getConstantIndex();
      ConstantPoolInfo cpi = this.pool.get(index);
      return cpi;
    }
   
    return null;
  }
View Full Code Here


    public Imports getImports(ClassFile cf) {
    Imports imports = new Imports(cf.getPackageName());
    ConstantPool pool = cf.getPool();

    for (int i = 0; i < pool.size(); i++) {
      ConstantPoolInfo cpi = pool.get(i);
      if (cpi != null) {
        if (cpi.getType() == ConstantPoolInfo.CLASS) {
          // there can be array definitions here, too
          JavaType cls = new JavaType(cpi.getValue());
          imports.addType(cls.getType());
        } else if (cpi.getType() == ConstantPoolInfo.NAME_AND_TYPE) {
          NameAndTypeInfo nati = (NameAndTypeInfo) cpi;
          Descriptor desc = nati.getDescriptor();
          if (!desc.getReturn().isPrimitive()) {
            imports.addType(desc.getReturn().getType());
          }
View Full Code Here

        this.cp = pool;
        List<Wrapper> al = new ArrayList<Wrapper>();
        this.imports = EditorFacade.getInstance().getImports(this.cf);

        for (int i = 0; i < this.cp.size(); i++) {
            ConstantPoolInfo cpi = this.cp.get(i);
            if (cpi != null) {
                if (cpi.getType() == ConstantPoolInfo.FIELD_REF) {
                    al.add(createWrapper((RefInfo) cpi));
                }
            }
        }
        this.model = new DefaultComboBoxModel(al.toArray());
View Full Code Here

  }

  @Override
  public List<StackElement> getPushedElements(DecompilationContext dc) {
    List<StackElement> elements = new ArrayList<StackElement>();
    ConstantPoolInfo cpi = dc.getConstantPool().get(this.index);
    if (cpi instanceof IntegerInfo) {
      elements.add(new StackElement("value", StackElementType.INT));
    } else if (cpi instanceof FloatInfo) {
      elements.add(new StackElement("value", StackElementType.FLOAT));
    } else if (cpi instanceof StringInfo) {
      elements.add(new StackElement("value", StackElementType.REF));
    } else {
      throw new AssertionError("ldc_w points to an invalid item on the constant pool: " + cpi.getClass());
    }
    return elements;
  }
View Full Code Here

  }

  @Override
  public List<StackElement> getPushedElements(DecompilationContext dc) {
    List<StackElement> elements = new ArrayList<StackElement>();
    ConstantPoolInfo cpi = dc.getConstantPool().get(this.index);
    if (cpi instanceof DoubleInfo) {
      elements.add(new StackElement("value", StackElementType.DOUBLE));
    } else if (cpi instanceof LongInfo) {
      elements.add(new StackElement("value", StackElementType.LONG));
    } else {
      throw new AssertionError("ldc2_w points to an invalid item on the constant pool: " + cpi.getClass());
    }
    return elements;
  }
View Full Code Here

  @Override
  public void processInstruction(IterationContext sc, Instruction instruction) {
    Parameters params = instruction.getParameters();
    for (int i = 0; i < params.getCount(); i++) {
      if (params.getType(i) == ParameterType.TYPE_CONSTANT_POOL_FIELD_REF) {
        ConstantPoolInfo cpi = sc.getDc().getConstantPool().get(
            params.getInt(i));
        RefInfo ri = (RefInfo) cpi;
        boolean classNamesMatch = ri.getClassName().equals(className);
        boolean fieldNamesMatch = ri.getTargetName().equals(fieldName);
        boolean descriptorsMatch = ri.getDescriptor().equals(desc);
View Full Code Here

  @Override
  public void processInstruction(IterationContext sc, Instruction instruction) {
    Parameters params = instruction.getParameters();
    for (int i = 0; i < params.getCount(); i++) {
      if (params.getType(i) == ParameterType.TYPE_CONSTANT_POOL_METHOD_REF) {
        ConstantPoolInfo cpi = sc.getDc().getConstantPool().get(
            params.getInt(i));
        RefInfo ri = (RefInfo) cpi;
        boolean classNamesMatch = ri.getClassName().equals(className);
        boolean methodNamesMatch = ri.getTargetName()
            .equals(methodName);
View Full Code Here

            case TYPE_CONSTANT: {
                sb.append(getInt(i));
                break;
            }
            case TYPE_CONSTANT_POOL_CLASS: {
                ConstantPoolInfo cpi = dc.getConstantPool().get(getInt(i));
                ClassInfo ci = (ClassInfo) cpi;
                sb.append(ci.getName());
                break;
            }
            case TYPE_CONSTANT_POOL_CONSTANT: {
                ConstantPoolInfo cpi = dc.getConstantPool().get(getInt(i));
                sb.append(cpi.getValue());
                break;
            }
            case TYPE_CONSTANT_POOL_FIELD_REF: {
                ConstantPoolInfo cpi = dc.getConstantPool().get(getInt(i));
                RefInfo ri = (RefInfo) cpi;
                Descriptor desc = ri.getDescriptor();
                sb.append(desc.getReturn() + " " + ri.getClassName() + "."
                        + ri.getTargetName());
                break;
            }
            case TYPE_CONSTANT_POOL_METHOD_REF: {
                ConstantPoolInfo cpi = dc.getConstantPool().get(getInt(i));
                RefInfo ri = (RefInfo) cpi;
                Descriptor desc = ri.getDescriptor();
                sb.append(desc.getReturn() + " " + ri.getClassName() + "."
                        + ri.getTargetName() + "(" + desc.getParams() + ")");
                break;
View Full Code Here

  }

  @Override
  public List<StackElement> getPushedElements(DecompilationContext dc) {
    List<StackElement> elements = new ArrayList<StackElement>();
    ConstantPoolInfo cpi = dc.getConstantPool().get(this.index);
    if (cpi instanceof IntegerInfo) {
      elements.add(new StackElement("value", StackElementType.INT));
    } else if (cpi instanceof FloatInfo) {
      elements.add(new StackElement("value", StackElementType.FLOAT));
    } else if (cpi instanceof StringInfo) {
      elements.add(new StackElement("value", StackElementType.REF));
    } else {
      throw new AssertionError("ldc points to an invalid item on the constant pool: " + cpi.getClass());
    }
    return elements;
  }
View Full Code Here

TOP

Related Classes of net.sf.rej.java.constantpool.ConstantPoolInfo

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.