Program: 37610
Project: 37610
Buggy source:
/** 
 * ���դ��ץ���ʸ̮��ɽ���ץ������դ˷��ꤹ�롣
 */
void fixTypedProcesses() throws CompileException {
  identifiedCxtdefs=new HashSet<ContextDef>();
  for (  ContextDef def : typedProcessContexts.values()) {
    if (def.lhsOcc != null) {
      identifiedCxtdefs.add(def);
      for (int i=0; i < def.lhsOcc.args.length; i++) {
        if (!atomPaths.containsKey(def.lhsOcc.args[i].buddy.atom)) {
          error("String_Node_Str" + def.getName());
        }
      }
    }
 else     if (def.lhsMem != null) {
      if (def.lhsMem.pragmaAtHost.def == def) {
        identifiedCxtdefs.add(def);
        int atomid=varCount++;
        match.add(new Instruction(Instruction.GETRUNTIME,atomid,memToPath(def.lhsMem)));
        typedCxtSrcs.put(def,new Integer(atomid));
        typedCxtDefs.add(def);
        typedCxtTypes.put(def,UNARY_ATOM_TYPE);
        typedCxtDataTypes.put(def,new Integer(ISSTRING));
      }
    }
  }
  LinkedList<Atom> cstrs=new LinkedList<Atom>(typeConstraints);
{
    LinkedList<Atom> tmpFirst=new LinkedList<Atom>();
    LinkedList<Atom> tmpLast=new LinkedList<Atom>();
    for (Iterator<Atom> it=cstrs.iterator(); it.hasNext(); ) {
      Atom a=it.next();
      if (a.functor.getName().endsWith("String_Node_Str") || a.functor.getName().equals("String_Node_Str")) {
        tmpFirst.add(a);
        it.remove();
      }
      if (a.functor.getName().startsWith("String_Node_Str") || a.functor.getName().equals("String_Node_Str")) {
        tmpLast.add(a);
        it.remove();
      }
    }
    tmpFirst.addAll(cstrs);
    tmpFirst.addAll(tmpLast);
    cstrs=tmpFirst;
  }
  boolean changed;
  do {
    changed=false;
    FixType:     for (ListIterator<Atom> lit=cstrs.listIterator(); lit.hasNext(); ) {
      Atom cstr=lit.next();
      Functor func=cstr.functor;
      ContextDef def1=null;
      ContextDef def2=null;
      ContextDef def3=null;
      if (func.getArity() > 0)       def1=((ProcessContext)cstr.args[0].buddy.atom).def;
      if (func.getArity() > 1)       def2=((ProcessContext)cstr.args[1].buddy.atom).def;
      if (func.getArity() > 2)       def3=((ProcessContext)cstr.args[2].buddy.atom).def;
      if (func.equals(new SymbolFunctor("String_Node_Str",1))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        int atomid1=loadUnaryAtom(def1);
        match.add(new Instruction(Instruction.ISUNARY,atomid1));
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",1))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        checkGroundLink(def1);
      }
 else       if (func.getName().startsWith("String_Node_Str")) {
        boolean hasError=false;
        if (func.getName().length() < 7 + func.getArity() + 1)         hasError=true;
        boolean[] isIn=new boolean[func.getArity()];
        if (func.getName().charAt(7 + isIn.length) != '_')         hasError=true;
        for (int i=0; i < isIn.length; i++) {
          char ch=func.getName().charAt(7 + i);
          if (ch != 'i' && ch != 'o')           hasError=true;
          isIn[i]=ch == 'i';
        }
        if (hasError) {
          String mo="String_Node_Str";
          for (int i=0; i < isIn.length; i++)           mo+="String_Node_Str";
          error("String_Node_Str" + func.getName() + "String_Node_Str"+ mo+ "String_Node_Str");
        }
        String guardID=func.getName().substring(7 + func.getArity() + 1);
        ArrayList<Integer> vars=new ArrayList<Integer>();
        ArrayList<Integer> out=new ArrayList<Integer>();
        for (int k=0; k < cstr.args.length; k++) {
          ContextDef defK=((ProcessContext)cstr.args[k].buddy.atom).def;
          if (isIn[k] && !identifiedCxtdefs.contains(defK)) {
            continue FixType;
          }
          int aid;
          if (identifiedCxtdefs.contains(defK)) {
            aid=typedcxtToSrcPath(defK);
            if (aid == UNBOUND) {
              checkGroundLink(defK);
              aid=groundToSrcPath(defK);
            }
          }
 else {
            int atomid=varCount++;
            bindToUnaryAtom(defK,atomid);
            typedCxtDataTypes.put(def3,new Integer(ISINT));
            aid=typedcxtToSrcPath(defK);
            out.add(new Integer(aid));
          }
          vars.add(new Integer(aid));
        }
        match.add(new Instruction(Instruction.GUARD_INLINE,guardID,vars,out));
      }
 else       if (func.getName().equals("String_Node_Str") || func.getName().equals("String_Node_Str")) {
        ArrayList<Integer> uniqVars=new ArrayList<Integer>();
        for (int k=0; k < cstr.args.length; k++) {
          ContextDef defK=((ProcessContext)cstr.args[k].buddy.atom).def;
          if (!identifiedCxtdefs.contains(defK))           continue FixType;
          int srcPath;
          checkGroundLink(defK);
          srcPath=groundToSrcPath(defK);
          if (srcPath == UNBOUND)           continue FixType;
          uniqVars.add(new Integer(srcPath));
        }
        if (func.getName().equals("String_Node_Str")) {
          match.add(new Instruction(Instruction.UNIQ,uniqVars));
        }
 else {
          match.add(new Instruction(Instruction.NOT_UNIQ,uniqVars));
        }
        rc.theRule.hasUniq=true;
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        if (!GROUND_ALLOWED || typedCxtTypes.get(def1) == UNARY_ATOM_TYPE || typedCxtTypes.get(def2) == UNARY_ATOM_TYPE) {
          int atomid1=loadUnaryAtom(def1);
          int atomid2=loadUnaryAtom(def2);
          if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)           connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
          match.add(new Instruction(Instruction.ISUNARY,atomid1));
          match.add(new Instruction(Instruction.ISUNARY,atomid2));
          int funcid1=varCount++;
          int funcid2=varCount++;
          match.add(new Instruction(Instruction.GETFUNC,funcid1,atomid1));
          match.add(new Instruction(Instruction.GETFUNC,funcid2,atomid2));
          match.add(new Instruction(Instruction.NEQFUNC,funcid1,funcid2));
        }
 else {
          checkGroundLink(def1);
          checkGroundLink(def2);
          if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)           connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
          int linkid1=loadGroundLink(def1);
          int linkid2=loadGroundLink(def2);
          match.add(new Instruction(Instruction.NEQGROUND,linkid1,linkid2));
        }
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        int atomid2=loadUnaryAtom(def2);
        if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)         connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
        if (!new Integer(ISSTRING).equals(typedCxtDataTypes.get(def2))) {
          match.add(new Instruction(ISSTRING,atomid2));
          typedCxtDataTypes.put(def2,new Integer(ISSTRING));
        }
        int classnameAtomid=varCount++;
        match.add(new Instruction(Instruction.GETCLASS,classnameAtomid,atomid1));
        match.add(new Instruction(Instruction.SUBCLASS,classnameAtomid,atomid2));
      }
 else       if (func instanceof runtime.IntegerFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISINT));
      }
 else       if (func instanceof runtime.FloatingFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISFLOAT));
      }
 else       if (func instanceof runtime.StringFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISSTRING));
      }
 else       if (cstr.isSelfEvaluated && func.getArity() == 1) {
        bindToFunctor(def1,func);
      }
 else       if (func.equals(Functor.UNIFY)) {
        if (!identifiedCxtdefs.contains(def2)) {
          ContextDef swaptmp=def1;
          def1=def2;
          def2=swaptmp;
          if (!identifiedCxtdefs.contains(def2))           continue;
        }
        if (GROUND_ALLOWED && typedCxtTypes.get(def2) != UNARY_ATOM_TYPE) {
          if (!identifiedCxtdefs.contains(def1))           continue;
        }
        processEquivalenceConstraint(def1,def2);
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        match.add(new Instruction(Instruction.ISUNARY,atomid1));
        int atomid2=loadUnaryAtom(def2);
        match.add(new Instruction(Instruction.ISUNARY,atomid2));
        match.add(new Instruction(Instruction.SAMEFUNC,atomid1,atomid2));
      }
 else       if (guardLibrary0.containsKey(func)) {
        int[] desc=guardLibrary0.get(func);
        int atomid=varCount++;
        match.add(new Instruction(desc[0],atomid));
        bindToUnaryAtom(def1,atomid);
        typedCxtDataTypes.put(def1,new Integer(desc[1]));
        if (identifiedCxtdefs.contains(def1)) {
          int funcid2=varCount++;
          match.add(new Instruction(Instruction.GETFUNC,funcid2,atomid));
          int atomid1=varCount++;
          match.add(new Instruction(Instruction.ALLOCATOMINDIRECT,atomid1,funcid2));
          typedCxtSrcs.put(def1,new Integer(atomid1));
          typedCxtDefs.add(def1);
          identifiedCxtdefs.add(def1);
          typedCxtTypes.put(def1,UNARY_ATOM_TYPE);
        }
      }
 else       if (guardLibrary1.containsKey(func)) {
        int[] desc=guardLibrary1.get(func);
        if (!identifiedCxtdefs.contains(def1))         continue;
        int atomid1=loadUnaryAtom(def1);
        if (desc[0] != 0 && !new Integer(desc[0]).equals(typedCxtDataTypes.get(def1))) {
          match.add(new Instruction(desc[0],atomid1));
          typedCxtDataTypes.put(def1,new Integer(desc[0]));
        }
        if (func.getArity() == 1) {
          if (desc.length > 1)           match.add(new Instruction(desc[1],atomid1));
        }
 else {
          int atomid2;
          if (desc[1] == -1) {
            atomid2=atomid1;
          }
 else {
            atomid2=varCount++;
            match.add(new Instruction(desc[1],atomid2,atomid1));
          }
          bindToUnaryAtom(def2,atomid2);
          typedCxtDataTypes.put(def2,new Integer(desc[2]));
        }
      }
 else       if (guardLibrary2.containsKey(func)) {
        int[] desc=guardLibrary2.get(func);
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        int atomid2=loadUnaryAtom(def2);
        if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)         connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
        if (desc[0] != 0 && !new Integer(desc[0]).equals(typedCxtDataTypes.get(def1))) {
          match.add(new Instruction(desc[0],atomid1));
          typedCxtDataTypes.put(def1,new Integer(desc[0]));
        }
        if (desc[1] != 0 && !new Integer(desc[1]).equals(typedCxtDataTypes.get(def2))) {
          match.add(new Instruction(desc[1],atomid2));
          typedCxtDataTypes.put(def2,new Integer(desc[1]));
        }
        if (func.getArity() == 2) {
          match.add(new Instruction(desc[2],atomid1,atomid2));
        }
 else {
          int atomid3=varCount++;
          match.add(new Instruction(desc[2],atomid3,atomid1,atomid2));
          bindToUnaryAtom(def3,atomid3);
          typedCxtDataTypes.put(def3,new Integer(desc[3]));
        }
      }
 else {
        error("String_Node_Str" + cstr);
        discardTypeConstraint(cstr);
      }
      lit.remove();
      changed=true;
    }
    if (cstrs.isEmpty())     return;
  }
 while (changed);
  String text="String_Node_Str";
  for (ListIterator<Atom> lit=cstrs.listIterator(); lit.hasNext(); ) {
    Atom cstr=lit.next();
    discardTypeConstraint(cstr);
    if (text.length() > 0)     text+="String_Node_Str";
    text+=cstr.toStringAsTypeConstraint();
  }
  error("String_Node_Str" + text);
}

Fixed version (ground truth):
/** 
 * ���դ��ץ���ʸ̮��ɽ���ץ������դ˷��ꤹ�롣
 */
void fixTypedProcesses() throws CompileException {
  identifiedCxtdefs=new HashSet<ContextDef>();
  for (  ContextDef def : typedProcessContexts.values()) {
    if (def.lhsOcc != null) {
      identifiedCxtdefs.add(def);
      for (int i=0; i < def.lhsOcc.args.length; i++) {
        if (!atomPaths.containsKey(def.lhsOcc.args[i].buddy.atom)) {
          error("String_Node_Str" + def.getName());
        }
      }
    }
 else     if (def.lhsMem != null) {
      if (def.lhsMem.pragmaAtHost.def == def) {
        identifiedCxtdefs.add(def);
        int atomid=varCount++;
        match.add(new Instruction(Instruction.GETRUNTIME,atomid,memToPath(def.lhsMem)));
        typedCxtSrcs.put(def,new Integer(atomid));
        typedCxtDefs.add(def);
        typedCxtTypes.put(def,UNARY_ATOM_TYPE);
        typedCxtDataTypes.put(def,new Integer(ISSTRING));
      }
    }
  }
  LinkedList<Atom> cstrs=new LinkedList<Atom>(typeConstraints);
{
    LinkedList<Atom> tmpFirst=new LinkedList<Atom>();
    LinkedList<Atom> tmpLast=new LinkedList<Atom>();
    for (Iterator<Atom> it=cstrs.iterator(); it.hasNext(); ) {
      Atom a=it.next();
      if (a.functor.getName().endsWith("String_Node_Str") || a.functor.getName().equals("String_Node_Str")) {
        tmpFirst.add(a);
        it.remove();
      }
      if (a.functor.getName().startsWith("String_Node_Str") || a.functor.getName().equals("String_Node_Str") || a.functor.getName().equals("String_Node_Str")) {
        tmpLast.add(a);
        it.remove();
      }
    }
    tmpFirst.addAll(cstrs);
    tmpFirst.addAll(tmpLast);
    cstrs=tmpFirst;
  }
  boolean changed;
  do {
    changed=false;
    FixType:     for (ListIterator<Atom> lit=cstrs.listIterator(); lit.hasNext(); ) {
      Atom cstr=lit.next();
      Functor func=cstr.functor;
      ContextDef def1=null;
      ContextDef def2=null;
      ContextDef def3=null;
      if (func.getArity() > 0)       def1=((ProcessContext)cstr.args[0].buddy.atom).def;
      if (func.getArity() > 1)       def2=((ProcessContext)cstr.args[1].buddy.atom).def;
      if (func.getArity() > 2)       def3=((ProcessContext)cstr.args[2].buddy.atom).def;
      if (func.equals(new SymbolFunctor("String_Node_Str",1))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        int atomid1=loadUnaryAtom(def1);
        match.add(new Instruction(Instruction.ISUNARY,atomid1));
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",1))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        checkGroundLink(def1);
      }
 else       if (func.getName().startsWith("String_Node_Str")) {
        boolean hasError=false;
        if (func.getName().length() < 7 + func.getArity() + 1)         hasError=true;
        boolean[] isIn=new boolean[func.getArity()];
        if (func.getName().charAt(7 + isIn.length) != '_')         hasError=true;
        for (int i=0; i < isIn.length; i++) {
          char ch=func.getName().charAt(7 + i);
          if (ch != 'i' && ch != 'o')           hasError=true;
          isIn[i]=ch == 'i';
        }
        if (hasError) {
          String mo="String_Node_Str";
          for (int i=0; i < isIn.length; i++)           mo+="String_Node_Str";
          error("String_Node_Str" + func.getName() + "String_Node_Str"+ mo+ "String_Node_Str");
        }
        String guardID=func.getName().substring(7 + func.getArity() + 1);
        ArrayList<Integer> vars=new ArrayList<Integer>();
        ArrayList<Integer> out=new ArrayList<Integer>();
        for (int k=0; k < cstr.args.length; k++) {
          ContextDef defK=((ProcessContext)cstr.args[k].buddy.atom).def;
          if (isIn[k] && !identifiedCxtdefs.contains(defK)) {
            continue FixType;
          }
          int aid;
          if (identifiedCxtdefs.contains(defK)) {
            aid=typedcxtToSrcPath(defK);
            if (aid == UNBOUND) {
              checkGroundLink(defK);
              aid=groundToSrcPath(defK);
            }
          }
 else {
            int atomid=varCount++;
            bindToUnaryAtom(defK,atomid);
            typedCxtDataTypes.put(def3,new Integer(ISINT));
            aid=typedcxtToSrcPath(defK);
            out.add(new Integer(aid));
          }
          vars.add(new Integer(aid));
        }
        match.add(new Instruction(Instruction.GUARD_INLINE,guardID,vars,out));
      }
 else       if (func.getName().equals("String_Node_Str") || func.getName().equals("String_Node_Str")) {
        ArrayList<Integer> uniqVars=new ArrayList<Integer>();
        for (int k=0; k < cstr.args.length; k++) {
          ContextDef defK=((ProcessContext)cstr.args[k].buddy.atom).def;
          if (!identifiedCxtdefs.contains(defK))           continue FixType;
          int srcPath;
          checkGroundLink(defK);
          srcPath=groundToSrcPath(defK);
          if (srcPath == UNBOUND)           continue FixType;
          uniqVars.add(new Integer(srcPath));
        }
        if (func.getName().equals("String_Node_Str")) {
          match.add(new Instruction(Instruction.UNIQ,uniqVars));
        }
 else {
          match.add(new Instruction(Instruction.NOT_UNIQ,uniqVars));
        }
        rc.theRule.hasUniq=true;
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        if (!GROUND_ALLOWED || typedCxtTypes.get(def1) == UNARY_ATOM_TYPE || typedCxtTypes.get(def2) == UNARY_ATOM_TYPE) {
          int atomid1=loadUnaryAtom(def1);
          int atomid2=loadUnaryAtom(def2);
          if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)           connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
          match.add(new Instruction(Instruction.ISUNARY,atomid1));
          match.add(new Instruction(Instruction.ISUNARY,atomid2));
          int funcid1=varCount++;
          int funcid2=varCount++;
          match.add(new Instruction(Instruction.GETFUNC,funcid1,atomid1));
          match.add(new Instruction(Instruction.GETFUNC,funcid2,atomid2));
          match.add(new Instruction(Instruction.NEQFUNC,funcid1,funcid2));
        }
 else {
          checkGroundLink(def1);
          checkGroundLink(def2);
          if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)           connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
          int linkid1=loadGroundLink(def1);
          int linkid2=loadGroundLink(def2);
          match.add(new Instruction(Instruction.NEQGROUND,linkid1,linkid2));
        }
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        int atomid2=loadUnaryAtom(def2);
        if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)         connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
        if (!new Integer(ISSTRING).equals(typedCxtDataTypes.get(def2))) {
          match.add(new Instruction(ISSTRING,atomid2));
          typedCxtDataTypes.put(def2,new Integer(ISSTRING));
        }
        int classnameAtomid=varCount++;
        match.add(new Instruction(Instruction.GETCLASS,classnameAtomid,atomid1));
        match.add(new Instruction(Instruction.SUBCLASS,classnameAtomid,atomid2));
      }
 else       if (func instanceof runtime.IntegerFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISINT));
      }
 else       if (func instanceof runtime.FloatingFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISFLOAT));
      }
 else       if (func instanceof runtime.StringFunctor) {
        bindToFunctor(def1,func);
        typedCxtDataTypes.put(def1,new Integer(ISSTRING));
      }
 else       if (cstr.isSelfEvaluated && func.getArity() == 1) {
        bindToFunctor(def1,func);
      }
 else       if (func.equals(Functor.UNIFY)) {
        if (!identifiedCxtdefs.contains(def2)) {
          ContextDef swaptmp=def1;
          def1=def2;
          def2=swaptmp;
          if (!identifiedCxtdefs.contains(def2))           continue;
        }
        if (GROUND_ALLOWED && typedCxtTypes.get(def2) != UNARY_ATOM_TYPE) {
          if (!identifiedCxtdefs.contains(def1))           continue;
        }
        processEquivalenceConstraint(def1,def2);
      }
 else       if (func.equals(new SymbolFunctor("String_Node_Str",2))) {
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        match.add(new Instruction(Instruction.ISUNARY,atomid1));
        int atomid2=loadUnaryAtom(def2);
        match.add(new Instruction(Instruction.ISUNARY,atomid2));
        match.add(new Instruction(Instruction.SAMEFUNC,atomid1,atomid2));
      }
 else       if (guardLibrary0.containsKey(func)) {
        int[] desc=guardLibrary0.get(func);
        int atomid=varCount++;
        match.add(new Instruction(desc[0],atomid));
        bindToUnaryAtom(def1,atomid);
        typedCxtDataTypes.put(def1,new Integer(desc[1]));
        if (identifiedCxtdefs.contains(def1)) {
          int funcid2=varCount++;
          match.add(new Instruction(Instruction.GETFUNC,funcid2,atomid));
          int atomid1=varCount++;
          match.add(new Instruction(Instruction.ALLOCATOMINDIRECT,atomid1,funcid2));
          typedCxtSrcs.put(def1,new Integer(atomid1));
          typedCxtDefs.add(def1);
          identifiedCxtdefs.add(def1);
          typedCxtTypes.put(def1,UNARY_ATOM_TYPE);
        }
      }
 else       if (guardLibrary1.containsKey(func)) {
        int[] desc=guardLibrary1.get(func);
        if (!identifiedCxtdefs.contains(def1))         continue;
        int atomid1=loadUnaryAtom(def1);
        if (desc[0] != 0 && !new Integer(desc[0]).equals(typedCxtDataTypes.get(def1))) {
          match.add(new Instruction(desc[0],atomid1));
          typedCxtDataTypes.put(def1,new Integer(desc[0]));
        }
        if (func.getArity() == 1) {
          if (desc.length > 1)           match.add(new Instruction(desc[1],atomid1));
        }
 else {
          int atomid2;
          if (desc[1] == -1) {
            atomid2=atomid1;
          }
 else {
            atomid2=varCount++;
            match.add(new Instruction(desc[1],atomid2,atomid1));
          }
          bindToUnaryAtom(def2,atomid2);
          typedCxtDataTypes.put(def2,new Integer(desc[2]));
        }
      }
 else       if (guardLibrary2.containsKey(func)) {
        int[] desc=guardLibrary2.get(func);
        if (!identifiedCxtdefs.contains(def1))         continue;
        if (!identifiedCxtdefs.contains(def2))         continue;
        int atomid1=loadUnaryAtom(def1);
        int atomid2=loadUnaryAtom(def2);
        if (Env.findatom2 && def1.lhsOcc != null && def2.lhsOcc != null)         connectAtoms(def1.lhsOcc.args[0].buddy.atom,def2.lhsOcc.args[0].buddy.atom);
        if (desc[0] != 0 && !new Integer(desc[0]).equals(typedCxtDataTypes.get(def1))) {
          match.add(new Instruction(desc[0],atomid1));
          typedCxtDataTypes.put(def1,new Integer(desc[0]));
        }
        if (desc[1] != 0 && !new Integer(desc[1]).equals(typedCxtDataTypes.get(def2))) {
          match.add(new Instruction(desc[1],atomid2));
          typedCxtDataTypes.put(def2,new Integer(desc[1]));
        }
        if (func.getArity() == 2) {
          match.add(new Instruction(desc[2],atomid1,atomid2));
        }
 else {
          int atomid3=varCount++;
          match.add(new Instruction(desc[2],atomid3,atomid1,atomid2));
          bindToUnaryAtom(def3,atomid3);
          typedCxtDataTypes.put(def3,new Integer(desc[3]));
        }
      }
 else {
        error("String_Node_Str" + cstr);
        discardTypeConstraint(cstr);
      }
      lit.remove();
      changed=true;
    }
    if (cstrs.isEmpty())     return;
  }
 while (changed);
  String text="String_Node_Str";
  for (ListIterator<Atom> lit=cstrs.listIterator(); lit.hasNext(); ) {
    Atom cstr=lit.next();
    discardTypeConstraint(cstr);
    if (text.length() > 0)     text+="String_Node_Str";
    text+=cstr.toStringAsTypeConstraint();
  }
  error("String_Node_Str" + text);
}