=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/sm1stackmachine.c,v retrieving revision 1.1.1.1 retrieving revision 1.7 diff -u -p -r1.1.1.1 -r1.7 --- OpenXM/src/kxx/sm1stackmachine.c 1999/10/08 02:12:13 1.1.1.1 +++ OpenXM/src/kxx/sm1stackmachine.c 2006/02/02 04:16:49 1.7 @@ -3,6 +3,9 @@ #include "ox_kan.h" #include "serversm.h" extern int OXprintMessage; +extern char *MsgStackTrace; +extern char *MsgSourceTrace; +extern struct object *MsgStackTraceInArrayp; /* server stack machine */ @@ -31,8 +34,8 @@ int Sm1_start(int argc, char *fnames[],char *myname) { for (i=0; i 1024) { - fprintf(stderr,"Too long name for sm1 library file to load.\n"); - exit(10); + fprintf(stderr,"Too long name for sm1 library file to load.\n"); + exit(10); } sprintf(cmd," [(parse) (%s) pushfile ] extension pop ",fnames[i]); KSexecuteString(cmd); @@ -57,8 +60,8 @@ int Sm1_setMathCap(ox_stream os) { /* Set the mathcap data of the client in the server. */ /* sm1 <====== ox_sm1 mathcap is set in ox_stream = FILE2 * */ /* The mathcap data is on the stack. */ - struct object ob; - struct object ob2; + struct object ob = OINIT; + struct object ob2 = OINIT; int n,i; ob = KSpop(); KSpush(ob); KSexecuteString(" (mathcap data is ) message message "); @@ -93,7 +96,7 @@ char *Sm1_popString(void) { int Sm1_setName(void) { char *s; - struct object ob; + struct object ob = OINIT; s = Sm1_popString(); if (s == NULL) { printf("NULL argument for setName.\n"); @@ -109,7 +112,7 @@ int Sm1_setName(void) int Sm1_evalName(void) { char *s; - struct object ob; + struct object ob = OINIT; s = Sm1_popString(); if (s == NULL) { printf("NULL argument for evalName.\n"); @@ -137,8 +140,65 @@ int Sm1_popCMO(ox_stream fp,int serial) int Sm1_pushError2(int serial, int no, char *s) { - struct object ob; - ob = KnewErrorPacket(serial,no,s); + struct object ob = OINIT; + struct object core = OINIT; + struct object core1 = OINIT; + char *ss; + + ss = (char *)sGC_malloc(strlen(s)+1); + strcpy(ss,s); + /* + char *error_message=""; + char *message=""; + char *stack_trace=""; + char *source_trace=""; + char *error_message2=""; + char *message2=""; + char *stack_trace2=""; + char *source_trace2=""; + ss = (char *) sGC_malloc(strlen(s)+strlen(MsgStackTrace)+ + strlen(MsgSourceTrace)+ + strlen(error_message)+strlen(error_message2)+ + strlen(message)+strlen(message2)+ + strlen(stack_trace)+strlen(stack_trace2)+ + strlen(source_trace)+strlen(source_trace2)+2); + + strcat(ss,error_message); + strcat(ss,message); + strcat(ss,s); + strcat(ss,message2); + if (MsgStackTrace != NULL) { + strcat(ss,stack_trace); + strcat(ss,MsgStackTrace); + strcat(ss,stack_trace2); + } + if (MsgSourceTrace != NULL) { + strcat(ss,source_trace); + strcat(ss,MsgSourceTrace); + strcat(ss,source_trace2); + } + strcat(ss,error_message2); + */ + + if (MsgStackTraceInArrayp != NULL) { + core = KSnewObjectArray(2); + core1 = KSnewObjectArray(2); + putoa(core1,0,KpoString("where")); /* keyword */ + putoa(core1,1,(*MsgStackTraceInArrayp)); + putoa(core,0,core1); + core1 = KSnewObjectArray(2); + putoa(core1,0,KpoString("reason_of_error")); /* keyword */ + putoa(core1,1,KpoString(s)); + putoa(core,1,core1); + }else{ + core = KSnewObjectArray(0); + } + ob = KSnewObjectArray(4); + putoa(ob,0,KpoInteger(serial)); putoa(ob,1,KpoInteger(no)); + putoa(ob,2,KpoString(ss)); + putoa(ob,3,core); + + ob = KnewErrorPacketObj(ob); KSpush(ob); } @@ -176,5 +236,16 @@ void Sm1_dupErrors(void) { KSpush(KSdupErrors()); } +void Sm1_pushCMOtag(int serial) { + struct object obj = OINIT; + int t; + obj = KSpeek(0); + t = KgetCmoTagOfObject(obj); + if (t != -1) { + KSpush(KpoInteger(t)); + }else{ + Sm1_pushError2(serial,-1,"The top object on the server stack cannot be translated to cmo."); + } +}