Exemplo 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);
            }
        }
Exemplo n.º 2
0
 public override Expression Deserialize()
 {
     return(Expression.Dynamic(
                YacqBinder.GetIndex(this.ArgumentNames),
                this.Type.Deserialize(),
                this.Arguments.SelectAll(n => n.Deserialize())
                ));
 }
Exemplo n.º 3
0
 public override Expression Deserialize()
 {
     return(Expression.Dynamic(
                YacqBinder.UnaryOperation(this.Operation),
                this.Type.Deserialize(),
                this.Arguments.SelectAll(n => n.Deserialize())
                ));
 }
Exemplo n.º 4
0
 public override Expression Deserialize()
 {
     return(Expression.Dynamic(
                YacqBinder.SetMember(this.Name),
                this.Type.Deserialize(),
                this.Arguments.SelectAll(n => n.Deserialize())
                ));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Default definition method of <see cref="SymbolTable.Missing"/>.
 /// </summary>
 /// <param name="e">The expression to be reduced.</param>
 /// <param name="s">The symbol table which this symbol (value) belongs.</param>
 /// <param name="t">The expected <see cref="Expression.Type"/> from the caller, or <c>null</c> if any type will be accepted.</param>
 /// <returns>The reduced expression.</returns>
 public static Expression DefaultMissing(DispatchExpression e, SymbolTable s, Type t)
 {
     return(e._left is DynamicExpression || YacqBinder.IsInDynamicContext(s, e.Arguments.StartWith(e.Left))
         ? e.DispatchByDynamicBinder(s, t)
         : e.DispatchByTypeSystem(s, t));
 }