this.callingContext = callingContext;
this.argumentInfo = argumentInfo.ToReadOnly ();
}
-
- public IList<CSharpArgumentInfo> ArgumentInfo {
- get {
- return argumentInfo;
- }
- }
-
- public override bool Equals (object obj)
- {
- var other = obj as CSharpGetIndexBinder;
- return other != null && other.callingContext == callingContext &&
- other.argumentInfo.SequenceEqual (argumentInfo);
- }
-
- public override int GetHashCode ()
- {
- return Extensions.HashCode (
- callingContext.GetHashCode (),
- argumentInfo.GetHashCode (),
- GetType().GetHashCode ());
- }
-
+
public override DynamicMetaObject FallbackGetIndex (DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion)
{
if (argumentInfo.Count != indexes.Length + 1) {
return errorSuggestion;
}
- var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
- var args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
- expr = new Compiler.ElementAccess (expr, args);
- expr = new Compiler.Cast (new Compiler.TypeExpression (typeof (object), Compiler.Location.Null), expr); // TODO: ReturnType replace
+ var ctx = DynamicContext.Create ();
+ var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
+ var args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
+ expr = new Compiler.ElementAccess (expr, args, Compiler.Location.Null);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
+
+ var binder = new CSharpBinder (this, expr, errorSuggestion);
+ binder.AddRestrictions (target);
+ binder.AddRestrictions (indexes);
- var restrictions = CSharpBinder.CreateRestrictionsOnTarget (target).Merge (CSharpBinder.CreateRestrictionsOnTarget (indexes));
- return CSharpBinder.Bind (target, expr, callingContext, restrictions, errorSuggestion);
+ return binder.Bind (ctx, callingContext);
}
}
}