Package net.sf.rej.java.attribute

Examples of net.sf.rej.java.attribute.CodeAttribute


  }

  public void execute() {
    if (this.codeAttr == null) {
      int index = this.cp.optionalAddUtf8("Code");
      this.codeAttr = new CodeAttribute(index, this.cp, 0, 0);
    }
   
    this.attrs.addAttribute(this.codeAttr);
  }
View Full Code Here


        Map<Object, Range> map = fNode.getField().getOffsetMap();
        return map.get(Field.OffsetTag.ATTRIBUTES).offsetBy(parentRange.getOffset());
      } else if (parent instanceof AttributeNode) {
        // code attribute attributes
        AttributeNode aNode = (AttributeNode) parent;
        CodeAttribute cAttr = (CodeAttribute) aNode.getAttributeObject();
        Range range = cAttr.getOffsetMap().get(CodeAttribute.OffsetTag.ATTRIBUTES);
        Range parentRange = getRange(parent);
        return range.offsetBy(parentRange.getOffset());
      }
      return null;
    } else {
View Full Code Here

        Range offset = this.offsets.get(mdr.getMethod());
        this.hexEditor.getHexEditor().getSelectionModel().setSelectedInverval(offset.getOffset(), offset.getOffset() + offset.getSize());         
      } else if (er instanceof CodeRow) {
        CodeRow cr = (CodeRow) er;
        Method m = cr.getEnclosingMethodDef().getMethod();
        CodeAttribute ca = m.getAttributes().getCode();
        // "cache" method offset maps
        Map<Object, Range> methodOffsetMap = this.methodOffsets.get(m);
        if (methodOffsetMap == null) {
          methodOffsetMap = m.getOffsetMap();
          this.methodOffsets.put(m, methodOffsetMap);
        }
        Range range = methodOffsetMap.get(ca);
        int offset = this.offsets.get(m).getOffset() +  range.getOffset() + 14 + cr.getPosition();
        DecompilationContext dc = ca.getCode().createDecompilationContext();
        dc.setPosition(cr.getPosition());
        int size = cr.getInstruction().getSize(dc);
       
        this.hexEditor.getHexEditor().getSelectionModel().setSelectedInverval(offset, offset + size);         
      } else {
View Full Code Here

                  sd.drawDefaultOverstrike(m.getName());
                } else {
                  sd.drawDefault(m.getName());
                }

                CodeAttribute ca = m.getAttributes().getCode();
                LocalVariableTableAttribute lvs = null;
                if (ca != null) {
                  lvs = ca.getAttributes().getLocalVariableTable();
                }

                int paramLVDefOffset = 0;
                if (!AccessFlags.isStatic(m.getAccessFlags())) {
                  paramLVDefOffset = 1;
View Full Code Here

    MethodDefRow mdr = new MethodDefRow(cf, method, true, method.getAttributes().getCode() != null);
    list.add(mdr);

    Attributes attr = method.getAttributes();
    CodeAttribute codeAttr = attr.getCode();

    LineNumberTableAttribute lnAttr = null;
    LocalVariableTableAttribute lvs = null;
    if (codeAttr != null) {
      if (codeAttr.getAttributes() != null) {
        lnAttr = codeAttr.getAttributes().getLineNumberTable();
        lvs = codeAttr.getAttributes().getLocalVariableTable();
      }
      Code code = codeAttr.getCode();
      DecompilationContext dc = code.createDecompilationContext();
      List instructions = code.getInstructions();
      dc.setPosition(0);
      for (int j = 0; j < instructions.size(); j++) {
        Instruction instruction = (Instruction) instructions.get(j);
View Full Code Here

      rowsAll.add(mdrB);
    }

    Attributes attrA = methodA.getAttributes();
    Attributes attrB = methodB.getAttributes();
    CodeAttribute codeAttrA = attrA.getCode();
    CodeAttribute codeAttrB = attrB.getCode();

    LineNumberTableAttribute lnAttrA = null;
    LineNumberTableAttribute lnAttrB = null;
    LocalVariableTableAttribute lvsA = null;
    LocalVariableTableAttribute lvsB = null;
    if (codeAttrA != null && codeAttrB != null) {
      // TODO: deal with the case where only one is null
      // ie, one method has code, the other doesn't
     
      if (codeAttrA.getAttributes() != null) {
        lnAttrA = codeAttrA.getAttributes().getLineNumberTable();
        lvsA = codeAttrA.getAttributes().getLocalVariableTable();
      }
      if (codeAttrB.getAttributes() != null) {
        lnAttrB = codeAttrB.getAttributes().getLineNumberTable();
        lvsB = codeAttrB.getAttributes().getLocalVariableTable();
      }

      Code codeA = codeAttrA.getCode();
      Code codeB = codeAttrB.getCode();
     
      DecompilationContext dcA = codeA.createDecompilationContext();
      DecompilationContext dcB = codeB.createDecompilationContext();
     
      List<Instruction> instructionsA = codeA.getInstructions();
View Full Code Here

  }

  public void refresh() {
    this.subs = new ArrayList<AttributesNode>();
    if (this.attribute instanceof CodeAttribute) {
      CodeAttribute ca = (CodeAttribute) this.attribute;
      Attributes attrs = ca.getAttributes();
      AttributesNode attrsNode = new AttributesNode(attrs);
      attrsNode.setParent(this);
      this.subs.add(attrsNode);
    }
  }
View Full Code Here

        List<Method> methods = cf.getMethods();
        for (Method method : methods) {
          ic.setMethod(method);
          agent.processMethod(ic, method);

          CodeAttribute ca = method.getAttributes().getCode();
          ic.setCodeAttribute(ca);
          if (ca != null) {
            processAttributes(ic, ca.getAttributes(), agent);
          }
          // method variables
          LocalVariableTableAttribute lvt = null;
          if (ca != null) {
            lvt = ca.getAttributes().getLocalVariableTable();
          }
          if (lvt != null) {
            List<LocalVariable> lvs = lvt.getLocalVariables();

            for (LocalVariable lv : lvs) {
              agent.processLocalVariable(ic, lv);
            }
          }

          // method code
          Code code = null;
          if (ca != null)
            code = ca.getCode();
          if (code != null) {
            DecompilationContext dc = code
                .createDecompilationContext();
            ic.setDc(dc);
            dc.setPosition(0);
View Full Code Here

        Method method = new Method(cp);
        method.setAccessFlags(accessFlags);
        method.setNameIndex(nameIndex);
        method.setDescriptorIndex(descIndex);
        Attributes attributes = new Attributes();
        CodeAttribute ca = new CodeAttribute(codeAttrNameIndex, cp, maxStackSize, maxLocals);
        attributes.addAttribute(ca);
        ExceptionsAttribute ea = new ExceptionsAttribute(exAttrNameIndex, cp, exceptions);
        attributes.addAttribute(ea);
        method.setAttributes(attributes);
        return method;
View Full Code Here

          // create another deprecation EditorRow
        }
      }

      Attributes attr = method.getAttributes();
      CodeAttribute codeAttr = attr.getCode();
      MethodDefRow mdr = new MethodDefRow(cf, method, true,
          codeAttr != null);
      if (!deprecatedAnnotationAdded && method.isDeprecated()) {
        DeprecatedAnnotationDefRow ddr = new DeprecatedAnnotationDefRow();
        this.rows.add(ddr);
      }
      this.rows.add(mdr);
      this.classDef.addMethod(mdr);
      LineNumberTableAttribute lnAttr = null;
      LocalVariableTableAttribute lvs = null;
      if (codeAttr != null) {
        if (codeAttr.getAttributes() != null) {
          lnAttr = codeAttr.getAttributes().getLineNumberTable();
          lvs = codeAttr.getAttributes().getLocalVariableTable();
        }
        Code code = codeAttr.getCode();
        DecompilationContext dc = code.createDecompilationContext();
        dc.setPosition(0);
        for (Instruction instruction : code.getInstructions()) {

          if (instruction instanceof Label) {
View Full Code Here

TOP

Related Classes of net.sf.rej.java.attribute.CodeAttribute

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.