public override string FormatException(Exception exception) { while (exception is TargetInvocationException) { exception = exception.InnerException; } Builtins.lastException = exception; if (exception is Builtins.Continuation) { // cheat return @"&implementation-restriction &message: continuations cannot be used in this way, sorry :("; } if (exception is ThreadAbortException) { return "evaluation aborted"; } if (exception is SchemeException) { return exception.ToString(); } var w = new IronScheme.Runtime.StringWriter(); w.WriteLine("Unhandled CLR exception reading input:"); "(display {0} {1})".Eval(exception, w); return w.GetBuffer(); }
static string WriteFormat(object obj) { var w = new IronScheme.Runtime.StringWriter(); "(write {0} {1})".Eval(obj, w); return(w.GetBuffer()); }
public string ToPrettyString() { StringWriter w = new StringWriter(); ((Callable)Builtins.SymbolValue(SymbolTable.StringToObject("pretty-print"))).Call(this, w); return(w.GetBuffer()); }
public override string FormatException(Exception exception) { while (exception is TargetInvocationException) { exception = exception.InnerException; } Builtins.lastException = exception; if (exception is Builtins.Continuation) { // cheat return(@"&implementation-restriction &message: continuations cannot be used in this way, sorry :("); } if (exception is ThreadAbortException) { return("evaluation aborted"); } if (exception is SchemeException) { return(exception.ToString()); } var w = new IronScheme.Runtime.StringWriter(); w.WriteLine("Unhandled CLR exception reading input:"); "(display {0} {1})".Eval(exception, w); return(w.GetBuffer()); }
public override string FormatException(Exception exception) { while (exception is TargetInvocationException) { exception = exception.InnerException; } Builtins.lastException = exception; if (exception is Builtins.Continuation) { // cheat return(@"&implementation-restriction &message: ""continuations cannot be used in this way, sorry :("""); } if (exception is ThreadAbortException) { return("evaluation aborted"); } if (exception is SchemeException) { return(exception.ToString()); } if (exception is SyntaxErrorException) { var parts = exception.Message.Split('|'); if (parts.Length > 1) { return(@"Unhandled exception while reading input: &lexical &message: """ + parts[0] + @""" &irritants: (""" + parts[1] + @""") "); } else { return(@"Unhandled exception while reading input: &lexical &message: """ + parts[0] + @""" "); } } var w = new IronScheme.Runtime.StringWriter(); w.WriteLine("Unhandled CLR exception reading input:"); "(display {0} {1})".Eval(exception, w); return(w.GetBuffer()); }
static string WriteFormat(object obj) { var w = new IronScheme.Runtime.StringWriter(); "(write {0} {1})".Eval(obj, w); return w.GetBuffer(); }
public override string FormatException(Exception exception) { while (exception is TargetInvocationException) { exception = exception.InnerException; } Builtins.lastException = exception; if (exception is Builtins.Continuation) { // cheat return @"&implementation-restriction &message: ""continuations cannot be used in this way, sorry :("""; } if (exception is ThreadAbortException) { return "evaluation aborted"; } if (exception is SchemeException) { return exception.ToString(); } if (exception is SyntaxErrorException) { var parts = exception.Message.Split('|'); if (parts.Length > 1) { return @"Unhandled exception while reading input: &lexical &message: """ + parts[0] + @""" &irritants: (""" + parts[1] + @""") "; } else { return @"Unhandled exception while reading input: &lexical &message: """ + parts[0] + @""" "; } } var w = new IronScheme.Runtime.StringWriter(); w.WriteLine("Unhandled CLR exception reading input:"); "(display {0} {1})".Eval(exception, w); return w.GetBuffer(); }
public override object Call(object[] args) { try { object ppo; if (Builtins.cc.Scope.TryLookupName(SymbolTable.StringToId("trace-printer"), out ppo)) { ppo = (ppo as Callable).Call(); } else { ppo = "write".Eval(); } Callable pp = ppo as Callable; depth++; Cons c = Runtime.Cons.FromArray(args), u = c; if (filter != null) { while (c != null) { c.car = filter.Call(c.car); c = c.cdr as Cons; } } object a = args.Length == 1 ? Builtins.Car(u) : u; StringWriter pre = new StringWriter(); pp.Call(a, pre); string prefix = new string('|', depth); if ((Console.LargestWindowWidth | Console.LargestWindowHeight) == 0) { Console.WriteLine("{0} -> {1}", prefix, name); Console.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); object result = realtarget.Call(args); StringWriter p = new StringWriter(); pp.Call(filter == null ? result : filter.Call(result), p); Console.WriteLine("{0} <- {1}", prefix, name); Console.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); return(result); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("{0} -> {1}", prefix, name); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); Console.ForegroundColor = ConsoleColor.Gray; object result = realtarget.Call(args); StringWriter p = new StringWriter(); pp.Call(filter == null ? result : filter.Call(result), p); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0} <- {1}", prefix, name); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); Console.ForegroundColor = ConsoleColor.Gray; return(result); } } finally { depth--; } }
public override object Call(object[] args) { try { object ppo; if (Builtins.cc.Scope.TryLookupName(SymbolTable.StringToId("trace-printer"), out ppo)) { ppo = (ppo as Callable).Call(); } else { ppo = "write".Eval(); } Callable pp = ppo as Callable; depth++; Cons c = Runtime.Cons.FromArray(args), u = c; if (filter != null) { while (c != null) { c.car = filter.Call(c.car); c = c.cdr as Cons; } } object a = args.Length == 1 ? Builtins.Car(u) : u; StringWriter pre = new StringWriter(); pp.Call(a, pre); string prefix = new string('|', depth); if ((Console.LargestWindowWidth | Console.LargestWindowHeight) == 0) { Console.Error.WriteLine("{0} -> {1}", prefix, name); Console.Error.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); object result = realtarget.Call(args); StringWriter p = new StringWriter(); pp.Call(filter == null ? result : filter.Call(result), p); Console.Error.WriteLine("{0} <- {1}", prefix, name); Console.Error.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); return result; } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.Error.WriteLine("{0} -> {1}", prefix, name); Console.ForegroundColor = ConsoleColor.White; Console.Error.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); Console.ForegroundColor = ConsoleColor.Gray; object result = realtarget.Call(args); StringWriter p = new StringWriter(); pp.Call(filter == null ? result : filter.Call(result), p); Console.ForegroundColor = ConsoleColor.Cyan; Console.Error.WriteLine("{0} <- {1}", prefix, name); Console.ForegroundColor = ConsoleColor.White; Console.Error.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray())); Console.ForegroundColor = ConsoleColor.Gray; return result; } } finally { depth--; } }