public static Expression Clear(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.Dispatch(
                s,
                DispatchTypes.Method,
                s.Resolve("*textbox*"),
                "Clear"
                ));
 }
Example #2
0
 public static Expression DumpObject(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(JsonConvert))
            .Method(s, "SerializeObject",
                    e.Left,
                    Expression.Constant(Formatting.None),
                    SerializerSettings
                    ));
 }
Example #3
0
 internal static Dispatch Dispatch(DispatchExpression expression)
 {
     return(new Dispatch()
     {
         DispatchType = expression.DispatchType,
         Left = expression.Left.Null(e => Serialize(e)),
         Name = expression.Name,
         TypeArguments = expression.TypeArguments.Select(TypeRef.Serialize).ToArray(),
         Arguments = expression.Arguments.Select(Serialize).ToArray(),
     }.Apply(n => n.TypeHint = expression.TryType().Null(t => TypeRef.Serialize(t))));
 }
Example #4
0
 /// <summary>
 /// Gets the most appropriate symbol with the specified <see cref="DispatchExpression"/>.
 /// </summary>
 /// <param name="expression">The <see cref="DispatchExpression"/> to use as symbol key properties.</param>
 /// <returns>The symbol value with the most appropriate to the specified <see cref="DispatchExpression"/>.</returns>
 public SymbolDefinition Match(DispatchExpression expression)
 {
     return(this.Match(
                expression.DispatchType,
                expression.Left.Reduce(this)
                .Null(e => e is TypeCandidateExpression
                 ? Static.Type(((TypeCandidateExpression)e).ElectedType)
                 : e.Type
                      ),
                expression.Name
                ));
 }
Example #5
0
 /// <summary>
 /// Gets the most appropriate symbol from this symbol table's <see cref="Chain"/> with the specified <see cref="DispatchExpression"/>.
 /// </summary>
 /// <param name="expression">The <see cref="DispatchExpression"/> to use as symbol key properties.</param>
 /// <returns>The symbol value with the most appropriate to the specified <see cref="DispatchExpression"/>.</returns>
 public SymbolDefinition ResolveMatch(DispatchExpression expression)
 {
     return(expression.Left.Reduce(this)
            .Let(e => (e as SymbolTableExpression)
                 .Null(se => se.Symbols, this)
                 .Let(s => (e != null
                 ? (e as TypeCandidateExpression)
                            .Null(te => te.Candidates.Select(Static.Type))
                            ?? new [] { e.Type(this), }
                 : new Type[1]
                            ).Select(t => s.ResolveMatch(expression.DispatchType, t, expression.Name)))
                 )
            .FirstOrDefault(_ => _ != null));
 }
 public static Expression Write(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.Dispatch(
                s,
                DispatchTypes.Method,
                s.Resolve("*textbox*"),
                "AppendText",
                YacqExpression.Dispatch(
                    s,
                    DispatchTypes.Method,
                    e.Left,
                    "ToString"
                    )
                ));
 }
 public static Expression WriteLine(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.Dispatch(
                s,
                DispatchTypes.Method,
                YacqExpression.Dispatch(
                    s,
                    DispatchTypes.Method,
                    "+",
                    YacqExpression.Dispatch(
                        s,
                        DispatchTypes.Method,
                        e.Left,
                        "ToString"
                        ),
                    Expression.Constant("\n")
                    ),
                "printn"
                ));
 }
Example #8
0
            public static Expression Missing(DispatchExpression e, SymbolTable s, Type t)
            {
                Type type;

                if (e.DispatchType == DispatchTypes.Method &&
                    !s.ExistsKey(DispatchTypes.Method, e.Name) &&
                    (type = FilterRegistrant.GetFilter(e.Name).FirstOrDefault()) != null
                    )
                {
                    return(YacqExpression.Dispatch(
                               s,
                               DispatchTypes.Constructor,
                               YacqExpression.TypeCandidate(type),
                               null,
                               e.Arguments
                               )
                           .Method(s, "Filter", YacqExpression.Identifier(s, "it")));
                }
                return(DispatchExpression.DefaultMissing(e, s, t));
            }
Example #9
0
 public static Expression Tab(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(Setting))
            .Member(s, "Instance")
            .Member(s, "StateProperty")
            .Member(s, "TabInformations")
            .Method(s, "SelectMany",
                    YacqExpression.Function(s, "\\",
                                            YacqExpression.Vector(s, YacqExpression.Identifier(s, "e")),
                                            YacqExpression.Identifier(s, "e")
                                            )
                    )
            .Method(s, "First",
                    YacqExpression.LambdaList(s,
                                              YacqExpression.Identifier(s, "=="),
                                              YacqExpression.Identifier(s, "$0").Member(s, "Name"),
                                              e.Arguments[0]
                                              )
                    )
            .Member(s, "TweetSources")
            .Method(s, "Single"));
 }
Example #10
0
 public static Expression RangeExact(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(LongRange))
            .Method(s, "FromPivotValue", e.Arguments[0]));
 }
Example #11
0
 public static Expression RangeFromTo(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(LongRange))
            .Method(s, "FromBetweenValues", e.Left, e.Arguments[0]));
 }
Example #12
0
 public static Expression ShowManualPage(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(Process)).Method(s, "Start",
                                                                 Expression.Constant("http://yacq.net/")
                                                                 ));
 }
Example #13
0
 public static Expression ExitRepl(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(Environment)).Method(s, "Exit",
                                                                     Expression.Constant(0)
                                                                     ));
 }
Example #14
0
 public static Expression CollectGarbage(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(GC)).Method(s, "Collect"));
 }