=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/primitive.c,v retrieving revision 1.4 retrieving revision 1.14 diff -u -p -r1.4 -r1.14 --- OpenXM/src/kan96xx/Kan/primitive.c 2001/05/04 01:06:25 1.4 +++ OpenXM/src/kan96xx/Kan/primitive.c 2004/09/12 08:55:36 1.14 @@ -1,8 +1,9 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.3 2000/02/24 12:33:47 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.13 2004/09/12 02:37:57 takayama Exp $ */ /* primitive.c */ /* The functions in this module were in stackmachine.c */ #include +#include #include "datatype.h" #include "stackm.h" #include "extern.h" @@ -13,6 +14,7 @@ int PrintDollar = 1; /* flag for printObject() */ int PrintComma = 1; /* flag for printObject() */ +int InSendmsg2 = 0; #define OB_ARRAY_MAX (AGLIMIT+100) extern int GotoP; @@ -23,6 +25,7 @@ extern int ClassTypes[]; /* kclass.c */ extern struct context *PrimitiveContextp; extern struct context *CurrentContextp; extern struct dictionary *SystemDictionary; +extern int QuoteMode; static char *operatorType(int i); @@ -120,6 +123,8 @@ static char *operatorType(type) #define Ssupmsg2 98 #define Scclass 99 #define Scoeff2 100 +#define Stlimit 101 +#define Soxshell 102 /***********************************************/ void printObject(ob,nl,fp) struct object ob; @@ -372,6 +377,8 @@ void KdefinePrimitiveFunctions() { putPrimitiveFunction("system",Ssystem); putPrimitiveFunction("system_variable",Ssystem_variable); putPrimitiveFunction("test",Stest); + putPrimitiveFunction("tlimit",Stlimit); + putPrimitiveFunction("oxshell",Soxshell); putPrimitiveFunction("map",Smap); putPrimitiveFunction("to_records",Sto_records); putPrimitiveFunction("Usage",Susage); @@ -417,6 +424,8 @@ int executePrimitive(ob) int size; int i,j,k,n; int status; + int infixOn; + struct tokens infixToken; struct tokens *tokenArray; struct tokens token; FILE *fp; @@ -435,6 +444,8 @@ int executePrimitive(ob) extern TimerOn; extern SecureMode; + infixOn = 0; + if (DebugStack >= 2) { fprintf(Fstack,"In execute %d\n",ob.lc.ival); printOperandStack(); } @@ -589,21 +600,7 @@ int executePrimitive(ob) /* ob2 ob1 get */ ob1 = Kpop(); ob2 = Kpop(); - switch(ob2.tag) { - case Sarray: break; - default: errorStackmachine("Usage:get"); - } - switch(ob1.tag) { - case Sinteger: break; - default: errorStackmachine("Usage:get"); - } - i =ob1.lc.ival; - size = getoaSize(ob2); - if ((0 <= i) && (i= size) { - i=0; - } - status = executeToken(token); - if (status || GotoP) break; + status = executeExecutableArray(ob1,(char *)NULL); + if ((status & STATUS_BREAK) || GotoP) break; /* here, do not return 1. Do not propagate exit signal outside of the loop. */ } @@ -796,25 +784,17 @@ int executePrimitive(ob) */ for ( ; i<=lim; i += inc) { Kpush(KpoInteger(i)); - tokenArray = ob1.lc.tokenArray; - size = ob1.rc.ival; - for (j=0; j i) errorStackmachine("The initial value must not be less than limit value (for).\n"); */ for ( ; i>=lim; i += inc) { Kpush(KpoInteger(i)); - tokenArray = ob1.lc.tokenArray; - size = ob1.rc.ival; - for (j=0; j 0) { + if (getoa(ob2,getoaSize(ob2)-1).tag == Spoly) { + Kpush(oInitW(ob2,newObjectArray(0))); + }else{ + ob1 = Kpop(); + Kpush(oInitW(ob1,ob2)); + } + }else{ + ob1 = Kpop(); + Kpush(oInitW(ob1,ob2)); + } } break; @@ -1493,17 +1467,12 @@ int executePrimitive(ob) } /* normal exec. */ Kpush(ob2); - tokenArray = ob1.lc.tokenArray; - size = ob1.rc.ival; - for (i=0; icontextName)); + } + putoa(qattr,0,qattr2); + putoa(qob,1,qattr); + putoa(qob,2,ob4); /* Argument */ + qob = KpoTree(qob); + Kpush(qob); + } else if (status & STATUS_BREAK) break; + } if (ccflag) { contextControl(CCPOP); ccflag = 0; @@ -1565,14 +1579,7 @@ int executePrimitive(ob) contextControl(CCPUSH); ccflag = 1; CurrentContextp = PrimitiveContextp; /* normal exec. */ - tokenArray = ob1.lc.tokenArray; - size = ob1.rc.ival; - for (i=0; i 0) { + signal(SIGALRM,ctrlC); alarm((unsigned int) n); + status = executeExecutableArray(ob1,(char *)NULL); + cancelAlarm(); + }else{ + before_real = time(&before_real); + times(&before); + status = executeExecutableArray(ob1,(char *)NULL); + times(&after); + after_real = time(&after_real); + ob1 = newObjectArray(3); + putoa(ob1,0,KpoInteger((int) after.tms_utime - before.tms_utime)); + putoa(ob1,1,KpoInteger((int) after.tms_stime - before.tms_stime)); + putoa(ob1,2,KpoInteger((int) (after_real-before_real))); + Kpush(ob1); + } + break; default: