示例#1
0
        static void CompileAssembly()
        {
            var options = new CompilerOptions();

            //redirect cl options to compiler
            if (!RedirectOptions(options))
            {
                LogError(Errors.InvalidCommandLine);
                Environment.Exit(-1);
            }

            //remove system references
            options.References.RemoveAll(IsSysRef);

            //add reference to pagefx corlib
            AddCorlibRef(options);
            AddCommonoRefs(options);

            if (cl.HasOption(PFCOptions.MX))
            {
                string mx = GlobalSettings.GetMxLibraryPath();
                if (!File.Exists(mx))
                {
                    //TODO: raise error
                }
                options.AddRef(mx);
            }

            var rsls = RslList.Parse(cl);

            foreach (var rsl in rsls)
            {
                options.AddRef(rsl.Library);
            }

            options.NoLogo   = true;
            options.NoStdlib = true;
            options.NoConfig = true;
            options.Output   = asmpath;

            string cout = CompilerConsole.Run(options, true);

            var errors = CompilerConsole.ParseOutput(cout);

            if (NoMain(errors))
            {
                asmpath        = Path.ChangeExtension(asmpath, ".dll");
                options.Output = asmpath;
                options.Target = CompilerTarget.Library;

                cout   = CompilerConsole.Run(options, true);
                errors = CompilerConsole.ParseOutput(cout);
            }

            if (errors.HasErrors)
            {
                Console.WriteLine(cout);
                Environment.Exit(-1);
            }
        }
示例#2
0
 public void ClearConsole()
 {
     if (Visible)
     {
         this.BeginInvoke(new _noparamsdegeate(CompilerConsole.Clear));
     }
     else
     {
         CompilerConsole.Clear();
     }
 }
示例#3
0
        void Compiler_OnChangeCompilerState(PascalABCCompiler.ICompiler sender, PascalABCCompiler.CompilerState State, string FileName)
        {
            string text;

            if (State == PascalABCCompiler.CompilerState.CompilationStarting || State == PascalABCCompiler.CompilerState.Reloading)
            {
                //CompilerConsole.Clear();
                dt = DateTime.Now;
                if (OnRebuld.Checked)
                {
                    VisualEnvironmentCompiler.Compiler.CompilerOptions.Rebuild = true;
                }
            }
            text = State.ToString();
            if (FileName != null)
            {
                text += " " + System.IO.Path.GetFileName(FileName) + "...";
            }
            if (State == PascalABCCompiler.CompilerState.Ready)
            {
                if (VisualEnvironmentCompiler.Compiler.ErrorsList.Count > 0)
                {
                    text += string.Format(" [{0} errors]", VisualEnvironmentCompiler.Compiler.ErrorsList.Count);
                }
                text += string.Format(" [{0}ms]", (int)(DateTime.Now - dt).TotalMilliseconds);
                if (sender == VisualEnvironmentCompiler.RemoteCompiler)
                {
                    text += string.Format(Environment.NewLine + "WorkingSet {0}", VisualEnvironmentCompiler.RemoteCompiler.RemoteCompilerWorkingSet / 1024 / 1024);
                }
                NoSavePCU.Checked          = !VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
                NoSemantic.Checked         = !VisualEnvironmentCompiler.Compiler.InternalDebug.SemanticAnalysis;
                NoCodeGeneration.Checked   = !VisualEnvironmentCompiler.Compiler.InternalDebug.CodeGeneration;
                NoAddStandartUnits.Checked = !VisualEnvironmentCompiler.Compiler.InternalDebug.AddStandartUnits;
                NoSkipPCUErrors.Checked    = !VisualEnvironmentCompiler.Compiler.InternalDebug.SkipPCUErrors;
                NoSkipInternalErrorsIfSyntaxTreeIsCorrupt.Checked = !VisualEnvironmentCompiler.Compiler.InternalDebug.SkipInternalErrorsIfSyntaxTreeIsCorrupt;
                NoIncludeDebugInfoInPCU.Checked          = !VisualEnvironmentCompiler.Compiler.InternalDebug.IncludeDebugInfoInPCU;
                cbUseStandarParserForInellisense.Checked = VisualEnvironmentCompiler.Compiler.InternalDebug.UseStandarParserForIntellisense;
                //OnRebuld.Checked = VisualEnvironmentCompiler.Compiler.CompilerOptions.Rebuild;
            }
            text += Environment.NewLine;
            if (sender.CompilerType == PascalABCCompiler.CompilerType.Remote)
            {
                text = "[remote]" + text;
            }
            CompilerConsole.AppendText(text);
            CompilerConsole.SelectionStart = CompilerConsole.Text.Length;
            CompilerConsole.ScrollToCaret();
        }
示例#4
0
        public static bool Compile(TestCase tc)
        {
            tc.CopySourceFiles();

            var lang = tc.Language;

            if (lang == CompilerLanguage.CIL)
            {
                return(ILAsm.Run(tc));
            }

            using (tc.Root.ChangeCurrentDirectory())
            {
                var options = new CompilerOptions();
                try
                {
                    ResolveReferences(tc.Root, tc.References, options.References);
                }
                catch (Exception exc)
                {
                    tc.Error = String.Format("Unable to resolve test case {0} references. Exception:\n{1}",
                                             tc.Name, exc);
                    return(false);
                }

                SetCompilerOptions(tc, lang, options);

                try
                {
                    string cout = CompilerConsole.Run(options, true);
                    if (CompilerConsole.HasErrors(cout))
                    {
                        tc.Error = String.Format("Unable to compile test case {0}.\n{1}", tc.Name, cout);
                        return(false);
                    }
                }
                catch (Exception exc)
                {
                    tc.Error = String.Format("Unable to compile test case {0}. Exception:\n{1}", tc.Name, exc);
                    return(false);
                }
            }

            return(true);
        }
示例#5
0
        static void RunTest(Test test)
        {
            string wd = Environment.CurrentDirectory;

            const string prefix   = "__pfx_nunit";
            const string name_cs  = prefix + ".cs";
            const string name_exe = prefix + ".exe";
            const string name_swf = prefix + ".swf";

            string mainFile = Path.Combine(wd, name_cs);

            File.WriteAllText(mainFile, test.MainCode);

            var compilerOptions = new CompilerOptions
            {
                Target   = CompilerTarget.ConsoleApp,
                Output   = name_exe,
                NoLogo   = true,
                NoConfig = true,
                NoStdlib = true
            };

            GlobalSettings.AddCommonReferences(compilerOptions);
            compilerOptions.AddRef(_asmpath);
            compilerOptions.Input.Add(name_cs);

            string cout = CompilerConsole.Run(compilerOptions);

            if (CompilerConsole.HasErrors(cout))
            {
                Console.WriteLine(cout);
                Environment.Exit(-1);
            }

            string path_exe = Path.Combine(wd, name_exe);
            string path_swf = Path.Combine(wd, name_swf);

            var asm = LoadAssembly(path_exe);

            MakeSwf(asm, path_swf);
            RunPlayer(test, path_swf);
            Report.AddTest(test);
        }
示例#6
0
        private void Compile(string resname)
        {
            string sourceCode = GetType().GetTextResource(resname);
            string dir        = Path.Combine(QA.RootTestCases, "NegativeTests");

            Directory.CreateDirectory(dir);
            string csfile = Path.Combine(dir, "src.cs");

            File.WriteAllText(csfile, sourceCode);

            string asmpath = Path.Combine(dir, "out.dll");

            var options = new CompilerOptions
            {
                NoLogo   = true,
                NoConfig = true,
                NoStdlib = true,
                Target   = CompilerTarget.Library,
                Output   = asmpath
            };

            GlobalSettings.AddCommonReferences(options);

            options.Input.Add(csfile);

            string err = CompilerConsole.Run(options);

            if (!string.IsNullOrEmpty(err))
            {
                throw new InvalidOperationException("Unable to compile " + resname);
            }

            var asm = AssemblyLoader.Load(asmpath, VM.AVM, dir, ref err);

            string swfpath = Path.Combine(dir, "out.swf");

            FlashLanguageInfrastructure.Serialize(asm, swfpath, "/format:swf");
        }
示例#7
0
        private static void Compile(CompilerOptions copts, string path)
        {
            string olddir = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(path);
                string cout   = CompilerConsole.Run(copts, true);
                var    errors = CompilerConsole.ParseOutput(cout);
                if (errors.HasErrors)
                {
                    throw new InvalidOperationException(string.Format("Unable to generate wrapper.\n{0}", cout));
                }
                if (errors.HasWarnings)
                {
                    Console.WriteLine(cout);
                }
            }
            finally
            {
                Environment.CurrentDirectory = olddir;
            }
        }
示例#8
0
        static bool GenerateApp(TestCase test, TestDriverSettings tds)
        {
            test.VM         = VM.AVM;
            test.OutputPath = Path.Combine(test.Root, "test." + tds.OutputExtension);

            if (tds.IsJavaScript)
            {
                try
                {
                    var compiler = new JsCompiler(new FileInfo(test.ExePath));
                    compiler.Compile(new FileInfo(test.OutputPath));
                    return(true);
                }
                catch (Exception e)
                {
                    test.Error = string.Format("Unable to generate {0} file.\nException: {1}", tds.OutputFormat, e);
                    return(false);
                }
            }

            bool refl = test.FullName.Contains("Reflection");

            GlobalSettings.ReflectionSupport = refl;

            if (test.UsePfc)
            {
                var options = new PfxCompilerOptions
                {
                    Nologo     = true,
                    Input      = test.ExePath,
                    Output     = test.OutputPath,
                    Reflection = refl
                };
                string err = PfxCompiler.Run(options);
                if (CompilerConsole.HasErrors(err))
                {
                    throw new InvalidOperationException("Unable to compile " + test.Name + ".\n" + err);
                }
            }
            else
            {
                IAssembly asm;
                if (!LoadAssembly(test, tds, out asm))
                {
                    return(false);
                }

                try
                {
                    string cl = string.Format("/format:{0}", tds.OutputFormat);

                    if (tds.IsSWF)
                    {
                        cl += " /framesize:100 /fp:10 /nohtml /exception-break";
                    }

                    FlashLanguageInfrastructure.Serialize(asm, test.OutputPath, cl);
                }
                catch (Exception e)
                {
                    test.Error = string.Format("Unable to generate {0} file.\nException: {1}", tds.OutputFormat, e);
                    return(false);
                }
            }

            return(true);
        }
示例#9
0
 public void AppendTextToConsoleCompiler(object text)
 {
     CompilerConsole.AppendText(text as string);
 }
示例#10
0
 public void CompilerConsoleScrolToEnd()
 {
     CompilerConsole.SelectionStart = CompilerConsole.Text.Length;
     CompilerConsole.ScrollToCaret();
 }