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

Diff for /OpenXM/src/kan96xx/Kan/Kclass/tree.c between version 1.3 and 1.9

version 1.3, 2003/11/24 06:50:16 version 1.9, 2020/10/06 11:33:47
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/tree.c,v 1.2 2003/11/24 02:13:40 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/tree.c,v 1.8 2005/06/16 05:07:24 takayama Exp $ */
 #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 11  struct object KpoTree(struct object ob) {
Line 12  struct object KpoTree(struct object ob) {
   
 /* Data conversion function : see KclassDataConversion*/  /* Data conversion function : see KclassDataConversion*/
 struct object KpoTree(struct object ob) {  struct object KpoTree(struct object ob) {
   struct object rob;    struct object rob = OINIT;
   struct object ob1,ob2,ob3;    struct object ob1 = OINIT;
     struct object ob2 = OINIT;
     struct object ob3 = OINIT;
   struct object *newobp;    struct object *newobp;
   rob.tag = Sclass;    rob.tag = Sclass;
   rob.lc.ival = CLASSNAME_tree;    rob.lc.ival = CLASSNAME_tree;
Line 41  int isTreeAdd(struct object ob) {
Line 44  int isTreeAdd(struct object ob) {
 }  }
   
 int isTreeAdd(struct object ob) {  int isTreeAdd(struct object ob) {
   struct object name;    struct object name = OINIT;
   if (ob.tag != Sclass) {    if (ob.tag != Sclass) {
     return(0);      return(0);
   }    }
Line 56  int isTreeAdd(struct object ob) {
Line 59  int isTreeAdd(struct object ob) {
   if (name.tag != Sdollar) {    if (name.tag != Sdollar) {
     errorKan1("%s\n","CLASSNAME_tree is broken. Should be string.");      errorKan1("%s\n","CLASSNAME_tree is broken. Should be string.");
   }    }
   if (strcmp(KopString(name),"add") == 0) {    if (strcmp(KopString(name),"plus") == 0) {
     return(1);      return(1);
   }else{    }else{
     return(0);      return(0);
Line 65  struct object addTree(struct object ob1, struct object
Line 68  struct object addTree(struct object ob1, struct object
   
 struct object addTree(struct object ob1, struct object ob2)  struct object addTree(struct object ob1, struct object ob2)
 {  {
   struct object rob,aob;    struct object rob = OINIT;
   struct object ob3,ob4;    struct object aob = OINIT;
     struct object ob3 = OINIT;
     struct object ob4 = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   int i;    int i;
     to = ob2; ob2=ob1; ob1=to; /* Exchange ob1 and ob2 */
   if (isTreeAdd(ob1) && !isTreeAdd(ob2)) {    if (isTreeAdd(ob1) && !isTreeAdd(ob2)) {
     ob1 = KopTree(ob1);      ob1 = KopTree(ob1);
     ob3 = getoa(ob1,2);      ob3 = getoa(ob1,2);
Line 101  struct object addTree(struct object ob1, struct object
Line 110  struct object addTree(struct object ob1, struct object
     putoa(aob,0,ob1);      putoa(aob,0,ob1);
     putoa(aob,1,ob2);      putoa(aob,1,ob2);
   }    }
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
   rob = newObjectArray(3);    rob = newObjectArray(3);
   putoa(rob,0,KpoString("add"));    putoa(rob,0,KpoString("plus"));
   putoa(rob,1,KpoString("basic"));    putoa(rob,1,attr);
   putoa(rob,2,aob);    putoa(rob,2,aob);
   return(KpoTree(rob));    return(KpoTree(rob));
 }  }
   struct object minusTree(struct object ob1,struct object ob2) {
     struct object rob = OINIT;
     struct object aob = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   
     rob = NullObject;
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     aob = newObjectArray(2);
     putoa(aob,0,ob1);
     putoa(aob,1,ob2);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
     rob = newObjectArray(3);
     putoa(rob,0,KpoString("minus"));
     putoa(rob,1,attr);
     putoa(rob,2,aob);
     return(KpoTree(rob));
     return(rob);
   }
   struct object timesTree(struct object ob1,struct object ob2) {
     struct object rob = OINIT;
     struct object aob = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   
     rob = NullObject;
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     aob = newObjectArray(2);
     putoa(aob,0,ob1);
     putoa(aob,1,ob2);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
     rob = newObjectArray(3);
     putoa(rob,0,KpoString("times"));
     putoa(rob,1,attr);
     putoa(rob,2,aob);
     return(KpoTree(rob));
     return(rob);
   }
   struct object divideTree(struct object ob1,struct object ob2) {
     struct object rob = OINIT;
     struct object aob = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   
     rob = NullObject;
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     aob = newObjectArray(2);
     putoa(aob,0,ob1);
     putoa(aob,1,ob2);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
     rob = newObjectArray(3);
     putoa(rob,0,KpoString("divide"));
     putoa(rob,1,attr);
     putoa(rob,2,aob);
     return(KpoTree(rob));
     return(rob);
   }
   struct object powerTree(struct object ob1,struct object ob2) {
     struct object rob = OINIT;
     struct object aob = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   
     rob = NullObject;
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     aob = newObjectArray(2);
     putoa(aob,0,ob1);
     putoa(aob,1,ob2);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
     rob = newObjectArray(3);
     putoa(rob,0,KpoString("power"));
     putoa(rob,1,attr);
     putoa(rob,2,aob);
     return(KpoTree(rob));
     return(rob);
   }
   struct object unaryminusTree(struct object ob1) {
     struct object rob = OINIT;
     struct object aob = OINIT;
     struct object attr = OINIT;
     struct object keyValue = OINIT;
     struct object to = OINIT;
   
     rob = NullObject;
     attr = newObjectArray(1);
     keyValue = newObjectArray(2);
     aob = newObjectArray(1);
     putoa(aob,0,ob1);
     putoa(keyValue,0,KpoString("cd"));
     putoa(keyValue,1,KpoString("arith1"));
     putoa(attr,0,keyValue);
     rob = newObjectArray(3);
     putoa(rob,0,KpoString("unaryminus"));
     putoa(rob,1,attr);
     putoa(rob,2,aob);
     return(KpoTree(rob));
     return(rob);
   }
   
 /* XML DOM-like interfaces */  /* XML DOM-like interfaces */
 struct object KtreeGetDocumentElement(struct object to) {  struct object KtreeGetDocumentElement(struct object to) {
   struct object rob;    struct object rob = OINIT;
   struct object ob;    struct object ob = OINIT;
   if (to.tag != Sclass) errorKan1("%s\n","KtreeGetDocumentElement");    if (to.tag != Sclass) errorKan1("%s\n","KtreeGetDocumentElement");
   if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetDocumentElement");    if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetDocumentElement");
   ob = KopTree(to);    ob = KopTree(to);
   if (ob.tag != Sdollar) errorKan1("%s\n","KtreeGetDocumentElement: element name is not a string.");    if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetDocumentElement: not an array.");
   return getoa(ob,0);    if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetDocumentElement: array is broken.");
     ob=getoa(ob,0);
     if (ob.tag != Sdollar) errorKan1("%s\n","KtreeGetDocumentElement: element must be a string");
     return ob;
 }  }
   
 struct object KtreeGetAttributes(struct object to) {  struct object KtreeGetAttributes(struct object to) {
   struct object rob;    struct object rob = OINIT;
   struct object ob;    struct object ob = OINIT;
   if (to.tag != Sclass) errorKan1("%s\n","KtreeGetAttributes:");    if (to.tag != Sclass) errorKan1("%s\n","KtreeGetAttributes:");
   if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetAttributes:");    if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetAttributes:");
   ob = KopTree(to);    ob = KopTree(to);
   if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetAttributes: not an array.");    if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetAttributes: not an array.");
     if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetAttributes: array is broken.");
   return getoa(ob,1);    return getoa(ob,1);
 }  }
   
 struct object KtreeGetChildNodes(struct object to) {  struct object KtreeGetChildNodes(struct object to) {
   struct object rob;    struct object rob = OINIT;
   struct object ob;    struct object ob = OINIT;
   if (to.tag != Sclass) errorKan1("%s\n","KtreeGetChildNodes:");    if (to.tag != Sclass) errorKan1("%s\n","KtreeGetChildNodes:");
   if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetChildNodes:");    if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetChildNodes:");
   ob = KopTree(to);    ob = KopTree(to);
   if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetChildNodes: not an array.");    if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetChildNodes: not an array.");
     if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetChildNodes: array is broken.");
   return getoa(ob,2);    return getoa(ob,2);
 }  }
   
 struct object KtreeCreateElement(struct object ostr) {  struct object KtreeCreateElement(struct object ostr) {
   struct object ob;    struct object ob = OINIT;
   if (ostr.tag != Sdollar) errorKan1("%s\n","KtreeCreateElement: not a string.");    if (ostr.tag != Sdollar) errorKan1("%s\n","KtreeCreateElement: not a string.");
   ob = newObjectArray(3);    ob = newObjectArray(3);
   getoa(ob,0)=ostr;    getoa(ob,0)=ostr;

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

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