コード例 #1
0
        internal override Expression ToExpression(OverloadResolver resolver, IList <ArgBuilder> builders, RestrictedArguments args, Expression ret)
        {
            if (_returnArgs.Count == 1)
            {
                if (_returnArgs[0] == -1)
                {
                    return(ret);
                }
                return(Ast.Block(ret, builders[_returnArgs[0]].ToReturnExpression(resolver)));
            }

            Expression[] retValues = new Expression[_returnArgs.Count];
            int          rIndex    = 0;
            bool         usesRet   = false;

            foreach (int index in _returnArgs)
            {
                if (index == -1)
                {
                    usesRet             = true;
                    retValues[rIndex++] = ret;
                }
                else
                {
                    retValues[rIndex++] = builders[index].ToReturnExpression(resolver);
                }
            }

            Expression retArray = AstUtils.NewArrayHelper(typeof(object), retValues);

            if (!usesRet)
            {
                retArray = Ast.Block(ret, retArray);
            }

            return(resolver.GetByRefArrayExpression(retArray));
        }