Exemple #1
0
 public GenericConstructionChecker(TypeSystemServices tss, Node constructionNode, IType[] typeArguments, CompilerErrorCollection errorCollection)
 {
     _tss = tss;
     _constructionNode = constructionNode;
     _typeArguments = typeArguments;
     _errors = errorCollection;
 }
 public GenericConstructionChecker(TypeSystemServices tss, Node constructionNode, TypeReferenceCollection argumentNodes, CompilerErrorCollection errorCollection)
 {
     _tss = tss;
     _constructionNode = constructionNode;
     _argumentNodes = argumentNodes;
     _errors = errorCollection;
 }
Exemple #3
0
 public ArrayType(TypeSystemServices tagManager, IType elementType, int rank)
 {
     _array = tagManager.ArrayType;
     _elementType = elementType;
     _rank = rank;
     _enumerable = tagManager.IEnumerableGenericType;
 }
Exemple #4
0
 /// <summary>
 /// Constrcuts a new GenericMapping for a specific mapping of generic parameters to type arguments.
 /// </summary>
 /// <param name="parameters">The generic parameters that should be mapped.</param>
 /// <param name="arguments">The type arguments to map generic parameters to.</param>
 protected GenericMapping(TypeSystemServices tss, IGenericParameter[] parameters, IType[] arguments)
 {
     _tss = tss;
     for (int i = 0; i < parameters.Length; i++)
     {
         _map.Add(parameters[i], arguments[i]);
     }
 }
 public ExternalGenericParameter(TypeSystemServices tss, Type type)
     : base(tss, type)
 {
     if (type.DeclaringMethod != null)
     {
         _declaringMethod = (IMethod)tss.Map(type.DeclaringMethod);
     }
 }
Exemple #6
0
        public NamespaceEntity(INamespace parent, TypeSystemServices tagManager, string name)
        {
            _parent = parent;
            _typeSystemServices = tagManager;
            _name = name;
			_assemblies = new Dictionary<Assembly, Dictionary<string, List<Type>>>(AssemblyEqualityComparer.Default);
            _childrenNamespaces = new Dictionary<string, NamespaceEntity>();
            _internalModules = new List<ModuleEntity>();
            _externalModules = new List<ExternalType>();
Exemple #7
0
 public ModuleEntity(NameResolutionService nameResolutionService,
     TypeSystemServices typeSystemServices,
     Module module)
 {
     _nameResolutionService = nameResolutionService;
     _typeSystemServices = typeSystemServices;
     _module = module;
     _namespace = SafeNamespace(module);
 }
        public GenericConstructedMethod(TypeSystemServices tss, IMethod definition, IType[] arguments)
        {
            _tss = tss;
            _definition = definition;
            _genericArguments = arguments;

            _genericMapping = new GenericMapping(tss, this, arguments);

            _fullyConstructed = IsFullyConstructed();
        }
        public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration)
        {
            _tss = tss;
            _declaration = declaration;

            // Determine and remember declaring type and declaring method (if applicable)
            _declaringMethod = declaration.ParentNode as Method;
            _declaringType = (
                _declaringMethod == null ?
                declaration.ParentNode as TypeDefinition : _declaringMethod.DeclaringType);
        }
Exemple #10
0
 internal AnonymousCallableType(TypeSystemServices services, CallableSignature signature)
 {
     if (null == services)
     {
         throw new ArgumentNullException("services");
     }
     if (null == signature)
     {
         throw new ArgumentNullException("signature");
     }
     _typeSystemServices = services;
     _signature = signature;
 }
Exemple #11
0
 internal InternalMethod(TypeSystemServices typeSystemServices, Method method)
 {
     _typeSystemServices = typeSystemServices;
     _method = method;
     if (method.NodeType != NodeType.Constructor && method.NodeType != NodeType.Destructor)
     {
         if (null == _method.ReturnType)
         {
             IType returnType = _method.DeclaringType.NodeType == NodeType.ClassDefinition
                 ? Unknown.Default
                 : (IType)_typeSystemServices.VoidType;
             _method.ReturnType = _typeSystemServices.CodeBuilder.CreateTypeReference(method.LexicalInfo, returnType);
         }
     }
 }
Exemple #12
0
 public ReferenceExpression CreateReference(ParameterDeclaration parameter)
 {
     return(CreateReference((InternalParameter)TypeSystemServices.GetEntity(parameter)));
 }
Exemple #13
0
 public ReferenceExpression CreateReference(LexicalInfo li, System.Type type)
 {
     return(CreateReference(li, TypeSystemServices.Map(type)));
 }
Exemple #14
0
 public TypeReference CreateTypeReference(Type type)
 {
     return(CreateTypeReference(TypeSystemServices.Map(type)));
 }
Exemple #15
0
 public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration, AbstractInternalType declaringType, int position)
     : this(tss, declaration, position)
 {
     _declaringType = declaringType;
 }
Exemple #16
0
 public ExternalParameter(TypeSystemServices service, ParameterInfo parameter)
 {
     _typeSystemServices = service;
     _parameter = parameter;
 }
Exemple #17
0
 public InternalProperty(TypeSystemServices tagManager, Property property)
 {
     _typeSystemServices = tagManager;
     _property           = property;
 }
Exemple #18
0
 public ExternalConstructor(TypeSystemServices manager, ConstructorInfo ci) : base(manager, ci)
 {
 }
Exemple #19
0
 public ArrayType(TypeSystemServices tagManager, IType elementType)
     : this(tagManager, elementType, 1)
 {
 }
Exemple #20
0
 public InternalEvent(TypeSystemServices tagManager, Event event_)
 {
     _event = event_;
 }
Exemple #21
0
 public AbstractExternalGenericInfo(TypeSystemServices tss)
 {
     _tss = tss;
 }
Exemple #22
0
 internal ExternalMethod(TypeSystemServices manager, MethodBase mi)
 {
     _typeSystemServices = manager;
     _mi = mi;
 }
Exemple #23
0
 private static IMethod GetNoArgsNoVoid(IEnumerable <IEntity> value, TypeSystemServices tss)
 {
     return(value.Cast <IMethod>().SingleOrDefault(m =>
                                                   ((m.GetParameters().Length == 0) || (m.IsExtension && m.GetParameters().Length == 1)) &&
                                                   m.ReturnType != tss.VoidType));
 }
Exemple #24
0
 private static IMethod GetNoArgs(IEnumerable <IEntity> value, TypeSystemServices tss)
 {
     return(value.Cast <IMethod>().SingleOrDefault(m => m.GetParameters().Length == 0));
 }
Exemple #25
0
 public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration, InternalMethod declaringMethod, int position)
     : this(tss, declaration, position)
 {
     _declaringMethod = declaringMethod;
 }
Exemple #26
0
        private int CalculateArgumentScore(IType parameterType, IType argumentType)
        {
            if (parameterType == argumentType || (TypeSystemServices.IsSystemObject(argumentType) && TypeSystemServices.IsSystemObject(parameterType)))
            {
                return(parameterType is ICallableType ? CallableExactMatchScore : ExactMatchScore);
            }

            if (TypeCompatibilityRules.IsAssignableFrom(parameterType, argumentType))
            {
                var callableType = parameterType as ICallableType;
                var callableArg  = argumentType as ICallableType;
                if (callableType != null && callableArg != null)
                {
                    return(CalculateCallableScore(callableType, callableArg));
                }
                return(UpCastScore);
            }

            if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
            {
                return(ImplicitConversionScore);
            }

            if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
            {
                return(IsWideningPromotion(parameterType, argumentType) ? WideningPromotion : NarrowingPromotion);
            }

            if (MyDowncastPermissions().CanBeReachedByDowncast(parameterType, argumentType))
            {
                return(DowncastScore);
            }

            return(-1);
        }
Exemple #27
0
 internal InternalClass(TypeSystemServices manager, TypeDefinition typeDefinition) :
     base(manager, typeDefinition)
 {
 }
Exemple #28
0
 internal InternalEnum(TypeSystemServices tagManager, EnumDefinition enumDefinition)
     : base(tagManager, enumDefinition)
 {
 }
Exemple #29
0
 internal ExternalType(TypeSystemServices tss, Type type)
 {
     if (null == type) throw new ArgumentException("type");
     _typeSystemServices = tss;
     _type = type;
 }
Exemple #30
0
 public InternalProperty(TypeSystemServices typeSystemServices, Property property)
 {
     _typeSystemServices = typeSystemServices;
     _property = property;
 }
Exemple #31
0
 public DeclarationsNamespace(INamespace parent, TypeSystemServices tagManager, DeclarationCollection declarations)
 {
     _parent = parent;
     _declarations = declarations;
 }
Exemple #32
0
 internal InternalCallableType(TypeSystemServices typeSystemServices, TypeDefinition typeDefinition) :
     base(typeSystemServices, typeDefinition)
 {
 }
Exemple #33
0
 internal ExternalCallableType(TypeSystemServices typeSystemServices, Type type) : base(typeSystemServices, type)
 {
     _invoke = typeSystemServices.Map(type.GetMethod("Invoke"));
 }
Exemple #34
0
 /// <summary>
 /// Constructs a new generic mapping between a generic method and one of its constructed methods.
 /// </summary>
 public GenericMapping(TypeSystemServices tss, IMethod constructedMethod, IType[] arguments)
     : this(tss, constructedMethod.ConstructedInfo.GenericDefinition.GenericInfo.GenericParameters, arguments)
 {
     _constructedOwner = constructedMethod;
     _genericSource = constructedMethod.ConstructedInfo.GenericDefinition;
 }
Exemple #35
0
 public MethodInvocationExpression CreateMethodInvocation(MethodInfo staticMethod, Expression arg0, Expression arg1)
 {
     return(CreateMethodInvocation(TypeSystemServices.Map(staticMethod), arg0, arg1));
 }
 public InternalGenericMethod(TypeSystemServices tss, Method method)
     : base(tss, method)
 {
 }
Exemple #37
0
 public TypeReference CreateTypeReference(LexicalInfo li, Type type)
 {
     return(CreateTypeReference(li, TypeSystemServices.Map(type)));
 }
 public ExternalGenericMethodDefinitionInfo(TypeSystemServices tss, ExternalMethod method) :     base(tss)
 {
     _method = method;
 }
Exemple #39
0
 public BinaryExpression CreateAssignment(Expression lhs, Expression rhs)
 {
     return(CreateBoundBinaryExpression(TypeSystemServices.GetExpressionType(lhs), BinaryOperatorType.Assign, lhs, rhs));
 }
 internal InternalInterface(TypeSystemServices manager, TypeDefinition typeDefinition)
     : base(manager, typeDefinition)
 {
 }
Exemple #41
0
 protected IType ArgumentType(Expression e)
 {
     return(TypeSystemServices.GetExpressionType(e));
 }
Exemple #42
0
 internal InternalCallableType(TypeSystemServices typeSystemServices, TypeDefinition typeDefinition)
     : base(typeSystemServices, typeDefinition)
 {
 }
        public InternalConstructor(TypeSystemServices typeSystemServices,
		                           Constructor constructor)
            : base(typeSystemServices, constructor)
        {
        }
Exemple #44
0
 public ExternalEntity(TypeSystemServices typeSystemServices, T memberInfo)
 {
     _typeSystemServices = typeSystemServices;
     _memberInfo         = memberInfo;
 }
Exemple #45
0
 public ExternalParameter(TypeSystemServices service, ParameterInfo parameter)
 {
     _typeSystemServices = service;
     _parameter          = parameter;
 }
 public InternalEnumMember(TypeSystemServices tagManager, EnumMember member)
 {
     _member = member;
 }
 public ExternalConstructor(TypeSystemServices manager, ConstructorInfo ci)
     : base(manager, ci)
 {
 }
Exemple #48
0
 internal VoidTypeImpl(TypeSystemServices typeSystemServices)
     : base(typeSystemServices, Types.Void)
 {
 }
Exemple #49
0
 protected AbstractInternalType(TypeSystemServices typeSystemServices, TypeDefinition typeDefinition)
 {
     _typeSystemServices = typeSystemServices;
     _typeDefinition     = typeDefinition;
 }
 public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration, int position)
     : this(tss, declaration)
 {
     _position = position;
 }
Exemple #51
0
 internal InternalEnum(TypeSystemServices tagManager, EnumDefinition enumDefinition) :
     base(tagManager, enumDefinition)
 {
 }
Exemple #52
0
 public RaiseStatement RaiseException(LexicalInfo lexicalInfo, IConstructor exceptionConstructor, params Expression[] args)
 {
     Debug.Assert(TypeSystemServices.IsValidException(exceptionConstructor.DeclaringType));
     return(new RaiseStatement(lexicalInfo, CreateConstructorInvocation(lexicalInfo, exceptionConstructor, args)));
 }
Exemple #53
0
 public DeclarationsNamespace(INamespace parent, TypeSystemServices tagManager, Declaration declaration)
 {
     _parent = parent;
     _declarations = new DeclarationCollection();
     _declarations.Add(declaration);
 }
Exemple #54
0
 public Expression CreateTypeofExpression(System.Type type)
 {
     return(CreateTypeofExpression(TypeSystemServices.Map(type)));
 }
Exemple #55
0
 public ExternalConstructedTypeInfo(TypeSystemServices tss, ExternalType type)
 {
     _type = type;
     _tss  = tss;
 }
Exemple #56
0
 public MethodInvocationExpression CreateMethodInvocation(Expression target, MethodInfo method)
 {
     return(CreateMethodInvocation(target, TypeSystemServices.Map(method)));
 }
Exemple #57
0
 internal ExternalCallableType(TypeSystemServices typeSystemServices, Type type)
     : base(typeSystemServices, type)
 {
     _invoke = typeSystemServices.Map(type.GetMethod("Invoke"));
 }
 public ExternalConstructedMethodInfo(TypeSystemServices tss, ExternalMethod method)
 {
     _method = method;
     _tss    = tss;
 }
 public ExternalConstructedTypeInfo(TypeSystemServices tss, ExternalType type)
 {
     _type = type;
     _tss = tss;
 }
 public ExternalGenericTypeInfo(TypeSystemServices tss, ExternalType type) : base(tss)
 {
     _type = type;
 }