Example #1
0
        /// <summary>
        /// Creates symbols for method identified by <c>oldToken</c> by translating symbols
        /// from new version of method identified by <c>newToken</c>.
        /// </summary>
        /// <param name="newToken">Identifies new version of method.</param>
        /// <param name="oldToken">Identifies old version of method.</param>
        /// <param name="placeholder">Translation definition for local variables.</param>
        public List <SequencePoint> EmitMethod(uint oldToken, uint newToken, Dictionary <int, int> placeholder = null)
        {
            if (State != WriterState.Building)
            {
                throw new TranslatingException("ISym* interfaces were not initializde. (EnC)");
            }
            int bla = ((IMetaDataImport)manager.MetadataManager.OldEmitter.CorMetaDataEmit).IsValidToken(oldToken);
            ISymUnmanagedMethod smMethod = mReader.__GetMethod(newToken);

            mWriter.__OpenMethod(oldToken);

            uint seqCount = smMethod.__GetSequencePointCount();

            uint[] lines      = new uint[seqCount];
            uint[] offsets    = new uint[seqCount];
            uint[] columns    = new uint[seqCount];
            uint[] endLines   = new uint[seqCount];
            uint[] endColumns = new uint[seqCount];
            ISymUnmanagedDocument[]       documents  = new ISymUnmanagedDocument[seqCount];
            ISymUnmanagedDocumentWriter[] docWriters = new ISymUnmanagedDocumentWriter[seqCount];
            uint cCount;

            smMethod.__GetSequencePoints(seqCount, out cCount, offsets, documents, lines, columns, endLines, endColumns);
            for (int i = 0; i < seqCount; i++)
            {
                docWriters[i] = DefineDocument(documents[i]);
                mWriter.__DefineSequencePoints(docWriters[i], 1, ref offsets[i], ref lines[i], ref columns[i],
                                               ref endLines[i], ref endColumns[i]);
            }
            mWriter.__SetMethodSourceRange(docWriters[0], lines[0], columns[0], docWriters[seqCount - 1], endLines[seqCount - 1], endColumns[seqCount - 1]);

            EmitScope(smMethod.__GetRootScope(), placeholder);    //

            try{
                mWriter.__CloseMethod();
            } catch (COMException) {
            }

            return(SequencePoint.StoreSequencePoints(offsets, lines, columns, endLines, endColumns));
        }
 public static void SetMethodSourceRange(this ISymUnmanagedWriter2 instance, ISymUnmanagedDocumentWriter startDoc, uint startLine, uint startColumn, ISymUnmanagedDocumentWriter endDoc, uint endLine, uint endColumn)
 {
     instance.__SetMethodSourceRange(startDoc, startLine, startColumn, endDoc, endLine, endColumn);
 }