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


C# Compiler.Field类代码示例

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


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

示例1: IsSpecPublic

        private static bool IsSpecPublic(Field f)
        {
            // F: 
            Contract.Requires(f != null);

            return f.Attributes.HasAttribute(ContractNodes.SpecPublicAttributeName);
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:7,代码来源:VisibilityHelper.cs

示例2: FindShadow

        /// <summary>
        /// Find shadow field in given type corresponding to field.
        /// </summary>
        public static Field FindShadow(this TypeNode parent, Field field)
        {
            if (field == null || field.Name == null)
            {
                return null;
            }

            MemberList members = parent.GetMembersNamed(field.Name);

            for (int i = 0, n = members == null ? 0 : members.Count; i < n; i++)
            {
                Field f = members[i] as Field;
                if (f != null) return f;
            }

            return null;
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:20,代码来源:ExtractorExtensions.cs

示例3: GetReturnValueClosureField

    private Field GetReturnValueClosureField(TypeNode declaringType, TypeNode resultType, FieldFlags flags, int uniqueKey)
    {
      Contract.Requires(declaringType != null);
      
      Contract.Assume(declaringType.Template == null);
      Identifier name = Identifier.For("_result" + uniqueKey.ToString()); // unique name for this field

      Field f = declaringType.GetField(name);
      if (f != null) return f;

      f = new Field(declaringType,
        null,
        flags,
        name,
        resultType,
        null);

      declaringType.Members.Add(f);
      // remember we added it so we can make it part of initializations
      if (f.IsStatic)
      {
        topLevelStaticResultField = f;
      }
      else
      {
        topLevelClosureResultField = f;
      }
      return f;
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:29,代码来源:Rewriter.cs

示例4: FieldElementsPeerPositions

 public static List<int> FieldElementsPeerPositions(Field f)
 {
     List<int> res = new List<int>();
     if (f == null) return res;
     AttributeList al = f.GetAllAttributes(SystemTypes.ElementsPeerAttribute);
     if (al == null) return res;
     foreach (AttributeNode attr in al)
     {
         ExpressionList exprs = attr.Expressions;
         int value = -10;
         if (exprs == null || exprs.Count == 0) 
             value = -1; // default value for attribute w/o param
         else
         {
             Expression arg = exprs[0];
             Literal lit = arg as Literal;
             if (lit != null && lit.Value is int)
                 value = (int)lit.Value;
         }
         if (value == -1)  // all positions are ElementsPeer
         {
             return ElementsPositions(f.Type);
         }
         else // a specific type argument is ElementsPeer
         {
             res.Add(value);
         }
     }
     return res;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:30,代码来源:AdmissibilityChecker.cs

示例5: VisitField

        public override void VisitField(Field field)
        {
            base.VisitField(field);

            var type = HelperMethods.Unspecialize(field.Type);

            if (type == contractClass)
            {
                if (field.Type.TemplateArguments != null)
                {
                    var inst = this.OriginalType.GetTemplateInstance(field.Type, field.Type.TemplateArguments);
                    field.Type = inst;
                }
                else
                {
                    field.Type = this.OriginalType;
                }
            }
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:19,代码来源:ScrubContractClass.cs

示例6: GetFieldQualifiers

        private static string GetFieldQualifiers(Field field)
        {
            string qualifiers = string.Empty;

            if (field.IsStatic)
                qualifiers += "static ";

            return qualifiers;
        }
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:9,代码来源:ZDecompiler.cs

示例7: VisitField

        public override void VisitField(Field field)
        {
            if (field == null) return;

            this.CheckField(field);
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:6,代码来源:PostExtractorChecker.cs

示例8: PrepareGuardedClass

 private void PrepareGuardedClass(TypeNode typeNode) {
   SpecSharpCompilerOptions options = this.currentOptions as SpecSharpCompilerOptions;
   if (!(options != null && (options.DisableGuardedClassesChecks || options.Compatibility))) {
     if (typeNode is Class && typeNode.Contract != null && (typeNode.Contract.InvariantCount > 0 || typeNode.Contract.ModelfieldContractCount > 0) ||
       typeNode is Class && this.currentPreprocessorDefinedSymbols != null && this.currentPreprocessorDefinedSymbols.ContainsKey("GuardAllClasses")) {
       if (typeNode.Interfaces == null) {
         typeNode.Interfaces = new InterfaceList();
       }
       if (typeNode.Template == null) { //we have to be careful when we are passed a typeNode of a specialized generic type as it shares the contract of the 'real' generic typeNode
         #region Add the field "frame" to the class.
         Field frameField = new Field(typeNode, null, FieldFlags.Public, Identifier.For("SpecSharp::frameGuard"), SystemTypes.Guard, null);
         frameField.CciKind = CciMemberKind.Auxiliary;
         typeNode.Contract.FrameField = frameField;
         typeNode.Members.Add(frameField);
         This thisParameter = new This(typeNode);
         Method frameGetter = new Method(typeNode, NoDefaultExpose(), Identifier.For("get_SpecSharp::FrameGuard"), null, OptionalModifier.For(SystemTypes.NonNullType, SystemTypes.Guard),
           new Block(new StatementList(new Return(new BinaryExpression(new MemberBinding(thisParameter, frameField), new Literal(SystemTypes.NonNullType, SystemTypes.Type), System.Compiler.NodeType.ExplicitCoercion, OptionalModifier.For(SystemTypes.NonNullType, SystemTypes.Guard))))));
         // Pretend this method is [Delayed] so that we can call it from a delayed constructor.
         frameGetter.Attributes.Add(new AttributeNode(new Literal(ExtendedRuntimeTypes.DelayedAttribute, SystemTypes.Type), null, AttributeTargets.Method));
         frameGetter.CciKind = CciMemberKind.FrameGuardGetter;
         frameGetter.Attributes.Add(new AttributeNode(new Literal(SystemTypes.PureAttribute, SystemTypes.Type), null, AttributeTargets.Method));
         frameGetter.Flags = MethodFlags.Public | MethodFlags.HideBySig | MethodFlags.SpecialName;
         frameGetter.CallingConvention = CallingConventionFlags.HasThis;
         frameGetter.ThisParameter = thisParameter;
         typeNode.Contract.FramePropertyGetter = frameGetter;
         typeNode.Members.Add(frameGetter);
         Property frameProperty = new Property(typeNode, null, PropertyFlags.None, Identifier.For("SpecSharp::FrameGuard"), frameGetter, null);
         typeNode.Members.Add(frameProperty);
         typeNode.Contract.FrameProperty = frameProperty;
         #endregion
         typeNode.Contract.InitFrameSetsMethod = new Method(typeNode, NoDefaultExpose(), Identifier.For("SpecSharp::InitGuardSets"), null, SystemTypes.Void, null);
         typeNode.Contract.InitFrameSetsMethod.CciKind = CciMemberKind.Auxiliary;
         typeNode.Contract.InitFrameSetsMethod.Flags = MethodFlags.Public | MethodFlags.HideBySig | MethodFlags.SpecialName;
       }
     }
   }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:37,代码来源:Looker.cs

示例9: TryAddDebuggerBrowsableNeverAttribute

 internal static void TryAddDebuggerBrowsableNeverAttribute(Field field)
 {
     Contract.Requires(field != null);
     TryAddDebuggerBrowsableNeverAttribute(field, System.AttributeTargets.Field);
 }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:5,代码来源:RewriteUtils.cs

示例10: FieldAssociatedWithParameter

        private static bool FieldAssociatedWithParameter(Field field, Method originalMethod, out Parameter p)
        {
            string fname = field.Name.Name;

            if (fname.EndsWith("__this"))
            {
                // check that it is not a nested one
                if (fname.Length > 8 && !fname.Substring(2, fname.Length - 8).Contains("__"))
                {
                    p = originalMethod.ThisParameter;
                    return true;
                }
            }

            foreach (Parameter par in originalMethod.Parameters)
            {
                string pname = par.Name.Name;
                if (fname == pname)
                {
                    p = par;
                    return true;
                }
            }

            p = null;
            return false;
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:27,代码来源:ExtractorVisitor.cs

示例11: IsClosureField

        public static bool IsClosureField(TypeNode container, Field field)
        {
            Contract.Requires(container != null);
            Contract.Requires(field != null);

            var type = Unspecialize(field.DeclaringType);

            if (IsClosureType(container, type)) return true;
            
            // can be a direct member of a type inside container for caching delegates
            
            if (!field.IsPrivate) return false;
            
            if (!(field.Type.IsDelegateType())) return false;
            
            if (!IsInsideOf(field, container)) return false;
            
            if (!IsCompilerGenerated(field)) return false;
            
            return true;
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:21,代码来源:HelperMethods.cs

示例12: IsAccessibleFrom

 bool IsAccessibleFrom(Field field, Method from)
 {
 }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:3,代码来源:Rewriter.cs

示例13: VisitLocal

        public override Expression VisitLocal(Local local)
        {
            if (HelperMethods.IsClosureType(this.declaringType, local.Type))
            {
                MemberBinding mb;
                if (!closureLocals.TryGetValue(local, out mb))
                {
                    // Forwarder would be null, if enclosing method with async closure is not generic
                    var localType = forwarder != null ? forwarder.VisitTypeReference(local.Type) : local.Type;

                    var closureField = new Field(this.closureClass, null, FieldFlags.Public, local.Name, localType, null);
                    this.closureClass.Members.Add(closureField);
                    mb = new MemberBinding(this.checkMethod.ThisParameter, closureField);
                    closureLocals.Add(local, mb);

                    // initialize the closure field
                    var instantiatedField = GetMemberInstanceReference(closureField, this.closureClassInstance);
                    this.ClosureInitializer.Statements.Add(new AssignmentStatement(new MemberBinding(this.ClosureLocal, instantiatedField), local));

                }
                return mb;
            }
            return local;
        }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:24,代码来源:Rewriter.cs

示例14: CreateProperResultAccess

    private static Expression CreateProperResultAccess(ReturnValue returnValue, Expression closureObject, Field resultField)
    {
      Contract.Requires(returnValue != null);
      Contract.Requires(resultField != null);

      var fieldAccess = new MemberBinding(closureObject, resultField);

      if (resultField.Type != returnValue.Type)
      {
        // must cast to generic type expected in this context (box instance unbox.any Generic)
        return new BinaryExpression(new BinaryExpression(fieldAccess, new Literal(resultField.Type), NodeType.Box), new Literal(returnValue.Type), NodeType.UnboxAny);
      }
      else
      {
        return fieldAccess;
      }
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:17,代码来源:Rewriter.cs

示例15: FindAndInstantiateBaseClassInvariantMethod

    private Method FindAndInstantiateBaseClassInvariantMethod(Class asClass, out Field baseReentrancyFlag)
    {
      baseReentrancyFlag = null;
      if (asClass == null || asClass.BaseClass == null) return null;
      if (!this.Emit(RuntimeContractEmitFlags.InheritContracts)) return null; // don't call base class invariant if we don't inherit

      var baseClass = asClass.BaseClass;

      if (!this.InheritInvariantsAcrossAssemblies && (baseClass.DeclaringModule != asClass.DeclaringModule))
        return null;

      var result = baseClass.GetMethod(Identifier.For("$InvariantMethod$"), null);

      if (result != null && !HelperMethods.IsVisibleFrom(result, asClass)) return null;

      if (result == null && baseClass.Template != null)
      {
        // instantiation of generated method has not happened.
        var generic = baseClass.Template.GetMethod(Identifier.For("$InvariantMethod$"), null);
        if (generic != null)
        {
          if (!HelperMethods.IsVisibleFrom(generic, asClass)) return null;
          // generate proper reference.
          result = GetMethodInstanceReference(generic, baseClass);
        }
      }
      // extract base reentrancy flag
      if (result != null) {
        var instantiatedParent = result.DeclaringType;
        baseReentrancyFlag = instantiatedParent.GetField(Identifier.For("$evaluatingInvariant$"));

        if (baseReentrancyFlag == null && baseClass.Template != null)
        {
          // instantiation of generated baseReentrancy flag has not happened.
          var generic = baseClass.Template.GetField(Identifier.For("$evaluatingInvariant$"));
          if (generic != null)
          {
            if (HelperMethods.IsVisibleFrom(generic, asClass))
            {
              baseReentrancyFlag = GetFieldInstanceReference(generic, baseClass);
            }
          }
        }
      }

      return result;
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:47,代码来源:Rewriter.cs


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