public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue(nameof(ExceptionScope), _serializer.Serialize(ExceptionScope)); //info.AddValue(nameof(ExceptionScope), ExceptionScope); info.AddValue(nameof(CurrentStatement), CurrentStatement); info.AddValue(nameof(CurrentExpression), CurrentExpression); info.AddValue(nameof(Details), Details); }
public static void Dump(AphidInterpreter interpreter, AphidObject obj) { AphidObject vmObj; interpreter.CurrentScope.TryResolve(ViewModelName, out vmObj); var vm = (AphidReplViewModel)vmObj.Value; var serializer = new AphidSerializer() { IgnoreFunctions = false }; vm._codeViewer.Dispatcher.Invoke(() => { if (obj != null) { vm._codeViewer.AppendCode(serializer.Serialize(obj)); } else { throw new InvalidOperationException(); } }); }
private void ExecuteExpression() { if (string.IsNullOrEmpty(Code)) { return; } AddHistoricalCode(); var tokens = new AphidLexer(Code + " ").GetTokens(); if (!tokens.Any(x => x.TokenType == AphidTokenType.EndOfStatement)) { tokens.Add(new AphidToken(AphidTokenType.EndOfStatement, "", 0)); } List <Components.Aphid.Parser.Expression> ast = null; try { ast = new AphidParser(tokens).Parse(); } catch (AphidParserException ex) { InvokeDispatcher(() => _codeViewer.AppendParserException(Code, ex)); return; } if (ast.Count != 1) { throw new InvalidOperationException(); } var exp = ast.First(); var unary = exp as UnaryOperatorExpression; if (unary == null || unary.Operator != AphidTokenType.retKeyword) { ast.Clear(); ast.Add(new UnaryOperatorExpression( AphidTokenType.retKeyword, exp)); } try { _interpreter.Interpret(ast); } catch (AphidRuntimeException ex) { InvokeDispatcher(() => _codeViewer.AppendException(Code, "Runtime error", ex)); return; } catch (AphidParserException ex) { InvokeDispatcher(() => _codeViewer.AppendParserException(Code, ex)); return; } var retVal = _interpreter.GetReturnValue(); var serializer = new AphidSerializer() { IgnoreFunctions = false }; InvokeDispatcher(() => _codeViewer.AppendOutput(Code, serializer.Serialize(retVal))); UpdateVariables(); ExecuteWatchExpressions(); }