public Compiler getCompiler(ProgrammingLanguageEnum languageEnum) { Compiler comp = null; if (languageEnum == ProgrammingLanguageEnum.Cpp89) { comp = new CPPCompiler(GPP_COMPILER_PATH, "-std=c++98"); } else if (languageEnum == ProgrammingLanguageEnum.Cpp11) { comp = new CPPCompiler(GPP_COMPILER_PATH, "-std=c++11"); } else if (languageEnum == ProgrammingLanguageEnum.C) { comp = new CPPCompiler(GCC_COMPILER_PATH); } else if (languageEnum == ProgrammingLanguageEnum.Python3) { comp = new PythonCompiler(PYTHON_INTERPRETER_PATH); } else { comp = null; throw new Exception("Invalid programming languageEnum enum: " + languageEnum); } return(comp); }
private static void TestCCompiler() { string source_path = DummyCode.getCCode(); ProgrammingLanguageEnum lang = ProgrammingLanguageEnum.C; CodeRunner runner = new CodeRunner(lang, source_path, DummyData.intput, DummyData.expected_output, time_limit); runner.OnExecutionFinished += CodeResultsHandler; runner.RunCode(); }
// time_limit is in seconds public CodeRunner(ProgrammingLanguageEnum languageEnum, string source_code, string input, string expected_output, double time_limit) { this.input = input; this.expected_output = expected_output; this.source_code = source_code; this.time_limit = time_limit; this.compiler = CompilerFactory.getInstance().getCompiler(languageEnum); // this.compiler = new CPPCompiler(@"C:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe", "-std=c++11"); }