Esempio n. 1
0
        public override void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            var superInvocation = IsInvocationOnSuperMethod(node);
            var et = node.ExpressionType;

            base.OnMethodInvocationExpression(node);
            if (node.Target.Entity.EntityType == EntityType.Field)
            {
                ContextAnnotations.AddFieldInvocation(node);
            }
            else if (node.Target.Entity.EntityType == EntityType.BuiltinFunction)
            {
                if (node.Target.Entity == BuiltinFunction.Default)
                {
                    node.ExpressionType = node.Arguments[0].ExpressionType;
                }
            }
            if (et != null &&
                ((et.GenericInfo != null ||
                  (et.ConstructedInfo != null && !et.ConstructedInfo.FullyConstructed)) &&
                 node.Target.ExpressionType != null))
            {
                node.ExpressionType = node.Target.Entity.EntityType == EntityType.Constructor ?
                                      ((IConstructor)node.Target.Entity).DeclaringType:
                                      ((ICallableType)node.Target.ExpressionType).GetSignature().ReturnType;
            }
            if (!superInvocation)
            {
                return;
            }

            var accessor = CreateAccessorForSuperMethod(node.Target);

            Bind(node.Target, accessor);
        }
 public void CheckEntryPoint(Method node)
 {
     if ((node.IsStatic && node.IsPublic) && ((node.Name == "Main") && (this.GetType(node.ReturnType) == this.TypeSystemServices.VoidType)))
     {
         ContextAnnotations.SetEntryPoint(base._context, node);
     }
 }
Esempio n. 3
0
 private void PreprocessMethod()
 {
     if (ContextAnnotations.AwaitInExceptionHandler(_method.Method))
     {
         AsyncExceptionHandlerRewriter.Rewrite(_method.Method);
     }
     AwaitExpressionSpiller.Rewrite(_method.Method);
 }
Esempio n. 4
0
        internal static bool InAsyncMethod(Expression value)
        {
            INodeWithBody ancestor = value.GetAncestor <BlockExpression>();

            if (ancestor == null)
            {
                ancestor = value.GetAncestor <Method>();
            }
            return(ContextAnnotations.IsAsync(ancestor));
        }
Esempio n. 5
0
        public static bool TryCreate(TypeSystemServices tss, Method method, IType genericArg,
                                     out AsyncMethodBuilderMemberCollection collection)
        {
            if (ContextAnnotations.IsAsync(method))
            {
                var returnType = (IType)method.ReturnType.Entity;
                if (returnType == tss.VoidType)
                {
                    return(TryCreateVoid(tss, out collection));
                }
                if (returnType == tss.TaskType)
                {
                    return(TryCreateTask(tss, out collection));
                }
                if (returnType.ConstructedInfo != null &&
                    returnType.ConstructedInfo.GenericDefinition == tss.GenericTaskType)
                {
                    return(TryCreateGenericTask(tss, genericArg, out collection));
                }
            }

            throw CompilerErrorFactory.InvalidAsyncType(method.ReturnType);
        }