private void PopulateLocalScope(
DynamicMetaObjectBinder payload,
Scope pScope,
ArgumentObject[] arguments,
IEnumerable<Expression> parameterExpressions,
Dictionary<int, LocalVariableSymbol> dictionary)
{
// We use the compile time types for the local variables, and then
// cast them to the runtime types for the expression tree.
int i = 0;
foreach (Expression parameter in parameterExpressions)
{
CType type = _symbolTable.GetCTypeFromType(parameter.Type);
// Make sure we're not setting ref for the receiver of a call - the argument
// will be marked as ref if we're calling off a struct, but we don't want
// to persist that in our system.
bool isFirstParamOfCallOrInvoke = false;
if (i == 0 && IsBinderThatCanHaveRefReceiver(payload))
{
isFirstParamOfCallOrInvoke = true;
}
// If we have a ref or out, get the parameter modifier type.
if ((parameter is ParameterExpression && (parameter as ParameterExpression).IsByRef) &&
(arguments[i].Info.IsByRef || arguments[i].Info.IsOut))
{
// If we're the first param of a call or invoke, and we're ref, it must be
// because of structs. Don't persist the parameter modifier type.
if (!isFirstParamOfCallOrInvoke)
{
type = _semanticChecker.GetTypeManager().GetParameterModifier(type, arguments[i].Info.IsOut);
}
}
LocalVariableSymbol local = _semanticChecker.GetGlobalSymbolFactory().CreateLocalVar(_semanticChecker.GetNameManager().Add("p" + i), pScope, type);
local.fUsedInAnonMeth = true;
dictionary.Add(i++, local);
isFirstParamOfCallOrInvoke = false;
}
}