Exemple #1
0
 internal static DLR.Expression BuildPresetCallbackCall(AplusScope scope, DLR.ParameterExpression valueParam)
 {
     DLR.ParameterExpression callbackParameter = DLR.Expression.Parameter(typeof(CallbackItem), "__CALLBACK__");
     DLR.Expression callback = DLR.Expression.Block(
         new DLR.ParameterExpression[] { callbackParameter },
         DLR.Expression.Condition(
             DLR.Expression.Call(
                 scope.GetRuntimeExpression().Property("CallbackManager"),
                 typeof(CallbackManager).GetMethod("TryGetPresetCallback"),
                 scope.CallbackInfo.QualifiedName,
                 callbackParameter
             ),
             DLR.Expression.Dynamic(
         // TODO: do not instantiate the binder here
                 new Runtime.Binder.CallbackBinder(),
                 typeof(object),
                 callbackParameter,
                 scope.GetRuntimeExpression(),
                 valueParam,
                 scope.CallbackInfo.Index,
                 scope.CallbackInfo.Path
             ).To<AType>(),
             (DLR.Expression)valueParam.To<AType>()
         )
     );
     return callback;
 }