Exemplo n.º 1
0
        private CCI.AssemblyNode ResolveReference(CCI.AssemblyReference reference, CCI.Module referencingModule)
        {
            var info = default(Info);

            if (strongNameToInfo.TryGetValue(reference.StrongName, out info))
            {
                return(info.Assembly);
            }
            else
            {
                var sourceInfo     = default(Info);
                var sourceFileName = "<unknown>";
                if (strongNameToInfo.TryGetValue(referencingModule.ContainingAssembly.StrongName, out sourceInfo))
                {
                    sourceFileName = sourceInfo.FileName;
                }
                var key = "(" + referencingModule.ContainingAssembly.StrongName + "," + reference.StrongName + ")";
                if (!knownBad.Contains(key))
                {
                    knownBad.Add(key);
                    env.Log
                        (new UnresolvableReferenceMessage
                            (referencingModule.ContainingAssembly.StrongName, sourceFileName, reference.StrongName));
                }
                // CCI will swallow this exception
                loadFailed = true;
                throw new ExitException();
            }
        }
      public DumbBlockMethodVisitor(IMetadataHost host, MethodBody method, string methodName)
        : base(host, method) {

        Console.WriteLine(MemberHelper.GetMemberSignature(method.MethodDefinition, NameFormattingOptions.None));

        this.anchors = new Dictionary<uint, uint>();
        this.methodName = //methodName;// method.MethodDefinition.ToString(); 
          MemberHelper.GetMethodSignature(method.MethodDefinition, NameFormattingOptions.SmartTypeName);

        var zombieAssemblyIdentity = new AssemblyIdentity(host.NameTable.GetNameFor("Zombie"), "", new Version(1, 0, 0), new byte[0], "Zombie.dll");
        var zombieAssemblyReference = new AssemblyReference() {
          Host = host,
          AssemblyIdentity = zombieAssemblyIdentity
        };
        var counterClassNamespaceReference = ILMethodBodyRewriter.CreateTypeReference(host, zombieAssemblyReference, "BlockCounter");

        this.blockCounterDotVisitMaybeAnchorInstruction = new Microsoft.Cci.MethodReference(
          this.host, counterClassNamespaceReference,
          CallingConvention.Default,
          host.PlatformType.SystemVoid,
          host.NameTable.GetNameFor("VisitMaybeAnchorInstruction"),
          0,
          host.PlatformType.SystemString);

        this.blockCounterDotVisitInstruction = new Microsoft.Cci.MethodReference(
          this.host, counterClassNamespaceReference,
          CallingConvention.Default,
          host.PlatformType.SystemVoid,
          host.NameTable.GetNameFor("VisitInstruction"),
          0,
          host.PlatformType.SystemString);
      }