private void btnLog_Click(object sender, EventArgs e) { int c = (int)double.Parse(txtLog.Text); TransformLog transfor = new TransformLog(); transfor.C = c; transfor.setImage(bitmapFromSource()); actions(transfor, "Log Transform"); }
public static void Main(string[] args) { // Acquire a log for, well, logging purposes. var rawLog = TerminalLog.Acquire(); Log = new TransformLog( rawLog, entry => DiagnosticExtractor.Transform(entry, new Text("LeMP-repl"))); // Wrap the log in a Loyc message sink. Sink = new SeverityMessageFilter( new PixieMessageSink(Log), Loyc.Severity.NoteDetail); // Create an option parser. var optParser = new GnuOptionSetParser( Options.All, Options.Files, Options.Files.Forms[0]); // Parse command-line arguments. var parsedOptions = optParser.Parse(args, Log); // Optionally display help message. if (parsedOptions.GetValue <bool>(Options.Help)) { rawLog.Log( new HelpMessage( "LeMP-repl is a simple interactive program that " + "reads unprocessed EC#, LES v2 or LES v3 code as " + "input and produces processed or unprocessed EC#, " + "LES v2 or LES v3 code as output.", "LeMP-repl [options]", Options.All)); return; } // Create a macro processor. if (!parsedOptions.GetValue <bool>(Options.DoNotProcessMacros)) { Processor = new MacroProcessor(Sink); Processor.AddMacros(typeof(StandardMacros).Assembly, false); Processor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP")); } Parser = GetParser(parsedOptions); Printer = GetPrinter(parsedOptions); // Start the REPL. RunRepl(); }
public static int Main(string[] args) { // Acquire a log. var rawLog = TerminalLog.Acquire(); var log = new TransformLog( rawLog, new Func <LogEntry, LogEntry>[] { MakeDiagnostic }); // Parse command-line options. var parser = new GnuOptionSetParser( Options.All, Options.Input); var recLog = new RecordingLog(log); var parsedOptions = parser.Parse(args, recLog); if (recLog.Contains(Severity.Error)) { // Stop the program if the command-line arguments // are half baked. return(1); } if (parsedOptions.GetValue <bool>(Options.Help)) { // Wrap the help message into a log entry and send it to the log. rawLog.Log( new LogEntry( Severity.Info, new HelpMessage( "fbfc is a compiler that turns Brainfuck code into CIL assemblies.", "fbfc path [options...]", Options.All))); return(0); } var inputPath = parsedOptions.GetValue <string>(Options.Input); if (string.IsNullOrEmpty(inputPath)) { log.Log( new LogEntry( Severity.Error, "nothing to compile", "no input file")); return(1); } var outputPath = parsedOptions.GetValue <string>(Options.Output); if (string.IsNullOrEmpty(outputPath)) { outputPath = Path.GetFileNameWithoutExtension(inputPath) + ".exe"; } // Read the Brainfuck source code from disk. SourceDocument source; try { source = new StringDocument(inputPath, File.ReadAllText(inputPath)); } catch (Exception) { log.Log( new LogEntry( Severity.Error, "invalid source path", Quotation.QuoteEvenInBold( "cannot read Brainfuck source code at ", inputPath, "."))); return(1); } var asmName = Path.GetFileNameWithoutExtension(outputPath); var cecilAsm = Mono.Cecil.AssemblyDefinition.CreateAssembly( new Mono.Cecil.AssemblyNameDefinition(asmName, new Version(1, 0, 0, 0)), asmName, Mono.Cecil.ModuleKind.Console); var flameAsm = ClrAssembly.Wrap(cecilAsm); var typeEnv = flameAsm.Resolver.TypeEnvironment; var compiler = new Compiler( flameAsm, Dependencies.Resolve( typeEnv, new ReadOnlyTypeResolver(typeEnv.Object.Parent.Assembly), log), log, parsedOptions); compiler.Compile(source); cecilAsm.Write(outputPath); return(0); }