Exemplo n.º 1
0
 public CommandLineOptions()
 {
     this.profile            = false;
     this.analyzeOnly        = false;
     this.liveness           = LivenessOption.None;
     this.outputDir          = null;
     this.outputFormula      = false;
     this.test               = false;
     this.shortFileNames     = false;
     this.printTypeInference = false;
     this.noCOutput          = false;
     this.noSourceInfo       = false;
 }
Exemplo n.º 2
0
        private static bool ParseTestString(string[] args, CommandLineOptions compilerOptions)
        {
            LivenessOption liveness  = LivenessOption.None;
            string         outputDir = null;

            for (int i = 1; i < args.Length; i++)
            {
                string arg = args[i];
                if (liveness == LivenessOption.None && arg.StartsWith("/liveness"))
                {
                    if (arg == "/liveness")
                    {
                        liveness = LivenessOption.Standard;
                    }
                    else if (arg.StartsWith("/liveness:"))
                    {
                        var colonIndex = arg.IndexOf(':');
                        var colonArg   = arg.Substring(colonIndex + 1);
                        if (colonArg == "mace")
                        {
                            liveness = LivenessOption.Mace;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (outputDir == null && arg.StartsWith("/outputDir:"))
                {
                    var colonIndex = arg.IndexOf(':');
                    outputDir = arg.Substring(colonIndex + 1);
                    if (!Directory.Exists(outputDir))
                    {
                        Console.WriteLine("Output directory {0} does not exist", outputDir);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            compilerOptions.liveness  = liveness;
            compilerOptions.outputDir = outputDir;
            return(true);
        }
Exemplo n.º 3
0
        public static bool ParseCompileString(IEnumerable <string> args, out CommandLineOptions options)
        {
            options = new CommandLineOptions();
            List <string>  inputFileNames     = new List <string>();
            bool           profile            = false;
            bool           outputFormula      = false;
            bool           printTypeInference = false;
            string         outputDir          = null;
            bool           shortFileNames     = false;
            CompilerOutput compilerOutput     = CompilerOutput.None;
            LivenessOption liveness           = LivenessOption.None;

            foreach (string x in args)
            {
                string arg      = x;
                string colonArg = null;
                if (arg[0] == '-' || arg[0] == '/')
                {
                    var colonIndex = arg.IndexOf(':');
                    if (colonIndex >= 0)
                    {
                        arg      = x.Substring(0, colonIndex);
                        colonArg = x.Substring(colonIndex + 1);
                    }
                    switch (arg.Substring(1).ToLowerInvariant())
                    {
                    case "profile":
                        profile = true;
                        break;

                    case "shortfilenames":
                        shortFileNames = true;
                        break;

                    case "shared":
                        options.compilerService = true;
                        break;

                    case "dumpformulamodel":
                        outputFormula = true;
                        break;

                    case "printtypeinference":
                        printTypeInference = true;
                        break;

                    case "generate":
                        if (colonArg == null)
                        {
                            Console.WriteLine("Missing generation argument, expecting one of generate:C, C0, Zing, or C#");
                            return(false);
                        }
                        else if (colonArg == "C0")
                        {
                            compilerOutput = CompilerOutput.C0;
                        }
                        else if (colonArg == "C")
                        {
                            compilerOutput = CompilerOutput.C;
                        }
                        else if (colonArg == "Zing")
                        {
                            compilerOutput = CompilerOutput.Zing;
                        }
                        else if (colonArg == "C#")
                        {
                            compilerOutput = CompilerOutput.CSharp;
                        }
                        else
                        {
                            Console.WriteLine("Unrecognized generate option '{0}', expecing C, C0, Zing, or C#", colonArg);
                            return(false);
                        }
                        break;

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

                    case "liveness":
                        if (string.IsNullOrEmpty(colonArg))
                        {
                            liveness = LivenessOption.Standard;
                        }
                        else if (colonArg == "mace")
                        {
                            liveness = LivenessOption.Mace;
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    default:
                        return(false);
                    }
                }
                else
                {
                    inputFileNames.Add(arg);
                }
            }

            if (inputFileNames.Count == 0)
            {
                Console.WriteLine("Must provide files to compile");
                return(false);
            }
            List <string> fullInputFileNames = new List <string>();

            foreach (var inputFileName in inputFileNames)
            {
                if (!(inputFileName != null && inputFileName.Length > 2 && inputFileName.EndsWith(".p")))
                {
                    Console.WriteLine("Illegal source file name: {0}", inputFileName);
                    return(false);
                }
                if (!File.Exists(inputFileName))
                {
                    Console.WriteLine("File does not exist: {0}", inputFileName);
                    return(false);
                }
                fullInputFileNames.Add(Path.GetFullPath(inputFileName));
            }
            options.profile            = profile;
            options.outputFormula      = outputFormula;
            options.printTypeInference = printTypeInference;
            options.outputDir          = outputDir;
            options.liveness           = liveness;
            options.shortFileNames     = shortFileNames;
            options.compilerOutput     = compilerOutput;
            options.inputFileNames     = fullInputFileNames;
            return(true);
        }
Exemplo n.º 4
0
        private static bool ParseTestString(string[] args, CommandLineOptions compilerOptions)
        {
            LivenessOption liveness  = LivenessOption.None;
            string         outputDir = null;

            for (int i = 1; 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 "outputdir":
                        if (colonArg == null)
                        {
                            Console.WriteLine("Must supply path for output directory");
                            return(false);
                        }
                        if (!Directory.Exists(colonArg))
                        {
                            Console.WriteLine("Output directory {0} does not exist", colonArg);
                            return(false);
                        }
                        outputDir = colonArg;
                        break;

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

                    default:
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            compilerOptions.liveness  = liveness;
            compilerOptions.outputDir = outputDir;
            return(true);
        }