當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。