Exemplo n.º 1
0
        public IEntity ResolveGenericTypeReference(GenericTypeReference gtr, IEntity definition)
        {
            ResolveTypeReferenceCollection(gtr.GenericArguments);
            IType[] typeArguments = gtr.GenericArguments.ToArray(t => TypeSystemServices.GetType(t));

            return(My <GenericsServices> .Instance.ConstructEntity(gtr, definition, typeArguments));
        }
Exemplo n.º 2
0
        public override void OnReferenceExpression(ReferenceExpression node)
        {
            if (!HasImplictTypeOfExpression(node))
            {
                return;
            }

            node.ParentNode.Replace(node, CodeBuilder.CreateTypeofExpression(TypeSystemServices.GetType(node)));
        }
Exemplo n.º 3
0
        public override void OnMemberReferenceExpression(MemberReferenceExpression node)
        {
            if (HasImplictTypeOfExpression(node))
            {
                node.ParentNode.Replace(node, CodeBuilder.CreateTypeofExpression(TypeSystemServices.GetType(node)));
                return;
            }

            base.OnMemberReferenceExpression(node);
        }
Exemplo n.º 4
0
 override public bool IsSubclassOf(IType type)
 {
     foreach (TypeReference baseTypeReference in _node.BaseTypes)
     {
         IType baseType = TypeSystemServices.GetType(baseTypeReference);
         if (type == baseType || baseType.IsSubclassOf(type))
         {
             return(true);
         }
     }
     return(_provider.IsSystemObject(type));
 }
Exemplo n.º 5
0
        public IType[] GetInterfaces()
        {
            var buffer = new List <IType>(_node.BaseTypes.Count);

            foreach (TypeReference baseType in _node.BaseTypes)
            {
                var type = TypeSystemServices.GetType(baseType);
                if (type.IsInterface)
                {
                    buffer.AddUnique(type);
                }
            }
            return(buffer.ToArray());
        }
Exemplo n.º 6
0
        public override void OnBinaryExpression(BinaryExpression node)
        {
            if (node.Operator == BinaryOperatorType.Assign && node.Left.ExpressionType == TypeSystemServices.TypeType && node.Right.ExpressionType.EntityType == EntityType.Type && (node.Right.Entity != null && node.Right.Entity.EntityType == EntityType.Type))
            {
                node.Replace(node.Right, CodeBuilder.CreateTypeofExpression(TypeSystemServices.GetType(node.Right)));
            }
            else if (node.Operator == BinaryOperatorType.TypeTest)
            {
                var typeofExpression = (TypeofExpression)node.Right;
                node.Replace(node.Right, CodeBuilder.CreateReference(typeofExpression.Type.Entity));
            }

            base.OnBinaryExpression(node);
        }
Exemplo n.º 7
0
        int GetMaxBaseInterfaceDepth()
        {
            int max = 0;

            foreach (TypeReference baseType in _node.BaseTypes)
            {
                IType tag   = TypeSystemServices.GetType(baseType);
                int   depth = tag.GetTypeDepth();
                if (depth > max)
                {
                    max = depth;
                }
            }
            return(max);
        }
Exemplo n.º 8
0
 private static bool IsContextPrivate(Node context, IType type)
 {
     if (context == null)
     {
         return(false);
     }
     if (context.NodeType == NodeType.ClassDefinition && TypeSystemServices.GetType(context) == type)
     {
         return(true);
     }
     if (context.NodeType == NodeType.StructDefinition && TypeSystemServices.GetType(context) == type)
     {
         return(true);
     }
     return(IsContextPrivate(context.ParentNode, type));
 }
Exemplo n.º 9
0
        protected override void ResolveImpl(MappedToken token)
        {
            try
            {
                var type = TypeSystemServices.GetType(Node);
                if (type is Error)
                {
                    return;
                }
//                quickInfoTip = "class " + type.FullName;
                format = Formats.BooType;
            }
            catch
            {
                return;
            }
        }
Exemplo n.º 10
0
        public override void OnMethod(Method node)
        {
            IEnumerator <Local> enumerator = node.Locals.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Local current = enumerator.Current;
                    if (LookingFor(current))
                    {
                        Found(TypeSystemServices.GetType(current));
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Exemplo n.º 11
0
        public void ResolveArrayTypeReference(ArrayTypeReference node)
        {
            if (null != node.Entity)
            {
                return;
            }

            ResolveTypeReference(node.ElementType);

            IType elementType = TypeSystemServices.GetType(node.ElementType);

            if (TypeSystemServices.IsError(elementType))
            {
                node.Entity = TypeSystemServices.ErrorEntity;
            }
            else
            {
                int rank = null == node.Rank ? 1 : (int)node.Rank.Value;
                node.Entity = elementType.MakeArrayType(rank);
            }
        }
Exemplo n.º 12
0
        override public bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
        {
            bool found = base.Resolve(resultingSet, name, typesToConsider);

            foreach (TypeReference baseType in _node.BaseTypes)
            {
                if (TypeSystemServices.GetType(baseType).Resolve(resultingSet, name, typesToConsider))
                {
                    found = true;
                }
            }

            if (!found)
            {
                // also look in System.Object
                if (BaseType.Resolve(resultingSet, name, typesToConsider))
                {
                    found = true;
                }
            }
            return(found);
        }
Exemplo n.º 13
0
 protected override void ResolveImpl(MappedToken token)
 {
     try
     {
         var type = TypeSystemServices.GetType(Node);
         if (type is Error)
         {
             return;
         }
         var a = Node as Attribute;
         if (a == null)
         {
             return;
         }
         quickInfoTip = "class " + a.Name;
         format       = Formats.BooType;
     }
     catch
     {
         return;
     }
 }
Exemplo n.º 14
0
        protected override void ResolveImpl(MappedToken token)
        {
            try
            {
                var type = TypeSystemServices.GetType(Node);
                if (type is Error)
                {
                    return;
                }

                format = Formats.BooType;
                var prefix = "struct ";
                if (type.IsClass)
                {
                    prefix = "class ";
                }
                if (type.IsInterface)
                {
                    prefix = "interface ";
                }
                if (type.IsEnum)
                {
                    prefix = "enumeration ";
                }
                quickInfoTip = prefix + type.FullName;

                var internalType = type as AbstractInternalType;
                if (internalType != null)
                {
                    declaringNode = CompileResults.GetMappedNode(internalType.Node);
                }
            }
            catch (Exception)
            {
                return;
            }
        }
Exemplo n.º 15
0
 protected void Found(TypeReference type)
 {
     Found(TypeSystemServices.GetType(type));
 }
 protected IType GetType(Node node)
 {
     return(TypeSystemServices.GetType(node));
 }
Exemplo n.º 17
0
        protected override void ResolveImpl(MappedToken token)
        {
            switch (Node.NodeType)
            {
            case NodeType.SelfLiteralExpression:
                var classDefinition = Node;
                while (classDefinition.ParentNode != null)
                {
                    if (classDefinition.NodeType != NodeType.ClassDefinition)
                    {
                        classDefinition = classDefinition.ParentNode;
                    }
                    else
                    {
                        varType = TypeSystemServices.GetType(classDefinition);
                        break;
                    }
                }
                break;

            case NodeType.MemberReferenceExpression:
            case NodeType.ReferenceExpression:
                var     expression = (ReferenceExpression)Node;
                IEntity entity;
                try
                {
                    entity = TypeSystemServices.GetEntity(expression);
                }
                catch
                {
                    break;
                }
                var prefix = "";
                if (entity is InternalParameter)
                {
                    prefix          = "(parameter) ";
                    varType         = TypeSystemServices.GetType(expression);
                    declarationNode = CompileResults.GetMappedNode(((InternalParameter)entity).Parameter);
                }
                if (entity is InternalLocal)
                {
                    prefix          = "(local variable) ";
                    varType         = ((InternalLocal)entity).Type;
                    declarationNode = CompileResults.GetMappedNode(((InternalLocal)entity).Local);
                }
                if (entity is InternalField)
                {
                    varType         = TypeSystemServices.GetType(Node);
                    declaringType   = ((InternalField)entity).DeclaringType;
                    declarationNode = CompileResults.GetMappedNode(((InternalField)entity).Field);
                }
                if (entity is InternalMethod)
                {
                    declaringType   = ((InternalMethod)entity).DeclaringType;
                    declarationNode = CompileResults.GetMappedNode(((InternalMethod)entity).Method);
                    if (entity is InternalConstructor)
                    {
                        varType = ((InternalConstructor)entity).DeclaringType;
                    }
                    else
                    {
                        varType = ((InternalMethod)entity).ReturnType;
                    }
                }
                if (entity is InternalProperty)
                {
                    declaringType   = ((InternalProperty)entity).DeclaringType;
                    varType         = TypeSystemServices.GetType(Node);
                    declarationNode = CompileResults.GetMappedNode(((InternalProperty)entity).Property);
                }
                if (entity is InternalEvent)
                {
                    declaringType   = ((InternalEvent)entity).DeclaringType;
                    varType         = TypeSystemServices.GetType(Node);
                    declarationNode = CompileResults.GetMappedNode(((InternalEvent)entity).Event);
                }
                if (entity is ExternalType)
                {
                    varType         = ((ExternalType)entity).Type;
                    format          = Formats.BooType;
                    isTypeReference = true;
                }
                if (entity is AbstractInternalType)
                {
                    varType         = ((AbstractInternalType)entity).Type;
                    format          = Formats.BooType;
                    isTypeReference = true;
                    declarationNode = CompileResults.GetMappedNode(((AbstractInternalType)entity).TypeDefinition);
                }
                if (entity is ExternalField)
                {
                    varType       = TypeSystemServices.GetType(Node);
                    declaringType = ((ExternalField)entity).DeclaringType;
//                        declarationNode = CompileResults.GetMappedNode(((ExternalField)entity).Field);
                }
                if (entity is ExternalMethod)
                {
                    declaringType = ((ExternalMethod)entity).DeclaringType;
//                        declarationNode = CompileResults.GetMappedNode(declaration);
                    if (entity is ExternalConstructor)
                    {
                        varType = ((ExternalConstructor)entity).DeclaringType;
                    }
                    else
                    {
                        varType = ((ExternalMethod)entity).ReturnType;
                    }
                }
                if (entity is ExternalProperty)
                {
                    declaringType = ((ExternalProperty)entity).DeclaringType;
                    varType       = TypeSystemServices.GetType(Node);
//                        declarationNode = CompileResults.GetMappedNode(((ExternalProperty)entity).Property);
                }
                if (entity is ExternalEvent)
                {
                    declaringType = ((ExternalEvent)entity).DeclaringType;
                    varType       = TypeSystemServices.GetType(Node);
//                        declarationNode = CompileResults.GetMappedNode(((ExternalEvent)entity).Event);
                }
                if (expression.ExpressionType != null)
                {
                    if (declaringType != null)
                    {
                        prefix += declaringType.FullName + '.';
                    }
                    quickInfoTip = prefix + expression.Name + " as " + expression.ExpressionType.FullName;
                }
                break;

            default:
                break;
            }
        }