IType GetConcreteType(IType type) { AnonymousCallableType anonymous = type as AnonymousCallableType; if (null == anonymous) { return(type); } return(anonymous.ConcreteType); }
public ICallableType GetCallableType(CallableSignature signature) { AnonymousCallableType type = GetCachedCallableType(signature); if (type == null) { type = new AnonymousCallableType(TypeSystemServices, signature); _cache.Add(signature, type); } return(type); }
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)); }
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); }
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); }
public virtual IType GetConcreteCallableType(Node sourceNode, AnonymousCallableType anonymousType) { return _anonymousCallablesManager.GetConcreteCallableType(sourceNode, anonymousType); }
public IType GetConcreteCallableType(Node sourceNode, AnonymousCallableType anonymousType) { return(anonymousType.ConcreteType ?? (anonymousType.ConcreteType = CreateConcreteCallableType(sourceNode, anonymousType))); }
Method CreateInvokeMethod(AnonymousCallableType anonymousType) { CallableSignature signature = anonymousType.GetSignature(); return(CodeBuilder.CreateRuntimeMethod("Invoke", signature.ReturnType, signature.Parameters, signature.AcceptVarArgs)); }