예제 #1
0
 internal int CopyTo(int offset, char[] destination, int destinationOffset, int length, IPrimarySourceLocation primarySourceLocation) {
   if (this.offset <= offset && offset < this.offset + this.buffer.Length && offset+length <= this.offset+this.buffer.Length) {
     Array.Copy(this.buffer, offset-this.offset, destination, destinationOffset, length);
     return length;
   } else
     return primarySourceLocation.CopyTo(offset-primarySourceLocation.StartIndex, destination, destinationOffset, length);
 }
예제 #2
0
 internal SourceLocationWrapper(
 IPrimarySourceLocation firstSourceLocation, 
 IPrimarySourceLocation lastSourceLocation, 
 Func<string> getSource)
 {
     this.firstSourceLocation = firstSourceLocation;
       this.lastSourceLocation = lastSourceLocation;
       this.source = new Lazy<string>(getSource);
 }
예제 #3
0
        private static SourceCodeLocation Of(this IObjectWithLocations locatable, PdbReader pdb)
        {
            IPrimarySourceLocation location = locatable.GetValidLocation(pdb);

            return(location != null?location.ToSourceCodeLocation() : SourceCodeLocation.None);
        }
        private ISourceMappedItem GetSourceMappedItem(IPrimarySourceLocation location, MissingInfo memberInfo)
        {
            var unsupportedPlatformNames = GetUnsupportedPlatformNames(GetTargetStatus(memberInfo));

            return new CciSourceItem(location, memberInfo, unsupportedPlatformNames);
        }
예제 #5
0
 private PointerIsValidationLocation(CompileTimeConstant pointerSize, IPrimarySourceLocation expressionLocation)
     : base(expressionLocation)
 {
     this.pointerSize = pointerSize;
 }
예제 #6
0
 static void GetLocationLineSpan(IPrimarySourceLocation loc, out uint startLine, out uint endLine)
 {
     IIncludedSourceLocation/*?*/ iloc = loc as IIncludedSourceLocation;
       if (iloc != null) {
     startLine = (uint)iloc.OriginalStartLine;
     endLine = (uint)iloc.OriginalEndLine;
       } else {
     startLine = (uint)loc.StartLine;
     endLine = (uint)loc.EndLine;
       }
 }
예제 #7
0
파일: ErrorHandler.cs 프로젝트: tupipa/vcc
        public void HandleErrors(object sender, Microsoft.Cci.ErrorEventArgs args)
        {
            foreach (IErrorMessage error in args.Errors)
            {
                ISourceLocation /*?*/ sourceLocation = error.Location as ISourceLocation;
                if (sourceLocation == null)
                {
                    continue;
                }
                if (this.DebugOnWarningOrError)
                {
                    System.Diagnostics.Debugger.Launch();
                }
                bool isError = !error.IsWarning || WarningsAsErrors;
                if (!isError && GetWarningLevel(error.Code) > WarningLevel)
                {
                    continue;
                }
                if (isError)
                {
                    VccCommandLineHost.IncreaseErrorCount();
                }
                CompositeSourceDocument /*?*/ compositeDocument = sourceLocation.SourceDocument as CompositeSourceDocument;
                if (compositeDocument != null)
                {
                    foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sourceLocation))
                    {
                        sourceLocation = sl;
                        break;
                    }
                }
                IPrimarySourceLocation /*?*/ primarySourceLocation = sourceLocation as IPrimarySourceLocation;
                if (primarySourceLocation == null)
                {
                    Logger.Instance.Error(error.Message);
                    continue;
                }
                string docName     = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                int    startLine   = primarySourceLocation.StartLine;
                int    startColumn = primarySourceLocation.StartColumn;
                IncludedSourceLocation /*?*/ includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                if (includedSourceLocation != null)
                {
                    docName = includedSourceLocation.OriginalSourceDocumentName;
                    if (docName != null)
                    {
                        docName = docName.Replace("\\\\", "\\");
                    }
                    startLine = includedSourceLocation.OriginalStartLine;
                }
                long id = error.IsWarning ? ErrorToId(error.Code) : error.Code;
                if (WarningIsDisabled(id))
                {
                    return;
                }

                Logger.Instance.LogWithLocation(String.Format("VC{0:0000}", id), error.Message, new Location(docName, startLine, startColumn), isError ? LogKind.Error : LogKind.Warning, false);

                string firstErrFile = docName;
                int    firstErrLine = startLine;

                foreach (ILocation relatedLocation in error.RelatedLocations)
                {
                    ISourceLocation /*?*/ sloc = relatedLocation as ISourceLocation;
                    if (sloc != null)
                    {
                        compositeDocument = sloc.SourceDocument as CompositeSourceDocument;
                        if (compositeDocument != null)
                        {
                            foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sloc))
                            {
                                sloc = sl;
                                break;
                            }
                        }
                        primarySourceLocation = sloc as IPrimarySourceLocation;
                        if (primarySourceLocation == null)
                        {
                            continue;
                        }
                        docName                = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                        startLine              = primarySourceLocation.StartLine;
                        startColumn            = primarySourceLocation.StartColumn;
                        includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                        if (includedSourceLocation != null)
                        {
                            docName = includedSourceLocation.OriginalSourceDocumentName;
                            if (docName != null)
                            {
                                docName = docName.Replace("\\\\", "\\");
                            }
                            startLine = includedSourceLocation.OriginalStartLine;
                        }
                        if (docName != firstErrFile || firstErrLine != startLine)
                        {
                            Logger.Instance.LogWithLocation(
                                null,
                                String.Format("(Location of symbol related to previous {0}.)", isError ? "error" : "warning"),
                                new Location(docName, startLine, startColumn),
                                isError ? LogKind.Error : LogKind.Warning,
                                true);
                        }
                    }
                    //TODO: deal with non source locations
                }
            }
        }
예제 #8
0
 private PointerIsValidationLocation(CompileTimeConstant pointerSize, IPrimarySourceLocation expressionLocation)
     : base(expressionLocation)
 {
     this.pointerSize = pointerSize;
 }
예제 #9
0
 void ICcsHost.Event(CcsEventLevel level, IPrimarySourceLocation location, string format, params object[] args)
 {
     Contract.Requires(location != null);
     Contract.Requires(!String.IsNullOrEmpty(format));
     Contract.Requires(args != null);
     throw new NotImplementedException();
 }
예제 #10
0
 internal ExpressionSourceLocation(IPrimarySourceLocation primarySourceLocation)
 {
     Contract.Requires(primarySourceLocation != null);
     this.primarySourceLocation = primarySourceLocation;
 }
예제 #11
0
 public CciMethodLine(IPrimarySourceLocation sourceLocation)
 {
     SourceLocation = sourceLocation;
 }
예제 #12
0
        public void Event(CcsEventLevel level, IPrimarySourceLocation location, string format, params object[] args)
        {
            //Contract.Requires(location != null);
            //Contract.Requires(!String.IsNullOrEmpty(format));

            this.Event(level, location, String.Format(format, args));
        }
예제 #13
0
 public void Event(CcsEventLevel level, IPrimarySourceLocation location,  string message)
 {
     this.CountErrorsAndWarnings(level);
     [email protected]("CciSharp: {0}({1}): {2}{3}", location.SourceDocument.Location, location.StartLine, LevelToString(level), message);
 }
 public CciSourceItem(IPrimarySourceLocation location, MissingInfo item, IEnumerable<FrameworkName> unsupportedPlatformNames)
 {
     _column = location.StartColumn;
     _line = location.StartLine;
     _path = location.SourceDocument.Location;
     _item = item;
     _unsupportedPlatforms = unsupportedPlatformNames;
 }
예제 #15
0
 private void PrintSourceLocation(IPrimarySourceLocation psloc)
 {
     sourceEmitterOutput.WriteLine("");
     sourceEmitterOutput.Write(psloc.Document.Name.Value + "(" + psloc.StartLine + ":" + psloc.StartColumn + ")-(" + psloc.EndLine + ":" + psloc.EndColumn + "): ", true);
     sourceEmitterOutput.WriteLine(psloc.Source);
 }
예제 #16
0
 void ICcsHost.Event(CcsEventLevel level, IPrimarySourceLocation location, string message)
 {
     Contract.Requires(location != null);
     Contract.Requires(!String.IsNullOrEmpty(message));
     throw new NotImplementedException();
 }
예제 #17
0
 private void PrintSourceLocation(IPrimarySourceLocation psloc)
 {
     sourceEmitterOutput.WriteLine("");
     sourceEmitterOutput.Write(psloc.Document.Name.Value + "(" + psloc.StartLine + ":" + psloc.StartColumn + ")-(" + psloc.EndLine + ":" + psloc.EndColumn + "): ", true);
     sourceEmitterOutput.WriteLine(psloc.Source);
 }
예제 #18
0
 protected AssertionAdderSourceLocationWrapper(IPrimarySourceLocation wrappedSourceLocation)
 {
     this.wrappedSourceLocation = wrappedSourceLocation;
 }
예제 #19
0
 internal PreprocessorSourceLocation(IPrimarySourceLocation slFromDocument, Preprocessor preprocessor) {
   this.slFromDocument = slFromDocument;
   this.preprocessor = preprocessor;
 }
예제 #20
0
        internal static PointerIsValidationLocation For(CompileTimeConstant pointerSize, IEnumerable <ILocation> locations)
        {
            IPrimarySourceLocation ploc = AssertAssumeAdderVisitor.GetPrimarySourceLocationFrom(locations);

            return(new PointerIsValidationLocation(pointerSize, ploc));
        }
예제 #21
0
 internal string GetSource(IPrimarySourceLocation primarySourceLocation) {
   if (this.offset <= primarySourceLocation.StartIndex && primarySourceLocation.EndIndex <= this.offset+this.buffer.Length)
     return new String(this.buffer, primarySourceLocation.StartIndex-this.offset, primarySourceLocation.Length);
   else
     return primarySourceLocation.Source;
 }
        private ISourceMappedItem GetSourceMappedItem(IPrimarySourceLocation location, MissingInfo memberInfo)
        {
            var unsupportedPlatformNames = GetUnsupportedPlatformNames(GetTargetStatus(memberInfo));

            return(new CciSourceItem(_assemblyPath, location, memberInfo, unsupportedPlatformNames));
        }
예제 #23
0
 private void PrintSourceLocation(IPrimarySourceLocation psloc) {
   sourceEmitterOutput.WriteLine("");
   sourceEmitterOutput.Write(psloc.Document.Name.Value+"("+psloc.StartLine+":"+psloc.StartColumn+")-("+psloc.EndLine+":"+psloc.EndColumn+"): ");
   var source = psloc.Source;
   var newLinePos = source.IndexOf('\n');
   if (newLinePos > 0) source = source.Substring(0, newLinePos);
   sourceEmitterOutput.WriteLine(source);
 }
예제 #24
0
 protected AssertionAdderSourceLocationWrapper(IPrimarySourceLocation wrappedSourceLocation)
 {
     this.wrappedSourceLocation = wrappedSourceLocation;
 }
예제 #25
0
파일: Helpers.cs 프로젝트: xornand/cci
 internal ExpressionSourceLocation(IPrimarySourceLocation primarySourceLocation) {
   Contract.Requires(primarySourceLocation != null);
   this.primarySourceLocation = primarySourceLocation;
 }
예제 #26
0
 internal void HandleErrors(object sender, Microsoft.Cci.ErrorEventArgs args)
 {
     foreach (IErrorMessage error in args.Errors)
     {
         ISourceLocation /*?*/ sourceLocation = error.Location as ISourceLocation;
         if (sourceLocation == null)
         {
             continue;
         }
         if (!error.IsWarning)
         {
             hasError = true;
         }
         CompositeSourceDocument /*?*/ compositeDocument = sourceLocation.SourceDocument as CompositeSourceDocument;
         if (compositeDocument != null)
         {
             foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sourceLocation))
             {
                 sourceLocation = sl;
                 break;
             }
         }
         IPrimarySourceLocation /*?*/ primarySourceLocation = sourceLocation as IPrimarySourceLocation;
         if (primarySourceLocation == null)
         {
             Console.Out.WriteLine(error.Message);
             continue;
         }
         string docName     = primarySourceLocation.SourceDocument.Name.Value;
         int    startLine   = primarySourceLocation.StartLine;
         int    startColumn = primarySourceLocation.StartColumn;
         int    endLine     = primarySourceLocation.EndLine;
         int    endColumn   = primarySourceLocation.EndColumn;
         IncludedSourceLocation /*?*/ includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
         if (includedSourceLocation != null)
         {
             docName   = includedSourceLocation.OriginalSourceDocumentName;
             startLine = includedSourceLocation.OriginalStartLine;
             endLine   = includedSourceLocation.OriginalEndLine;
         }
         if (!displayFileName)
         {
             docName = "";
         }
         Console.Out.WriteLine("{6}({0},{1})-({2},{3}): {4}: {5}", startLine, startColumn, endLine, endColumn,
                               error.IsWarning ? "warning" : "error", error.Message, docName);
         foreach (ILocation relatedLocation in error.RelatedLocations)
         {
             ISourceLocation /*?*/ sloc = relatedLocation as ISourceLocation;
             if (sloc != null)
             {
                 compositeDocument = sloc.SourceDocument as CompositeSourceDocument;
                 if (compositeDocument != null)
                 {
                     foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sloc))
                     {
                         sloc = sl;
                         break;
                     }
                 }
                 primarySourceLocation = sloc as IPrimarySourceLocation;
                 if (primarySourceLocation == null)
                 {
                     continue;
                 }
                 docName                = primarySourceLocation.SourceDocument.Name.Value;
                 startLine              = primarySourceLocation.StartLine;
                 startColumn            = primarySourceLocation.StartColumn;
                 endLine                = primarySourceLocation.EndLine;
                 endColumn              = primarySourceLocation.EndColumn;
                 includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                 if (includedSourceLocation != null)
                 {
                     docName   = includedSourceLocation.OriginalSourceDocumentName;
                     startLine = includedSourceLocation.OriginalStartLine;
                     endLine   = includedSourceLocation.OriginalEndLine;
                 }
                 Console.Out.WriteLine("({0},{1})-({2},{3}): (Location of symbol related to previous {4}.)", startLine, startColumn, endLine, endColumn, error.IsWarning ? "warning" : "error");
             }
             //TODO: deal with non source locations
         }
     }
 }
예제 #27
0
 public CciMethodLine(IPrimarySourceLocation sourceLocation)
 {
     SourceLocation = sourceLocation;
 }