Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void DoCompile()
        {
            PythonCompiler pc = new PythonCompiler(files, outAsm, new CodeDomCompilerSink(this));

            pc.IncludeDebugInformation = debugInfo;
            pc.TargetKind    = peKind;
            pc.AutoImportAll = true;

            foreach (string s in refs)
            {
                pc.ReferencedAssemblies.Add(s);
            }

            try {
                pc.Compile();

                try {
                    compAssm = Assembly.LoadFrom(outAsm);
                } catch {
                    errorCnt = 1;
                }
            } catch (CompilerException ex) {
                // errors occured during compilation
                errorCnt = Errors.Count;
                Errors.Add(new CompilerError("unknown", 0, 0, "unknown", ex.ToString()));
            } catch (Exception ex) {
                errorCnt++;
                Errors.Add(new CompilerError("unknown", 0, 0, "unknown", ex.ToString()));
            }
        }
Esempio n. 3
0
 public override string Render()
 {
     executableCode += ((PythonParser)parser).Parse(codeTemplate, variables, values);
     using (compiler = new PythonCompiler())
     {
         compiler.Compile(executableCode);
     }
     return(compiler.Result);
 }
		public void NoMainSpecifiedForLibraryThrowsNoError()
		{
			PythonCompiler compiler = new PythonCompiler();
			compiler.TargetKind = PEFileKinds.Dll;
			compiler.OutputAssembly = "test.dll";
			compiler.SourceFiles = new string[0];
			compiler.MainFile = null;
			compiler.VerifyParameters();
		}
Esempio n. 5
0
        public static void Main(string[] args)
        {
            var parser = new MoccaParser("../../../Example/middle_lang.mocca", CompileMode.FILE_PASS);
            var tree   = parser.Parse();
            var eval   = tree.Eval();

            Console.WriteLine(tree.PrintTree());
            var compiler = new PythonCompiler(eval);

            Console.WriteLine(compiler.Compile());
        }
Esempio n. 6
0
        public void NoMainFileSpecifiedForWindowsApplication()
        {
            try {
                PythonCompiler compiler = new PythonCompiler();
                compiler.TargetKind     = PEFileKinds.WindowApplication;
                compiler.OutputAssembly = "test.exe";
                compiler.SourceFiles    = new string[0];
                compiler.MainFile       = null;
                compiler.Compile();

                Assert.Fail("Expected PythonCompilerException.");
            } catch (PythonCompilerException ex) {
                Assert.AreEqual(Resources.NoMainFileSpecified, ex.Message);
            }
        }