예제 #1
0
        private static int Main(string[] args)
        {
            CommandLineOptions options;

            if (!CommandLineOptions.ParseCompileString(args, out options))
            {
                goto error;
            }
            bool result;

            if (options.compilerService)
            {
                // use separate process that contains pre-compiled P compiler.
                CompilerServiceClient svc = new CompilerServiceClient();
                if (string.IsNullOrEmpty(options.outputDir))
                {
                    options.outputDir = Directory.GetCurrentDirectory();
                }
                result = svc.Compile(options, Console.Out);
            }
            else
            {
                var compiler = new Compiler(options.shortFileNames);
                result = compiler.Compile(new StandardOutput(), options);
            }
            if (!result)
            {
                return(-1);
            }
            return(0);

error:
            {
                Console.WriteLine("USAGE: Pc.exe file.p [options]");
                Console.WriteLine("Compiles *.p programs and produces *.4ml intermediate output which can then be passed to PLink.exe");
                Console.WriteLine("/outputDir:path         -- where to write the linker.c and linker.h files");
                Console.WriteLine("/liveness[:mace]        -- these control what the Zing program is looking for");
                Console.WriteLine("/shortFileNames         -- print only file names in error messages");
                Console.WriteLine("/printTypeInference     -- dumps compiler type inference information (in formula)");
                Console.WriteLine("/dumpFormulaModel       -- write the entire formula model to a file named 'output.4ml'");
                Console.WriteLine("/profile                -- print detailed timing information)");
                Console.WriteLine("/generate:[C0,C,Zing,C#]");
                Console.WriteLine("    C0  : generate C without model functions");
                Console.WriteLine("    C   : generate C with model functions");
                Console.WriteLine("    Zing: generate Zing");
                Console.WriteLine("    C#  : generate C# code");
                Console.WriteLine("/shared                 -- use the compiler service)");
                return(-1);
            }
        }
예제 #2
0
파일: CommandLine.cs 프로젝트: tvrprasad/P
        private static int Main(string[] args)
        {
            CommandLineOptions options = new CommandLineOptions();

            if (!options.ParseArguments(args))
            {
                goto error;
            }
            bool result;

            if (options.compilerService)
            {
                // use separate process that contains pre-compiled P compiler.
                CompilerServiceClient svc = new CompilerServiceClient();
                if (options.compilerOutput != CompilerOutput.Link)
                {
                    result = svc.Compile(options, Console.Out);
                }
                else
                {
                    result = svc.Link(options, Console.Out);
                }
            }
            else
            {
                var compiler = new Compiler(options.shortFileNames);
                if (options.compilerOutput != CompilerOutput.Link)
                {
                    result = compiler.Compile(new StandardOutput(), options);
                }
                else
                {
                    result = compiler.Link(new StandardOutput(), options);
                }
            }
            if (!result)
            {
                return(-1);
            }
            return(0);

error:
            {
                Console.WriteLine(" ------------ Compiler Phase ------------");
                Console.WriteLine("USAGE: Pc.exe file1.p [file2.p ...] [/t:tfile.4ml] [/r:rfile.4ml ...] [options]");
                Console.WriteLine("Compiles *.p programs and produces .4ml summary file which can then be passed to PLink.exe");
                Console.WriteLine("/t:file.4ml             -- name of summary file produced for this compilation unit; if not supplied then file1.4ml");
                Console.WriteLine("/r:file.4ml             -- refer to another summary file");
                Console.WriteLine("/outputDir:path         -- where to write the generated files");
                Console.WriteLine("/shared                 -- use the compiler service)");
                Console.WriteLine("/profile                -- print detailed timing information");
                Console.WriteLine("/generate:[C0,C#,Zing]");
                Console.WriteLine("    C0  : generate C without model functions");
                Console.WriteLine("    C#  : generate C# (and C) with model functions");
                Console.WriteLine("    Zing: generate Zing");
                Console.WriteLine("/liveness[:sampling]    -- controls compilation for Zinger");
                Console.WriteLine("/shortFileNames         -- print only file names in error messages");
                Console.WriteLine("/dumpFormulaModel       -- write the entire formula model to a file named 'output.4ml'");
                Console.WriteLine(" ------------ Linker Phase ------------");
                Console.WriteLine("USAGE: Pc.exe [linkfile.p] /link /r:file1.4ml [/r:file2.4ml ...] [options]");
                Console.WriteLine("Links *.4ml summary files against an optional linkfile.p and generates linker.{h,c,dll}");
                Console.WriteLine("/outputDir:path  -- where to write the generated files");
                Console.WriteLine("/shared          -- use the compiler service");
                Console.WriteLine("/profile         -- print detailed timing information");
                Console.WriteLine("Profiling can also be enabled by setting the environment variable PCOMPILE_PROFILE=1");
                return(-1);
            }
        }
예제 #3
0
        private static int Main(string[] args)
        {
            bool   sharedCompiler = false;
            string inputFileName  = null;
            var    options        = new CommandLineOptions();

            if (args.Length == 0)
            {
                goto error;
            }

            for (int i = 0; i < args.Length; i++)
            {
                string arg      = args[i];
                string colonArg = null;
                if (arg[0] == '-' || arg[0] == '/')
                {
                    var colonIndex = arg.IndexOf(':');
                    if (colonIndex >= 0)
                    {
                        arg      = args[i].Substring(0, colonIndex);
                        colonArg = args[i].Substring(colonIndex + 1);
                    }
                    switch (arg.Substring(1).ToLowerInvariant())
                    {
                    case "analyzeonly":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.analyzeOnly = true;
                        break;

                    case "profile":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.profile = true;
                        break;

                    case "dumpformulamodel":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.outputFormula = true;
                        break;

                    case "outputdir":
                        if (colonArg == null)
                        {
                            Console.WriteLine("Must supply path for output directory");
                            goto error;
                        }
                        if (!Directory.Exists(colonArg))
                        {
                            Console.WriteLine("Output directory {0} does not exist", colonArg);
                            goto error;
                        }
                        options.outputDir = colonArg;
                        break;

                    case "outputfilename":
                        if (colonArg == null)
                        {
                            Console.WriteLine("Must supply name for output files");
                            goto error;
                        }
                        options.outputFileName = colonArg;
                        break;

                    case "test":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.test = true;
                        break;

                    case "shortfilenames":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.shortFileNames = true;
                        break;

                    case "printtypeinference":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.printTypeInference = true;
                        break;

                    case "liveness":
                        if (colonArg == null)
                        {
                            options.liveness = LivenessOption.Standard;
                        }
                        else if (colonArg == "mace")
                        {
                            options.liveness = LivenessOption.Mace;
                        }
                        else
                        {
                            goto error;
                        }
                        break;

                    case "noc":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.noCOutput = true;
                        break;

                    case "nosourceinfo":
                        if (colonArg != null)
                        {
                            goto error;
                        }
                        options.noSourceInfo = true;
                        break;

                    case "shared":
                        sharedCompiler = true;
                        break;

                    default:
                        goto error;
                    }
                }
                else
                {
                    if (inputFileName == null)
                    {
                        inputFileName = arg;
                    }
                    else
                    {
                        goto error;
                    }
                }
            }
            if (inputFileName != null && inputFileName.Length > 2 && inputFileName.EndsWith(".p"))
            {
                bool result = false;
                if (sharedCompiler)
                {
                    // compiler service requires full path.
                    inputFileName = Path.GetFullPath(inputFileName);
                    // use separate process that contains pre-compiled P compiler.
                    CompilerServiceClient svc = new CompilerServiceClient();
                    options.inputFileName = inputFileName;
                    if (string.IsNullOrEmpty(options.outputDir))
                    {
                        options.outputDir = Directory.GetCurrentDirectory();
                    }
                    result = svc.Compile(options, Console.Out);
                }
                else
                {
                    var compiler = new Compiler(options.shortFileNames);
                    result = compiler.Compile(inputFileName, new StandardOutput(), options);
                }
                if (!result)
                {
                    return(-1);
                }
                return(0);
            }
            else
            {
                Console.WriteLine("Illegal input file name");
            }
error:
            {
                Console.WriteLine("USAGE: Pc.exe file.p [options]");
                Console.WriteLine("/outputDir:path");
                Console.WriteLine("/outputFileName:name");
                Console.WriteLine("/test");
                Console.WriteLine("/liveness[:mace]");
                Console.WriteLine("/shortFileNames");
                Console.WriteLine("/printTypeInference");
                Console.WriteLine("/dumpFormulaModel");
                Console.WriteLine("/profile");
                Console.WriteLine("/noC");
                Console.WriteLine("/noSourceInfo");
                Console.WriteLine("/shared");
                Console.WriteLine("/analyzeOnly");
                return(0);
            }
        }
예제 #4
0
파일: CommandLine.cs 프로젝트: up1/P
        private static int Main(string[] args)
        {
            CommandLineOptions options = new CommandLineOptions();

            if (!options.ParseArguments(args))
            {
                goto error;
            }
            bool result;

            if (options.compilerService)
            {
                // use separate process that contains pre-compiled P compiler.
                CompilerServiceClient svc = new CompilerServiceClient();
                if (string.IsNullOrEmpty(options.outputDir))
                {
                    options.outputDir = Directory.GetCurrentDirectory();
                }
                if (!options.isLinkerPhase)
                {
                    result = svc.Compile(options, Console.Out);
                }
                else
                {
                    result = svc.Link(options, Console.Out);
                }
            }
            else
            {
                var compiler = new Compiler(options.shortFileNames);
                if (!options.isLinkerPhase)
                {
                    result = compiler.Compile(new StandardOutput(), options);
                }
                else
                {
                    result = compiler.Link(new StandardOutput(), options);
                }
            }
            if (!result)
            {
                return(-1);
            }
            return(0);

error:
            {
                Console.WriteLine(" ------------ Compiler Phase ------------");
                Console.WriteLine("USAGE: Pc.exe file.p [options]");
                Console.WriteLine("Compiles *.p programs and produces *.4ml intermediate output which can then be passed to PLink.exe");
                Console.WriteLine("/outputDir:path         -- where to write the generated *.c, *.h and *.4ml files");
                Console.WriteLine("/liveness[:sampling]    -- these control what the Zing program is looking for");
                Console.WriteLine("/shortFileNames         -- print only file names in error messages");
                Console.WriteLine("/printTypeInference     -- dumps compiler type inference information (in formula)");
                Console.WriteLine("/dumpFormulaModel       -- write the entire formula model to a file named 'output.4ml'");
                Console.WriteLine("/profile                -- print detailed timing information");
                Console.WriteLine("/rebuild                -- rebuild all the P files");
                Console.WriteLine("/generate:[C0,C,Zing,C#]");
                Console.WriteLine("    C0  : generate C without model functions");
                Console.WriteLine("    C   : generate C with model functions");
                Console.WriteLine("    Zing: generate Zing");
                Console.WriteLine("    C#  : generate C# code");
                Console.WriteLine("/shared                 -- use the compiler service)");
                Console.WriteLine(" ------------ Linker Phase ------------");
                Console.WriteLine("USAGE: Pc.exe /link file1.4ml [file2.4ml ...] linkfile.p [options]");
                Console.WriteLine("Takes the *.4ml output from pc.exe and generates the combined linker.c linker.h output from them");
                Console.WriteLine("/outputDir:path  -- where to write the generated linker.c and linker.h files");
                Console.WriteLine("/shared          -- use the compiler service");
                Console.WriteLine("/parallel        -- run multiple tests in parallel for quicker overall test run times");
                Console.WriteLine("/profile         -- print detailed timing information");
                Console.WriteLine("Profiling can also be enabled by setting the environment variable PCOMPILE_PROFILE=1");
                return(-1);
            }
        }