private static EncLocalInfo GetLocalInfo(
            IReadOnlyDictionary <SyntaxNode, int> declaratorToIndex,
            Microsoft.Cci.ILocalDefinition localDef,
            byte[] signature)
        {
            var def = localDef as LocalDefinition;

            if (def != null)
            {
                // Local symbol will be null for short-lived temporaries.
                var local = (LocalSymbol)def.Identity;
                if ((object)local != null)
                {
                    var syntaxRefs = local.DeclaringSyntaxReferences;
                    Debug.Assert(!syntaxRefs.IsDefault);

                    if (!syntaxRefs.IsDefaultOrEmpty)
                    {
                        var syntax = syntaxRefs[0].GetSyntax();
                        var offset = declaratorToIndex[syntax];
                        return(new EncLocalInfo(offset, localDef.Type, def.Constraints, (int)local.SynthesizedLocalKind, signature));
                    }
                }
            }

            return(new EncLocalInfo(signature));
        }
示例#2
0
 public string GetSourceNameFor(Microsoft.Cci.ILocalDefinition localDefinition, out bool isCompilerGenerated)
 {
     isCompilerGenerated = localDefinition.IsCompilerGenerated;
     return(localDefinition.Name);
 }