Ejemplo n.º 1
0
        /// <summary>
        /// Resolves function from its name.
        /// </summary>
        /// <param name="moduleName">module name</param>
        /// <param name="className">class name</param>
        /// <param name="functionName">wanted function name</param>
        /// <returns></returns>
        public CorFunction ResolveFunctionName(String moduleName, String className, String functionName)
        {
            // find module
            CorModule module = FindModuleByName(moduleName);

            if (module == null)
            {
                return(null);
            }

            Int32 typeToken = module.GetTypeTokenFromName(className);

            if (typeToken == CorConstants.TokenNotFound)
            {
                return(null);
            }

            Type        t    = new MetadataType(module.GetMetadataInterface <IMetadataImport>(), typeToken);
            CorFunction func = null;

            foreach (MethodInfo mi in t.GetMethods())
            {
                if (String.Equals(mi.Name, functionName, StringComparison.Ordinal))
                {
                    func = module.GetFunctionFromToken(mi.MetadataToken);
                    break;
                }
            }
            return(func);
        }
Ejemplo n.º 2
0
        // Initializes all private symbol variables
        private void SetupSymbolInformation()
        {
            if (p_symbolsInitialized)
            {
                return;
            }

            p_symbolsInitialized = true;
            CorModule     module    = GetModule();
            ISymbolReader symreader = module.GetSymbolReader();

            p_hasSymbols = symreader != null;
            if (p_hasSymbols)
            {
                ISymbolMethod sm = null;
                sm = symreader.GetMethod(new SymbolToken((Int32)GetToken())); // FIXME add version
                if (sm == null)
                {
                    p_hasSymbols = false;
                    return;
                }
                p_symMethod      = sm;
                p_SPcount        = p_symMethod.SequencePointCount;
                p_SPoffsets      = new Int32[p_SPcount];
                p_SPdocuments    = new ISymbolDocument[p_SPcount];
                p_SPstartLines   = new Int32[p_SPcount];
                p_SPendLines     = new Int32[p_SPcount];
                p_SPstartColumns = new Int32[p_SPcount];
                p_SPendColumns   = new Int32[p_SPcount];

                p_symMethod.GetSequencePoints(p_SPoffsets, p_SPdocuments, p_SPstartLines,
                                              p_SPstartColumns, p_SPendLines, p_SPendColumns);
            }
        }