Esempio n. 1
0
        private Expression DispatchByDynamicBinder(SymbolTable symbols, Type expectedType)
        {
            switch (this.DispatchType & DispatchTypes.TargetMask)
            {
            case DispatchTypes.Member:
                return(Dynamic(
                           YacqBinder.GetMember(symbols, this.Name),
                           typeof(Object),
                           this.Arguments.ReduceAll(symbols)
                           .StartWith((this._left as TypeCandidateExpression)
                                      .Null(tc => Constant(Static.Value(tc.ElectedType)))
                                      ?? this._left
                                      )
                           ));

            case DispatchTypes.Method:
                return(Dynamic(
                           YacqBinder.InvokeMember(symbols, this.Name, Enumerable.Repeat("", this.Arguments.Count)),
                           typeof(Object),
                           this.Arguments.ReduceAll(symbols)
                           .StartWith((this._left as TypeCandidateExpression)
                                      .Null(tc => Constant(Static.Value(tc.ElectedType)))
                                      ?? this._left
                                      )
                           ));

            default:
                throw new NotSupportedException("Dispatcher (in dynamic context) doesn't support: " + this.DispatchType);
            }
        }
Esempio n. 2
0
 public override Expression Deserialize()
 {
     return(Expression.Dynamic(
                YacqBinder.InvokeMember(this.Name, this.ArgumentNames),
                this.Type.Deserialize(),
                this.Arguments.SelectAll(n => n.Deserialize())
                ));
 }