private void PopulateSymbolTableWithPayloadInformation(
DynamicMetaObjectBinder payload,
Type callingType,
ArgumentObject[] arguments)
{
ICSharpInvokeOrInvokeMemberBinder callOrInvoke;
CSharpGetMemberBinder getmember;
CSharpSetMemberBinder setmember;
if ((callOrInvoke = payload as ICSharpInvokeOrInvokeMemberBinder) != null)
{
Type type;
if (callOrInvoke.StaticCall)
{
if (arguments[0].Value == null || !(arguments[0].Value is Type))
{
Debug.Assert(false, "Cannot make static call without specifying a type");
throw Error.InternalCompilerError();
}
type = arguments[0].Value as Type;
}
else
{
type = callingType;
}
_symbolTable.PopulateSymbolTableWithName(
callOrInvoke.Name,
callOrInvoke.TypeArguments,
type);
// If it looks like we're invoking a get_ or a set_, load the property as well.
// This is because we need COM indexed properties called via method calls to
// work the same as it used to.
if (callOrInvoke.Name.StartsWith("set_", StringComparison.Ordinal) ||
callOrInvoke.Name.StartsWith("get_", StringComparison.Ordinal))
{
_symbolTable.PopulateSymbolTableWithName(
callOrInvoke.Name.Substring(4), //remove prefix
callOrInvoke.TypeArguments,
type);
}
}
else if ((getmember = payload as CSharpGetMemberBinder) != null)
{
_symbolTable.PopulateSymbolTableWithName(
getmember.Name,
null,
arguments[0].Type);
}
else if ((setmember = payload as CSharpSetMemberBinder) != null)
{
_symbolTable.PopulateSymbolTableWithName(
setmember.Name,
null,
arguments[0].Type);
}
else if (payload is CSharpGetIndexBinder || payload is CSharpSetIndexBinder)
{
_symbolTable.PopulateSymbolTableWithName(
SpecialNames.Indexer,
null,
arguments[0].Type);
}
else if (payload is CSharpBinaryOperationBinder)
{
CSharpBinaryOperationBinder op = payload as CSharpBinaryOperationBinder;
if (GetCLROperatorName(op.Operation) == null)
{
Debug.Assert(false, "Unknown operator: " + op.Operation);
throw Error.InternalCompilerError();
}
_symbolTable.PopulateSymbolTableWithName(
GetCLROperatorName(op.Operation),
null,
arguments[0].Type);
_symbolTable.PopulateSymbolTableWithName(
GetCLROperatorName(op.Operation),
null,
arguments[1].Type);
}
else if (payload is CSharpUnaryOperationBinder)
{
CSharpUnaryOperationBinder op = payload as CSharpUnaryOperationBinder;
_symbolTable.PopulateSymbolTableWithName(
GetCLROperatorName(op.Operation),
null,
arguments[0].Type);
}
else if (payload is CSharpIsEventBinder)
{
CSharpIsEventBinder op = payload as CSharpIsEventBinder;
// Populate the symbol table with the LHS.
_symbolTable.PopulateSymbolTableWithName(
op.Name,
null,
arguments[0].Info.IsStaticType ? arguments[0].Value as Type : arguments[0].Type);
}
else if (!(payload is CSharpConvertBinder))
{
// Conversions don't need to do anything, since they're just conversions!
// After we add payload information, we add conversions for all argument
// types anyway, so that will get handled there.
//
// All other unknown payload types will generate an error.
Debug.Assert(false, "Unknown payload kind");
throw Error.InternalCompilerError();
}
}