public static CompileResults RunCompiler(string source) { var results = new CompileResults( () => "Test", () => source, () => 4 ); CompilerManager.Compile(4, new[] { typeof(SerializableAttribute).Assembly }, new[] { results }); return(results); }
/// <summary> /// Builds the project. /// </summary> /// <returns>The build result.</returns> /// <param name="monitor">Progress monitor.</param> /// <param name="configuration">Configuration to build.</param> /// <remarks>This method is invoked to build the project. Support files such as files with the Copy to Output flag will /// be copied before calling this method.</remarks> protected override Task <BuildResult> DoBuild(ProgressMonitor monitor, ConfigurationSelector configuration) { var pc = (CProjectConfiguration)GetConfiguration(configuration); pc.SourceDirectory = BaseDirectory; return(Task <BuildResult> .Factory.StartNew(delegate { return CompilerManager.Compile(this, Files, packages, pc, monitor); })); }
public Judger() { sandbox = new Sandbox(); problemModel = new ProblemModel(); userModel = new UserModel(); judgeModel = new JudgeModel(); compilerManager = new CompilerManager(); checker = new Checker(); workSpace = FS.JudgeWorkspace; FS.WriteAllBytes(FS.RunEXE, Properties.Resources.run_PCMS2); FS.WriteAllBytes(FS.InvokeDLL, Properties.Resources.invoke2_PCMS2); FS.WriteAllBytes(FS.CompilerTemplates, Properties.Resources.compilerTemplates); FS.CleanAppData(); }
private void CompileWithErrorHandler() { log.Info("编译程序启动"); if (editor.Text == "") { log.Info("编辑框为空"); if (System.Threading.Thread.CurrentThread.CurrentCulture.Name == "zh-CN") { MessageBox.Show("错误:编辑框为空。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("The textbox is empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } log.Info("正在进行编译"); CompilerResults cr = CompilerManager.CompileFromString(editor.Text); log.Info("输出框弹出"); OutputForm of = new OutputForm(); of.Owner = this; string tempcr = System.Threading.Thread.CurrentThread.CurrentCulture.Name == "zh-CN" ? "================ Compiler Output ================" : "=================== 编译器输出 ==================="; foreach (string str in cr.Output) { tempcr = tempcr + "\r\n" + str; } of.OutputText = tempcr; of.Show(); log.Info("正在检查操作"); if (!File.Exists("rcse_compiled.cache.lk")) { log.Info("返回: 未能找到被编译文件"); MessageBox.Show("无法找到编译文件: 是否编译错误?", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } log.Info("编译成功,正在重命名文件"); File.Move("rcse_compiled.cache.lk", "dbgcache.exe"); }
public void ExcuteTest() { StringBuilder stringbuilder = new StringBuilder(); stringbuilder.AppendLine(" class Program"); stringbuilder.AppendLine("{"); stringbuilder.AppendLine(" public string Main() {"); stringbuilder.AppendLine(" return \"Hello world\"; "); stringbuilder.AppendLine(" }"); stringbuilder.AppendLine("}"); CompilerManager.Add("petapoco"); string result = CompilerManager.Excute(stringbuilder.ToString(), "Main") as string; Assert.Equal(result, "Hello world"); }
/// <summary>Add the PRO license purchased from ZZZ Projects Inc. (http://eval-expression.net/).</summary> /// <param name="licenseName">The license name.</param> /// <param name="licenseKey">The license key.</param> public static void AddLicense(string licenseName, string licenseKey) { CompilerManager.AddLicense(licenseName, licenseKey); }
/// <summary>Add the PRO license purchased from ZZZ Projects Inc. (http://eval-sql.net/).</summary> /// <param name="licenseName">The license name.</param> /// <param name="licenseKey">The license key.</param> public static bool AddLicense(string licenseName, string licenseKey) { CompilerManager.AddLicense(licenseName, licenseKey); return(true); }