Inheritance: IPrimarySourceDocument
コード例 #1
0
 /// <summary>
 /// Allocates a source location that falls inside a region of text that originally came from another source document.
 /// </summary>
 /// <param name="document">A document with a region of text that orignally came from another source document.</param>
 /// <param name="startIndex">The character index of the first character of this location, when treating the source document as a single string.</param>
 /// <param name="length">The number of characters in this source location.</param>
 internal IncludedSourceLocation(SourceDocumentWithInclusion document, int startIndex, int length)
   //^ requires startIndex >= 0 && (startIndex < document.Length || startIndex == 0);
   //^ requires length >= 0 && length <= document.Length;
   //^ requires (startIndex + length) <= document.Length;
 {
   this.sourceDocument = document;
   this.startIndex = startIndex;
   this.length = length;
 }
コード例 #2
0
    /// <summary>
    /// Allocates a source location that falls inside a region of text that originally came from another source document.
    /// </summary>
    /// <param name="document">A document with a region of text that orignally came from another source document.</param>
    /// <param name="startIndex">The character index of the first character of this location, when treating the source document as a single string.</param>
    /// <param name="length">The number of characters in this source location.</param>
    internal IncludedSourceLocation(SourceDocumentWithInclusion document, int startIndex, int length) {
      Contract.Requires(document != null);
      Contract.Requires(startIndex >= 0 && (startIndex < document.Length || startIndex == 0));
      Contract.Requires(length >= 0 && length <= document.Length);
      Contract.Requires((startIndex + length) <= document.Length);

      this.sourceDocument = document;
      this.startIndex = startIndex;
      this.length = length;
    }
コード例 #3
0
ファイル: Preprocessor.cs プロジェクト: edgar-pek/VCDryad
 internal PreprocessorInformation(IPrimarySourceDocument newDocumentToPreprocess, PreprocessorInformation template)
 {
     this.sourceDocument = newDocumentToPreprocess;
       SourceDocumentWithInclusion/*?*/ sourceOfInclusion = null;
       List<Directive> directives = new List<Directive>(template.Directives);
       List<IErrorMessage> errors = new List<IErrorMessage>(template.errors);
       List<ISourceLocation> excludedLocations = new List<ISourceLocation>(template.ExcludedLocations);
       List<ISourceLocation> includedLocations = new List<ISourceLocation>(template.IncludedLocations);
       for (int i = 0, n = directives.Count; i < n; i++) {
     //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(directives[i].SourceLocation.SourceDocument);
     directives[i] = directives[i].MakeShallowCopy(newDocumentToPreprocess);
       }
       for (int i = 0, n = errors.Count; i < n; i++) {
     ISourceErrorMessage/*?*/ sourceError = errors[i] as ISourceErrorMessage;
     //^ assume sourceError != null;
     //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sourceError.SourceLocation.SourceDocument);
     errors[i] = sourceError.MakeShallowCopy(newDocumentToPreprocess);
       }
       for (int i = 0, n = excludedLocations.Count; i < n; i++) {
     ISourceLocation excludedLocation = excludedLocations[i];
     SourceDocumentWithInclusion/*?*/ idoc = excludedLocation.SourceDocument as SourceDocumentWithInclusion;
     if (idoc != null) {
       if (sourceOfInclusion == null || !idoc.IsUpdatedVersionOf(sourceOfInclusion))
     sourceOfInclusion = new SourceDocumentWithInclusion(newDocumentToPreprocess, idoc.OriginalLineNumber, idoc.OriginalDocumentName, idoc.StartingPositionOfIncludedRegion);
       excludedLocations[i] = sourceOfInclusion.GetCorrespondingSourceLocation(excludedLocation);
     } else {
       //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(excludedLocation.SourceDocument);
       excludedLocations[i] =  newDocumentToPreprocess.GetCorrespondingSourceLocation(excludedLocation);
     }
       }
       for (int i = 0, n = includedLocations.Count; i < n; i++) {
     ISourceLocation includedLocation = includedLocations[i];
     SourceDocumentWithInclusion/*?*/ idoc = includedLocation.SourceDocument as SourceDocumentWithInclusion;
     if (idoc != null) {
       if (sourceOfInclusion == null || !idoc.IsUpdatedVersionOf(sourceOfInclusion))
     sourceOfInclusion = new SourceDocumentWithInclusion(newDocumentToPreprocess, idoc.OriginalLineNumber, idoc.OriginalDocumentName, idoc.StartingPositionOfIncludedRegion);
       includedLocations[i] = sourceOfInclusion.GetCorrespondingSourceLocation(includedLocation);
     } else {
       //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(includedLocation.SourceDocument);
       includedLocations[i] =  newDocumentToPreprocess.GetCorrespondingSourceLocation(includedLocation);
     }
       }
       this.directives = directives;
       this.errors = errors;
       this.excludedLocations = excludedLocations;
       this.includedLocations = includedLocations;
 }
コード例 #4
0
 //^ requires startIndex >= 0 && (startIndex < document.Length || startIndex == 0);
 //^ requires length >= 0 && length <= document.Length;
 //^ requires (startIndex + length) <= document.Length;
 /// <summary>
 /// Allocates a source location that falls inside a region of text that originally came from another source document.
 /// </summary>
 /// <param name="document">A document with a region of text that orignally came from another source document.</param>
 /// <param name="startIndex">The character index of the first character of this location, when treating the source document as a single string.</param>
 /// <param name="length">The number of characters in this source location.</param>
 internal IncludedSourceLocation(SourceDocumentWithInclusion document, int startIndex, int length)
 {
     this.sourceDocument = document;
       this.startIndex = startIndex;
       this.length = length;
 }
コード例 #5
0
ファイル: Preprocessor.cs プロジェクト: edgar-pek/VCDryad
 //^ requires this.fragmentIndex > 0;
 //^ ensures this.startOfCurrentLine == this.fragmentIndex;
 /// <summary>
 /// Parses a #line directive, starting at the character following "line".
 /// Adds a LineDirective instance to this.preprocesorInformation.
 /// Leaves this.fragmentIndex pointing to the start of the first line after the line containing the #line directive. 
 /// </summary>
 private void ParseLine(bool include)
 {
     this.SkipBlanks();
       int? lineNumber = null;
       string/*?*/ documentName = null;
       string docName;
       this.errorIndex = this.fragmentIndex;
       char c = this.GetCurrentChar();
       if (c == 'd') {
     string d = this.ScanDirective();
     if (d != "default") {
       //^ assume this.fragmentIndex > this.errorIndex;
       this.HandleError(Error.PPDirectiveExpected);
     }
     this.sourceOfInclusion = null;
       } else {
     if (!Scanner.IsDigit(c)) {
       if (this.fragmentIndex == this.fragmentLength)
     this.errorIndex = fragmentIndex -1;
       else
     this.fragmentIndex++;
       this.HandleError(Error.InvalidLineNumber);
     } else
       lineNumber = this.originalLineNumber = this.ScanNumber();
       }
       this.SkipBlanks();
       if (this.GetCurrentChar() == '"') {
     documentName = docName = this.ScanString('"');
       } else {
     docName = this.documentToProcess.Name.Value;
     if (this.sourceOfInclusion != null) docName = this.sourceOfInclusion.Name.Value;
       }
       if (include) {
     //^ assume this.fragmentIndex > this.startOfCurrentLine;
     LineDirective lineDirective = new LineDirective(lineNumber, documentName, this.GetSourceLocation(this.startOfCurrentLine, this.fragmentIndex-this.startOfCurrentLine));
     this.preprocessorInformation.directives.Add(lineDirective);
       }
       //^ assume this.fragmentIndex <= this.fragmentLength;
       this.SkipPastBlanksCommentAndNewLine();
       this.sourceOfInclusion = new SourceDocumentWithInclusion(this.documentToProcess, this.originalLineNumber, docName, this.offset+this.startOfCurrentLine);
 }