当前位置: 首页>>代码示例>>C#>>正文


C# Compiler.Module类代码示例

本文整理汇总了C#中System.Compiler.Module的典型用法代码示例。如果您正苦于以下问题:C# Module类的具体用法?C# Module怎么用?C# Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Module类属于System.Compiler命名空间,在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveReference

        public virtual AssemblyNode ResolveReference(AssemblyReference reference, Module module) {

            if (reference == null) throw new ArgumentNullException("reference");

            //Console.WriteLine("resolving {0}", reference.StrongName);

            // try to get it from the cache
            string name = reference.StrongName;
            if (cache.ContainsKey(name)) return (cache[name]);

            // try to get it from the gac
            if (useGac) {
                string location = GlobalAssemblyCache.GetLocation(reference);
                if (location != null) {
                    AssemblyNode assembly = AssemblyNode.GetAssembly(location, null, false, false, false, false);
                    if (assembly != null) {
                        Add(assembly);
                        return (assembly);
                    }
                }
            }

            // couldn't find it; return null
            // Console.WriteLine("returning null on request for {0}", reference.StrongName);
            //OnUnresolvedAssemblyReference(reference, module);
            return (null);

        }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:28,代码来源:AssemblyResolver.cs

示例2: Parse

    //IDebugExpressionEvaluator
    public  HRESULT Parse( 
      [In,MarshalAs(UnmanagedType.LPWStr)]
      string                    pszExpression,
      PARSEFLAGS                  flags,
      uint                        radix,
      out string                  pbstrErrorMessages,
      out uint                    perrorCount,
      out IDebugParsedExpression  ppparsedExpression
      ) 
    {
      
      HRESULT hr = (HRESULT)HResult.S_OK;
      perrorCount = 0;
      pbstrErrorMessages = null;
      ppparsedExpression = null;
      ErrorNodeList errors =  new ErrorNodeList();
      Module symbolTable = new Module();
      Document doc = this.cciEvaluator.ExprCompiler.CreateDocument(null, 1, pszExpression);
      IParser exprParser = this.cciEvaluator.ExprCompiler.CreateParser(doc.Name, doc.LineNumber, doc.Text, symbolTable, errors, null);
      Expression parsedExpression = exprParser.ParseExpression();

      perrorCount = (uint)errors.Count;
      if (perrorCount > 0)
        pbstrErrorMessages = errors[0].GetMessage();
      else
        ppparsedExpression = new BaseParsedExpression(pszExpression, parsedExpression, this);

      return hr;
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:30,代码来源:DebuggerHelpers.cs

示例3: CollectOldExpressions

 public CollectOldExpressions(Module module, Method method, ContractNodes contractNodes, Dictionary<TypeNode, Local> closureLocals, 
     int localCounterStart, Class initialClosureClass)
     : this(module, method, contractNodes, closureLocals, localCounterStart)
 {
     this.topLevelClosureClass = initialClosureClass;
     this.currentClosureClass = initialClosureClass;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:CollectOldExpressions.cs

示例4: Specializer

 public Specializer(Module targetModule, TypeNodeList pars, TypeNodeList args)
 {
     Debug.Assert(pars != null && pars.Count > 0);
     Debug.Assert(args != null && args.Count > 0);
     this.pars = pars;
     this.args = args;
     this.TargetModule = targetModule;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:8,代码来源:Specializer.cs

示例5: Duplicator

 /// <param name="module">The module into which the duplicate IR will be grafted.</param>
 /// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
 public Duplicator(Module/*!*/ module, TypeNode type)
 {
     this.TargetModule = module;
     this.TargetType = this.OriginalTargetType = type;
     this.DuplicateFor = new TrivialHashtable();
     this.TypesToBeDuplicated = new TrivialHashtable();
     //^ base();
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:10,代码来源:Duplicator.cs

示例6: DuplicatorForContractsAndClosures

        public DuplicatorForContractsAndClosures(Module module, Method sourceMethod, Method targetMethod,
            ContractNodes contractNodes, bool mapParameters)
            : base(module, targetMethod.DeclaringType)
        {
            this.sourceMethod = sourceMethod;
            this.targetMethod = targetMethod;

            this.RemoveNameForLocals = true;

            Duplicator dup = this;

            if (mapParameters)
            {
                if (sourceMethod.ThisParameter != null)
                {
                    if (targetMethod.ThisParameter != null)
                    {
                        dup.DuplicateFor[sourceMethod.ThisParameter.UniqueKey] = targetMethod.ThisParameter;
                    }
                    else
                    {
                        // target is a static wrapper. But duplicator cannot handle This -> Parameter conversion
                        // so we handle it explicitly here in this visitor.
                        replaceThisWithParameter = targetMethod.Parameters[0];
                    }
                }

                if (sourceMethod.Parameters != null && targetMethod.Parameters != null
                    && sourceMethod.Parameters.Count == targetMethod.Parameters.Count)
                {
                    for (int i = 0, n = sourceMethod.Parameters.Count; i < n; i++)
                    {
                        dup.DuplicateFor[sourceMethod.Parameters[i].UniqueKey] = targetMethod.Parameters[i];
                    }
                }
            }

            var originalType = HelperMethods.IsContractTypeForSomeOtherType(sourceMethod.DeclaringType, contractNodes);
            if (originalType != null)
            {
                var contractType = this.contractClass = sourceMethod.DeclaringType;
                while (contractType.Template != null)
                {
                    contractType = contractType.Template;
                }
                    
                while (originalType.Template != null)
                {
                    originalType = originalType.Template;
                }

                // forward ContractType<A,B> -> originalType<A',B'>
                this.contractClassToForward = contractType;
                this.targetTypeToForwardTo = originalType;

                //dup.DuplicateFor[contractType.UniqueKey] = originalType;
            }
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:58,代码来源:DuplicatorForContractsAndClosures.cs

示例7: Write

    public static void Write(Compilation compilation, Module module, CompilerParameters options) {
      XmlTextWriter writer = new XmlTextWriter(module.Name + ".source.xml", Encoding.Default);

      SourceContextWriter scw = new SourceContextWriter(writer);

      writer.WriteStartDocument();
      writer.WriteStartElement("Module");
      writer.WriteAttributeString("name", module.Name);

      scw.VisitCompilation(compilation);

      writer.WriteEndElement(); // Module
      writer.WriteEndDocument();
      writer.Flush();
      writer.Close();
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:16,代码来源:SourceContextWriter.cs

示例8: ReplaceResult

    readonly private TypeNode declaringType; // needed to copy anonymous delegates into

    public ReplaceResult(Method containingMethod, Local r, Module assemblyBeingRewritten) {
      Contract.Requires(containingMethod != null);
      
      this.assemblyBeingRewritten = assemblyBeingRewritten;
      this.declaringType = containingMethod.DeclaringType;
      this.topLevelMethodFormals = containingMethod.TemplateParameters;
      this.originalLocalForResult = r;
      this.delegateNestingLevel = 0;
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:11,代码来源:Rewriter.cs

示例9: AssemblyReferenceResolution

 /// <summary>
 /// Resolves assembly references based on the library paths specified.
 /// Tries to resolve to ".dll" or ".exe". First found wins.
 /// </summary>
 /// <param name="assemblyReference">Reference to resolve.</param>
 /// <param name="referencingModule">Referencing module.</param>
 /// <returns>The resolved assembly node (null if not found).</returns>
 private static AssemblyNode AssemblyReferenceResolution (AssemblyReference assemblyReference, Module referencingModule) {
   AssemblyNode a = ProbeForAssembly(assemblyReference.Name, referencingModule.Directory, DllAndExeExt);
   return a;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:11,代码来源:Program.cs

示例10: DuplicatorForContractsAndClosures

        public DuplicatorForContractsAndClosures(Module module, Method sourceMethod, Method targetMethod,
            ContractNodes contractNodes, bool mapParameters)
            : base(module, targetMethod.DeclaringType)
        {
            this.sourceMethod = sourceMethod;
            this.targetMethod = targetMethod;

            this.RemoveNameForLocals = true;

            Duplicator dup = this;

            if (mapParameters)
            {
                if (sourceMethod.ThisParameter != null)
                {
                    if (targetMethod.ThisParameter != null)
                    {
                        dup.DuplicateFor[sourceMethod.ThisParameter.UniqueKey] = targetMethod.ThisParameter;
                    }
                    else
                    {
                        // target is a static wrapper. But duplicator cannot handle This -> Parameter conversion
                        // so we handle it explicitly here in this visitor.
                        replaceThisWithParameter = targetMethod.Parameters[0];
                    }
                }

                if (sourceMethod.Parameters != null && targetMethod.Parameters != null
                    && sourceMethod.Parameters.Count == targetMethod.Parameters.Count)
                {
                    for (int i = 0, n = sourceMethod.Parameters.Count; i < n; i++)
                    {
                        dup.DuplicateFor[sourceMethod.Parameters[i].UniqueKey] = targetMethod.Parameters[i];
                    }
                }

                // This code makes sure that generic method parameters used by contracts inherited from contract class
                // are correctly replaced by the one defined in the target method.
                // Without this mapping <c>CheckPost</c> method in generated async closure class would contain an invalid
                // reference to a generic contract method parameter instead of generic async closure type parameter.
                // For more about this problem see comments for Microsoft.Contracts.Foxtrot.EmitAsyncClosure.GenericTypeMapper class
                // and issue #380.
                if (sourceMethod.TemplateParameters != null && targetMethod.TemplateParameters != null
                    && sourceMethod.TemplateParameters.Count == targetMethod.TemplateParameters.Count)
                {
                    for (int i = 0, n = sourceMethod.TemplateParameters.Count; i < n; i++)
                    {
                        dup.DuplicateFor[sourceMethod.TemplateParameters[i].UniqueKey] = targetMethod.TemplateParameters[i];
                    }
                }
            }

            var originalType = HelperMethods.IsContractTypeForSomeOtherType(sourceMethod.DeclaringType, contractNodes);
            if (originalType != null)
            {
                var contractType = this.contractClass = sourceMethod.DeclaringType;
                while (contractType.Template != null)
                {
                    contractType = contractType.Template;
                }
                    
                while (originalType.Template != null)
                {
                    originalType = originalType.Template;
                }

                // forward ContractType<A,B> -> originalType<A',B'>
                this.contractClassToForward = contractType;
                this.targetTypeToForwardTo = originalType;

                //dup.DuplicateFor[contractType.UniqueKey] = originalType;
            }
        }
开发者ID:flcdrg,项目名称:CodeContracts,代码行数:73,代码来源:DuplicatorForContractsAndClosures.cs

示例11: ProvideNestedTypes

 private void ProvideNestedTypes(TypeNode/*!*/ dup, object/*!*/ handle)
 {
     TypeNode template = (TypeNode)handle;
     TypeNode savedTargetType = this.TargetType;
     Module savedTargetModule = this.TargetModule;
     this.TargetType = dup;
     //^ assume dup.DeclaringModule != null;
     this.TargetModule = dup.DeclaringModule;
     this.FindTypesToBeDuplicated(template.NestedTypes);
     dup.NestedTypes = this.VisitNestedTypes(dup, template.NestedTypes);
     this.TargetModule = savedTargetModule;
     this.TargetType = savedTargetType;
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:13,代码来源:Duplicator.cs

示例12: Duplicator

 /// <param name="module">The module into which the duplicate IR will be grafted.</param>
 /// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
 public Duplicator(Module module, TypeNode type)
     : base(module, type)
 {
 }
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:6,代码来源:ZDuplicator.cs

示例13: MyMethodBodySpecializer

 public MyMethodBodySpecializer(Module module, TypeNodeList source, TypeNodeList target)
     : base(module, source, target)
 {
 }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:4,代码来源:ExtractorVisitor.cs

示例14: ResolveReference

        /// <summary>
        /// This is used to try and resolve an assembly reference
        /// </summary>
        /// <param name="reference">The assembly reference</param>
        /// <param name="referrer">The module requiring the reference</param>
        /// <returns>The assembly node if resolved or null if not resolved</returns>
        public virtual AssemblyNode ResolveReference(AssemblyReference reference, Module referrer)
        {
            AssemblyNode assembly;

            if(reference == null)
                throw new ArgumentNullException("reference");

            // Try to get it from the cache
            string name = reference.StrongName;

            if(cache.ContainsKey(name))
                return cache[name];

            // Try to get it from the GAC if so indicated
            if(this.UseGac)
            {
                string location = GlobalAssemblyCache.GetLocation(reference);

                if(location != null)
                {
                    assembly = AssemblyNode.GetAssembly(location, null, false, false, false, false);

                    if(assembly != null)
                    {
                        this.Add(assembly);
                        return assembly;
                    }
                }
            }

            // Try the redirects if not found
            foreach(BindingRedirectSettings brs in redirects)
                if(brs.IsRedirectFor(name) && cache.ContainsKey(brs.StrongName))
                {
                    ConsoleApplication.WriteMessage(LogLevel.Info, "Using redirect '{0}' in place of '{1}'",
                        brs.StrongName, name);

                    assembly = cache[brs.StrongName];

                    // Add the same assembly under the current name
                    cache.Add(name, assembly);
                    return assembly;
                }

            // Couldn't find it; return null
            return null;
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:53,代码来源:AssemblyResolver.cs

示例15: UnresolvedReference

        /// <summary>
        /// This is called if assembly reference resolution fails after probing
        /// </summary>
        /// <param name="reference">The assembly reference</param>
        /// <param name="module">The module</param>
        /// <returns>Always returns null</returns>
        private AssemblyNode UnresolvedReference(AssemblyReference reference, Module module)
        {
            // Don't raise the event if ignored
            if(!ignoreIfUnresolved.Contains(reference.Name))
                OnUnresolvedAssemblyReference(reference, module);
            else
                ConsoleApplication.WriteMessage(LogLevel.Warn, "Ignoring unresolved assembly " +
                    "reference: {0} ({1}) required by {2}", reference.Name, reference.StrongName,
                    module.Name);

            return null;
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:18,代码来源:AssemblyResolver.cs


注:本文中的System.Compiler.Module类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。