private static void CreateCodeFiles(string file) { var codefile = $"{file}.dwx"; var dwsfile = $"{file}.dws"; if (File.Exists(codefile)) { return; } Console.WriteLine($"Create missing codefiles: {codefile}."); var interpreter = CreateInterpreter(); var aplc = new CodeFile(interpreter); for (var i = 0; i < N; i++) { var letter = alphabet.Substring(i, 1); Console.WriteLine($"Generating function tree: {letter}."); aplc.GenerateTfns(letter); } Console.WriteLine($"Save to: {codefile}."); aplc.CreateCodeFile(codefile, 1); Console.WriteLine($"Save to: {dwsfile}."); aplc.Dispose(); Console.WriteLine($"Done creating codefiles."); interpreter.Unload(); }
public void TestUseSharedCodeFileMultiHost() { var codefile = Path.Combine(Path.GetTempPath(), "simplecodefile.dwx"); if (File.Exists(codefile)) { File.Delete(codefile); } var interpreter = CreateInterpreter(); var aplc = new CodeFile(interpreter); aplc.CreateSimpleCodeFile(codefile, 5); aplc.Dispose(); interpreter.Unload(); var interpreter1 = CreateInterpreter(new[] { codefile }); var interpreter2 = CreateInterpreter(new[] { codefile }); var interpreter3 = CreateInterpreter(new[] { codefile }); var aplc1 = new CodeFile(interpreter1); var aplc2 = new CodeFile(interpreter2); var aplc3 = new CodeFile(interpreter3); aplc1.Execute("#.fn1 1"); aplc2.Execute("#.fn1 2"); aplc3.Execute("#.fn1 3"); }
public void TestUseSharedCodeFileLargeNamespacesMultiHost() { var codefile = Path.Combine(Path.GetTempPath(), "largecachefile.dwx"); if (File.Exists(codefile)) { File.Delete(codefile); } var interpreter = CreateInterpreter(); var aplc = new CodeFile(interpreter); aplc.CreateLargeCache(codefile, 7); aplc.Dispose(); interpreter.Unload(); var interpreter1 = CreateInterpreter(new[] { codefile }); var interpreter2 = CreateInterpreter(new[] { codefile }); var interpreter3 = CreateInterpreter(new[] { codefile }); }
private static DyalogInterpreter CreateInterpreter(string[] codeFiles = null) { var interpreterSettings = new Dictionary <string, string> { ["RUNASSERVICE"] = "2", ["MAXWS"] = "1G" }; var interpreter = new DyalogInterpreter(null, interpreterSettings) { SingleThreaded = true, DeleteOnUnload = true, UnloadWhenEmpty = false }; if (codeFiles != null) { var aplc = new CodeFile(interpreter); aplc.AttachCodeFiles(codeFiles); aplc.Dispose(); } return(interpreter); }
public void TestAttachSameCodeFileTwice() { var codefile = Path.Combine(Path.GetTempPath(), "simplecodefile2.dwx"); if (File.Exists(codefile)) { File.Delete(codefile); } var interpreter1 = CreateInterpreter(); var aplc = new CodeFile(interpreter1); aplc.CreateSimpleCodeFile(codefile, 3); aplc.Dispose(); interpreter1.Unload(); var interpreter2 = CreateInterpreter(new[] { codefile }); var interpreter3 = CreateInterpreter(new[] { codefile }); Assert.IsTrue(interpreter2.Unload()); //Assert.IsTrue(interpreter3.Unload()); }