Exemplo n.º 1
0
        Expression CreateDelegate(IType type, Expression source)
        {
            var method = (IMethod)GetEntity(source);

            Expression target = method.IsStatic
                ? CodeBuilder.CreateNullLiteral()
                : ((MemberReferenceExpression)source).Target;

            var cType = GetConcreteType(type) ??
                        TypeSystemServices.GetConcreteCallableType(source, (AnonymousCallableType)type);

            return(CodeBuilder.CreateConstructorInvocation(cType.GetConstructors().First(),
                                                           target,
                                                           CodeBuilder.CreateAddressOfExpression(method)));
        }
Exemplo n.º 2
0
        override public void LeaveCallableTypeReference(CallableTypeReference node)
        {
            IParameter[] parameters = new IParameter[node.Parameters.Count];
            for (int i = 0; i < parameters.Length; ++i)
            {
                parameters[i] = new InternalParameter(node.Parameters[i], i);
            }

            IType returnType = null;

            if (null != node.ReturnType)
            {
                returnType = GetType(node.ReturnType);
            }
            else
            {
                returnType = TypeSystemServices.VoidType;
            }

            node.Entity = TypeSystemServices.GetConcreteCallableType(node, new CallableSignature(parameters, returnType));
        }
Exemplo n.º 3
0
 override public void LeaveCallableTypeReference(CallableTypeReference node)
 {
     node.Entity = TypeSystemServices.GetConcreteCallableType(node, CallableSignatureFor(node));
 }