Ejemplo n.º 1
0
 public VariableNode(StateNode par, string realName, Model.Element elt, string shortName)
     : base(par, realName, elt)
 {
     this.realName = realName;
     name          = new EdgeName(vm.GetUserVariableName(realName));
     ShortName     = shortName;
 }
Ejemplo n.º 2
0
 public FieldNode(StateNode par, EdgeName realName, Model.Element elt)
     : base(par, realName, elt)
 {
     /*
      * var idx = realName.LastIndexOf('.');
      * if (idx > 0)
      * name = realName.Substring(idx + 1);
      */
 }
Ejemplo n.º 3
0
 public ILanguageSpecificModel GetLanguageSpecificModel(Model m, ViewOptions opts)
 {
   var dm = new DafnyModel(m, opts);
   foreach (var s in m.States) {
     var sn = new StateNode(dm.states.Count, dm, s);
     dm.states.Add(sn);
   }
   dm.FinishStates();
   return dm;
 }
Ejemplo n.º 4
0
        public ILanguageSpecificModel GetLanguageSpecificModel(Model m, ViewOptions opts)
        {
            var dm = new DafnyModel(m, opts);

            foreach (var s in m.States)
            {
                var sn = new StateNode(dm.states.Count, dm, s);
                dm.states.Add(sn);
            }
            dm.FinishStates();
            return(dm);
        }
Ejemplo n.º 5
0
 public MapletNode(StateNode par, EdgeName realName, Model.Element elt)
     : base(par, realName, elt)
 {
 }
Ejemplo n.º 6
0
 public ElementNode(StateNode st, string name, Model.Element elt)
     : this(st, new EdgeName(name), elt)
 {
 }
Ejemplo n.º 7
0
 public ElementNode(StateNode st, EdgeName name, Model.Element elt)
     : base(st.dm, name, elt)
 {
     this.stateNode = st;
     this.elt       = elt;
 }
Ejemplo n.º 8
0
        public IEnumerable <ElementNode> GetExpansion(StateNode state, Model.Element elt)
        {
            List <ElementNode> result = new List <ElementNode>();

            if (elt.Kind != Model.ElementKind.Uninterpreted)
            {
                return(result);
            }

            // Perhaps elt is a known datatype value
            Model.FuncTuple fnTuple;
            if (DatatypeValues.TryGetValue(elt, out fnTuple))
            {
                // elt is a datatype value
                int i = 0;
                foreach (var arg in fnTuple.Args)
                {
                    var edgname = new EdgeName(this, i.ToString());
                    result.Add(new FieldNode(state, edgname, arg));
                    i++;
                }
                return(result);
            }

            // Perhaps elt is a sequence
            var seqLen = f_seq_length.AppWithArg(0, elt);

            if (seqLen != null)
            {
                // elt is a sequence
                foreach (var tpl in f_seq_index.AppsWithArg(0, elt))
                {
                    var edgname = new EdgeName(this, "[%0]", tpl.Args[1]);
                    result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
                }
                return(result);
            }

            // Perhaps elt is a set
            foreach (var tpl in f_set_select.AppsWithArg(0, elt))
            {
                var setElement  = tpl.Args[1];
                var containment = tpl.Result;
                var edgname     = new EdgeName(this, "[%0]", Unbox(setElement));
                result.Add(new FieldNode(state, edgname, containment));
            }
            if (result.Count != 0)
            {
                return(result); // elt is a set
            }
            // It seems elt is an object or array
            Model.Element[] lengths;
            if (ArrayLengths.TryGetValue(elt, out lengths))
            {
                int i = 0;
                foreach (var len in lengths)
                {
                    var name    = lengths.Length == 1 ? "Length" : "Length" + i;
                    var edgname = new EdgeName(this, name);
                    result.Add(new FieldNode(state, edgname, len));
                    i++;
                }
            }
            var heap = state.State.TryGet("$Heap");

            if (heap != null)
            {
                foreach (var tpl in f_heap_select.AppsWithArgs(0, heap, 1, elt))
                {
                    var field = new FieldName(tpl.Args[2], this);
                    if (field.NameFormat != "alloc")
                    {
                        var edgname = new EdgeName(this, field.NameFormat, field.NameArgs);
                        result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
 public VariableNode(StateNode par, string realName, Model.Element elt, string shortName)
   : base(par, realName, elt)
 {
   this.realName = realName;
   name = new EdgeName(vm.GetUserVariableName(realName));
   ShortName = shortName;
 }
Ejemplo n.º 10
0
 public MapletNode(StateNode par, EdgeName realName, Model.Element elt)
   : base(par, realName, elt)
 {
 }
Ejemplo n.º 11
0
 public FieldNode(StateNode par, EdgeName realName, Model.Element elt)
   : base(par, realName, elt)
 {
   /*
   var idx = realName.LastIndexOf('.');
   if (idx > 0)
     name = realName.Substring(idx + 1);
    */
 }
Ejemplo n.º 12
0
 public ElementNode(StateNode st, string name, Model.Element elt)
   : this(st, new EdgeName(name), elt) { }
Ejemplo n.º 13
0
 public ElementNode(StateNode st, EdgeName name, Model.Element elt)
   : base(st.dm, name, elt)
 {
   this.stateNode = st;
   this.elt = elt;
 }
Ejemplo n.º 14
0
    public IEnumerable<ElementNode> GetExpansion(StateNode state, Model.Element elt)
    {
      List<ElementNode> result = new List<ElementNode>();

      if (elt.Kind != Model.ElementKind.Uninterpreted)
        return result;

      // Perhaps elt is a known datatype value
      Model.FuncTuple fnTuple;
      if (DatatypeValues.TryGetValue(elt, out fnTuple)) {
        // elt is a datatype value
        int i = 0;
        foreach (var arg in fnTuple.Args) {
          var edgname = new EdgeName(this, i.ToString());
          result.Add(new FieldNode(state, edgname, arg));
          i++;
        }
        return result;
      }

      // Perhaps elt is a sequence
      var seqLen = f_seq_length.AppWithArg(0, elt);
      if (seqLen != null) {
        // elt is a sequence
        foreach (var tpl in f_seq_index.AppsWithArg(0, elt)) {
          var edgname = new EdgeName(this, "[%0]", tpl.Args[1]);
          result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
        }
        return result;
      }

      // Perhaps elt is a set
      foreach (var tpl in f_set_select.AppsWithArg(0, elt)) {
        var setElement = tpl.Args[1];
        var containment = tpl.Result;
        var edgname = new EdgeName(this, "[%0]", Unbox(setElement));
        result.Add(new FieldNode(state, edgname, containment));
      }
      if (result.Count != 0)
        return result;  // elt is a set

      // It seems elt is an object or array
      Model.Element[] lengths;
      if (ArrayLengths.TryGetValue(elt, out lengths)) {
        int i = 0;
        foreach (var len in lengths) {
          var name = lengths.Length == 1 ? "Length" : "Length" + i;
          var edgname = new EdgeName(this, name);
          result.Add(new FieldNode(state, edgname, len));
          i++;
        }
      }
      var heap = state.State.TryGet("$Heap");
      if (heap != null) {
        foreach (var tpl in f_heap_select.AppsWithArgs(0, heap, 1, elt)) {
          var field = new FieldName(tpl.Args[2], this);
          if (field.NameFormat != "alloc") {
            var edgname = new EdgeName(this, field.NameFormat, field.NameArgs);
            result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
          }
        }
      }
      return result;
    }