Example #1
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);
        }