public Utility(IYololExecutor executor, IYololParser parser, Configuration config) { _executor = executor; _parser = parser; _yogi = config.YogiPath; _debuggerUrl = config.OnlineDebuggerUrl; }
private async Task RunYolol(string input, IYololExecutor executor, uint lines) { // Try to parse code as Yolol var result = await Parse(input); if (result == null) { return; } // Prep execution state var compileTimer = new Stopwatch(); compileTimer.Start(); var state = await executor.Prepare(result); compileTimer.Stop(); // Run for N lines, 500ms or until `:done!=0` var exeTimer = new Stopwatch(); exeTimer.Start(); var saved = state.Serialize(); var err = await state.Run(lines, TimeSpan.FromMilliseconds(500)); // Print out the final machine state var embed = state.ToEmbed(embed => { embed.AddField("Setup", $"{compileTimer.ElapsedMilliseconds}ms", true); embed.AddField("Execute", $"{exeTimer.ElapsedMilliseconds}ms", true); if (err != null) { embed.AddField("Error", $"{err}", false); } if (_debuggerUrl != null) { var base64 = saved.Serialize(); embed.WithUrl($"{_debuggerUrl}?state={base64}"); } }); await ReplyAsync(embed : embed.Build()); }
private async Task RunYolol(string input, IYololExecutor executor) { // Try to parse code as Yolol var result = await Parse(input); if (result == null) { return; } // Prep execution state var compileTimer = new Stopwatch(); compileTimer.Start(); var state = executor.Prepare(result); compileTimer.Stop(); // Run for 2000 lines, 500ms or until `:done!=0` var exeTimer = new Stopwatch(); exeTimer.Start(); var err = state.Run(2000, TimeSpan.FromMilliseconds(500)); // Print out error if execution terminated for some reason if (err != null) { await ReplyAsync(err); return; } // Print out the final machine state var embed = state.ToEmbed(embed => { embed.AddField("Setup", $"{compileTimer.ElapsedMilliseconds}ms", true); embed.AddField("Execute", $"{exeTimer.ElapsedMilliseconds}ms", true); }); await ReplyAsync(embed : embed.Build()); }
public Utility(IYololExecutor executor, IYololParser parser) { _executor = executor; _parser = parser; }
public BasicVerification(IYololExecutor executor) { _executor = executor; }
public JupyterContext(IYololExecutor executor) { _executor = executor; }
public Jupyter(IYololExecutor executor) { _executor = executor; }
public BasicVerification(Configuration config, IYololExecutor executor) { _config = config; _executor = executor; }
public static async Task <IExecutionState> Prepare(this IYololExecutor executor, Yolol.Grammar.AST.Program program, string done = ":done") { return((await executor.Prepare(new[] { program }, done)).Single()); }