Exemplo n.º 1
0
        IType GetConcreteType(IType type)
        {
            AnonymousCallableType anonymous = type as AnonymousCallableType;

            if (null == anonymous)
            {
                return(type);
            }
            return(anonymous.ConcreteType);
        }
Exemplo n.º 2
0
        public ICallableType GetCallableType(CallableSignature signature)
        {
            AnonymousCallableType type = GetCachedCallableType(signature);

            if (type == null)
            {
                type = new AnonymousCallableType(TypeSystemServices, signature);
                _cache.Add(signature, type);
            }
            return(type);
        }
Exemplo n.º 3
0
        public virtual IType MapCallableType(AnonymousCallableType sourceType)
        {
            CallableSignature signature = sourceType.GetSignature();

            IType returnType = MapType(signature.ReturnType);

            IParameter[] parameters = MapParameters(signature.Parameters);

            CallableSignature mappedSignature = new CallableSignature(
                parameters, returnType, signature.AcceptVarArgs);

            return(TypeSystemServices.GetCallableType(mappedSignature));
        }
Exemplo n.º 4
0
        public virtual IType MapType(IType sourceType)
        {
            if (sourceType == null)
            {
                return(null);
            }

            if (_cache.ContainsKey(sourceType))
            {
                return((IType)_cache[sourceType]);
            }

            if (sourceType.IsByRef)
            {
                return(MapByRefType(sourceType));
            }

            if (sourceType.ConstructedInfo != null)
            {
                return(MapConstructedType(sourceType));
            }

            // TODO: Map nested types
            // GenericType[of T].NestedType => GenericType[of int].NestedType

            IArrayType array = (sourceType as IArrayType);

            if (array != null)
            {
                return(MapArrayType(array));
            }

            AnonymousCallableType anonymousCallableType = sourceType as AnonymousCallableType;

            if (anonymousCallableType != null)
            {
                return(MapCallableType(anonymousCallableType));
            }

            return(sourceType);
        }
Exemplo n.º 5
0
        private IType CreateConcreteCallableType(Node sourceNode, AnonymousCallableType anonymousType)
        {
            var module = TypeSystemServices.GetCompilerGeneratedTypesModule();

            var name = GenerateCallableTypeNameFrom(sourceNode, module);

            ClassDefinition cd = My <CallableTypeBuilder> .Instance.CreateEmptyCallableDefinition(name);

            cd.Annotate(AnonymousCallableTypeAnnotation);
            cd.Modifiers  |= TypeMemberModifiers.Public;
            cd.LexicalInfo = sourceNode.LexicalInfo;

            cd.Members.Add(CreateInvokeMethod(anonymousType));

            Method beginInvoke = CreateBeginInvokeMethod(anonymousType);

            cd.Members.Add(beginInvoke);

            cd.Members.Add(CreateEndInvokeMethod(anonymousType));
            AddGenericTypes(cd);
            module.Members.Add(cd);
            return((IType)cd.Entity);
        }
Exemplo n.º 6
0
		public virtual IType GetConcreteCallableType(Node sourceNode, AnonymousCallableType anonymousType)
		{
			return _anonymousCallablesManager.GetConcreteCallableType(sourceNode, anonymousType);
		}
Exemplo n.º 7
0
 public IType GetConcreteCallableType(Node sourceNode, AnonymousCallableType anonymousType)
 {
     return(anonymousType.ConcreteType ??
            (anonymousType.ConcreteType = CreateConcreteCallableType(sourceNode, anonymousType)));
 }
Exemplo n.º 8
0
        Method CreateInvokeMethod(AnonymousCallableType anonymousType)
        {
            CallableSignature signature = anonymousType.GetSignature();

            return(CodeBuilder.CreateRuntimeMethod("Invoke", signature.ReturnType, signature.Parameters, signature.AcceptVarArgs));
        }