| version 1.8, 2001/12/19 23:39:53 |
version 1.14, 2003/12/05 13:51:31 |
|
|
| /* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.7 2001/05/04 01:06:25 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.13 2003/11/20 09:20:36 takayama Exp $ */ |
| /* stackmachin.c */ |
/* stackmachin.c */ |
| |
|
| #include <stdio.h> |
#include <stdio.h> |
| Line 74 static void pstack(void); |
|
| Line 74 static void pstack(void); |
|
| static struct object executableStringToExecutableArray(char *str); |
static struct object executableStringToExecutableArray(char *str); |
| |
|
| extern int SerialCurrent; |
extern int SerialCurrent; |
| |
extern int QuoteMode; |
| |
|
| int SGClock = 0; |
int SGClock = 0; |
| int UserCtrlC = 0; |
int UserCtrlC = 0; |
| Line 733 void scanner() { |
|
| Line 734 void scanner() { |
|
| char *tmp2; |
char *tmp2; |
| extern int ErrorMessageMode; |
extern int ErrorMessageMode; |
| int jval; |
int jval; |
| |
extern int InSendmsg2; |
| getokenSM(INIT); |
getokenSM(INIT); |
| initSystemDictionary(); |
initSystemDictionary(); |
| |
|
| |
#if defined(__CYGWIN__) |
| |
if (sigsetjmp(EnvOfStackMachine,1)) { |
| |
#else |
| if (setjmp(EnvOfStackMachine)) { |
if (setjmp(EnvOfStackMachine)) { |
| |
#endif |
| /* do nothing in the case of error */ |
/* do nothing in the case of error */ |
| fprintf(stderr,"An error or interrupt in reading macros, files and command strings.\n"); |
fprintf(stderr,"An error or interrupt in reading macros, files and command strings.\n"); |
| exit(10); |
exit(10); |
| Line 796 void scanner() { |
|
| Line 802 void scanner() { |
|
| |
|
| |
|
| for (;;) { |
for (;;) { |
| |
#if defined(__CYGWIN__) |
| |
if (jval=sigsetjmp(EnvOfStackMachine,1)) { |
| |
#else |
| if (jval=setjmp(EnvOfStackMachine)) { |
if (jval=setjmp(EnvOfStackMachine)) { |
| |
#endif |
| /* *** The following does not work properly. **** |
/* *** The following does not work properly. **** |
| if (jval == 2) { |
if (jval == 2) { |
| if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
| Line 808 void scanner() { |
|
| Line 818 void scanner() { |
|
| fprintf(Fstack,"\nscanner> "); |
fprintf(Fstack,"\nscanner> "); |
| } |
} |
| KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook? */ |
| |
InSendmsg2 = 0; |
| continue ; |
continue ; |
| } else { } |
} else { } |
| if (DebugStack >= 1) { printOperandStack(); } |
if (DebugStack >= 1) { printOperandStack(); } |
|
|
| extern int SGClock; |
extern int SGClock; |
| extern int UserCtrlC; |
extern int UserCtrlC; |
| extern int OXlock; |
extern int OXlock; |
| |
|
| signal(sig,SIG_IGN); |
signal(sig,SIG_IGN); |
| /* see 133p */ |
/* see 133p */ |
| |
cancelAlarm(); |
| |
if (sig == SIGALRM) { |
| |
fprintf(stderr,"ctrlC by SIGALRM\n"); |
| |
} |
| |
|
| if (SGClock) { |
if (SGClock) { |
| UserCtrlC = 1; |
UserCtrlC = 1; |
| fprintf(stderr,"ctrl-c is locked because of gc.\n"); |
fprintf(stderr,"ctrl-c is locked because of gc.\n"); |
| signal(SIGINT,ctrlC); |
signal(sig,ctrlC); if (sig == SIGALRM) alarm((unsigned int)10); |
| return; |
return; |
| } |
} |
| if (OXlock) { |
if (OXlock) { |
|
|
| unlockCtrlCForOx(); |
unlockCtrlCForOx(); |
| } |
} |
| fprintf(stderr,"ctrl-c is locked because of ox lock %d.\n",UserCtrlC); |
fprintf(stderr,"ctrl-c is locked because of ox lock %d.\n",UserCtrlC); |
| signal(SIGINT,ctrlC); |
signal(sig,ctrlC); if (sig == SIGALRM) alarm((unsigned int)10); |
| return; |
return; |
| } |
} |
| if (ErrorMessageMode != 1) { |
if (ErrorMessageMode != 1) { |
|
|
| */ |
*/ |
| getokenSM(INIT); /* It might fix the bug above. 1992/11/14 */ |
getokenSM(INIT); /* It might fix the bug above. 1992/11/14 */ |
| signal(SIGINT,ctrlC); |
signal(SIGINT,ctrlC); |
| |
#if defined(__CYGWIN__) |
| |
siglongjmp(EnvOfStackMachine,2); |
| |
#else |
| longjmp(EnvOfStackMachine,2); /* returns 2 for ctrl-C */ |
longjmp(EnvOfStackMachine,2); /* returns 2 for ctrl-C */ |
| |
#endif |
| } |
} |
| |
|
| int executeToken(token) |
int executeToken(token) |
| Line 881 int executeToken(token) |
|
| Line 901 int executeToken(token) |
|
| int i,h0,h1; |
int i,h0,h1; |
| extern int WarningMessageMode; |
extern int WarningMessageMode; |
| extern int Strict; |
extern int Strict; |
| |
extern int InSendmsg2; |
| |
|
| if (GotoP) { /* for goto */ |
if (GotoP) { /* for goto */ |
| if (token.kind == ID && isLiteral(token.token)) { |
if (token.kind == ID && isLiteral(token.token)) { |
| Line 945 int executeToken(token) |
|
| Line 966 int executeToken(token) |
|
| ob.lc.ival = primitive; |
ob.lc.ival = primitive; |
| return(executePrimitive(ob)); |
return(executePrimitive(ob)); |
| } else { |
} else { |
| |
if (QuoteMode) { |
| |
if (InSendmsg2) return(DO_QUOTE); |
| |
else { |
| |
Kpush(KpoString(token.token)); |
| |
return(0); /* normal exit.*/ |
| |
} |
| |
} |
| if (WarningMessageMode == 1 || WarningMessageMode == 2) { |
if (WarningMessageMode == 1 || WarningMessageMode == 2) { |
| char tmpc[1024]; |
char tmpc[1024]; |
| if (strlen(token.token) < 900) { |
if (strlen(token.token) < 900) { |
| Line 992 errorStackmachine(str) |
|
| Line 1020 errorStackmachine(str) |
|
| char message0[1024]; |
char message0[1024]; |
| char *message; |
char *message; |
| extern int ErrorMessageMode; |
extern int ErrorMessageMode; |
| |
cancelAlarm(); |
| if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
| pushErrorStack(KnewErrorPacket(SerialCurrent,-1,str)); |
pushErrorStack(KnewErrorPacket(SerialCurrent,-1,str)); |
| } |
} |
| Line 1083 KSexecuteString(s) |
|
| Line 1112 KSexecuteString(s) |
|
| |
|
| if (KSPushEnvMode) { |
if (KSPushEnvMode) { |
| *saved_EnvOfStackMachine = *EnvOfStackMachine; |
*saved_EnvOfStackMachine = *EnvOfStackMachine; |
| |
#if defined(__CYGWIN__) |
| |
if (jval = sigsetjmp(EnvOfStackMachine,1)) { |
| |
#else |
| if (jval = setjmp(EnvOfStackMachine)) { |
if (jval = setjmp(EnvOfStackMachine)) { |
| |
#endif |
| *EnvOfStackMachine = *saved_EnvOfStackMachine; |
*EnvOfStackMachine = *saved_EnvOfStackMachine; |
| if (jval == 2) { |
if (jval == 2) { |
| if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
| Line 1092 KSexecuteString(s) |
|
| Line 1125 KSexecuteString(s) |
|
| } |
} |
| recursive--; |
recursive--; |
| if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
| |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook?*/ |
| return(-1); |
return(-1); |
| }else{ } |
}else{ } |
| }else{ |
}else{ |
| if (recursive == 0) { |
if (recursive == 0) { |
| |
#if defined(__CYGWIN__) |
| |
if (jval=sigsetjmp(EnvOfStackMachine,1)) { |
| |
#else |
| if (jval=setjmp(EnvOfStackMachine)) { |
if (jval=setjmp(EnvOfStackMachine)) { |
| |
#endif |
| if (jval == 2) { |
if (jval == 2) { |
| if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
| pushErrorStack(KnewErrorPacket(SerialCurrent,-1,"User interrupt by ctrl-C.")); |
pushErrorStack(KnewErrorPacket(SerialCurrent,-1,"User interrupt by ctrl-C.")); |
| Line 1104 KSexecuteString(s) |
|
| Line 1143 KSexecuteString(s) |
|
| } |
} |
| recursive = 0; |
recursive = 0; |
| if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
| |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
KSexecuteString(" (Computation is interrupted.) "); |
| return(-1); |
return(-1); |
| }else { } |
}else { } |
| } |
} |
| Line 1450 struct object KSdupErrors() { |
|
| Line 1491 struct object KSdupErrors() { |
|
| } |
} |
| return(rob); |
return(rob); |
| } |
} |
| |
|
| |
void cancelAlarm() { |
| |
alarm((unsigned int) 0); |
| |
signal(SIGALRM,SIG_DFL); |
| |
} |