=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/primitive.c,v retrieving revision 1.9 retrieving revision 1.18 diff -u -p -r1.9 -r1.18 --- OpenXM/src/kan96xx/Kan/primitive.c 2003/12/03 01:21:43 1.9 +++ OpenXM/src/kan96xx/Kan/primitive.c 2004/09/17 02:42:57 1.18 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.8 2003/11/20 09:20:36 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.17 2004/09/16 02:22:03 takayama Exp $ */ /* primitive.c */ /* The functions in this module were in stackmachine.c */ @@ -14,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; @@ -39,6 +40,9 @@ static char *operatorType(type) return("Unknown operator"); } +#define evalEA(ob1) if (ob1.tag == SexecutableArray) {\ + executeExecutableArray(ob1,(char *)NULL,0); ob1 = Kpop();} + /****** primitive functions ***************************************** the values must be greater than 1. 0 is used for special purposes.*/ #define Sadd 1 @@ -423,6 +427,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; @@ -440,11 +446,26 @@ int executePrimitive(ob) extern struct ring *CurrentRingp; extern TimerOn; extern SecureMode; + extern int RestrictedMode; + infixOn = 0; + if (DebugStack >= 2) { fprintf(Fstack,"In execute %d\n",ob.lc.ival); printOperandStack(); } + if (RestrictedMode) { + switch(ob.lc.ival) { + case SleftBrace: + case SrightBrace: + case Sexec: + break; + default: + fprintf(stderr,"primitive No = %d : ", ob.lc.ival); + errorStackmachine("You cannot use this primitive in the RestrictedMode.\n"); + } + } + if (GotoP) return(0); switch (ob.lc.ival) { /* Postscript primitives :stack */ @@ -535,31 +556,36 @@ int executePrimitive(ob) /* Postscript primitives :arithmetic */ case Sadd: - ob1 = Kpop(); + ob1 = Kpop(); ob2 = Kpop(); + evalEA(ob1); evalEA(ob2); rob = KooAdd(ob1,ob2); Kpush(rob); break; case Ssub: ob2 = Kpop(); ob1 = Kpop(); + evalEA(ob1); evalEA(ob2); rob = KooSub(ob1,ob2); Kpush(rob); break; case Smult: ob2 = Kpop(); ob1 = Kpop(); + evalEA(ob1); evalEA(ob2); rob = KooMult(ob1,ob2); Kpush(rob); break; case Sidiv: ob2 = Kpop(); ob1 = Kpop(); + evalEA(ob1); evalEA(ob2); rob = KooDiv(ob1,ob2); Kpush(rob); break; case Sdiv: ob2 = Kpop(); ob1 = Kpop(); + evalEA(ob1); evalEA(ob2); rob = KooDiv2(ob1,ob2); Kpush(rob); break; @@ -595,21 +621,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,1); + if ((status & STATUS_BREAK) || GotoP) break; /* here, do not return 1. Do not propagate exit signal outside of the loop. */ } @@ -802,25 +808,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; jcontextName)); } putoa(qattr,0,qattr2); @@ -1588,7 +1582,8 @@ int executePrimitive(ob) putoa(qob,2,ob4); /* Argument */ qob = KpoTree(qob); Kpush(qob); - } else if (status != 0) break; + } else if (status & STATUS_BREAK) break; + } if (ccflag) { contextControl(CCPOP); ccflag = 0; @@ -1608,14 +1603,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); - for (i=0; i