Esempio n. 1
0
        /// <summary>
        /// Calls the given visitor for the type's component.
        /// </summary>
        /// <param name="visitor">Visitor to use.</param>
        public void Accept(ITypeVisitor visitor)
        {
            if (visitor == null) throw new ArgumentNullException("visitor");

              visitor.Visit(_type);
              if (_type.HasSecurityDeclarations) visitor.Visit(_type.SecurityDeclarations);
              if (_type.HasGenericParameters) visitor.Visit(_type.GenericParameters);
              if (_type.HasInterfaces) visitor.Visit(_type.Interfaces);
              if (_type.HasCustomAttributes) visitor.Visit(_type.CustomAttributes);
              if (_type.HasEvents) visitor.Visit(_type.Events);
              if (_type.HasFields) visitor.Visit(_type.Fields);
              if (_type.HasProperties) visitor.Visit(_type.Properties);
              if (_type.HasMethods) visitor.Visit(_type.Methods);
              if (_type.HasNestedTypes) visitor.Visit(_type.NestedTypes);
        }
Esempio n. 2
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitMemberPointerType(this, quals));
 }
Esempio n. 3
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitUnaryTransformType(this, quals));
 }
Esempio n. 4
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitDependentNameType(this, quals));
 }
Esempio n. 5
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitTemplateParameterSubstitutionType(this, quals));
 }
Esempio n. 6
0
 public T Visit <T>(ITypeVisitor <T> visitor)
 {
     return(Type.Visit(visitor, Qualifiers));
 }
Esempio n. 7
0
 public abstract void Accept(ITypeVisitor visitor);
Esempio n. 8
0
File: Type.cs Progetto: condda/ql
 public abstract T Accept <T>(ITypeVisitor <T> visitor);
Esempio n. 9
0
 /// <summary>
 /// Extension method that uses the <see cref="TypeCrawler"/> to visit a type with a visitor.
 /// </summary>
 /// <param name="self">Instance parameter. Type to be visited.</param>
 /// <param name="visitor">The visitor to use.</param>
 public static void Accept(this TypeDefinition self, ITypeVisitor visitor)
 {
     if (self == null) throw new InstanceArgumentNullException();
       new TypeCrawler(self).Accept(visitor);
 }
Esempio n. 10
0
 public T Accept <T>(ITypeVisitor <T> visitor) => visitor.VisitFunctionType(this);
Esempio n. 11
0
 public override void Visit(ITypeVisitor visitor) => visitor.Visit(this);
Esempio n. 12
0
 public T Visit <T>(ITypeVisitor <T> visitor)
 {
     return(visitor.VisitQualifiedType(this));
 }
Esempio n. 13
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitUnresolvedUsingType(this, quals));
 }
Esempio n. 14
0
        /// <summary>
        /// Walk over a type to create a value.
        /// </summary>
        /// <param name="visitor">The type visitor object.</param>
        /// <param name="type">The type.</param>
        /// <typeparam name="T">The return type.</typeparam>
        /// <returns>A value.</returns>
        public static T ApplyTypeVisitor <T>(ITypeVisitor <T> visitor, Type type)
        {
            if (type == BoolType)
            {
                return(visitor.VisitBool());
            }

            if (type == ByteType)
            {
                return(visitor.VisitByte());
            }

            if (type == ShortType)
            {
                return(visitor.VisitShort());
            }

            if (type == UshortType)
            {
                return(visitor.VisitUshort());
            }

            if (type == IntType)
            {
                return(visitor.VisitInt());
            }

            if (type == UintType)
            {
                return(visitor.VisitUint());
            }

            if (type == LongType)
            {
                return(visitor.VisitLong());
            }

            if (type == UlongType)
            {
                return(visitor.VisitUlong());
            }

            if (IsOptionType(type))
            {
                var t = type.GetGenericArguments()[0];
                return(visitor.VisitOption(ty => ApplyTypeVisitor(visitor, ty), t));
            }

            if (IsTupleType(type))
            {
                var tleft  = type.GetGenericArguments()[0];
                var tright = type.GetGenericArguments()[1];
                return(visitor.VisitTuple(ty => ApplyTypeVisitor(visitor, ty), tleft, tright));
            }

            if (IsValueTupleType(type))
            {
                var tleft  = type.GetGenericArguments()[0];
                var tright = type.GetGenericArguments()[1];
                return(visitor.VisitValueTuple(ty => ApplyTypeVisitor(visitor, ty), tleft, tright));
            }

            if (IsIListType(type))
            {
                var t = type.GetGenericArguments()[0];
                return(visitor.VisitList(ty => ApplyTypeVisitor(visitor, ty), type, t));
            }

            if (IsIDictionaryType(type))
            {
                var args   = type.GetGenericArguments();
                var tkey   = args[0];
                var tvalue = args[1];
                return(visitor.VisitDictionary(ty => ApplyTypeVisitor(visitor, ty), type, tkey, tvalue));
            }

            if (IsListType(type) || IsDictionaryType(type))
            {
                throw new InvalidOperationException($"Unsupported object field type: {type}");
            }

            // some class or struct
            var dict = new Dictionary <string, Type>();

            foreach (var field in GetAllFields(type))
            {
                dict[field.Name] = field.FieldType;
            }

            foreach (var property in GetAllProperties(type))
            {
                dict[property.Name] = property.PropertyType;
            }

            return(visitor.VisitObject(t => ApplyTypeVisitor(visitor, t), type, dict));
        }
Esempio n. 15
0
 public abstract object Accept <T>(ITypeVisitor <T> visitor);
Esempio n. 16
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals)
 {
     return(visitor.VisitAttributedType(this, quals));
 }
Esempio n. 17
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitPointerType(this, QualifiedPointee.Qualifiers));
 }
Esempio n. 18
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals)
 {
     return(visitor.VisitBuiltinType(this, quals));
 }
Esempio n. 19
0
 public override object Accept <T>(ITypeVisitor <T> visitor)
 {
     return(visitor.Visit(this));
 }
Esempio n. 20
0
 public abstract SemanticAtom Accept(ITypeVisitor v);
Esempio n. 21
0
 public override SemanticAtom Accept(ITypeVisitor v)
 {
     return(v.Visit(this));
 }
Esempio n. 22
0
 public void AcceptTypeVisitor(ITypeVisitor visitor, DB_Type type)
 {
     VisitType(type, visitor);
 }
Esempio n. 23
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitDependentTemplateSpecializationType(this, quals));
 }
Esempio n. 24
0
 public CreateBindings(ITypeVisitor <IWidget> widgetFactory)
 {
     Bindings      = new List <UIBinding>();
     WidgetFactory = widgetFactory;
 }
Esempio n. 25
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitInjectedClassNameType(this, quals));
 }
Esempio n. 26
0
 /// <summary>
 /// Accept a visit from the given visitor for each item
 /// </summary>
 internal static void AcceptAll <T, VisitorT, DataT>(this IEnumerable <T> items, ITypeVisitor <VisitorT, DataT> visitor, DataT data)
     where T : TypeReference
 {
     foreach (var x in items)
     {
         x.Accept(visitor, data);
     }
 }
Esempio n. 27
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitPackExpansionType(this, quals));
 }
Esempio n. 28
0
 public override TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor)
 {
     return(defaultTypeVisitor.Visit(this));
 }
Esempio n. 29
0
 public abstract T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals
                             = new TypeQualifiers());
Esempio n. 30
0
 public override TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor)
 {
     EnsureReferenceType();
     return(ReferenceType.Accept(defaultTypeVisitor));
 }
Esempio n. 31
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitTypedefType(this, quals));
 }
Esempio n. 32
0
 public abstract TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor);