public AppNode(BaseState m, Model.FuncTuple t, Func <Model.Element, string> nameElement) : base(m, t.Func.Name, t.Result) { tupl = t; var sb = new StringBuilder(); sb.Append(t.Func.Name); if (t.Args.Length > 0) { sb.Append("("); for (int i = 0; i < t.Args.Length; ++i) { var n = nameElement(t.Args[i]); if (n == null) { sb.AppendFormat("%{0}, ", i); } else { sb.AppendFormat("{0}, ", n); } } sb.Length -= 2; sb.Append(")"); } name = new EdgeName(m.m, sb.ToString(), t.Args); }
public Edge(EdgeName name, int cost, Node pointOne, Node pointTwo) { this.name = name; this.cost = cost; this.pointOne = pointOne; this.pointTwo = pointTwo; }
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; }
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); */ }
protected void ClearBoundsBody(EdgeName edge) { for (int i = 0; i < boundsBodies.Length; i++) { if (boundsBodies[i] != null && (EdgeName)boundsBodies[i].GetUserData() == edge) { world.DestroyBody(boundsBodies[i]); boundsBodies[i] = null; break; } } }
public ElementNode(StateNode st, EdgeName name, Model.Element elt) : base(st.dm, name, elt) { this.stateNode = st; this.elt = elt; }
public MapletNode(StateNode par, EdgeName realName, Model.Element elt) : base(par, realName, elt) { }
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); }
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); */ }
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; }
public AppNode(BaseState m, Model.FuncTuple t, Func<Model.Element, string> nameElement) : base(m, t.Func.Name, t.Result) { tupl = t; var sb = new StringBuilder(); sb.Append(t.Func.Name); if (t.Args.Length > 0) { sb.Append("("); for (int i = 0; i < t.Args.Length; ++i) { var n = nameElement(t.Args[i]); if (n == null) sb.AppendFormat("%{0}, ", i); else sb.AppendFormat("{0}, ", n); } sb.Length -= 2; sb.Append(")"); } name = new EdgeName(m.m, sb.ToString(), t.Args); }