| version 1.15, 2004/09/04 11:25:58 |
version 1.17, 2004/09/05 01:15:47 |
|
|
| /* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.14 2003/12/05 13:51:31 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.16 2004/09/05 00:51:17 takayama Exp $ */ |
| /* stackmachin.c */ |
/* stackmachin.c */ |
| |
|
| #include <stdio.h> |
#include <stdio.h> |
| Line 54 struct context *PrimitiveContextp = &StandardContext; |
|
| Line 54 struct context *PrimitiveContextp = &StandardContext; |
|
| |
|
| static struct object ObjTmp; /* for poor compiler */ |
static struct object ObjTmp; /* for poor compiler */ |
| |
|
| |
int Calling_ctrlC_hook = 0; |
| |
|
| int StandardMacros = 1; |
int StandardMacros = 1; |
| int StartAFile = 0; |
int StartAFile = 0; |
| char *StartFile; |
char *StartFile; |
|
|
| { |
{ |
| int h=0; |
int h=0; |
| while (*str != '\0') { |
while (*str != '\0') { |
| h = ((h*128)+(*str)) % USER_DICTIONARY_SIZE; |
h = ((h*128)+((unsigned char)(*str))) % USER_DICTIONARY_SIZE; |
| str++; |
str++; |
| } |
} |
| return(h); |
return(h); |
|
|
| int hash1(str) |
int hash1(str) |
| char *str; |
char *str; |
| { |
{ |
| return(8-(str[0]%8)); |
return(8-((unsigned char)(str[0])%8)); |
| } |
} |
| |
|
| void hashInitialize(struct dictionary *dic) |
void hashInitialize(struct dictionary *dic) |
| Line 817 void scanner() { |
|
| Line 819 void scanner() { |
|
| if (DebugStack >= 1) { |
if (DebugStack >= 1) { |
| fprintf(Fstack,"\nscanner> "); |
fprintf(Fstack,"\nscanner> "); |
| } |
} |
| KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
if (!Calling_ctrlC_hook) { /* to avoid recursive call of ctrlC-hook. */ |
| |
Calling_ctrlC_hook = 1; |
| |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
} |
| |
Calling_ctrlC_hook = 0; |
| KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook? */ |
KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook? */ |
| InSendmsg2 = 0; |
InSendmsg2 = 0; |
| continue ; |
continue ; |
|
|
| return; |
return; |
| } |
} |
| if (ErrorMessageMode != 1) { |
if (ErrorMessageMode != 1) { |
| |
(void *) traceShowStack(); |
| fprintf(Fstack,"User interruption by ctrl-C. We are in the top-level.\n"); |
fprintf(Fstack,"User interruption by ctrl-C. We are in the top-level.\n"); |
| fprintf(Fstack,"Type in quit in order to exit sm1.\n"); |
fprintf(Fstack,"Type in quit in order to exit sm1.\n"); |
| } |
} |
| |
traceClearStack(); |
| if (GotoP) { |
if (GotoP) { |
| fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
| GotoP = 0; |
GotoP = 0; |
| Line 1061 errorStackmachine(str) |
|
| Line 1069 errorStackmachine(str) |
|
| fprintf(stderr,str); |
fprintf(stderr,str); |
| } |
} |
| fprintf(stderr,"\n"); |
fprintf(stderr,"\n"); |
| (void) traceShowStack(); traceClearStack(); |
(void) traceShowStack(); |
| } |
} |
| |
traceClearStack(); |
| if (GotoP) { |
if (GotoP) { |
| fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
| GotoP = 0; |
GotoP = 0; |
| Line 1133 KSexecuteString(s) |
|
| Line 1142 KSexecuteString(s) |
|
| } |
} |
| recursive--; |
recursive--; |
| if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
| KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
if (!Calling_ctrlC_hook) { |
| |
Calling_ctrlC_hook = 1; |
| |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
} |
| |
Calling_ctrlC_hook = 0; |
| KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook?*/ |
KSexecuteString(" (Computation is interrupted.) "); /* move to ctrlC-hook?*/ |
| return(-1); |
return(-1); |
| }else{ } |
}else{ } |
| Line 1151 KSexecuteString(s) |
|
| Line 1164 KSexecuteString(s) |
|
| } |
} |
| recursive = 0; |
recursive = 0; |
| if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
if (localCatchCtrlC) { signal(SIGINT, sigfunc); } |
| KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
if (!Calling_ctrlC_hook) { |
| |
Calling_ctrlC_hook = 1; |
| |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
| |
} |
| |
Calling_ctrlC_hook = 0; |
| |
Calling_ctrlC_hook = 0; |
| KSexecuteString(" (Computation is interrupted.) "); |
KSexecuteString(" (Computation is interrupted.) "); |
| return(-1); |
return(-1); |
| }else { } |
}else { } |
| Line 1548 char *traceShowStack(void) { |
|
| Line 1566 char *traceShowStack(void) { |
|
| if (t == NULL) { |
if (t == NULL) { |
| s[p] = ';'; s[p+1] = 0; |
s[p] = ';'; s[p+1] = 0; |
| break; |
break; |
| }else if (strlen(t) + p -10 > TRACE_MSG_SIZE) { |
}else if ((strlen(t) + p -10) > TRACE_MSG_SIZE) { |
| |
/* fprintf(stderr,"p=%d, TraceNameStackp=%d, strlen(t)=%d, t=%s\n",p,TraceNameStackp,strlen(t),t); */ |
| strcpy(&(s[p])," ..."); |
strcpy(&(s[p])," ..."); |
| break; |
break; |
| } |
} |