/* ================================================================================ RPL/2 (R) version 4.1.32 Copyright (C) 1989-2019 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl-conv.h" /* ================================================================================ Analyseur syntaxique de l'interprète RPL/2 ================================================================================ Entrées : -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ static void creation_instruction(struct_processus *s_etat_processus, unsigned char *instruction, void (*routine)()) { int i; struct_instruction *l_instruction_courante; unsigned char *ptr; BUG(strlen(instruction) >= d_longueur_maximale_instruction, printf("%s -> %d >= %d\n", instruction, (int) strlen(instruction), d_longueur_maximale_instruction)); if ((*s_etat_processus).arbre_instructions == NULL) { if (((*s_etat_processus).arbre_instructions = malloc(sizeof(struct_instruction))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*(*s_etat_processus).arbre_instructions).feuille = NULL; if (((*(*s_etat_processus).arbre_instructions).noeuds = malloc(((size_t) (*s_etat_processus).nombre_caracteres) * sizeof(struct_instruction))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { (*(*s_etat_processus).arbre_instructions).noeuds[i] = NULL; } } l_instruction_courante = (*s_etat_processus).arbre_instructions; ptr = instruction; while((*ptr) != d_code_fin_chaine) { BUG((*s_etat_processus).pointeurs_caracteres[*ptr] < 0, printf("Instruction=\"%s\", (*ptr)='%c'\n", instruction, *ptr)); if ((*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]] == NULL) { // Le noeud suivant n'existe pas, on le crée. if (((*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]] = malloc(sizeof(struct_instruction))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*(*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]]).feuille = NULL; if (((*(*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]]).noeuds = malloc(((size_t) (*s_etat_processus).nombre_caracteres) * sizeof(struct_instruction))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { (*(*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]]).noeuds[i] = NULL; } } l_instruction_courante = (*l_instruction_courante).noeuds [(*s_etat_processus).pointeurs_caracteres[*ptr]]; ptr++; } BUG((*l_instruction_courante).feuille != NULL, printf("Instruction=\"%s\"\n", instruction)); (*l_instruction_courante).feuille = routine; return; } void liberation_arbre_instructions(struct_processus *s_etat_processus, struct_instruction *arbre) { int i; for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { if ((*arbre).noeuds[i] != NULL) { liberation_arbre_instructions(s_etat_processus, (*arbre).noeuds[i]); } } free((*arbre).noeuds); free(arbre); return; } /* * Caractères autorisés dans les instructions * * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z * e i (mais traités comme des majuscules grâce à 'instruction_*_sensible()' * + - * / % ^ < > = ? 1 2 */ void initialisation_instructions(struct_processus *s_etat_processus) { int decalage; int i; int longueur_tableau; unsigned char caractere; // Récupération de la longueur d'un unsigned char longueur_tableau = 1; decalage = 0; caractere = 1; while((1L << decalage) == (long) ((unsigned char) (caractere << decalage))) { decalage++; longueur_tableau *= 2; } if (((*s_etat_processus).pointeurs_caracteres = malloc(((size_t) longueur_tableau * sizeof(int)))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } for(i = 0; i < longueur_tableau; i++) { (*s_etat_processus).pointeurs_caracteres[i] = -1; } (*s_etat_processus).nombre_caracteres = 0; #define DECLARATION_CARACTERE(c) \ do { (*s_etat_processus).pointeurs_caracteres[c] = \ (*s_etat_processus).nombre_caracteres++; } while(0) DECLARATION_CARACTERE('A'); DECLARATION_CARACTERE('B'); DECLARATION_CARACTERE('C'); DECLARATION_CARACTERE('D'); DECLARATION_CARACTERE('E'); DECLARATION_CARACTERE('F'); DECLARATION_CARACTERE('G'); DECLARATION_CARACTERE('H'); DECLARATION_CARACTERE('I'); DECLARATION_CARACTERE('J'); DECLARATION_CARACTERE('K'); DECLARATION_CARACTERE('L'); DECLARATION_CARACTERE('M'); DECLARATION_CARACTERE('N'); DECLARATION_CARACTERE('O'); DECLARATION_CARACTERE('P'); DECLARATION_CARACTERE('Q'); DECLARATION_CARACTERE('R'); DECLARATION_CARACTERE('S'); DECLARATION_CARACTERE('T'); DECLARATION_CARACTERE('U'); DECLARATION_CARACTERE('V'); DECLARATION_CARACTERE('W'); DECLARATION_CARACTERE('X'); DECLARATION_CARACTERE('Y'); DECLARATION_CARACTERE('Z'); DECLARATION_CARACTERE('+'); DECLARATION_CARACTERE('-'); DECLARATION_CARACTERE('/'); DECLARATION_CARACTERE('*'); DECLARATION_CARACTERE('%'); DECLARATION_CARACTERE('^'); DECLARATION_CARACTERE('<'); DECLARATION_CARACTERE('>'); DECLARATION_CARACTERE('='); DECLARATION_CARACTERE('?'); DECLARATION_CARACTERE('1'); DECLARATION_CARACTERE('2'); #undef DECLARATION_CARACTERE #define INSTRUCTION(chaine, fonction) \ creation_instruction(s_etat_processus, chaine, fonction) INSTRUCTION("E", instruction_sensible_e); INSTRUCTION("I", instruction_sensible_i); INSTRUCTION("+", instruction_plus); INSTRUCTION("-", instruction_moins); INSTRUCTION("*", instruction_multiplication); INSTRUCTION("/", instruction_division); INSTRUCTION("%", instruction_pourcent); INSTRUCTION("^", instruction_puissance); INSTRUCTION("<", instruction_lt); INSTRUCTION("=", instruction_egalite); INSTRUCTION(">", instruction_gt); INSTRUCTION("CF", instruction_cf); INSTRUCTION("CR", instruction_cr); INSTRUCTION("DO", instruction_do); INSTRUCTION("FP", instruction_fp); INSTRUCTION("IF", instruction_if); INSTRUCTION("IM", instruction_im); INSTRUCTION("IN", instruction_in); INSTRUCTION("IP", instruction_ip); INSTRUCTION("LN", instruction_ln); INSTRUCTION("LQ", instruction_lq); INSTRUCTION("LU", instruction_lu); INSTRUCTION("NS", instruction_ns); INSTRUCTION("OR", instruction_or); INSTRUCTION("PI", instruction_pi); INSTRUCTION("QR", instruction_qr); INSTRUCTION("RE", instruction_re); INSTRUCTION("RL", instruction_rl); INSTRUCTION("RR", instruction_rr); INSTRUCTION("SF", instruction_sf); INSTRUCTION("SL", instruction_sl); INSTRUCTION("SQ", instruction_sq); INSTRUCTION("SR", instruction_sr); INSTRUCTION("SX", instruction_sx); INSTRUCTION("SY", instruction_sy); INSTRUCTION("S+", instruction_s_plus); INSTRUCTION("S-", instruction_s_moins); INSTRUCTION("->", instruction_fleche); INSTRUCTION("*D", instruction_star_d); INSTRUCTION("*H", instruction_star_h); INSTRUCTION("*S", instruction_star_s); INSTRUCTION("*W", instruction_star_w); INSTRUCTION("**", instruction_puissance); INSTRUCTION("%T", instruction_pourcent_t); INSTRUCTION("<=", instruction_le); INSTRUCTION("<<", instruction_vers_niveau_superieur); INSTRUCTION("<>", instruction_ne); INSTRUCTION("==", instruction_same); INSTRUCTION("=>", instruction_ge); INSTRUCTION("=<", instruction_le); INSTRUCTION(">=", instruction_ge); INSTRUCTION(">>", instruction_vers_niveau_inferieur); INSTRUCTION("ABS", instruction_abs); INSTRUCTION("AND", instruction_and); //INSTRUCTION("ARC") //(centre, rayon, theta1, theta2 dans le sens trigonométrique) INSTRUCTION("ARG", instruction_arg); INSTRUCTION("ASL", instruction_asl); INSTRUCTION("ASR", instruction_asr); //INSTRUCTION("BAR") //Instruction HP48 (sélectionne le type de graphique à barres) //Chaque point est représenté par une barre verticale. INSTRUCTION("BIN", instruction_bin); //INSTRUCTION("BOX") //(point 1, point 2) INSTRUCTION("CHR", instruction_chr); INSTRUCTION("CLS", instruction_cls); INSTRUCTION("CON", instruction_con); INSTRUCTION("COS", instruction_cos); INSTRUCTION("COV", instruction_cov); INSTRUCTION("DEC", instruction_dec); INSTRUCTION("DEG", instruction_deg); INSTRUCTION("DER", instruction_der); INSTRUCTION("DET", instruction_det); INSTRUCTION("DFT", instruction_dft); INSTRUCTION("DOT", instruction_dot); INSTRUCTION("DUP", instruction_dup); INSTRUCTION("EGV", instruction_egv); INSTRUCTION("END", instruction_end); INSTRUCTION("ENG", instruction_eng); INSTRUCTION("EQV", instruction_eqv); INSTRUCTION("EXP", instruction_exp); INSTRUCTION("FC?", instruction_fc_test); INSTRUCTION("FFT", instruction_fft); //INSTRUCTION("FIT") //Extension RPL/2 (choix de la méthode de régression, par défaut, 'LINEAR'. //Les types sont //'LINEAR' => y = b + mx //'LOGARITHMIC' => y = b + m ln(x) //'EXPONENTIAL' => y = be^(mx) ou ln(y) = ln(b) + mx //'POWER' => y = bx^m ou ln(y) = ln(b) + m ln(x) INSTRUCTION("FIX", instruction_fix); INSTRUCTION("FOR", instruction_for); INSTRUCTION("FS?", instruction_fs_test); INSTRUCTION("GET", instruction_get); INSTRUCTION("HEX", instruction_hex); INSTRUCTION("IDN", instruction_idn); INSTRUCTION("IFT", instruction_ift); INSTRUCTION("INT", instruction_int); INSTRUCTION("INV", instruction_inv); INSTRUCTION("KEY", instruction_key); INSTRUCTION("LOG", instruction_log); INSTRUCTION("LSQ", instruction_lsq); INSTRUCTION("MAX", instruction_max); INSTRUCTION("MEM", instruction_mem); INSTRUCTION("MIN", instruction_min); INSTRUCTION("MOD", instruction_mod); INSTRUCTION("NEG", instruction_neg); INSTRUCTION("NOT", instruction_not); INSTRUCTION("NUM", instruction_num); INSTRUCTION("OCT", instruction_oct); INSTRUCTION("POS", instruction_pos); INSTRUCTION("PR1", instruction_pr1); INSTRUCTION("PUT", instruction_put); INSTRUCTION("RAD", instruction_rad); INSTRUCTION("RCI", instruction_rci); INSTRUCTION("RCL", instruction_rcl); INSTRUCTION("RDM", instruction_rdm); INSTRUCTION("RDZ", instruction_rdz); INSTRUCTION("RES", instruction_res); INSTRUCTION("RLB", instruction_rlb); INSTRUCTION("RND", instruction_rnd); INSTRUCTION("ROT", instruction_rot); INSTRUCTION("RRB", instruction_rrb); INSTRUCTION("RSD", instruction_rsd); INSTRUCTION("SCI", instruction_sci); INSTRUCTION("SIN", instruction_sin); INSTRUCTION("SLB", instruction_slb); INSTRUCTION("SRB", instruction_srb); INSTRUCTION("SST", instruction_sst); INSTRUCTION("STD", instruction_std); INSTRUCTION("STO", instruction_sto); INSTRUCTION("SVD", instruction_svd); INSTRUCTION("SVL", instruction_svl); INSTRUCTION("SUB", instruction_sub); INSTRUCTION("SWI", instruction_swi); INSTRUCTION("SX2", instruction_sx2); INSTRUCTION("SXY", instruction_sxy); INSTRUCTION("SY2", instruction_sy2); INSTRUCTION("TAN", instruction_tan); INSTRUCTION("TOT", instruction_tot); INSTRUCTION("TRN", instruction_trn); INSTRUCTION("USE", instruction_use); INSTRUCTION("VAR", instruction_var); //INSTRUCTION("V->") //Instruction HP48 (éclate un vecteur [ x y ] => x y quel que soit le //système de //coordonnées) INSTRUCTION("XOR", instruction_xor); INSTRUCTION("->Q", instruction_fleche_q); INSTRUCTION("%CH", instruction_pourcent_ch); INSTRUCTION("ACOS", instruction_acos); INSTRUCTION("ALOG", instruction_alog); INSTRUCTION("ASIN", instruction_asin); INSTRUCTION("ATAN", instruction_atan); INSTRUCTION("AXES", instruction_axes); INSTRUCTION("BEEP", instruction_beep); INSTRUCTION("B->R", instruction_b_vers_r); INSTRUCTION("CASE", instruction_case); INSTRUCTION("CEIL", instruction_ceil); INSTRUCTION("CLMF", instruction_clmf); INSTRUCTION("CNRM", instruction_cnrm); INSTRUCTION("COLS", instruction_cols); INSTRUCTION("COL+", instruction_col_plus); INSTRUCTION("COL-", instruction_col_moins); INSTRUCTION("COMB", instruction_comb); INSTRUCTION("COND", instruction_cond); INSTRUCTION("CONJ", instruction_conj); INSTRUCTION("CONT", instruction_cont); INSTRUCTION("COPY", instruction_copy); INSTRUCTION("CORR", instruction_corr); INSTRUCTION("COSH", instruction_cosh); INSTRUCTION("CSWP", instruction_cswp); INSTRUCTION("C->R", instruction_c_vers_r); INSTRUCTION("DATE", instruction_date); INSTRUCTION("DECR", instruction_decr); INSTRUCTION("DISP", instruction_disp); INSTRUCTION("DRAW", instruction_draw); INSTRUCTION("DRAX", instruction_drax); INSTRUCTION("DROP", instruction_drop); INSTRUCTION("DRWS", instruction_drws); INSTRUCTION("DUP2", instruction_dup2); INSTRUCTION("DUPN", instruction_dupn); INSTRUCTION("D->R", instruction_d_vers_r); INSTRUCTION("EDIT", instruction_edit); INSTRUCTION("EGVL", instruction_egvl); INSTRUCTION("ELSE", instruction_else); INSTRUCTION("ERRM", instruction_errm); INSTRUCTION("ERRN", instruction_errn); INSTRUCTION("EVAL", instruction_eval); INSTRUCTION("EXIT", instruction_exit); INSTRUCTION("EXPM", instruction_expm); INSTRUCTION("FACT", instruction_fact); INSTRUCTION("FC?C", instruction_fc_test_c); INSTRUCTION("FC?S", instruction_fc_test_s); //INSTRUCTION("FORM") INSTRUCTION("FS?C", instruction_fs_test_c); INSTRUCTION("FS?S", instruction_fs_test_s); INSTRUCTION("FUSE", instruction_fuse); INSTRUCTION("GEGV", instruction_gegv); INSTRUCTION("GETC", instruction_getc); INSTRUCTION("GETI", instruction_geti); INSTRUCTION("GETR", instruction_getr); INSTRUCTION("HALT", instruction_halt); INSTRUCTION("HEAD", instruction_head); INSTRUCTION("HELP", instruction_help); INSTRUCTION("HMS+", instruction_hms_plus); INSTRUCTION("HMS-", instruction_hms_moins); //INSTRUCTION("HOME"); INSTRUCTION("IDFT", instruction_idft); INSTRUCTION("IFFT", instruction_ifft); INSTRUCTION("IFTE", instruction_ifte); INSTRUCTION("INCR", instruction_incr); //INSTRUCTION("ISOL"); INSTRUCTION("ISWI", instruction_iswi); INSTRUCTION("KILL", instruction_kill); INSTRUCTION("KIND", instruction_kind); INSTRUCTION("LAST", instruction_last); INSTRUCTION("LEGV", instruction_legv); INSTRUCTION("LINE", instruction_line); INSTRUCTION("LNP1", instruction_lnp1); INSTRUCTION("LOCK", instruction_lock); INSTRUCTION("L->T", instruction_l_vers_t); INSTRUCTION("MANT", instruction_mant); INSTRUCTION("MARK", instruction_mark); //INSTRUCTION("MAXR") INSTRUCTION("MAXS", instruction_maxs); INSTRUCTION("MEAN", instruction_mean); //INSTRUCTION("MINR"); INSTRUCTION("MINS", instruction_mins); // MAXDOUBLE/MINDOUBLE INSTRUCTION("NEXT", instruction_next); //INSTRUCTION("NUMX"); //INSTRUCTION("NUMY"); INSTRUCTION("OPEN", instruction_open); INSTRUCTION("OVER", instruction_over); //INSTRUCTION("PATH"); INSTRUCTION("PCOV", instruction_pcov); INSTRUCTION("PEEK", instruction_peek); INSTRUCTION("PERM", instruction_perm); INSTRUCTION("PICK", instruction_pick); INSTRUCTION("PLOT", instruction_plot); INSTRUCTION("PMAX", instruction_pmax); INSTRUCTION("PMIN", instruction_pmin); INSTRUCTION("POKE", instruction_poke); INSTRUCTION("POLL", instruction_poll); INSTRUCTION("PPAR", instruction_ppar); INSTRUCTION("PRMD", instruction_prmd); INSTRUCTION("PRST", instruction_prst); INSTRUCTION("PUTC", instruction_putc); INSTRUCTION("PUTI", instruction_puti); INSTRUCTION("PUTR", instruction_putr); INSTRUCTION("PVAR", instruction_pvar); INSTRUCTION("P->R", instruction_p_vers_r); //INSTRUCTION("QUAD"); INSTRUCTION("RAND", instruction_rand); INSTRUCTION("RANK", instruction_rank); //INSTRUCTION("RANM") //Instruction HP48 (crée une matrice aléatoire //{ nb_lignes nb_colonnes } ou tableau quelconque dont les éléments seront //modifiés pour prendre des valeurs aléatoires entre -9 et 9) INSTRUCTION("RCEQ", instruction_rceq); INSTRUCTION("RCIJ", instruction_rcij); INSTRUCTION("RCLF", instruction_rclf); INSTRUCTION("RCLS", instruction_rcls); INSTRUCTION("RCWS", instruction_rcws); INSTRUCTION("RDGN", instruction_rdgn); INSTRUCTION("READ", instruction_read); INSTRUCTION("RECV", instruction_recv); INSTRUCTION("REGV", instruction_regv); INSTRUCTION("REPL", instruction_repl); INSTRUCTION("RGDL", instruction_rgdl); INSTRUCTION("RGDR", instruction_rgdr); INSTRUCTION("RNRM", instruction_rnrm); INSTRUCTION("ROLL", instruction_roll); //INSTRUCTION("ROOT") INSTRUCTION("ROW-", instruction_row_moins); INSTRUCTION("ROW+", instruction_row_plus); //INSTRUCTION("RREF") //Instruction HP48 (transforme [A B] en [I C] par combinaisons linéaires //de lignes) INSTRUCTION("RSWP", instruction_rswp); INSTRUCTION("R->B", instruction_r_vers_b); INSTRUCTION("R->C", instruction_r_vers_c); INSTRUCTION("R->D", instruction_r_vers_d); INSTRUCTION("R->P", instruction_r_vers_p); INSTRUCTION("SAME", instruction_same); INSTRUCTION("SAVE", instruction_save); INSTRUCTION("SCLS", instruction_scls); INSTRUCTION("SDEV", instruction_sdev); INSTRUCTION("SEND", instruction_send); //INSTRUCTION("SHOW"); INSTRUCTION("SIGN", instruction_sign); INSTRUCTION("SINH", instruction_sinh); INSTRUCTION("SINV", instruction_sinv); INSTRUCTION("SIZE", instruction_size); INSTRUCTION("SNEG", instruction_sneg); INSTRUCTION("SORT", instruction_sort); INSTRUCTION("SPAR", instruction_spar); INSTRUCTION("SQRT", instruction_sqrt); //INSTRUCTION("SRAD"); INSTRUCTION("SREV", instruction_srev); //INSTRUCTION("SRNM") //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une //matrice, //la norme spectrale est égale à sa plus grande valeur singulière. Pour un //vecteur, la fonction est équivalente à ABS. INSTRUCTION("STEP", instruction_step); INSTRUCTION("STEQ", instruction_steq); INSTRUCTION("STO*", instruction_sto_fois); INSTRUCTION("STO+", instruction_sto_plus); INSTRUCTION("STO-", instruction_sto_moins); INSTRUCTION("STO/", instruction_sto_division); INSTRUCTION("STOF", instruction_stof); INSTRUCTION("STOP", instruction_stop); INSTRUCTION("STOS", instruction_stos); INSTRUCTION("STWS", instruction_stws); INSTRUCTION("SWAP", instruction_swap); INSTRUCTION("SYNC", instruction_sync); INSTRUCTION("TAIL", instruction_tail); INSTRUCTION("TANH", instruction_tanh); INSTRUCTION("THEN", instruction_then); INSTRUCTION("TIME", instruction_time); INSTRUCTION("TRIM", instruction_trim); INSTRUCTION("TRNC", instruction_trnc); INSTRUCTION("TRUE", instruction_true); INSTRUCTION("TYPE", instruction_type); INSTRUCTION("T->L", instruction_t_vers_l); INSTRUCTION("UTPC", instruction_utpc); INSTRUCTION("UTPF", instruction_utpf); INSTRUCTION("UTPN", instruction_utpn); INSTRUCTION("UTPT", instruction_utpt); INSTRUCTION("VARS", instruction_vars); INSTRUCTION("WAIT", instruction_wait); INSTRUCTION("XCOL", instruction_xcol); INSTRUCTION("XPON", instruction_xpon); //INSTRUCTION("XRNG") //INSTRUCTION("XVOL") INSTRUCTION("YCOL", instruction_ycol); //INSTRUCTION("YRNG") //INSTRUCTION("YVOL") //INSTRUCTION("ZVOL") //INSTRUCTION("->V2") //Instruction HP48 (combine deux réels x et y en un vecteur 2D en fonction //du mode de coordonnées en cours => [ x y ] et ce quel que soit le système //de coordonnées courant) //INSTRUCTION("->V3") INSTRUCTION("ABORT", instruction_abort); INSTRUCTION("ACOSH", instruction_acosh); INSTRUCTION("ALARM", instruction_alarm); INSTRUCTION("ASINH", instruction_asinh); INSTRUCTION("ATANH", instruction_atanh); //INSTRUCTION("BYTES"); INSTRUCTION("CENTR", instruction_centr); //INSTRUCTION("CIRCL"); INSTRUCTION("CLEAR", instruction_clear); INSTRUCTION("CLLCD", instruction_cllcd); INSTRUCTION("CLOSE", instruction_close); INSTRUCTION("CLUSR", instruction_clusr); //INSTRUCTION("CLVAR"); //INSTRUCTION("COLCT") INSTRUCTION("COL->", instruction_col_fleche); //INSTRUCTION("CONIC") //Instruction HP48 (sélectionne le type de tracé CONIC) //Permet de tracer des coniques en fonction d'équations //de type f(x, y) = 0. //INSTRUCTION("CRDIR") INSTRUCTION("CRMTX", instruction_crmtx); INSTRUCTION("CROSS", instruction_cross); INSTRUCTION("CRTAB", instruction_crtab); INSTRUCTION("CSTOP", instruction_cstop); INSTRUCTION("CYCLE", instruction_cycle); //INSTRUCTION("CYLIN") //Instruction HP48 (sélectionne le type de tracé CYLINDRIC) INSTRUCTION("DEPND", instruction_depnd); INSTRUCTION("DEPTH", instruction_depth); //INSTRUCTION("DOSUB") //Instruction HP48 (application séquentielle d'une fonction à une liste) //liste nombre_elements_traites_a_chaque_iteration fonction DOSUB //{ 1 2 3 4 5 } //2 //<< + 2 / >> //DOSUB //=> { 1.5 2.5 3.5 4.5 } INSTRUCTION("DGTIZ", instruction_dgtiz); INSTRUCTION("DROP2", instruction_drop2); INSTRUCTION("DROPN", instruction_dropn); INSTRUCTION("ERASE", instruction_erase); INSTRUCTION("EXGET", instruction_exget); //INSTRUCTION("EXPAN"); INSTRUCTION("EXSUB", instruction_exsub); INSTRUCTION("EYEPT", instruction_eyept); INSTRUCTION("FALSE", instruction_false); INSTRUCTION("FLOOR", instruction_floor); INSTRUCTION("GAMMA", instruction_gamma); INSTRUCTION("GEGVL", instruction_gegvl); INSTRUCTION("GLEGV", instruction_glegv); INSTRUCTION("GREGV", instruction_gregv); INSTRUCTION("HMS->", instruction_hms_fleche); INSTRUCTION("IFERR", instruction_iferr); INSTRUCTION("INDEP", instruction_indep); INSTRUCTION("INPUT", instruction_input); INSTRUCTION("JDATE", instruction_jdate); INSTRUCTION("LABEL", instruction_label); INSTRUCTION("LCASE", instruction_lcase); INSTRUCTION("LCHOL", instruction_lchol); INSTRUCTION("LCD->", instruction_lcd_fleche); INSTRUCTION("LIMIT", instruction_limit); //INSTRUCTION("NDIST") //Instruction HP48 (distribution normale, prend la moyenne au niveau 3, //la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité //qu'une variable aléatoire normale soit égale à x dans une distribution //normale). INSTRUCTION("NRAND", instruction_nrand); INSTRUCTION("OBGET", instruction_obget); INSTRUCTION("OBSUB", instruction_obsub); INSTRUCTION("PAPER", instruction_paper); //INSTRUCTION("PCOEFF") //INSTRUCTION("PEVAL") //INSTRUCTION("PGDIR") //INSTRUCTION("PIXEL") //INSTRUCTION("PLIST") //Instruction HP48 (produit des termes d'une liste) INSTRUCTION("POLAR", instruction_polar); INSTRUCTION("PRINT", instruction_print); //INSTRUCTION("PREDV"); INSTRUCTION("PRLCD", instruction_prlcd); //INSTRUCTION("PROOT") //Instruction HP48 (calcule les racines d'un polynôme en fonction du tableau //de coefficients) INSTRUCTION("PRSTC", instruction_prstc); INSTRUCTION("PRUSR", instruction_prusr); INSTRUCTION("PRVAR", instruction_prvar); INSTRUCTION("PSDEV", instruction_psdev); INSTRUCTION("PURGE", instruction_purge); INSTRUCTION("RDATE", instruction_rdate); INSTRUCTION("REGEX", instruction_regex); INSTRUCTION("RELAX", instruction_relax); INSTRUCTION("RFUSE", instruction_rfuse); INSTRUCTION("RSTOP", instruction_rstop); INSTRUCTION("ROLLD", instruction_rolld); INSTRUCTION("ROW->", instruction_row_fleche); INSTRUCTION("SCALE", instruction_scale); INSTRUCTION("SCHED", instruction_sched); INSTRUCTION("SCHUR", instruction_schur); INSTRUCTION("SCONJ", instruction_sconj); INSTRUCTION("SLICE", instruction_slice); //INSTRUCTION("SLIST") //Instruction HP48 (somme des termes d'une liste) INSTRUCTION("SPAWN", instruction_spawn); INSTRUCTION("START", instruction_start); INSTRUCTION("STORE", instruction_store); INSTRUCTION("STR->", instruction_str_fleche); INSTRUCTION("TAYLR", instruction_taylr); INSTRUCTION("TITLE", instruction_title); //INSTRUCTION("TRACE") //INSTRUCTION("TRUTH") INSTRUCTION("UCASE", instruction_ucase); INSTRUCTION("UCHOL", instruction_uchol); INSTRUCTION("UNTIL", instruction_until); //INSTRUCTION("UPDIR") INSTRUCTION("VISIT", instruction_visit); INSTRUCTION("WFACK", instruction_wfack); INSTRUCTION("WFSWI", instruction_wfswi); INSTRUCTION("WHILE", instruction_while); //INSTRUCTION("WIDTH") INSTRUCTION("WRITE", instruction_write); INSTRUCTION("XROOT", instruction_xroot); INSTRUCTION("YIELD", instruction_yield); INSTRUCTION("->COL", instruction_fleche_col); INSTRUCTION("->HMS", instruction_fleche_hms); INSTRUCTION("->LCD", instruction_fleche_lcd); INSTRUCTION("->NUM", instruction_fleche_num); INSTRUCTION("->ROW", instruction_fleche_row); INSTRUCTION("->STR", instruction_fleche_str); INSTRUCTION("APPEND", instruction_append); INSTRUCTION("ARRY->", instruction_array_fleche); INSTRUCTION("ATEXIT", instruction_atexit); INSTRUCTION("ATPOKE", instruction_atpoke); INSTRUCTION("BESSEL", instruction_bessel); INSTRUCTION("CIPHER", instruction_cipher); INSTRUCTION("CLRERR", instruction_clrerr); INSTRUCTION("CLRMTX", instruction_clrmtx); INSTRUCTION("CLRSWI", instruction_clrswi); INSTRUCTION("CREATE", instruction_create); INSTRUCTION("DELETE", instruction_delete); # ifdef SHARED_MEMORY INSTRUCTION("DETACH", instruction_detach); # else if ((*s_etat_processus).langue == 'F') { printf("+++Attention : DETACH est émulé par SPAWN car le système" " hôte ne supporte\n" " pas de mémoire partagée !\n"); } else { printf("+++Warning : DETACH is replaced by SPAWN as host system" " does not support\n" " shared memory !\n"); } INSTRUCTION("DETACH", instruction_spawn); # endif INSTRUCTION("DIAG->", instruction_diag_fleche); INSTRUCTION("DIGEST", instruction_digest); //INSTRUCTION("DOLIST") //Instruction HP48 (application d'une fonction à une liste) //liste(s) nombre_de_listes_a_traiter fonction DOLIST //{ 1 2 3 } //{ 4 5 6 } //{ 7 8 9 } //3 //<< * + >> //DOLIST //=> { 29 42 57 } INSTRUCTION("ELSEIF", instruction_elseif); INSTRUCTION("FORALL", instruction_forall); INSTRUCTION("FORMAT", instruction_format); //INSTRUCTION("HEIGHT") INSTRUCTION("ITRACE", instruction_itrace); INSTRUCTION("LIST->", instruction_list_fleche); INSTRUCTION("LOGGER", instruction_logger); INSTRUCTION("MCLRIN", instruction_mclrin); INSTRUCTION("NRPROC", instruction_nrproc); INSTRUCTION("PROCID", instruction_procid); INSTRUCTION("PROMPT", instruction_prompt); INSTRUCTION("RCLSWI", instruction_rclswi); INSTRUCTION("RECALL", instruction_recall); INSTRUCTION("RECODE", instruction_recode); INSTRUCTION("RECORD", instruction_record); INSTRUCTION("REDRAW", instruction_redraw); INSTRUCTION("REMOVE", instruction_remove); INSTRUCTION("REPEAT", instruction_repeat); INSTRUCTION("RETURN", instruction_return); INSTRUCTION("REWIND", instruction_rewind); //INSTRUCTION("SCREEN") INSTRUCTION("SELECT", instruction_select); //INSTRUCTION("SPHERE") INSTRUCTION("SHARED", instruction_shared); INSTRUCTION("SPLASH", instruction_splash); INSTRUCTION("STATIC", instruction_static); INSTRUCTION("STOSWI", instruction_stoswi); //INSTRUCTION("STREAM", instruction_stream); //{ 1 2 3 4 5 } << * >> STREAM => 120 INSTRUCTION("TARGET", instruction_target); INSTRUCTION("UNLOCK", instruction_unlock); INSTRUCTION("VERIFY", instruction_verify); INSTRUCTION("WFDATA", instruction_wfdata); INSTRUCTION("WFLOCK", instruction_wflock); INSTRUCTION("WFPOKE", instruction_wfpoke); INSTRUCTION("WFPROC", instruction_wfproc); INSTRUCTION("WFSOCK", instruction_wfsock); INSTRUCTION("->ARRY", instruction_fleche_array); INSTRUCTION("->DIAG", instruction_fleche_diag); INSTRUCTION("->LIST", instruction_fleche_list); INSTRUCTION("ARRAY->", instruction_array_fleche); //INSTRUCTION("BARPLOT") //INSTRUCTION("BESTFIT") //Instruction HP48 (choisit le meilleur modèle de régression) INSTRUCTION("CLRFUSE", instruction_clrfuse); INSTRUCTION("CONVERT", instruction_convert); INSTRUCTION("CRSMPHR", instruction_crsmphr); INSTRUCTION("CURRENC", instruction_currenc); INSTRUCTION("DEFAULT", instruction_default); INSTRUCTION("EPSILON", instruction_epsilon); //INSTRUCTION("GRIDMAP") //Instruction HP48 (sélectionne le mode de tracé GRIDMAP) //Le tracé GRIDMAP transforme la grille d'échantillonnage rectiligne //en appliquant la fonction en cours à valeurs complexes. //Les coordonnées de chaque point de la grille (un nombre complexe) //constituent //les données d'entrée de la fonction qui les projette ensuite dans le //grille //de sortie. //f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une //fonction paramétrique. INSTRUCTION("INQUIRE", instruction_inquire); INSTRUCTION("MEMLOCK", instruction_memlock); INSTRUCTION("MTXLOCK", instruction_mtxlock); INSTRUCTION("NBRCPUS", instruction_nbrcpus); INSTRUCTION("PERSIST", instruction_persist); INSTRUCTION("PLOTTER", instruction_plotter); INSTRUCTION("PRIVATE", instruction_private); INSTRUCTION("PROTECT", instruction_protect); INSTRUCTION("PSHPRFL", instruction_pshprfl); INSTRUCTION("PULPRFL", instruction_pulprfl); INSTRUCTION("RESTART", instruction_restart); INSTRUCTION("REVLIST", instruction_revlist); INSTRUCTION("SCATTER", instruction_scatter); INSTRUCTION("SUSPEND", instruction_suspend); INSTRUCTION("SWILOCK", instruction_swilock); INSTRUCTION("SYSEVAL", instruction_syseval); INSTRUCTION("TABLE->", instruction_table_fleche); INSTRUCTION("VERSION", instruction_version); INSTRUCTION("WORKDIR", instruction_workdir); INSTRUCTION("->ARRAY", instruction_fleche_array); INSTRUCTION("->TABLE", instruction_fleche_table); INSTRUCTION("CLRCNTXT", instruction_clrcntxt); INSTRUCTION("CLRSMPHR", instruction_clrsmphr); INSTRUCTION("COMPRESS", instruction_compress); INSTRUCTION("CONTINUE", instruction_continue); INSTRUCTION("CRITICAL", instruction_critical); INSTRUCTION("DUPCNTXT", instruction_dupcntxt); INSTRUCTION("FUNCTION", instruction_function); INSTRUCTION("IMPLICIT", instruction_implicit); INSTRUCTION("INFINITY", instruction_sensible_infinity); INSTRUCTION("KEYLABEL", instruction_keylabel); INSTRUCTION("KEYTITLE", instruction_keytitle); INSTRUCTION("LOGSCALE", instruction_logscale); INSTRUCTION("NEWPLANE", instruction_newplane); INSTRUCTION("PSHCNTXT", instruction_pshcntxt); INSTRUCTION("PULCNTXT", instruction_pulcntxt); INSTRUCTION("SQLQUERY", instruction_sqlquery); INSTRUCTION("SWIQUEUE", instruction_swiqueue); INSTRUCTION("TOKENIZE", instruction_tokenize); INSTRUCTION("VARIABLE", instruction_variable); INSTRUCTION("VOLATILE", instruction_volatile); INSTRUCTION("WARRANTY", instruction_warranty); INSTRUCTION("AUTOSCALE", instruction_autoscale); INSTRUCTION("BACKSPACE", instruction_backspace); INSTRUCTION("BACKTRACE", instruction_backtrace); INSTRUCTION("CLRATEXIT", instruction_clratexit); INSTRUCTION("CLRATPOKE", instruction_clratpoke); INSTRUCTION("COPYRIGHT", instruction_copyright); //INSTRUCTION("CYLINDRIC"); INSTRUCTION("DAEMONIZE", instruction_daemonize); INSTRUCTION("DROPCNTXT", instruction_dropcntxt); INSTRUCTION("EXTERNALS", instruction_externals); INSTRUCTION("HISTOGRAM", instruction_histogram); INSTRUCTION("MEMUNLOCK", instruction_memunlock); INSTRUCTION("MTXSTATUS", instruction_mtxstatus); INSTRUCTION("MTXUNLOCK", instruction_mtxunlock); INSTRUCTION("PARAMETER", instruction_parameter); //INSTRUCTION("PSCONTOUR") //INSTRUCTION("SCATRPLOT") //(trace un nuage de points de SDAT et la courbe de régression) INSTRUCTION("SMPHRDECR", instruction_smphrdecr); INSTRUCTION("SMPHRGETV", instruction_smphrgetv); INSTRUCTION("SMPHRINCR", instruction_smphrincr); INSTRUCTION("SWAPCNTXT", instruction_swapcntxt); INSTRUCTION("SWISTATUS", instruction_swistatus); INSTRUCTION("SWIUNLOCK", instruction_swiunlock); INSTRUCTION("UNPROTECT", instruction_unprotect); INSTRUCTION("WIREFRAME", instruction_wireframe); INSTRUCTION("MTXTRYLOCK", instruction_mtxtrylock); INSTRUCTION("PARAMETRIC", instruction_parametric); //INSTRUCTION("PARSURFACE") //Instruction HP48 (tracé PARSURFACE) Equation sous forme de liste INSTRUCTION("SLICESCALE", instruction_slicescale); INSTRUCTION("SQLCONNECT", instruction_sqlconnect); //INSTRUCTION("SLOPEFIELD") //Instruction HP48 (type de tracé) //Tracé 3D en courbes de niveaux. //Le type de tracé 'SLOPEFIELD' dessine un réseau de segments dont les //pentes //représentent la valeur de la fonction (x,y) en leur milieu. //=> utile pour y'=F(x,y) INSTRUCTION("UNCOMPRESS", instruction_uncompress); INSTRUCTION("LOCALIZATION", instruction_localization); INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr); INSTRUCTION("SQLDISCONNECT", instruction_sqldisconnect); #undef INSTRUCTION return; } void * analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) { int pointeur; struct_instruction *l_instruction_courante; l_instruction_courante = (*s_etat_processus).arbre_instructions; while((*ptr) != d_code_fin_chaine) { pointeur = (*s_etat_processus).pointeurs_caracteres[*ptr]; if (pointeur < 0) { // Caractère hors de l'alphabet des instructions return(NULL); } if ((*l_instruction_courante).noeuds[pointeur] == NULL) { // Le chemin de l'instruction candidate n'existe pas. return(NULL); } l_instruction_courante = (*l_instruction_courante).noeuds[pointeur]; ptr++; if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine)) { // Le chemin de l'instruction candidate est incomplet. return(NULL); } } if ((*l_instruction_courante).feuille != NULL) { return((*l_instruction_courante).feuille); } return(NULL); } void analyse(struct_processus *s_etat_processus, void (*fonction)()) { real8 attente; real8 pourcentage; real8 temps_cpu; real8 temps_reel; static struct timeval horodatage_initial; struct timeval horodatage_final; # ifndef OS2 static struct rusage usage_initial; struct rusage usage_final; # else static clock_t usage_initial; clock_t usage_final; # endif struct timespec temporisation; unsigned char *position; unsigned char *bibliotheque_candidate; unsigned char instruction_majuscule [d_longueur_maximale_instruction]; unsigned char registre_instruction_valide; void (*instruction)(); errno = 0; (*s_etat_processus).var_volatile_exception_gsl = 0; (*s_etat_processus).instruction_valide = 'Y'; (*s_etat_processus).constante_symbolique = 'N'; (*s_etat_processus).nombre_arguments = -2; (*s_etat_processus).instruction_intrinseque = 'I'; /* * On autorise l'exécution d'un fork() dans un thread concurrent. */ # ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) # else if (sem_post((*s_etat_processus).semaphore_fork) != 0) # endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; } # ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) # else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) # endif { if (errno != EINTR) { (*s_etat_processus).erreur_systeme = d_es_processus; return; } } /* * Verrou pour les sections_critiques */ if (pthread_mutex_lock(&mutex_sections_critiques) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; } if (pthread_mutex_unlock(&mutex_sections_critiques) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; } scrutation_injection(s_etat_processus); if (fonction == NULL) { conversion_majuscule_limitee((*s_etat_processus).instruction_courante, instruction_majuscule, d_longueur_maximale_instruction); instruction = analyse_instruction(s_etat_processus, instruction_majuscule); if (instruction == NULL) { // L'instruction n'existe pas. (*s_etat_processus).instruction_valide = 'N'; } else { // Exécution de l'instruction associée. Le drapeau // (*s_etat_processus).instruction_valide peut passer à 'N' // dans le cas d'instructions sensibles à la casse. if ((*s_etat_processus).niveau_profilage >= 2) { profilage(s_etat_processus, instruction_majuscule); } (*s_etat_processus).instruction_valide = 'Y'; instruction(s_etat_processus); if ((*s_etat_processus).niveau_profilage >= 2) { profilage(s_etat_processus, NULL); } } } else { if ((*s_etat_processus).niveau_profilage >= 2) { profilage(s_etat_processus, (*s_etat_processus).instruction_courante); } (*s_etat_processus).instruction_valide = 'Y'; fonction(s_etat_processus); if ((*s_etat_processus).niveau_profilage >= 2) { profilage(s_etat_processus, NULL); } } if ((*s_etat_processus).instruction_valide == 'Y') { (*s_etat_processus).instruction_intrinseque = 'Y'; } if ((*s_etat_processus).instruction_valide == 'N') { if ((position = index((*s_etat_processus).instruction_courante, '$')) != NULL) { if ((bibliotheque_candidate = malloc(((size_t) (position + 1 - (*s_etat_processus).instruction_courante)) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*bibliotheque_candidate) = d_code_fin_chaine; strncat(bibliotheque_candidate, (*s_etat_processus).instruction_courante, ((size_t) (position - (*s_etat_processus).instruction_courante))); position++; if (execution_fonction_de_bibliotheque(s_etat_processus, position, bibliotheque_candidate) == d_vrai) { (*s_etat_processus).instruction_valide = 'Y'; (*s_etat_processus).instruction_intrinseque = 'N'; } else { (*s_etat_processus).instruction_valide = 'N'; } free(bibliotheque_candidate); } else { if (execution_fonction_de_bibliotheque(s_etat_processus, (*s_etat_processus).instruction_courante, NULL) == d_vrai) { (*s_etat_processus).instruction_valide = 'Y'; (*s_etat_processus).instruction_intrinseque = 'N'; } else { (*s_etat_processus).instruction_valide = 'N'; } } } /* -------------------------------------------------------------------------------- Gestion des interruptions logicielles -------------------------------------------------------------------------------- */ if (((*s_etat_processus).erreur_systeme == d_es) && ((*s_etat_processus).erreur_execution == d_ex) && ((*s_etat_processus).exception == d_ep)) { if ((*s_etat_processus).test_instruction == 'N') { if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; } else { if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) { affectation_interruptions_logicielles(s_etat_processus); } if (pthread_mutex_unlock(&(*s_etat_processus) .mutex_interruptions) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; } } if (((*s_etat_processus).nombre_interruptions_en_queue != 0) && ((*s_etat_processus).erreur_systeme == d_es) && ((*s_etat_processus).erreur_execution == d_ex)) { registre_instruction_valide = (*s_etat_processus).instruction_valide; traitement_interruptions_logicielles(s_etat_processus); (*s_etat_processus).instruction_valide = registre_instruction_valide; } } } /* -------------------------------------------------------------------------------- Limitation du pourcetage de temps CPU -------------------------------------------------------------------------------- */ if ((*s_etat_processus).pourcentage_maximal_cpu < 100) { # ifndef OS2 getrusage(RUSAGE_SELF, &usage_final); # else usage_final = clock(); # endif gettimeofday(&horodatage_final, NULL); if ((*s_etat_processus).initialisation_scheduler == d_vrai) { temps_reel = ((real8) (horodatage_final.tv_sec - horodatage_initial.tv_sec)) + (((real8) (horodatage_final.tv_usec - horodatage_initial.tv_usec)) / ((real8) 1E6)); // Le temps depuis la dernière limitation est de plus de un // dixième de seconde. if (temps_reel >= 0.1) { # ifndef OS2 temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec + usage_final.ru_stime.tv_sec) - (usage_initial.ru_utime.tv_sec + usage_initial.ru_stime.tv_sec))) + (((real8) ((usage_final.ru_utime.tv_usec + usage_final.ru_stime.tv_usec) - (usage_initial.ru_utime.tv_usec + usage_initial.ru_stime.tv_usec))) / ((real8) 1E6)); # else temps_cpu = (usage_final - usage_initial) / CLOCKS_PER_SEC; # endif pourcentage = 100 * temps_cpu / temps_reel; if (pourcentage > 100) { pourcentage = 100; } if (pourcentage > (*s_etat_processus).pourcentage_maximal_cpu) { attente = ((pourcentage * temps_cpu) / (*s_etat_processus).pourcentage_maximal_cpu) - (pourcentage * temps_cpu / 100); temporisation.tv_sec = (time_t) floor(attente); temporisation.tv_nsec = (suseconds_t) ((attente - ((real8) temporisation.tv_sec)) * 1E9); while(nanosleep(&temporisation, &temporisation) == -1) { if (errno != EINTR) { break; } } } horodatage_initial = horodatage_final; usage_initial = usage_final; } } else { (*s_etat_processus).initialisation_scheduler = d_vrai; horodatage_initial = horodatage_final; usage_initial = usage_final; } } else { (*s_etat_processus).initialisation_scheduler = d_faux; } /* -------------------------------------------------------------------------------- Introduction des erreurs générées -------------------------------------------------------------------------------- */ if (((*s_etat_processus).test_instruction == 'N') && ((*s_etat_processus).instruction_valide == 'Y')) { traitement_asynchrone_exceptions_gsl(s_etat_processus); if ((*s_etat_processus).erreur_processus_fils == d_vrai) { (*s_etat_processus).erreur_processus_fils = d_faux; (*s_etat_processus).erreur_systeme = (*s_etat_processus).erreur_systeme_processus_fils; (*s_etat_processus).erreur_execution = (*s_etat_processus).erreur_execution_processus_fils; (*s_etat_processus).arret_si_exception = d_vrai; if ((*s_etat_processus).pid_erreur_processus_fils == getpid()) { (*s_etat_processus).invalidation_message_erreur = d_faux; } else { (*s_etat_processus).invalidation_message_erreur = d_vrai; } } if (((*s_etat_processus).erreur_execution != d_ex) || ((*s_etat_processus).erreur_systeme != d_es) || ((*s_etat_processus).exception != d_ep)) { (*s_etat_processus).niveau_derniere_erreur = (*s_etat_processus).niveau_courant; if ((*s_etat_processus).mode_execution_programme == 'Y') { if ((*s_etat_processus).instruction_derniere_erreur != NULL) { free((*s_etat_processus).instruction_derniere_erreur); (*s_etat_processus).instruction_derniere_erreur = NULL; } if ((*s_etat_processus).instruction_courante == NULL) { if (((*s_etat_processus).instruction_derniere_erreur = malloc(16 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*s_etat_processus).instruction_derniere_erreur, ""); } else { if (((*s_etat_processus).instruction_derniere_erreur = malloc((strlen((*s_etat_processus) .instruction_courante) + 1) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*s_etat_processus).instruction_derniere_erreur, (*s_etat_processus).instruction_courante); } } else { if ((*s_etat_processus).objet_courant != NULL) { if ((*s_etat_processus).instruction_derniere_erreur != NULL) { free((*s_etat_processus).instruction_derniere_erreur); (*s_etat_processus).instruction_derniere_erreur = NULL; } if (((*s_etat_processus).instruction_derniere_erreur = formateur(s_etat_processus, 0, (*s_etat_processus).objet_courant)) == NULL) { return; } (*s_etat_processus).objet_courant = NULL; } } } } return; } /* ================================================================================ Traitement asynchrone des erreurs de la bibliothèque GSL ================================================================================ Entrées : -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void traitement_asynchrone_exceptions_gsl(struct_processus *s_etat_processus) { if ((*s_etat_processus).var_volatile_exception_gsl != 0) { switch((*s_etat_processus).var_volatile_exception_gsl) { case GSL_EINVAL : { (*s_etat_processus).erreur_execution = d_ex_argument_invalide; break; } case GSL_EDOM : { (*s_etat_processus).exception = d_ep_domaine_definition; break; } case GSL_ERANGE : { (*s_etat_processus).exception = d_ep_resultat_indefini; break; } case GSL_EZERODIV : { (*s_etat_processus).exception = d_ep_division_par_zero; break; } case GSL_EUNDRFLW : { (*s_etat_processus).exception = d_ep_underflow; break; } case GSL_EOVRFLW : { (*s_etat_processus).exception = d_ep_overflow; break; } case GSL_ENOMEM : { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; break; } case GSL_ELOSS : { (*s_etat_processus).exception = d_ep_perte_precision; break; } default : { (*s_etat_processus).erreur_execution = d_ex_routines_mathematiques; break; } } (*s_etat_processus).var_volatile_exception_gsl = 0; } return; } // vim: ts=4