int traiteMot(char *M) { int Err=0; PFC tS; if (sigsetjmp(ENV_INT,1)) { interInfos("traiteMot",M); return 1; } if (!ITASK) SigOn=1; /* printf("traiteMot <%s> iTS=%d\n",M,iTS); */ tS = getTrSuite(); if (tS != (PFC)NULL) tS(M); else if (! execLib(M)) { Err=1; messErr2(10,M); } if (ITASK) exit(0); /* non interpretation in task ! */ if (!ITASK) SigOn=0; return Err; }
void execCod(void *A) { int i,n, ea, Ea, *ai, InDo=0, OnErr=0, mFCTP; long L, P; char * C, *D, *F, *W, *S, *ADo_Next, *ADo_Leave; void * T, *T2; void (*f)(void); struct Fct * FR; /* printf("pid = %d ITASK=%d FctInTask=%d\n",getpid(),ITASK,FctInTask);*/ if (FctInTask) { if (ITASK==0) { if (FctInTask==-1) { FctInTask=0; return; } if (MakeTask(A)) return; } if (ITASK!=FctInTask) return; } D_Cod++; ai = (int*)A; i = *ai++; ea = *ai++; Ea = *ai; if (ea) tellOnErr(A); C = (char*)A+(3*sizeof(int)); D = C; F = C+i; n = sizeof(T); while (C <= F) { /* printf("execCod : %s %d - %x : %ld\n", codByAddr(A),(int)(C-D),*C,(long)*(C+1)); */ if (noErr() && ((C==F) || ((Code)*C != T_ONER)) ) { /* to find onerr: */ if (ea && (OnErr==0)) { C = D+ea; } else { printf("Called in %s err=%d i=%d/%d cod=<%x>\n", codByAddr(A),noErr(),(int)(C-D),i,*C); break; /* end of while */ } } if (C==F) break; /* end of code */ switch((Code)*C) { case T_ONER : if (noErr()==0) { /* jmp end: */ if (Ea) C = D+Ea; else C = F; /* to break */ } else { if (OnErr==0) { OnErr=1; majLastErr(A); razErr(); } else C = F; } break; case T_RET : C = F; /* to break */ break; case T_END : break; /* nothing */ case T_JEND : if (Ea) C = D+Ea; else C = F; /* to break */ break; case T_NUM : bcopy((void*)(C+1),(void*)&T,n); insertVal(T); break; case T_CHA : bcopy((void*)(C+1),(void*)&W,n); putString(W); break; case T_LIB : if (InstallOn) { if (InstallOn < 3) { bcopy((void*)(C+1),(void*)&T,n); _MODIF_FCT_INST_(T); _MODIF_FCT_TYP_(1); } else { _MODIF_FCT_INST_(VIDE); _MODIF_FCT_TYP_(0); } InstallOn=0; } else { bcopy((void*)(C+1),(void*)&f,n); f(); /* free context loops */ if (Do_Evts) { /* quit or cut */ /*printf("execCod T_LIB : Evts %d\n",Do_Evts);*/ if (InDo) { if (Do_Evts>0) { C=ADo_Leave; I_DO--; InDo = 0; Do_Evts--; } else { C=ADo_Next; Do_Evts=0; } } else { /* quit */ C = F; } } } break; case T_FCT : if (InstallOn) { if (InstallOn < 3) { bcopy((void*)(C+1),(void*)&T,n); T2=fctByCode(T); _MODIF_FCT_INST_(T2); _MODIF_FCT_TYP_(2); } else { _MODIF_FCT_INST_(VIDE); _MODIF_FCT_TYP_(0); } InstallOn=0; } else { bcopy((void*)(C+1),(void*)&T,n); execCod(T); /* free context loops */ if (Do_Evts) { /* quit or cut */ /*printf("execCod T_FCT : Evts %d\n",Do_Evts);*/ if (InDo) { if (Do_Evts>0) { C=ADo_Leave; I_DO--; InDo = 0; Do_Evts--; } else { C=ADo_Next; Do_Evts=0; } } else { /* quit */ C = F; } } } break; case T_FCTDS : case T_EXEKS : if ((S = getString()) != NULL) free((void*)S); /* remove the string */ break; case T_FCTD : if ((S = getString()) != NULL) free((void*)S); /* remove the string */ if (noErr()) break; case T_FCTDW : case T_FCTP : bcopy((void*)(C+1),(void*)&T,n); FR = (struct Fct *)T; execCod(FR->c); /* free context loops */ if (Do_Evts) { /* quit or cut */ /*printf("execCod T_FCTD : Evts %d\n",Do_Evts);*/ if (InDo) { if (Do_Evts>0) { C=ADo_Leave; I_DO--; InDo = 0; Do_Evts--; } else { C=ADo_Next; Do_Evts=0; } } else { /* quit */ C = F; } } if (*C == T_FCTP) { if (mFCTP) *C = T_FCTDW; else *C = T_FCTD; } break; case T_EXEK : if ((S = getString()) != NULL) { if (strlen(S)>0) { /* to do with T_FCTD */ mFCTP=0; T = makeFunction(S); if (T != VIDE) { bcopy((void*)&T, (void*)(C+1),n); *C = T_FCTP; C -= (n+1); unlinkLastFct(); /* upgrading precedent code ? not always ! */ if (C >= D) { if (*C == T_CHA) { /* case of a string */ *C = T_CHAS; mFCTP=1; } if (*C == T_VAR) { /* case of a variable string */ bcopy((void*)(C+1),(void*)&W,n); if (isVarChar(W)) { *C = T_VARS; mFCTP=1; } } } } else /* error in compilation */ *C = T_EXEKS; } free((void*)S); } break; case T_IF : if (!getBool()) { bcopy((void*)(C+1),(void*)&L,n); C += L; } break; case T_IFN : if (getBool()) { bcopy((void*)(C+1),(void*)&L,n); C += L; } break; case T_DO : I_DO++; InDo=1; /* maj do_adresses */ W = C + (2*(n+1)); bcopy((void*)(W+1),(void*)&L,n); ADo_Leave=D+L-n-1; ADo_Next=ADo_Leave-(2*(n+1)); /* printf("execCod T_DO : AL= %d AN=%d\n", (int)(ADo_Leave-D), (int)(ADo_Next-D));*/ getParLong(&P); D_DO[I_DO] = P; getParLong(&P); L_DO[I_DO] = P; if (P > D_DO[I_DO]) S_DO[I_DO]=0; else S_DO[I_DO]=1; break; case T_DO_I : IF_getIndDo(0); break; case T_DO_J : IF_getIndDo(1); break; case T_DO_K : IF_getIndDo(2); break; case T_IFD : if (S_DO[I_DO]) { if (D_DO[I_DO] > L_DO[I_DO]) { bcopy((void*)(C+1),(void*)&L,n); C += L; } else { I_DO--; InDo=0; } } else { if (D_DO[I_DO] < L_DO[I_DO]) { bcopy((void*)(C+1),(void*)&L,n); C += L; } else { I_DO--; InDo=0; } } break; case T_LOOP : if (S_DO[I_DO]) D_DO[I_DO]--; else D_DO[I_DO]++; break; case T_PLOO : getParLong(&P); D_DO[I_DO]+=P; break; case T_JMP : bcopy((void*)(C+1),(void*)&L,n); C += L; break; case T_GOTO : bcopy((void*)(C+1),(void*)&L,n); C = D + L - n-1; break; case T_VAR : if (InstallOn) { if (InstallOn == 3) { bcopy((void*)(C+1),(void*)&T,n); _MODIF_FCT_INST_(T); _MODIF_FCT_TYP_(3); } else { _MODIF_FCT_INST_(VIDE); _MODIF_FCT_TYP_(0); } InstallOn=0; } else { bcopy((void*)(C+1),(void*)&W,n); executeVar(W); /* free context loops */ if (Do_Evts) { /* quit or cut */ /*printf("execCod T_VAR : Evts %d\n",Do_Evts);*/ if (InDo) { if (Do_Evts>0) { C=ADo_Leave; I_DO--; InDo = 0; Do_Evts--; } else { C=ADo_Next; Do_Evts=0; } } else { /* quit */ C = F; } } } break; case T_BKC : bcopy((void*)(C+1),(void*)&W,n); execLib(W); break; case T_BKC1 : /* like makeFct */ bcopy((void*)(C+1),(void*)&W,n); /* try to modify the code */ if (VARS==2) { /* VARS UP */ if ((T = varByName(W)) != VIDE) { *C = T_VAR; } else { if ((T = fctByName(W)) != VIDE) { *C = T_FCT; FR = (struct Fct *)T; T = FR->c; } } } else { if ((T = fctByName(W)) != VIDE) { *C = T_FCT; FR = (struct Fct *)T; T = FR->c; } else { if ((VARS==1) && ((T = varByName(W)) != VIDE)) { *C = T_VAR; } } } if ((Code)*C != T_BKC1) { /* code is updated */ bcopy((void*)&T, (void*)(C+1),n); C-=(n+1); /* it must be executed */ } break; case T_NOP : case T_CHAS : case T_VARS : case T_FCTDWS : break; default : messErr(11); } C+= n+1; } D_Cod--; if (ea) tellOnErr(VIDE); }