コード例 #1
0
        private TransitionRelationComputation(
            AtomicActionCopyAdapter first, AtomicActionCopyAdapter second,
            IEnumerable <Variable> frame, List <WitnessFunction> witnesses, bool ignorePostState,
            string messagePrefix)
        {
            this.first           = first;
            this.second          = second;
            this.frame           = new HashSet <Variable>(frame);
            this.ignorePostState = ignorePostState;

            this.messagePrefix   = messagePrefix;
            this.checkingContext = new CheckingContext(null);

            this.pathTranslations     = new List <Expr>();
            this.globalVarToWitnesses = new Dictionary <GlobalVariable, List <WitnessFunction> >();
            if (witnesses != null)
            {
                foreach (var witness in witnesses)
                {
                    var gVar = witness.globalVar;
                    if (!globalVarToWitnesses.ContainsKey(gVar))
                    {
                        globalVarToWitnesses[gVar] = new List <WitnessFunction>();
                    }
                    globalVarToWitnesses[gVar].Add(witness);
                }
            }
        }
コード例 #2
0
 public LinearTypeChecker(Program program)
 {
     this.program                = program;
     this.errorCount             = 0;
     this.checkingContext        = new CheckingContext(null);
     this.domainNameToType       = new Dictionary <string, Type>();
     this.availableLinearVars    = new Dictionary <Absy, HashSet <Variable> >();
     this.inoutParamToDomainName = new Dictionary <Variable, string>();
     this.varToDomainName        = new Dictionary <Variable, string>();
     this.linearDomains          = new Dictionary <string, LinearDomain>();
 }
コード例 #3
0
ファイル: LinearSets.cs プロジェクト: ggrov/tacny
 public LinearTypeChecker(Program program)
 {
     this.program = program;
     this.errorCount = 0;
     this.checkingContext = new CheckingContext(null);
     this.domainNameToCollectors = new Dictionary<string, Dictionary<Type, Function>>();
     this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>();
     this.inParamToLinearQualifier = new Dictionary<Variable, LinearQualifier>();
     this.outParamToDomainName = new Dictionary<Variable, string>();
     this.varToDomainName = new Dictionary<Variable, string>();
     this.globalVarToDomainName = new Dictionary<Variable, string>();
     this.linearDomains = new Dictionary<string, LinearDomain>();
 }
コード例 #4
0
ファイル: LinearTypeChecker.cs プロジェクト: smh0960/boogie
 public LinearTypeChecker(CivlTypeChecker civlTypeChecker)
 {
   this.civlTypeChecker = civlTypeChecker;
   this.program = civlTypeChecker.program;
   this.checkingContext = civlTypeChecker.checkingContext;
   this.domainNameToCollectors = new Dictionary<string, Dictionary<Type, Function>>();
   this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>();
   this.inParamToLinearQualifier = new Dictionary<Variable, LinearQualifier>();
   this.outParamToDomainName = new Dictionary<Variable, string>();
   this.globalVarToDomainName = new Dictionary<Variable, string>();
   this.linearDomains = new Dictionary<string, LinearDomain>();
   this.varToDomainName = new Dictionary<Variable, string>();
 }
コード例 #5
0
 public MoverTypeChecker(Program program)
 {
     this.qedGlobalVariables = new HashSet <Variable>();
     foreach (var g in program.GlobalVariables())
     {
         if (QKeyValue.FindBoolAttribute(g.Attributes, "qed"))
         {
             this.qedGlobalVariables.Add(g);
             g.Attributes = OwickiGries.RemoveQedAttribute(g.Attributes);
         }
     }
     this.procToActionInfo      = new Dictionary <Procedure, ActionInfo>();
     this.assertionPhaseNums    = new HashSet <int>();
     this.errorCount            = 0;
     this.checkingContext       = new CheckingContext(null);
     this.program               = program;
     this.enclosingProcPhaseNum = int.MaxValue;
     this.inAtomicSpecification = false;
 }
コード例 #6
0
        private TransitionRelationComputation(
            CivlTypeChecker civlTypeChecker,
            Implementation first, Implementation second,
            IEnumerable <Variable> frame, IEnumerable <CommutativityWitness> witnesses, Dictionary <Variable, Function> triggers,
            bool ignorePostState,
            string messagePrefix)
        {
            this.civlTypeChecker = civlTypeChecker;
            this.first           = first;
            this.second          = second;
            this.triggers        = triggers;
            this.frame           = new HashSet <Variable>(frame);
            this.ignorePostState = ignorePostState;

            allInParams  = new HashSet <Variable>(first.InParams);
            allOutParams = new HashSet <Variable>(first.OutParams);
            allLocVars   = new HashSet <Variable>(first.LocVars);
            if (IsJoint)
            {
                allInParams.UnionWith(second.InParams);
                allOutParams.UnionWith(second.OutParams);
                allLocVars.UnionWith(second.LocVars);
            }

            this.messagePrefix   = messagePrefix;
            this.checkingContext = new CheckingContext(null);

            this.pathTranslations     = new List <Expr>();
            this.globalVarToWitnesses = new Dictionary <Variable, List <CommutativityWitness> >();
            if (witnesses != null)
            {
                foreach (var witness in witnesses)
                {
                    var gVar = witness.witnessedVariable;
                    if (!globalVarToWitnesses.ContainsKey(gVar))
                    {
                        globalVarToWitnesses[gVar] = new List <CommutativityWitness>();
                    }

                    globalVarToWitnesses[gVar].Add(witness);
                }
            }
        }
コード例 #7
0
        public CivlTypeChecker(Program program)
        {
            this.errorCount                    = 0;
            this.checkingContext               = new CheckingContext(null);
            this.program                       = program;
            this.enclosingProc                 = null;
            this.enclosingImpl                 = null;
            this.sharedVarsAccessed            = null;
            this.introducedLocalVarsUpperBound = int.MinValue;

            this.localVarToLocalVariableInfo = new Dictionary <Variable, LocalVariableInfo>();
            this.absyToLayerNums             = new Dictionary <Absy, HashSet <int> >();
            this.globalVarToSharedVarInfo    = new Dictionary <Variable, SharedVariableInfo>();
            this.procToActionInfo            = new Dictionary <Procedure, ActionInfo>();
            this.procToAtomicProcedureInfo   = new Dictionary <Procedure, AtomicProcedureInfo>();
            this.pureCallLayer = new Dictionary <CallCmd, int>();

            foreach (var g in program.GlobalVariables)
            {
                List <int> layerNums = FindLayers(g.Attributes);
                if (layerNums.Count == 0)
                {
                    // Inaccessible from  yielding and atomic procedures
                }
                else if (layerNums.Count == 1)
                {
                    this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue);
                }
                else if (layerNums.Count == 2)
                {
                    this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]);
                }
                else
                {
                    Error(g, "Too many layer numbers");
                }
            }
        }
コード例 #8
0
ファイル: TypeCheck.cs プロジェクト: hertzel001/boogie
 public MoverTypeChecker(Program program)
 {
     this.ghostVars                = new HashSet <Variable>();
     this.absyToLayerNums          = new Dictionary <Absy, HashSet <int> >();
     this.globalVarToSharedVarInfo = new Dictionary <Variable, SharedVariableInfo>();
     this.procToActionInfo         = new Dictionary <Procedure, ActionInfo>();
     this.errorCount               = 0;
     this.checkingContext          = new CheckingContext(null);
     this.program                    = program;
     this.enclosingProc              = null;
     this.enclosingImpl              = null;
     this.canAccessSharedVars        = false;
     this.canAccessGhostVars         = false;
     this.minLayerNum                = int.MaxValue;
     this.maxLayerNum                = -1;
     this.leastUnimplementedLayerNum = int.MaxValue;
     foreach (var g in program.GlobalVariables)
     {
         List <int> layerNums = FindLayers(g.Attributes);
         if (layerNums.Count == 0)
         {
             // Cannot access atomic actions
         }
         else if (layerNums.Count == 1)
         {
             this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue);
         }
         else if (layerNums.Count == 2)
         {
             this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]);
         }
         else
         {
             Error(g, "Too many layer numbers");
         }
     }
 }
コード例 #9
0
ファイル: CivlTypeChecker.cs プロジェクト: qunyanm/boogie
        public CivlTypeChecker(Program program)
        {
            this.errorCount = 0;
            this.checkingContext = new CheckingContext(null);
            this.program = program;
            this.enclosingProc = null;
            this.enclosingImpl = null;
            this.sharedVarsAccessed = null;
            this.introducedLocalVarsUpperBound = int.MinValue;

            this.localVarToLocalVariableInfo = new Dictionary<Variable, LocalVariableInfo>();
            this.absyToLayerNums = new Dictionary<Absy, HashSet<int>>();
            this.globalVarToSharedVarInfo = new Dictionary<Variable, SharedVariableInfo>();
            this.procToActionInfo = new Dictionary<Procedure, ActionInfo>();
            this.procToAtomicProcedureInfo = new Dictionary<Procedure, AtomicProcedureInfo>();
            this.pureCallLayer = new Dictionary<CallCmd, int>();
            
            // Global variables
            foreach (var g in program.GlobalVariables)
            {
                List<int> layerNums = FindLayers(g.Attributes);
                if (layerNums.Count == 0)
                {
                    // Inaccessible from  yielding and atomic procedures
                }
                else if (layerNums.Count == 1)
                {
                    this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue);
                }
                else if (layerNums.Count == 2)
                {
                    this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]);
                }
                else
                {
                    Error(g, "Too many layer numbers");
                }
            }
        }
コード例 #10
0
ファイル: YieldTypeChecker.cs プロジェクト: omaragb/tlp182
 public YieldTypeChecker(CivlTypeChecker civlTypeChecker)
 {
     this.civlTypeChecker         = civlTypeChecker;
     this.checkingContext         = new CheckingContext(null);
     this.moverProcedureCallGraph = new Graph <MoverProc>();
 }
コード例 #11
0
        public static bool Check(Program program)
        {
            var checkingContext           = new CheckingContext(null);
            var functionDependencyChecker = new FunctionDependencyChecker();

            program.TopLevelDeclarations.OfType <Function>().Iter(function =>
            {
                var expr = QKeyValue.FindExprAttribute(function.Attributes, "inline");
                if (expr != null && expr.Type != Type.Bool)
                {
                    checkingContext.Error(function.tok, "Parameter to :inline attribute on a function must be Boolean");
                }
                if (QKeyValue.FindBoolAttribute(function.Attributes, "inline") &&
                    QKeyValue.FindBoolAttribute(function.Attributes, "define"))
                {
                    checkingContext.Error(function.tok, "A function may not have both :inline and :define attributes");
                }
                if (QKeyValue.FindBoolAttribute(function.Attributes, "inline") &&
                    function.Body == null)
                {
                    checkingContext.Error(function.tok, "Function with :inline attribute must have a body");
                }
                if (QKeyValue.FindBoolAttribute(function.Attributes, "define") &&
                    function.DefinitionBody == null)
                {
                    checkingContext.Error(function.tok, "Function with :define attribute must have a body");
                }
            });
            if (checkingContext.ErrorCount > 0)
            {
                return(false);
            }
            program.TopLevelDeclarations.OfType <Function>()
            .Iter(function => functionDependencyChecker.VisitFunction(function));
            var functionDependencyGraph = functionDependencyChecker.functionDependencyGraph;
            var selfLoops = functionDependencyGraph.Edges.SelectMany(edge =>
                                                                     edge.Item1 == edge.Item2 ? new[] { edge.Item1 } : Enumerable.Empty <Function>()).ToHashSet();
            var sccs = new StronglyConnectedComponents <Function>(
                functionDependencyGraph.Nodes,
                functionDependencyGraph.Predecessors,
                functionDependencyGraph.Successors);

            sccs.Compute();
            sccs.Iter(scc =>
            {
                if (scc.Count > 1 ||
                    scc.Count == 1 && selfLoops.Contains(scc.First()))
                {
                    var errorMsg = "Call cycle detected among functions";
                    var first    = true;
                    var token    = Token.NoToken;
                    scc.Iter(function =>
                    {
                        if (first)
                        {
                            first     = false;
                            errorMsg += ": ";
                            token     = function.tok;
                        }
                        else
                        {
                            errorMsg += ", ";
                        }
                        errorMsg += function.Name;
                    });
                    checkingContext.Error(token, errorMsg);
                }
            });
            return(checkingContext.ErrorCount == 0);
        }
コード例 #12
0
 public YieldSufficiencyTypeChecker(CivlTypeChecker civlTypeChecker)
 {
     this.civlTypeChecker         = civlTypeChecker;
     this.checkingContext         = civlTypeChecker.checkingContext;
     this.moverProcedureCallGraph = new Graph <MoverProc>();
 }
コード例 #13
0
ファイル: LinearSets.cs プロジェクト: Chenguang-Zhu/ICE-C5
 public LinearTypeChecker(Program program)
 {
     this.program = program;
     this.errorCount = 0;
     this.checkingContext = new CheckingContext(null);
     this.domainNameToType = new Dictionary<string, Type>();
     this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>();
     this.inoutParamToDomainName = new Dictionary<Variable, string>();
     this.varToDomainName = new Dictionary<Variable, string>();
     this.linearDomains = new Dictionary<string, LinearDomain>();
 }
コード例 #14
0
ファイル: TypeCheck.cs プロジェクト: ggrov/tacny
 public MoverTypeChecker(Program program)
 {
     this.ghostVars = new HashSet<Variable>();
     this.absyToLayerNums = new Dictionary<Absy, HashSet<int>>();
     this.globalVarToSharedVarInfo = new Dictionary<Variable, SharedVariableInfo>();
     this.procToActionInfo = new Dictionary<Procedure, ActionInfo>();
     this.errorCount = 0;
     this.checkingContext = new CheckingContext(null);
     this.program = program;
     this.enclosingProc = null;
     this.enclosingImpl = null;
     this.canAccessSharedVars = false;
     this.canAccessGhostVars = false;
     this.minLayerNum = int.MaxValue;
     this.maxLayerNum = -1;
     this.leastUnimplementedLayerNum = int.MaxValue;
     foreach (var g in program.GlobalVariables)
     {
         List<int> layerNums = FindLayers(g.Attributes);
         if (layerNums.Count == 0)
         {
             // Cannot access atomic actions
         }
         else if (layerNums.Count == 1)
         {
             this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue);
         }
         else if (layerNums.Count == 2)
         {
             this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]);
         }
         else
         {
             Error(g, "Too many layer numbers");
         }
     }
 }
コード例 #15
0
ファイル: TypeCheck.cs プロジェクト: Chenguang-Zhu/ICE-C5
 public MoverTypeChecker(Program program)
 {
     this.qedGlobalVariables = new HashSet<Variable>();
     foreach (var g in program.GlobalVariables())
     {
         if (QKeyValue.FindBoolAttribute(g.Attributes, "qed"))
         {
             this.qedGlobalVariables.Add(g);
             g.Attributes = OwickiGries.RemoveQedAttribute(g.Attributes);
         }
     }
     this.procToActionInfo = new Dictionary<Procedure, ActionInfo>();
     this.assertionPhaseNums = new HashSet<int>();
     this.errorCount = 0;
     this.checkingContext = new CheckingContext(null);
     this.program = program;
     this.enclosingProcPhaseNum = int.MaxValue;
     this.inAtomicSpecification = false;
 }