Exemplo n.º 1
0
        public CallValue(CallActivation activation, CompilationContext context)
            : base(context)
        {
            if (activation == null)
            {
                throw new ArgumentNullException("activation");
            }

            _activation = activation;
        }
Exemplo n.º 2
0
        internal CallActivation CreateCallActivation()
        {
            var overload   = resolveGenericBinding(_overload);
            var activation = new CallActivation(overload);

            foreach (var param in overload.Parameters)
            {
                RValueProvider arg;

                if (isUnresolved(param))
                {
                    if (param.HasDefaultValue)
                    {
                        //there is default value for the argument
                        arg = new DefaultArgValue(param.DefaultValue, param.Type, _context);
                    }
                    else if (param.HasParam)
                    {
                        arg = new ParamArgValue(param.Type, new RValueProvider[0], _context);
                    }
                    else
                    {
                        //parameter doesnt match
                        return(null);
                    }
                }
                else
                {
                    var args = _argBindings.Get(param).ToArray();

                    if (param.HasParam)
                    {
                        arg = new ParamArgValue(param.Type, args, _context);
                    }
                    else if (args.Length != 1)
                    {
                        throw new NotSupportedException("Wrong argument count for parameter: " + param.Name);
                    }
                    else
                    {
                        //TODO type conversions
                        arg = args[0];
                    }
                }

                activation.AddArgument(arg);
            }


            return(activation);
        }