private async Task DumpFormatAsync(ExpressionViewModel vm, string msg) => //if () //{ // return ; //} //var retVal = SerializingFormatter.Format( // Interpreter, // true, // Interpreter.GetReturnValue(), // ignoreNull: false, // ignoreClrObj: false, // scopes: AphidObject.GetScopeAncestors(Interpreter.CurrentScope)); //return CodeViewer.Run(() => vm.Value = retVal); await CodeViewer.Run( x => vm.Value = x, await(msg != null ? (Func <Task <string> >)(() => Task.FromResult(msg)) : (() => Task.Run( () => SerializingFormatter.Format( Interpreter, true, Interpreter.GetReturnValue(), ignoreNull: false, ignoreClrObj: false, scopes: AphidObject .GetScopeAncestors(Interpreter.CurrentScope)))))());
private void ExecuteWatchExpression(ExpressionViewModel vm) { try { _interpreter.Interpret("ret " + vm.Expression + ";"); } catch (AphidRuntimeException e) { InvokeDispatcher(() => vm.Value = "Runtime exception: " + e.Message); return; } catch (AphidParserException e) { InvokeDispatcher(() => vm.Value = "Parser exception: " + e.Message); return; } var retVal = new AphidSerializer() { IgnoreFunctions = false } .Serialize(_interpreter.GetReturnValue()); InvokeDispatcher(() => vm.Value = retVal); }
//private Task ExecuteWatchExpressionAsync(ExpressionViewModel vm) => // Task.Run(() => ExecuteWatchExpression(vm)); private async Task ExecuteWatchExpressionAsync(ExpressionViewModel vm) { string msg = null; try { Interpreter.ResetState(); Interpreter.TakeOwnership(); #if APHID_FRAME_ADD_DATA || APHID_FRAME_CATCH_POP try { #endif var ast = ParseRetExpression(vm.Expression); if (ast == null) { return; } Interpreter.Interpret(ast); #if APHID_FRAME_ADD_DATA || APHID_FRAME_CATCH_POP } #endif #if APHID_FRAME_ADD_DATA || APHID_FRAME_CATCH_POP #if APHID_FRAME_ADD_DATA catch (Exception e) #else catch #endif { if (e.Source != AphidName.DebugInterpreter) { e.Source = AphidName.DebugInterpreter; #if APHID_FRAME_CATCH_POP Interpreter.PopQueuedFrames(); #endif #if APHID_FRAME_ADD_DATA e.Data.Add(AphidName.Interpreter, Interpreter); e.Data.Add(AphidName.FramesKey, Interpreter.GetRawStackTrace()); #endif } throw; } #endif } catch (AphidRuntimeException e) { msg = AphidCli.Redirect(() => AphidCli.DumpException(e, Interpreter)); } catch (AphidParserException e) { msg = AphidCli.Redirect(() => AphidCli.DumpException(e, vm.Expression)); } catch (Exception e) { msg = AphidCli.Redirect(() => AphidCli.DumpException(e, Interpreter)); } await DumpFormatAsync(vm, msg); // ) //CodeViewer.Run( // x => vm.Value = x, // ) }