private static bool Run(DyaOptions options) { Printer.Header(); ctx = new InteractiveContext(options); dispatcher = new CommandDispatcher(ctx); if (options.Test) { Printer.LineFeed(); return(RunTests(options)); } else if (options.Compile) { Printer.LineFeed(); return(Compile(options)); } else if (options.FileNames != null && options.FileNames.Length > 0) { Printer.LineFeed(); var i = 0; foreach (var f in options.GetFileNames()) { if (i > 0) { ctx.Reset(); } if (!ctx.EvalFile(f, options.MeasureTime)) { return(false); } i++; } if (options.StayInInteractive) { RunInteractive(); } else { return(true); } } else { RunInteractive(); } return(true); }
private static bool RunTests(DyaOptions options) { if (options.FileNames == null || options.FileNames.Length == 0 || string.IsNullOrEmpty(options.FileNames[0])) { Printer.Error("File name(s) not specified."); return(false); } return(TestRunner.RunTests(options.GetFileNames(), options, InteractiveContext.CreateBuildOptions(options))); }
private static bool Compile(DyaOptions options) { var ctx = new InteractiveContext(options); foreach (var f in options.GetFileNames()) { var outFile = options.OutputDirectory; if (string.IsNullOrWhiteSpace(outFile)) { outFile = Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f) + ".dyo"); } else if (Directory.Exists(outFile)) { outFile = Path.Combine(outFile, Path.GetFileNameWithoutExtension(f) + ".dyo"); } if (!File.Exists(f) || !ctx.Compile(f, out var unit)) { Printer.Error($"Compilation of file \"{f}\" skipped."); continue; } #if !DEBUG try #endif { ObjectFileWriter.Write(outFile, unit); Printer.Information($"Compilation completed. File saved: \"{outFile}\""); } #if !DEBUG catch (Exception ex) { Printer.Error(ex.Message); Printer.Error($"Compilation of file \"{f}\" skipped."); continue; } #endif } return(true); }