コード例 #1
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 /**
  * Directly changes this record's internal location string. The format of this string is
  * unspecified in general and is determined by the associated IIndexLocationConverter. This method
  * should not be called on PDOMFile objects that are referenced by the file index.
  *
  * @param internalLocation
  * @throws CoreException
  */
 public void setInternalLocation(String internalLocation) throws CoreException {
   Database db = fLinkage.getDB();
   long oldRecord = db.getRecPtr(record + LOCATION_REPRESENTATION);
   if (oldRecord != 0) db.getString(oldRecord).delete();
   db.putRecPtr(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
   location = null;
 }
コード例 #2
0
 @Override
 public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
   if (newBinding instanceof ICPPTemplateTemplateParameter) {
     final Database db = getDB();
     ICPPTemplateTemplateParameter ttp = (ICPPTemplateTemplateParameter) newBinding;
     updateName(newBinding.getNameCharArray());
     IType newDefault = null;
     try {
       newDefault = ttp.getDefault();
     } catch (DOMException e) {
       // ignore
     }
     if (newDefault != null) {
       linkage.storeType(record + DEFAULT_TYPE, newDefault);
     }
     long oldRec = db.getRecPtr(record + PARAMETERS);
     IPDOMCPPTemplateParameter[] oldParams = getTemplateParameters();
     try {
       params =
           PDOMTemplateParameterArray.createPDOMTemplateParameters(
               getLinkage(), this, ttp.getTemplateParameters());
       long newRec = PDOMTemplateParameterArray.putArray(db, params);
       db.putRecPtr(record + PARAMETERS, newRec);
       if (oldRec != 0) db.free(oldRec);
       for (IPDOMCPPTemplateParameter opar : oldParams) {
         opar.forceDelete(linkage);
       }
     } catch (DOMException e) {
     }
   }
 }
コード例 #3
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public void setReplacementHeader(String replacementHeader) throws CoreException {
   Database db = fLinkage.getDB();
   long oldRecord = db.getRecPtr(record + REPLACEMENT_HEADER);
   if (oldRecord != 0) db.getString(oldRecord).delete();
   long newRecord = replacementHeader == null ? 0 : db.newString(replacementHeader).getRecord();
   db.putRecPtr(record + REPLACEMENT_HEADER, newRecord);
 }
コード例 #4
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 public static PDOMFile recreateFile(PDOM pdom, final long record) throws CoreException {
   final Database db = pdom.getDB();
   final int linkageID = db.get3ByteUnsignedInt(record + LINKAGE_ID);
   PDOMLinkage linkage = pdom.getLinkage(linkageID);
   if (linkage == null)
     throw new CoreException(createStatus("Invalid linkage ID in database")); // $NON-NLS-1$
   return new PDOMFile(linkage, record);
 }
コード例 #5
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public ISignificantMacros getSignificantMacros() throws CoreException {
   if (sigMacros == null) {
     Database db = fLinkage.getDB();
     final IString encoded = db.getString(db.getRecPtr(record + SIGNIFICANT_MACROS));
     sigMacros =
         encoded == null ? ISignificantMacros.NONE : new SignificantMacros(encoded.getChars());
   }
   return sigMacros;
 }
  public PDOMCPPTemplateTypeParameter(
      PDOMLinkage linkage, PDOMNode parent, ICPPTemplateTypeParameter param) throws CoreException {
    super(linkage, parent, param.getNameCharArray());

    final Database db = getDB();
    int id = param.getParameterID();
    if (param.isParameterPack()) {
      id |= PACK_BIT;
    }
    db.putInt(record + PARAMETERID, id);
  }
コード例 #7
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public void setPragmaOnceSemantics(boolean value) throws CoreException {
   Database db = fLinkage.getDB();
   byte flags = db.getByte(record + FLAGS);
   if (value) {
     flags |= FLAG_PRAGMA_ONCE_SEMANTICS;
   } else {
     flags &= ~FLAG_PRAGMA_ONCE_SEMANTICS;
   }
   db.putByte(record + FLAGS, flags);
 }
 private void readParamID() {
   if (fCachedParamID == -1) {
     try {
       final Database db = getDB();
       fCachedParamID = db.getInt(record + PARAMETERID);
     } catch (CoreException e) {
       CCorePlugin.log(e);
       fCachedParamID = Integer.MAX_VALUE;
     }
   }
 }
コード例 #9
0
 @Override
 public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point)
     throws CoreException {
   if (newBinding instanceof IVariable) {
     final Database db = getDB();
     ICPPVariable var = (ICPPVariable) newBinding;
     IType newType = var.getType();
     setType(linkage, newType);
     setValue(var.getInitialValue());
     db.putByte(record + ANNOTATIONS, PDOMCPPAnnotations.encodeVariableAnnotations(var));
   }
 }
コード例 #10
0
 public PDOMCPPMethodTemplateSpecialization(
     PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
     throws CoreException {
   super(linkage, parent, (ICPPFunctionTemplate) method, specialized);
   computeTemplateParameters((ICPPFunctionTemplate) method); // Sets fTemplateParameters
   final Database db = getDB();
   long rec = PDOMTemplateParameterArray.putArray(db, fTemplateParameters);
   db.putRecPtr(record + TEMPLATE_PARAMS, rec);
   linkage
   .new ConfigureTemplateParameters(
       ((ICPPFunctionTemplate) method).getTemplateParameters(), fTemplateParameters);
 }
コード例 #11
0
  @Override
  public void forceDelete(PDOMLinkage linkage) throws CoreException {
    getDBName().delete();
    linkage.storeType(record + DEFAULT_TYPE, null);

    final Database db = getDB();
    long oldRec = db.getRecPtr(record + PARAMETERS);
    IPDOMCPPTemplateParameter[] oldParams = getTemplateParameters();
    if (oldRec != 0) db.free(oldRec);
    for (IPDOMCPPTemplateParameter opar : oldParams) {
      opar.forceDelete(linkage);
    }
  }
コード例 #12
0
  public PDOMCPPVariable(
      PDOMLinkage linkage, PDOMNode parent, ICPPVariable variable, boolean setTypeAndValue)
      throws CoreException {
    super(linkage, parent, variable.getNameCharArray());

    // Find the type record
    Database db = getDB();
    db.putByte(record + ANNOTATIONS, PDOMCPPAnnotations.encodeVariableAnnotations(variable));
    if (setTypeAndValue) {
      setType(parent.getLinkage(), variable.getType());
      setValue(variable.getInitialValue());
    }
  }
コード例 #13
0
  public PDOMCPPParameter(
      PDOMLinkage linkage, PDOMNode parent, ICPPParameter param, PDOMCPPParameter next)
      throws CoreException {
    super(linkage, parent, param.getNameCharArray());
    fType = null; // This constructor is used for adding parameters to the database, only.
    fDefaultValue = param.getDefaultValue();

    Database db = getDB();
    linkage.storeValue(record + DEFAULT_VALUE, fDefaultValue);
    db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());

    storeAnnotations(db, param);
  }
コード例 #14
0
  private void storeProperties(ICPPEnumeration enumeration) throws CoreException {
    final Database db = getDB();
    db.putByte(record + OFFSET_FLAGS, enumeration.isScoped() ? (byte) 1 : (byte) 0);

    getLinkage().storeType(record + OFFSET_FIXED_TYPE, enumeration.getFixedType());

    if (enumeration instanceof ICPPInternalBinding) {
      if (((ICPPInternalBinding) enumeration).getDefinition() != null) {
        final long minValue = enumeration.getMinValue();
        final long maxValue = enumeration.getMaxValue();
        db.putLong(record + OFFSET_MIN_VALUE, minValue);
        db.putLong(record + OFFSET_MAX_VALUE, maxValue);
        fMinValue = minValue;
        fMaxValue = maxValue;
      }
    }
  }
コード例 #15
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public int compare(long record) throws CoreException {
   IString name = db.getString(db.getRecPtr(record + PDOMFile.LOCATION_REPRESENTATION));
   int cmp = name.compare(rawKey, true);
   if (cmp == 0 && linkageID >= 0) {
     cmp = db.get3ByteUnsignedInt(record + PDOMFile.LINKAGE_ID) - linkageID;
     if (cmp == 0 && rawSignificantMacros != null) {
       IString significantMacrosStr = getString(record + SIGNIFICANT_MACROS);
       if (significantMacrosStr != null) {
         cmp = significantMacrosStr.compare(rawSignificantMacros, true);
       } else {
         cmp = rawSignificantMacros.length > 0 ? -1 : 0;
       }
     }
   }
   return cmp;
 }
コード例 #16
0
  public PDOMCPPTemplateTemplateParameter(
      PDOMLinkage linkage, PDOMNode parent, ICPPTemplateTemplateParameter param)
      throws CoreException, DOMException {
    super(linkage, parent, param.getNameCharArray());

    final Database db = getDB();
    int id = param.getParameterID();
    if (param.isParameterPack()) {
      id |= PACK_BIT;
    }
    db.putInt(record + PARAMETERID, id);
    final ICPPTemplateParameter[] origParams = param.getTemplateParameters();
    final IPDOMCPPTemplateParameter[] params =
        PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
    long rec = PDOMTemplateParameterArray.putArray(db, params);
    getDB().putRecPtr(record + PARAMETERS, rec);
  }
コード例 #17
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
  /**
   * Deletes this file from PDOM. Only uncommitted files can be safely deleted.
   *
   * @throws CoreException
   */
  public void delete() throws CoreException {
    Database db = fLinkage.getDB();
    long locRecord = db.getRecPtr(record + LOCATION_REPRESENTATION);
    if (locRecord != 0) db.getString(locRecord).delete();
    locRecord = db.getRecPtr(record + SIGNIFICANT_MACROS);
    if (locRecord != 0) db.getString(locRecord).delete();
    locRecord = db.getRecPtr(record + REPLACEMENT_HEADER);
    if (locRecord != 0) db.getString(locRecord).delete();

    db.free(record);
  }
コード例 #18
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public IIndexFileLocation getLocation() throws CoreException {
   if (location == null) {
     Database db = fLinkage.getDB();
     String raw = db.getString(db.getRecPtr(record + LOCATION_REPRESENTATION)).getString();
     location = fLinkage.getPDOM().getLocationConverter().fromInternalFormat(raw);
     if (location == null) {
       URI uri;
       try {
         int idx = raw.lastIndexOf('>');
         uri = new URI("file", null, raw.substring(idx + 1), null); // $NON-NLS-1$
       } catch (URISyntaxException e) {
         uri = URI.create("file:/unknown-location"); // $NON-NLS-1$
       }
       location = new IndexFileLocation(uri, null);
     }
   }
   return location;
 }
コード例 #19
0
  public PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using)
      throws CoreException {
    super(linkage, parent, using.getNameCharArray());

    final Database db = getDB();
    final char[] name = using.getNameCharArray();
    PDOMCPPUsingDeclaration last = null;
    for (IBinding delegate : using.getDelegates()) {
      if (delegate != null) {
        if (last == null) {
          setTargetBinding(linkage, delegate);
          last = this;
        } else {
          PDOMCPPUsingDeclaration next = new PDOMCPPUsingDeclaration(linkage, parent, name);
          next.setTargetBinding(linkage, delegate);
          db.putRecPtr(last.getRecord() + NEXT_DELEGATE, next.record);
          last = next;
        }
      }
    }
  }
コード例 #20
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public int compare(long record1, long record2) throws CoreException {
   IString name1 = db.getString(db.getRecPtr(record1 + LOCATION_REPRESENTATION));
   IString name2 = db.getString(db.getRecPtr(record2 + LOCATION_REPRESENTATION));
   int cmp = name1.compare(name2, true);
   if (cmp == 0) {
     cmp =
         db.get3ByteUnsignedInt(record1 + LINKAGE_ID)
             - db.get3ByteUnsignedInt(record2 + LINKAGE_ID);
     if (cmp == 0) {
       IString sm1 = getString(record1 + SIGNIFICANT_MACROS);
       IString sm2 = getString(record2 + SIGNIFICANT_MACROS);
       if (sm1 == null) {
         cmp = sm2 == null ? 0 : -1;
       } else if (sm2 == null) {
         cmp = 1;
       } else {
         cmp = sm1.compare(sm2, true);
       }
     }
   }
   return cmp;
 }
コード例 #21
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
  /**
   * Transfers names, macros and includes from another file to this one and deletes the other file.
   *
   * @param sourceFile the file to transfer the local bindings from.
   * @throws CoreException
   */
  public void replaceContentsFrom(PDOMFile sourceFile) throws CoreException {
    // Delete current content
    clear();

    // Link in the using directives
    setLastUsingDirective(sourceFile.getLastUsingDirectiveRec());

    // Link in the includes, replace the owner.
    PDOMInclude include = sourceFile.getFirstInclude();
    setFirstInclude(include);
    for (; include != null; include = include.getNextInIncludes()) {
      include.setIncludedBy(this);
    }

    // In the unexpected case that there is an included by relation, append it.
    transferIncluders(sourceFile);

    // Link in the macros.
    PDOMMacro macro = sourceFile.getFirstMacro();
    setFirstMacro(macro);
    for (; macro != null; macro = macro.getNextMacro()) {
      macro.setFile(this);
    }

    // Link in macro references
    PDOMMacroReferenceName mref = sourceFile.getFirstMacroReference();
    setFirstMacroReference(mref);
    for (; mref != null; mref = mref.getNextInFile()) {
      mref.setFile(this);
    }

    // Replace all the names in this file
    PDOMName name = sourceFile.getFirstName();
    setFirstName(name);
    for (; name != null; name = name.getNextInFile()) {
      name.setFile(this);
    }

    setTimestamp(sourceFile.getTimestamp());
    setSourceReadTime(sourceFile.getSourceReadTime());
    setSizeAndEncodingHashcode(sourceFile.getSizeAndEncodingHashcode());
    setContentsHash(sourceFile.getContentsHash());

    // Transfer the flags.
    Database db = fLinkage.getDB();
    db.putByte(record + FLAGS, db.getByte(sourceFile.record + FLAGS));

    // Transfer the replacement header.
    db.putRecPtr(record + REPLACEMENT_HEADER, db.getRecPtr(sourceFile.record + REPLACEMENT_HEADER));
    db.putRecPtr(sourceFile.record + REPLACEMENT_HEADER, 0);

    // Delete the source file
    sourceFile.delete();
  }
コード例 #22
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 public PDOMFile(
     PDOMLinkage linkage, IIndexFileLocation location, int linkageID, ISignificantMacros macros)
     throws CoreException {
   fLinkage = linkage;
   this.location = location;
   Database db = fLinkage.getDB();
   record = db.malloc(RECORD_SIZE);
   String locationString = fLinkage.getPDOM().getLocationConverter().toInternalFormat(location);
   if (locationString == null)
     throw new CoreException(
         CCorePlugin.createStatus(
             Messages.getString("PDOMFile.toInternalProblem") + location.getURI())); // $NON-NLS-1$
   IString locationDBString = db.newString(locationString);
   db.putRecPtr(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
   db.put3ByteUnsignedInt(record + LINKAGE_ID, linkageID);
   db.putRecPtr(record + SIGNIFICANT_MACROS, db.newString(macros.encode()).getRecord());
   setTimestamp(-1);
 }
コード例 #23
0
  public PDOMMacroReferenceName(
      PDOMLinkage linkage, IASTName name, PDOMFile file, PDOMMacroContainer container)
      throws CoreException {
    this.linkage = linkage;
    Database db = linkage.getDB();
    record = db.malloc(RECORD_SIZE);

    db.putRecPtr(record + CONTAINER_REC_OFFSET, container.getRecord());
    db.putRecPtr(record + FILE_REC_OFFSET, file.getRecord());

    // Record our location in the file
    IASTFileLocation fileloc = name.getFileLocation();
    db.putInt(record + NODE_OFFSET_OFFSET, fileloc.getNodeOffset());
    db.putShort(record + NODE_LENGTH_OFFSET, (short) fileloc.getNodeLength());
    container.addReference(this);
  }
コード例 #24
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public long getContentsHash() throws CoreException {
   Database db = fLinkage.getDB();
   return db.getLong(record + CONTENT_HASH);
 }
コード例 #25
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public String getReplacementHeader() throws CoreException {
   Database db = fLinkage.getDB();
   long rec = db.getRecPtr(record + REPLACEMENT_HEADER);
   return rec == 0 ? null : db.getString(rec).getString();
 }
コード例 #26
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 private IString getString(long offset) throws CoreException {
   long rec = db.getRecPtr(offset);
   return rec != 0 ? db.getString(rec) : null;
 }
コード例 #27
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public void setSourceReadTime(long time) throws CoreException {
   Database db = fLinkage.getDB();
   db.putLong(record + SOURCE_READ_TIME, time);
 }
コード例 #28
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public void setContentsHash(long hash) throws CoreException {
   Database db = fLinkage.getDB();
   db.putLong(record + CONTENT_HASH, hash);
 }
コード例 #29
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public int getSizeAndEncodingHashcode() throws CoreException {
   Database db = fLinkage.getDB();
   return db.getInt(record + SIZE_AND_ENCODING_HASH);
 }
コード例 #30
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 @Override
 public void setSizeAndEncodingHashcode(int hashcode) throws CoreException {
   Database db = fLinkage.getDB();
   db.putInt(record + SIZE_AND_ENCODING_HASH, hashcode);
 }