[BACK]Return to kclass.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Diff for /OpenXM/src/kan96xx/Kan/kclass.c between version 1.3 and 1.7

version 1.3, 2001/04/12 06:48:26 version 1.7, 2020/10/06 11:33:46
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/kclass.c,v 1.2 2000/01/16 07:55:39 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/kclass.c,v 1.6 2006/01/30 10:38:36 takayama Exp $ */
 /* kclass.c,  1997, 3/1  /* kclass.c,  1997, 3/1
    This module handles class data base.     This module handles class data base.
    This is a top level and provides an interface for sm1 for Sclass objects.     This is a top level and provides an interface for sm1 for Sclass objects.
    Main processing is done in Kclass/*     Main processing is done in Kclass/*
    See, Kclass/sample.h, Kclass/sample.c  ;                                        See, Kclass/sample.h, Kclass/sample.c  ;
    grep the keyword CLASSNAME_sampleClass                                        grep the keyword CLASSNAME_sampleClass
 */  */
 #include <stdio.h>  #include <stdio.h>
   #include <string.h>
 #include "datatype.h"  #include "datatype.h"
 #include "stackm.h"  #include "stackm.h"
 #include "extern.h"  #include "extern.h"
Line 21  struct object * ClassDictionaries[CLASSTABLE_SIZE];
Line 22  struct object * ClassDictionaries[CLASSTABLE_SIZE];
 char *ClassNames[CLASSTABLE_SIZE];  char *ClassNames[CLASSTABLE_SIZE];
 int ClassTypes[CLASSTABLE_SIZE];  int ClassTypes[CLASSTABLE_SIZE];
   
 initClassDataBase() {  void initClassDataBase() {
   int i;    int i;
   for (i=0; i<CLASSTABLE_SIZE; i++) {    for (i=0; i<CLASSTABLE_SIZE; i++) {
     ClassTypes[i] = CLASS_NOT_USED;      ClassTypes[i] = CLASS_NOT_USED;
Line 30  initClassDataBase() {
Line 31  initClassDataBase() {
   ClassTypes[CLASSNAME_OPERANDSTACK] = CLASS_INTERNAL;    ClassTypes[CLASSNAME_OPERANDSTACK] = CLASS_INTERNAL;
   ClassNames[CLASSNAME_OPERANDSTACK] = "Class.OperandStack";    ClassNames[CLASSNAME_OPERANDSTACK] = "Class.OperandStack";
   ClassDictionaries[CLASSNAME_OPERANDSTACK] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_OPERANDSTACK] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_ERROR_PACKET] = CLASS_OBJ;    ClassTypes[CLASSNAME_ERROR_PACKET] = CLASS_OBJ;
   ClassNames[CLASSNAME_ERROR_PACKET] = "Class.ErrorPacket";    ClassNames[CLASSNAME_ERROR_PACKET] = "Class.ErrorPacket";
   ClassDictionaries[CLASSNAME_ERROR_PACKET] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_ERROR_PACKET] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_CONTEXT] = CLASS_INTERNAL;    ClassTypes[CLASSNAME_CONTEXT] = CLASS_INTERNAL;
   ClassNames[CLASSNAME_CONTEXT] = "Class.Context";    ClassNames[CLASSNAME_CONTEXT] = "Class.Context";
   ClassDictionaries[CLASSNAME_CONTEXT] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_CONTEXT] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_GradedPolySet] = CLASS_INTERNAL;    ClassTypes[CLASSNAME_GradedPolySet] = CLASS_INTERNAL;
   ClassNames[CLASSNAME_GradedPolySet] = "Class.GradedPolySet";    ClassNames[CLASSNAME_GradedPolySet] = "Class.GradedPolySet";
   ClassDictionaries[CLASSNAME_GradedPolySet] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_GradedPolySet] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_mathcap] = CLASS_OBJ;    ClassTypes[CLASSNAME_mathcap] = CLASS_OBJ;
   ClassNames[CLASSNAME_mathcap] = "Class.mathcap";    ClassNames[CLASSNAME_mathcap] = "Class.mathcap";
   ClassDictionaries[CLASSNAME_mathcap] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_mathcap] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_CMO] = CLASS_OBJ;    ClassTypes[CLASSNAME_CMO] = CLASS_OBJ;
   ClassNames[CLASSNAME_CMO] = "Class.CMO";    ClassNames[CLASSNAME_CMO] = "Class.CMO";
   ClassDictionaries[CLASSNAME_CMO] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_CMO] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
   ClassTypes[CLASSNAME_indeterminate] = CLASS_OBJ;    ClassTypes[CLASSNAME_indeterminate] = CLASS_OBJ;
   ClassNames[CLASSNAME_indeterminate] = "Class.indeterminate";    ClassNames[CLASSNAME_indeterminate] = "Class.indeterminate";
Line 76  initClassDataBase() {
Line 77  initClassDataBase() {
   ClassTypes[CLASSNAME_sampleClass] = CLASS_OBJ;    ClassTypes[CLASSNAME_sampleClass] = CLASS_OBJ;
   ClassNames[CLASSNAME_sampleClass] = "Class.sampleClass";    ClassNames[CLASSNAME_sampleClass] = "Class.sampleClass";
   ClassDictionaries[CLASSNAME_sampleClass] = (struct object *)NULL;    ClassDictionaries[CLASSNAME_sampleClass] = (struct object *)NULL;
                            /* We have to creat new dictionary in a future. */    /* We have to creat new dictionary in a future. */
   
 }  }
   
Line 141  int KclassEqualQ(struct object ob1,struct object ob2) 
Line 142  int KclassEqualQ(struct object ob1,struct object ob2) 
     return(eqSampleClass(KopSampleClass(ob1),KopSampleClass(ob2)));      return(eqSampleClass(KopSampleClass(ob1),KopSampleClass(ob2)));
     break;      break;
   case CLASSNAME_indeterminate:    case CLASSNAME_indeterminate:
         return(KooEqualQ(KopIndeterminate(ob1),KopIndeterminate(ob2)));      return(KooEqualQ(KopIndeterminate(ob1),KopIndeterminate(ob2)));
         break;      break;
   default:    default:
     errorKan1("%s\n","kclass.c (KclassEqualQ cannot compare these objects.)");      errorKan1("%s\n","kclass.c (KclassEqualQ cannot compare these objects.)");
     break;      break;
Line 160  void fprintMathCap(FILE *fp,struct object *op)
Line 161  void fprintMathCap(FILE *fp,struct object *op)
 }  }
   
 struct object KpoMathCap(struct object *obp) {  struct object KpoMathCap(struct object *obp) {
   struct object rob;    struct object rob = OINIT;
   struct object *newobp;    struct object *newobp;
   
   newobp = (struct object *) sGC_malloc(sizeof(struct object));    newobp = (struct object *) sGC_malloc(sizeof(struct object));
Line 185  struct object KclassDataConversion(struct object ob1,s
Line 186  struct object KclassDataConversion(struct object ob1,s
       ob1(with class tag) [(class) (class-name)]  dc  :  method=2        ob1(with class tag) [(class) (class-name)]  dc  :  method=2
       ob1(with class tag) (usual flag)            dc  :  method=3        ob1(with class tag) (usual flag)            dc  :  method=3
       It also create a new class object.        It also create a new class object.
         ob1 (error) dc --> ErrorObject with the contents ob1
   
         ob1(with class tag) (body) dc --> [left tag, right body of ob1.]
   */    */
   struct object rob = NullObject;    struct object rob = NullObject;
   int method ;    int method ;
   struct object ff0;    struct object ff0 = OINIT;
   struct object ff1;    struct object ff1 = OINIT;
   struct object ob3;  /* for work.*/    struct object ob3 = OINIT;  /* for work.*/
   struct object ob4;    struct object ob4 = OINIT;
   char *ccc;    char *ccc;
   char *key;    char *key;
   
Line 231  struct object KclassDataConversion(struct object ob1,s
Line 235  struct object KclassDataConversion(struct object ob1,s
       rob = KpoIndeterminate(ob1);        rob = KpoIndeterminate(ob1);
     }else if (strcmp(ccc,"mathcap") == 0) {      }else if (strcmp(ccc,"mathcap") == 0) {
       /* You should check ob1 contains mathcap data or not.        /* You should check ob1 contains mathcap data or not.
          I've not yet written them.           I've not yet written them.
       */        */
       rob = KpoMathCap(&ob1);        rob = KpoMathCap(&ob1);
     }else if (strcmp(ccc,"tree") == 0) {      }else if (strcmp(ccc,"tree") == 0) {
Line 256  struct object KclassDataConversion(struct object ob1,s
Line 260  struct object KclassDataConversion(struct object ob1,s
     switch(ectag(ob1)) {      switch(ectag(ob1)) {
     case CLASSNAME_sampleClass:      case CLASSNAME_sampleClass:
       if (strcmp(ccc,"sampleClass") == 0) {        if (strcmp(ccc,"sampleClass") == 0) {
         rob = KpoSampleClass(&ob1);          rob = KpoSampleClass(&ob1);
       }else{        }else{
         errorKan1("%s\n","KclassDataCOnversion: this type of data conversion from class object to class object is not supported.");          errorKan1("%s\n","KclassDataCOnversion: this type of data conversion from class object to class object is not supported.");
       }        }
       break;        break;
     default:      default:
         errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object to class object is not supported.");        errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object to class object is not supported.");
     }      }
     break;      break;
   case 3:    case 3:
     key = KopString(ob2);  /* target data type */      key = KopString(ob2);  /* target data type */
     if (key[0] == 't' || key[0] =='e') {      if (key[0] == 't' || key[0] =='e') {
       if (strcmp(key,"type?")==0) {        if (strcmp(key,"type?")==0) {
         rob = KpoInteger(ob1.tag);          rob = KpoInteger(ob1.tag);
         return(rob);          return(rob);
       }else if (strcmp(key,"type??")==0) {        }else if (strcmp(key,"type??")==0) {
         if (ob1.tag != Sclass) {          if (ob1.tag != Sclass) {
           rob = KpoInteger(ob1.tag);            rob = KpoInteger(ob1.tag);
         }else {          }else {
           rob = KpoInteger(ectag(ob1));            rob = KpoInteger(ectag(ob1));
         }          }
         return(rob);          return(rob);
       }else if (strcmp(key,"error")==0) {        }else if (strcmp(key,"error")==0) {
         rob = KnewErrorPacketObj(ob1);          rob = KnewErrorPacketObj(ob1);
         return(rob);          return(rob);
       }        }
       }else if (key[0] == 'b') {
         if (strcmp(key,"body") == 0) {
           rob = newObjectArray(2);
           putoa(rob,0,KpoInteger(ectag(ob1)));
           putoa(rob,1,*((struct object *)(ecbody(ob1))));
           return rob;
         }
     }      }
   
     /* Class object to primtive Object */      /* Class object to primtive Object */
     switch(ectag(ob1)) {      switch(ectag(ob1)) {
     case CLASSNAME_sampleClass:      case CLASSNAME_sampleClass:
       if (strcmp(key,"array") == 0) {        if (strcmp(key,"array") == 0) {
         rob = *(KopSampleClass(ob1));          rob = *(KopSampleClass(ob1));
       }else{        }else{
         errorKan1("%s\n","KclassDataCOnversion: this type of data conversion from class object to primitive object is not supported.");          errorKan1("%s\n","KclassDataCOnversion: this type of data conversion from class object to primitive object is not supported.");
       }        }
       break;        break;
     case CLASSNAME_mathcap:      case CLASSNAME_mathcap:
       if (strcmp(key,"array") == 0) {        if (strcmp(key,"array") == 0) {
         rob = newObjectArray(2);          rob = newObjectArray(2);
         ob3 = KpoString("mathcap-object");          ob3 = KpoString("mathcap-object");
         putoa(rob,0,ob3);          putoa(rob,0,ob3);
         putoa(rob,1,*(KopMathCap(ob1)));          putoa(rob,1,*(KopMathCap(ob1)));
       }else{        }else{
         errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object mathcap to primitive object is not supported.");          errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object mathcap to primitive object is not supported.");
       }        }
       break;        break;
     case CLASSNAME_indeterminate:      case CLASSNAME_indeterminate:
       if (strcmp(key,"string") == 0) {        if (strcmp(key,"string") == 0) {
         rob = KopIndeterminate(ob1);          rob = KopIndeterminate(ob1);
       }else {        }else {
         errorKan1("%s\n","KclassDataConversion: interminate-->?? is not supported..");          errorKan1("%s\n","KclassDataConversion: interminate-->?? is not supported..");
       }        }
       break;        break;
     case CLASSNAME_tree:      case CLASSNAME_tree:
       if (strcmp(key,"array") == 0) {        if (strcmp(key,"array") == 0) {
         rob = KopTree(ob1);          rob = KopTree(ob1);
       }else {        }else {
         errorKan1("%s\n","KclassDataConversion: tree-->?? is not supported..");          errorKan1("%s\n","KclassDataConversion: tree-->?? is not supported..");
       }        }
       break;        break;
     case CLASSNAME_recursivePolynomial:      case CLASSNAME_recursivePolynomial:
       if (strcmp(key,"string") == 0) {        if (strcmp(key,"string") == 0) {
         errorKan1("%s\n","Translation of recursive polynomial to a string should be implemented.");          errorKan1("%s\n","Translation of recursive polynomial to a string should be implemented.");
       }else if (strcmp(key,"poly") == 0) {        }else if (strcmp(key,"poly") == 0) {
         rob = recursivePolyToPoly(ob1);          rob = recursivePolyToPoly(ob1);
       }else if (strcmp(key,"array") == 0) {        }else if (strcmp(key,"array") == 0) {
         rob = KopRecursivePolynomial(ob1);          rob = KopRecursivePolynomial(ob1);
       }else {        }else {
         errorKan1("%s\n","KclassDataConversion: recursivePoly-->?? is not supported..");          errorKan1("%s\n","KclassDataConversion: recursivePoly-->?? is not supported..");
       }        }
       break;        break;
     default:      default:
         errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object to primitive object is not supported.");        errorKan1("%s\n","KclassDataConversion: this type of data conversion from class object to primitive object is not supported.");
     }      }
     break;      break;
   }    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>