version 1.6, 2003/12/05 23:14:14 |
version 1.9, 2020/10/06 11:33:47 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/tree.c,v 1.5 2003/12/05 13:51:32 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" |
|
|
|
|
/* 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 void fprintTree(FILE *fp,struct object op) |
|
Line 44 void fprintTree(FILE *fp,struct object op) |
|
} |
} |
|
|
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 65 int isTreeAdd(struct object ob) { |
|
Line 68 int isTreeAdd(struct object ob) { |
|
|
|
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 attr; |
struct object ob3 = OINIT; |
struct object keyValue; |
struct object ob4 = OINIT; |
struct object to; |
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 */ |
to = ob2; ob2=ob1; ob1=to; /* Exchange ob1 and ob2 */ |
if (isTreeAdd(ob1) && !isTreeAdd(ob2)) { |
if (isTreeAdd(ob1) && !isTreeAdd(ob2)) { |
Line 116 struct object addTree(struct object ob1, struct object |
|
Line 121 struct object addTree(struct object ob1, struct object |
|
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); |
Line 132 struct object KtreeGetDocumentElement(struct object to |
|
Line 251 struct object KtreeGetDocumentElement(struct object to |
|
} |
} |
|
|
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); |
Line 143 struct object KtreeGetAttributes(struct object to) { |
|
Line 262 struct object KtreeGetAttributes(struct object to) { |
|
} |
} |
|
|
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); |
Line 154 struct object KtreeGetChildNodes(struct object to) { |
|
Line 273 struct object KtreeGetChildNodes(struct object to) { |
|
} |
} |
|
|
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; |