Exemple #1
0
 private string GetSolverValue(Dictionary <string, string> parameters)
 {
     if (parameters.ContainsKey(SMTEngine.GetSolverParameter().Name))
     {
         if (!SMTEngine.GetSolverParameter().IsValidValue(parameters[SMTEngine.GetSolverParameter().Name]))
         {
             Console.WriteLine(string.Format("Unknown solver '{0}'", parameters[SMTEngine.GetSolverParameter().Name]));
             System.Environment.Exit((int)ToolExitCodes.OTHER_ERROR);
         }
         return(parameters[SMTEngine.GetSolverParameter().Name]);
     }
     return(SMTEngine.GetSolverParameter().DefaultValue);
 }
        public void ParsePipelineString()
        {
            if (PipelineString == null)
            {
                return;
            }

            const char lhsDelimiter    = '[';
            const char rhsDelimiter    = ']';
            const char engineDelimiter = '-';

            Debug.Assert(PipelineString[0] == lhsDelimiter && PipelineString[PipelineString.Length - 1] == rhsDelimiter);
            string[] engines = PipelineString.Substring(1, PipelineString.Length - 2).Split(engineDelimiter);
            foreach (string engineStr in engines)
            {
                int    lhsDelimiterIdx = engineStr.IndexOf(lhsDelimiter);
                string engine;
                if (lhsDelimiterIdx != -1)
                {
                    engine = engineStr.Substring(0, lhsDelimiterIdx);
                }
                else
                {
                    engine = engineStr;
                }

                // The user wants to override Houdini settings used in the cruncher
                if (engine.ToUpper().Equals(VanillaHoudini.Name))
                {
                    string parameterStr = engineStr.Substring(VanillaHoudini.Name.Length);
                    Dictionary <string, string> parameters = GetParameters(
                        VanillaHoudini.Name,
                        VanillaHoudini.GetAllowedParameters(),
                        VanillaHoudini.GetRequiredParameters(),
                        parameterStr);
                    CheckForMutuallyExclusiveParameters(
                        VanillaHoudini.Name,
                        VanillaHoudini.GetMutuallyExclusiveParameters(),
                        parameters);

                    int errorLimit = ParseIntParameter(
                        parameters,
                        SMTEngine.GetErrorLimitParameter().Name,
                        SMTEngine.GetErrorLimitParameter().DefaultValue);
                    VanillaHoudini houdiniEngine = new VanillaHoudini(
                        Pipeline.GetNextSMTEngineID(),
                        GetSolverValue(parameters),
                        errorLimit);
                    Pipeline.AddEngine(houdiniEngine);
                    houdiniEngine.Delay = ParseIntParameter(
                        parameters,
                        VanillaHoudini.GetDelayParameter().Name,
                        VanillaHoudini.GetDelayParameter().DefaultValue);
                    houdiniEngine.SlidingSeconds = ParseIntParameter(
                        parameters,
                        VanillaHoudini.GetSlidingSecondsParameter().Name,
                        VanillaHoudini.GetSlidingSecondsParameter().DefaultValue);
                    houdiniEngine.SlidingLimit = ParseIntParameter(
                        parameters,
                        VanillaHoudini.GetSlidingLimitParameter().Name,
                        VanillaHoudini.GetSlidingLimitParameter().DefaultValue);
                }
                else if (engine.ToUpper().Equals(SBASE.Name))
                {
                    string parameterStr = engineStr.Substring(SBASE.Name.Length);
                    Dictionary <string, string> parameters = GetParameters(
                        SBASE.Name,
                        SBASE.GetAllowedParameters(),
                        SBASE.GetRequiredParameters(),
                        parameterStr);
                    int errorLimit = ParseIntParameter(
                        parameters,
                        SMTEngine.GetErrorLimitParameter().Name,
                        SMTEngine.GetErrorLimitParameter().DefaultValue);
                    Pipeline.AddEngine(new SBASE(Pipeline.GetNextSMTEngineID(), GetSolverValue(parameters), errorLimit));
                }
                else if (engine.ToUpper().Equals(SSTEP.Name))
                {
                    string parameterStr = engineStr.Substring(SSTEP.Name.Length);
                    Dictionary <string, string> parameters = GetParameters(
                        SSTEP.Name,
                        SSTEP.GetAllowedParameters(),
                        SSTEP.GetRequiredParameters(),
                        parameterStr);
                    int errorLimit = ParseIntParameter(
                        parameters,
                        SMTEngine.GetErrorLimitParameter().Name,
                        SMTEngine.GetErrorLimitParameter().DefaultValue);
                    Pipeline.AddEngine(new SSTEP(Pipeline.GetNextSMTEngineID(), GetSolverValue(parameters), errorLimit));
                }
                else if (engine.ToUpper().Equals(LU.Name))
                {
                    string parameterStr = engineStr.Substring(LU.Name.Length);
                    Dictionary <string, string> parameters = GetParameters(
                        LU.Name,
                        LU.GetAllowedParameters(),
                        LU.GetRequiredParameters(),
                        parameterStr);
                    int errorLimit = ParseIntParameter(
                        parameters,
                        SMTEngine.GetErrorLimitParameter().Name,
                        SMTEngine.GetErrorLimitParameter().DefaultValue);
                    Pipeline.AddEngine(new LU(
                                           Pipeline.GetNextSMTEngineID(),
                                           GetSolverValue(parameters),
                                           errorLimit,
                                           ParseIntParameter(parameters, LU.GetUnrollParameter().Name, 1)));
                }
                else if (engine.ToUpper().Equals(DynamicAnalysis.Name))
                {
                    string parameterStr = engineStr.Substring(DynamicAnalysis.Name.Length);
                    Dictionary <string, string> parameters = GetParameters(
                        DynamicAnalysis.Name,
                        DynamicAnalysis.GetAllowedParameters(),
                        DynamicAnalysis.GetRequiredParameters(),
                        parameterStr);
                    DynamicAnalysis dynamicEngine = new DynamicAnalysis();
                    dynamicEngine.LoopHeaderLimit = ParseIntParameter(
                        parameters,
                        DynamicAnalysis.GetLoopHeaderLimitParameter().Name,
                        DynamicAnalysis.GetLoopHeaderLimitParameter().DefaultValue);
                    dynamicEngine.LoopEscape = ParseIntParameter(
                        parameters,
                        DynamicAnalysis.GetLoopEscapingParameter().Name,
                        DynamicAnalysis.GetLoopEscapingParameter().DefaultValue);
                    dynamicEngine.TimeLimit = ParseIntParameter(
                        parameters,
                        DynamicAnalysis.GetTimeLimitParameter().Name,
                        DynamicAnalysis.GetTimeLimitParameter().DefaultValue);
                    Pipeline.AddEngine(dynamicEngine);
                }
                else
                {
                    Console.WriteLine(string.Format("Unknown cruncher engine: '{0}'", engine));
                    System.Environment.Exit((int)ToolExitCodes.OTHER_ERROR);
                }
            }
        }