Exemple #1
0
            private void AsyncCheck()
            {
                var simulationRelation =
                    new SimulationRelation <Absy, int, string>(LabelsToLabeledEdges(asyncLabels), AsyncSpec, new Dictionary <Absy, HashSet <int> >())
                    .ComputeSimulationRelation();

                if (simulationRelation[initialState].Count == 0)
                {
                    civlTypeChecker.Error(impl,
                                          $"Implementation {impl.Name} fails async check at layer {currLayerNum}.");
                }
            }
Exemple #2
0
        private void BSpecCheck(List <Tuple <int, int, int> > implEdges)
        {
            Dictionary <int, HashSet <int> > initialConstraints = new Dictionary <int, HashSet <int> >();

            initialConstraints[initialState] = new HashSet <int>(new int[] { 1 });
            foreach (var finalState in finalStates)
            {
                initialConstraints[finalState] = new HashSet <int>(new int[] { 0 });
            }
            SimulationRelation <int, int, int> x = new SimulationRelation <int, int, int>(implEdges, BSpec, initialConstraints);
            Dictionary <int, HashSet <int> >   simulationRelation = x.ComputeSimulationRelation();

            if (simulationRelation[initialState].Count == 0)
            {
                moverTypeChecker.Error(impl, string.Format("Implementation {0} fails simulation check B at layer {1}. An action must be succeeded by a yield.\n", impl.Name, currLayerNum));
            }
        }
Exemple #3
0
            private void AtomicityCheck()
            {
                var initialConstraints = new Dictionary <Absy, HashSet <int> >();

                foreach (Block header in implGraph.Headers)
                {
                    if (civlTypeChecker.IsYieldingLoopHeader(header, currLayerNum) ||
                        civlTypeChecker.IsTerminatingLoopHeader(header, currLayerNum))
                    {
                        continue;
                    }
                    initialConstraints[header] = new HashSet <int> {
                        RM
                    };
                }

                if (IsMoverProcedure)
                {
                    foreach (var call in impl.Blocks.SelectMany(b => b.cmds).OfType <CallCmd>())
                    {
                        if (!IsTerminatingCall(call))
                        {
                            initialConstraints[call] = new HashSet <int> {
                                RM
                            };
                        }
                    }
                }

                var simulationRelation =
                    new SimulationRelation <Absy, int, string>(LabelsToLabeledEdges(atomicityLabels), AtomicitySpec, initialConstraints)
                    .ComputeSimulationRelation();

                if (IsMoverProcedure)
                {
                    if (!CheckAtomicity(simulationRelation))
                    {
                        civlTypeChecker.Error(impl, "The atomicity declared for mover procedure is not valid");
                    }
                }
                else if (simulationRelation[initialState].Count == 0)
                {
                    civlTypeChecker.Error(impl,
                                          $"Implementation {impl.Name} fails atomicity check at layer {currLayerNum}. Transactions must be separated by yields.");
                }
            }
Exemple #4
0
        private void CSpecCheck(List <Tuple <int, int, int> > implEdges)
        {
            Dictionary <int, HashSet <int> > initialConstraints = new Dictionary <int, HashSet <int> >();

            foreach (Block block in loopHeaders)
            {
                if (!IsTerminatingLoopHeader(block))
                {
                    initialConstraints[absyToNode[block]] = new HashSet <int>(new int[] { 0 });
                }
            }
            SimulationRelation <int, int, int> x = new SimulationRelation <int, int, int>(implEdges, CSpec, initialConstraints);
            Dictionary <int, HashSet <int> >   simulationRelation = x.ComputeSimulationRelation();

            if (simulationRelation[initialState].Count == 0)
            {
                moverTypeChecker.Error(impl, string.Format("Implementation {0} fails simulation check C at layer {1}. Transactions must be separated by a yield.\n", impl.Name, currLayerNum));
            }
        }
Exemple #5
0
            private void BSpecCheck()
            {
                var initialConstraints = new Dictionary <Absy, HashSet <int> >();

                initialConstraints[initialState] = new HashSet <int> {
                    LM
                };
                foreach (var finalState in finalStates)
                {
                    initialConstraints[finalState] = new HashSet <int> {
                        RM
                    };
                }

                var simulationRelation = new SimulationRelation <Absy, int, int>(implEdges, BSpec, initialConstraints).ComputeSimulationRelation();

                if (simulationRelation[initialState].Count == 0)
                {
                    @base.checkingContext.Error(impl, string.Format("Implementation {0} fails simulation check B at layer {1}. An action must be succeeded by a yield.", impl.Name, currLayerNum));
                }
            }
Exemple #6
0
            private void BracketCheck()
            {
                var initialConstraints = new Dictionary <Absy, HashSet <int> >();

                initialConstraints[initialState] = new HashSet <int> {
                    BEFORE
                };
                foreach (var finalState in finalStates)
                {
                    initialConstraints[finalState] = new HashSet <int> {
                        AFTER
                    };
                }

                var simulationRelation = new SimulationRelation <Absy, int, int>(implEdges, BracketSpec, initialConstraints).ComputeSimulationRelation();

                if (simulationRelation[initialState].Count == 0)
                {
                    @base.checkingContext.Error(impl, $"Implementation {impl.Name} fails bracket check at layer {currLayerNum}. All code that accesses global variables must be bracketed by yields.");
                }
            }
Exemple #7
0
            private void CSpecCheck()
            {
                var initialConstraints = new Dictionary <Absy, HashSet <int> >();

                foreach (Block header in implGraph.Headers)
                {
                    if (!IsTerminatingLoopHeader(header))
                    {
                        initialConstraints[header] = new HashSet <int> {
                            RM
                        };
                    }
                }
                if (IsMoverProcedure)
                {
                    foreach (var call in impl.Blocks.SelectMany(b => b.cmds).OfType <CallCmd>())
                    {
                        if (!IsTerminatingCall(call))
                        {
                            initialConstraints[call] = new HashSet <int> {
                                RM
                            };
                        }
                    }
                }

                var simulationRelation = new SimulationRelation <Absy, int, int>(implEdges, CSpec, initialConstraints).ComputeSimulationRelation();

                if (IsMoverProcedure)
                {
                    if (!CheckAtomicity(simulationRelation))
                    {
                        @base.checkingContext.Error(impl, "The atomicity declared for mover procedure is not valid");
                    }
                }
                else if (simulationRelation[initialState].Count == 0)
                {
                    @base.checkingContext.Error(impl, string.Format("Implementation {0} fails simulation check C at layer {1}. Transactions must be separated by a yield.", impl.Name, currLayerNum));
                }
            }