Ejemplo n.º 1
0
 private IEnumerable <CounterExampleItem> GetCounterExamples(ILanguageSpecificModel model)
 {
     return(model.States
            .WithCancellation(_cancellationToken)
            .OfType <StateNode>()
            .Where(state => !IsInitialState(state))
            .Select(GetCounterExample));
 }
            private StateNode FindInitialState(ILanguageSpecificModel specificModel)
            {
                foreach (IState s in specificModel.States)
                {
                    if (!(s is StateNode state))
                    {
                        continue;
                    }
                    if (state.Name.Contains(":initial state"))
                    {
                        return(state);
                    }
                }

                throw new InvalidOperationException(Resources.ExceptionMessages.counter_example_no_init_state);
            }
Ejemplo n.º 3
0
 private static void GetExpansions(StateNode state, ElementNode elementNode, CounterExampleState counterExampleState,
                                   ILanguageSpecificModel languageSpecificModel)
 {
     try {
         var dafnyModel = GetFieldValue <DafnyModel>(state, "dm");
         var elt        = GetFieldValue <Model.Element>(elementNode, "elt");
         var extras     = dafnyModel.GetExpansion(state, elt);
         foreach (var el in extras)
         {
             counterExampleState.Variables.Add(new CounterExampleVariable {
                 Name          = elementNode.Name + "." + el.Name,
                 Value         = el.Value,
                 CanonicalName = languageSpecificModel.CanonicalName(el.Element)
             });
         }
     } catch (Exception e) {
         Console.Error.WriteLine(e.Message);
     }
 }
Ejemplo n.º 4
0
 public DisplayNode(ILanguageSpecificModel model, EdgeName n, Model.Element elt)
 {
     langModel = model;
     name      = n;
     element   = elt;
 }
Ejemplo n.º 5
0
 public DisplayNode(ILanguageSpecificModel model, string n, Model.Element elt)
     : this(model, new EdgeName(n), elt)
 {
 }
Ejemplo n.º 6
0
        private void BuildModel()
        {
            stateList.Items.Clear();

              var items = new List<ListViewItem>();
              LangModel = langProvider.GetLanguageSpecificModel(currentModel, viewOpts);
              states = LangModel.States.ToArray();
              var oldRoot = unfoldingRoot;
              SkeletonItem selectedSkel = null;
              if (oldRoot != null && SelectedNode() != null) {
            selectedSkel = SelectedNode().skel;
              }
              unfoldingRoot = new SkeletonItem(this, states.Length);
              allItems = unfoldingRoot.PopulateRoot(states);

              var idx = 0;
              foreach (var i in states) {
            var it = new ListViewItem(new string[] { idx.ToString(), i.Name, "" });
            it.Tag = i;
            items.Add(it);
            idx++;
              }
              stateList.Items.AddRange(items.ToArray());
              unfoldingRoot.Expanded = true;

              if (oldRoot == null) {
            SetState(0);
            stateList.Items[0].Selected = true;
            SetColumnSizes();
              } else {
            var mapping = new Dictionary<SkeletonItem, SkeletonItem>();
            unfoldingRoot.SyncWith(mapping, oldRoot);
            SkeletonItem newIt = null;
            while (selectedSkel != null) {
              if (mapping.TryGetValue(selectedSkel, out newIt)) break;
              selectedSkel = selectedSkel.parent;
            }
            if (CurrentState >= stateList.Items.Count)
              CurrentState = 0;
            if (PreviousState >= stateList.Items.Count)
              PreviousState = -1;
            if (newIt != null) GotoNode(newIt);
            SyncStateListValues();
            UpdateMatches(true);
              }
        }
Ejemplo n.º 7
0
        private void BuildModel()
        {
            stateList.Items.Clear();

            var items = new List <ListViewItem>();

            LangModel = langProvider.GetLanguageSpecificModel(currentModel, viewOpts);
            states    = LangModel.States.ToArray();
            var          oldRoot      = unfoldingRoot;
            SkeletonItem selectedSkel = null;

            if (oldRoot != null && SelectedNode() != null)
            {
                selectedSkel = SelectedNode().skel;
            }
            unfoldingRoot = new SkeletonItem(this, states.Length);
            allItems      = unfoldingRoot.PopulateRoot(states);

            var idx = 0;

            foreach (var i in states)
            {
                var it = new ListViewItem(new string[] { idx.ToString(), i.Name, "" });
                it.Tag = i;
                items.Add(it);
                idx++;
            }
            stateList.Items.AddRange(items.ToArray());
            unfoldingRoot.Expanded = true;

            if (oldRoot == null)
            {
                SetState(0);
                stateList.Items[0].Selected = true;
                SetColumnSizes();
            }
            else
            {
                var mapping = new Dictionary <SkeletonItem, SkeletonItem>();
                unfoldingRoot.SyncWith(mapping, oldRoot);
                SkeletonItem newIt = null;
                while (selectedSkel != null)
                {
                    if (mapping.TryGetValue(selectedSkel, out newIt))
                    {
                        break;
                    }
                    selectedSkel = selectedSkel.parent;
                }
                if (CurrentState >= stateList.Items.Count)
                {
                    CurrentState = 0;
                }
                if (PreviousState >= stateList.Items.Count)
                {
                    PreviousState = -1;
                }
                if (newIt != null)
                {
                    GotoNode(newIt);
                }
                SyncStateListValues();
                UpdateMatches(true);
            }
        }
Ejemplo n.º 8
0
 public EdgeName(ILanguageSpecificModel n, string format, params Model.Element[] args)
 {
     this.langModel = n;
     this.format    = format;
     this.args      = args.ToArray();
 }