Exemple #1
0
 @Override
 public List copy(Map<Variable, Variable> sharedVariables) {
   if (immutable) {
     return this;
   } else {
     Term newHead = head.copy(sharedVariables);
     Term newTail = tail.copy(sharedVariables);
     if (newHead == head && newTail == tail) {
       return this;
     } else {
       return new List(newHead, newTail, newHead.isImmutable() && newTail.isImmutable());
     }
   }
 }
Exemple #2
0
 /** Gets a copy of this variable. */
 Term copy(AbstractMap vMap, AbstractMap substMap) {
   Var v;
   Object temp = vMap.get(this);
   if (temp == null) {
     v =
         new Var(
             null,
             Var.PROGRESSIVE,
             vMap.size(),
             timestamp); // name,Var.PROGRESSIVE,vMap.size(),timestamp);
     vMap.put(this, v);
   } else {
     v = (Var) temp;
   }
   Term t = getTerm();
   if (t instanceof Var) {
     Object tt = substMap.get(t);
     if (tt == null) {
       substMap.put(t, v);
       v.link = null;
     } else {
       v.link = (tt != v) ? (Var) tt : null;
     }
   }
   if (t instanceof Struct) {
     v.link = t.copy(vMap, substMap);
   }
   if (t instanceof Number) v.link = t;
   return v;
 }
Exemple #3
0
 /**
  * Gets a copy of this variable.
  *
  * <p>if the variable is not present in the list passed as argument, a copy of this variable is
  * returned and added to the list. If instead a variable with the same time identifier is found in
  * the list, then the variable in the list is returned.
  */
 Term copy(AbstractMap vMap, int idExecCtx) {
   Term tt = getTerm();
   if (tt == this) {
     Var v = (Var) (vMap.get(this));
     if (v == null) {
       // No occurence of v before
       v = new Var(name, idExecCtx, 0, timestamp);
       vMap.put(this, v);
     }
     return v;
   } else {
     return tt.copy(vMap, idExecCtx);
   }
 }