コード例 #1
0
 public virtual void VisitNew(BoundNewEx x)
 {
     VisitTypeRef(x.TypeRef);
     VisitRoutineCall(x);
 }
コード例 #2
0
 public virtual void VisitNew(BoundNewEx x)
 {
     VisitTypeRef(x.TypeRef);
     VisitRoutineCall(x);
 }
コード例 #3
0
 public virtual TResult VisitNew(BoundNewEx x) => VisitRoutineCall(x);
コード例 #4
0
        public override void VisitNew(BoundNewEx x)
        {
            VisitTypeRef(x.TypeRef);

            VisitRoutineCall(x);    // analyse arguments

            // resolve target type
            var type = (NamedTypeSymbol)x.TypeRef.ResolvedType;
            if (type != null)
            {
                if (type.IsStatic)
                {
                    // TODO: Err cannot instantiate a static class
                }

                var candidates = type.InstanceConstructors.ToArray();

                //
                var args = x.ArgumentsInSourceOrder.Select(a => a.Value).ToImmutableArray();
                var argsType = args.Select(a => a.TypeRefMask).ToArray();

                x.TargetMethod = new OverloadsList(candidates).Resolve(this.TypeCtx, argsType, null);

                // reanalyse candidates
                foreach (var c in candidates)
                {
                    // analyze TargetMethod with x.Arguments
                    this.Worklist.EnqueueRoutine(c, CurrentBlock, args);
                }

                x.ResultType = type;
            }

            x.TypeRefMask = TypeCtx.GetTypeMask(x.TypeRef.TypeRef, false);
        }