Annotation of rpl/src/analyse.c, revision 1.1
1.1 ! bertrand 1: /*
! 2: ================================================================================
! 3: RPL/2 (R) version 4.0.9
! 4: Copyright (C) 1989-2010 Dr. BERTRAND Joël
! 5:
! 6: This file is part of RPL/2.
! 7:
! 8: RPL/2 is free software; you can redistribute it and/or modify it
! 9: under the terms of the CeCILL V2 License as published by the french
! 10: CEA, CNRS and INRIA.
! 11:
! 12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
! 13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! 14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
! 15: for more details.
! 16:
! 17: You should have received a copy of the CeCILL License
! 18: along with RPL/2. If not, write to info@cecill.info.
! 19: ================================================================================
! 20: */
! 21:
! 22:
! 23: #include "rpl.conv.h"
! 24:
! 25:
! 26: /*
! 27: ================================================================================
! 28: Analyseur syntaxique de l'interpréteur RPL/2
! 29: ================================================================================
! 30: Entrées :
! 31: --------------------------------------------------------------------------------
! 32: Sorties :
! 33: --------------------------------------------------------------------------------
! 34: Effets de bord : néant
! 35: ================================================================================
! 36: */
! 37:
! 38:
! 39: static void
! 40: creation_instruction(struct_processus *s_etat_processus,
! 41: unsigned char *instruction, void (*routine)())
! 42: {
! 43: int i;
! 44:
! 45: struct_instruction *l_instruction_courante;
! 46:
! 47: unsigned char *ptr;
! 48:
! 49: if ((*s_etat_processus).arbre_instructions == NULL)
! 50: {
! 51: if (((*s_etat_processus).arbre_instructions =
! 52: malloc(sizeof(struct_instruction))) == NULL)
! 53: {
! 54: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 55: return;
! 56: }
! 57:
! 58: (*(*s_etat_processus).arbre_instructions).feuille = NULL;
! 59:
! 60: if (((*(*s_etat_processus).arbre_instructions).noeud =
! 61: malloc((*s_etat_processus).nombre_caracteres
! 62: * sizeof(struct_instruction))) == NULL)
! 63: {
! 64: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 65: return;
! 66: }
! 67:
! 68: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
! 69: {
! 70: (*(*s_etat_processus).arbre_instructions).noeud[i] = NULL;
! 71: }
! 72: }
! 73:
! 74: l_instruction_courante = (*s_etat_processus).arbre_instructions;
! 75: ptr = instruction;
! 76:
! 77: while((*ptr) != d_code_fin_chaine)
! 78: {
! 79: BUG((*s_etat_processus).pointeurs_caracteres[*ptr] < 0,
! 80: printf("Instruction=\"%s\", (*ptr)='%c'\n",
! 81: instruction, *ptr));
! 82:
! 83: if ((*l_instruction_courante).noeud[(*s_etat_processus)
! 84: .pointeurs_caracteres[*ptr]] == NULL)
! 85: {
! 86: // Le noeud suivant n'existe pas, on le crée.
! 87:
! 88: if (((*l_instruction_courante).noeud[(*s_etat_processus)
! 89: .pointeurs_caracteres[*ptr]] =
! 90: malloc(sizeof(struct_instruction))) == NULL)
! 91: {
! 92: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 93: return;
! 94: }
! 95:
! 96: (*(*l_instruction_courante).noeud[(*s_etat_processus)
! 97: .pointeurs_caracteres[*ptr]]).feuille = NULL;
! 98:
! 99: if (((*(*l_instruction_courante).noeud[(*s_etat_processus)
! 100: .pointeurs_caracteres[*ptr]]).noeud =
! 101: malloc((*s_etat_processus).nombre_caracteres
! 102: * sizeof(struct_instruction))) == NULL)
! 103: {
! 104: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 105: return;
! 106: }
! 107:
! 108: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
! 109: {
! 110: (*(*l_instruction_courante).noeud[(*s_etat_processus)
! 111: .pointeurs_caracteres[*ptr]]).noeud[i] = NULL;
! 112: }
! 113: }
! 114:
! 115: l_instruction_courante = (*l_instruction_courante).noeud
! 116: [(*s_etat_processus).pointeurs_caracteres[*ptr]];
! 117: ptr++;
! 118: }
! 119:
! 120: BUG((*l_instruction_courante).feuille != NULL,
! 121: printf("Instruction=\"%s\"\n", instruction));
! 122:
! 123: (*l_instruction_courante).feuille = routine;
! 124:
! 125: return;
! 126: }
! 127:
! 128:
! 129: void
! 130: liberation_arbre_instructions(struct_processus *s_etat_processus,
! 131: struct_instruction *arbre)
! 132: {
! 133: int i;
! 134:
! 135: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
! 136: {
! 137: if ((*arbre).noeud[i] != NULL)
! 138: {
! 139: liberation_arbre_instructions(s_etat_processus, (*arbre).noeud[i]);
! 140: }
! 141: }
! 142:
! 143: free((*arbre).noeud);
! 144: free(arbre);
! 145:
! 146: return;
! 147: }
! 148:
! 149:
! 150: /*
! 151: * Caractères autorisés dans les instructions
! 152: *
! 153: * 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
! 154: * e i (mais traités comme des majuscules grâce à 'instruction_*_sensible()'
! 155: * + - * / % ^ < > = ? 1 2
! 156: */
! 157:
! 158: void
! 159: initialisation_instructions(struct_processus *s_etat_processus)
! 160: {
! 161: int decalage;
! 162: int i;
! 163: int longueur_tableau;
! 164:
! 165: unsigned char caractere;
! 166:
! 167: // Récupération de la longueur d'un unsigned char
! 168:
! 169: longueur_tableau = 1;
! 170: decalage = 0;
! 171: caractere = 1;
! 172:
! 173: while((1L << decalage) == (long) ((unsigned char) (caractere << decalage)))
! 174: {
! 175: decalage++;
! 176: longueur_tableau *= 2;
! 177: }
! 178:
! 179: if (((*s_etat_processus).pointeurs_caracteres =
! 180: malloc(longueur_tableau * sizeof(int))) == NULL)
! 181: {
! 182: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 183: return;
! 184: }
! 185:
! 186: for(i = 0; i < longueur_tableau; i++)
! 187: {
! 188: (*s_etat_processus).pointeurs_caracteres[i] = -1;
! 189: }
! 190:
! 191: (*s_etat_processus).nombre_caracteres = 0;
! 192:
! 193: #define DECLARATION_CARACTERE(c) \
! 194: do { (*s_etat_processus).pointeurs_caracteres[c] = \
! 195: (*s_etat_processus).nombre_caracteres++; } while(0)
! 196:
! 197: DECLARATION_CARACTERE('A');
! 198: DECLARATION_CARACTERE('B');
! 199: DECLARATION_CARACTERE('C');
! 200: DECLARATION_CARACTERE('D');
! 201: DECLARATION_CARACTERE('E');
! 202: DECLARATION_CARACTERE('F');
! 203: DECLARATION_CARACTERE('G');
! 204: DECLARATION_CARACTERE('H');
! 205: DECLARATION_CARACTERE('I');
! 206: DECLARATION_CARACTERE('J');
! 207: DECLARATION_CARACTERE('K');
! 208: DECLARATION_CARACTERE('L');
! 209: DECLARATION_CARACTERE('M');
! 210: DECLARATION_CARACTERE('N');
! 211: DECLARATION_CARACTERE('O');
! 212: DECLARATION_CARACTERE('P');
! 213: DECLARATION_CARACTERE('Q');
! 214: DECLARATION_CARACTERE('R');
! 215: DECLARATION_CARACTERE('S');
! 216: DECLARATION_CARACTERE('T');
! 217: DECLARATION_CARACTERE('U');
! 218: DECLARATION_CARACTERE('V');
! 219: DECLARATION_CARACTERE('W');
! 220: DECLARATION_CARACTERE('X');
! 221: DECLARATION_CARACTERE('Y');
! 222: DECLARATION_CARACTERE('Z');
! 223: DECLARATION_CARACTERE('+');
! 224: DECLARATION_CARACTERE('-');
! 225: DECLARATION_CARACTERE('/');
! 226: DECLARATION_CARACTERE('*');
! 227: DECLARATION_CARACTERE('%');
! 228: DECLARATION_CARACTERE('^');
! 229: DECLARATION_CARACTERE('<');
! 230: DECLARATION_CARACTERE('>');
! 231: DECLARATION_CARACTERE('=');
! 232: DECLARATION_CARACTERE('?');
! 233: DECLARATION_CARACTERE('1');
! 234: DECLARATION_CARACTERE('2');
! 235:
! 236: #undef DECLARATION_CARACTERE
! 237:
! 238: #define INSTRUCTION(chaine, fonction) \
! 239: creation_instruction(s_etat_processus, chaine, fonction)
! 240:
! 241: INSTRUCTION("E", instruction_sensible_e);
! 242: INSTRUCTION("I", instruction_sensible_i);
! 243: INSTRUCTION("+", instruction_plus);
! 244: INSTRUCTION("-", instruction_moins);
! 245: INSTRUCTION("*", instruction_multiplication);
! 246: INSTRUCTION("/", instruction_division);
! 247: INSTRUCTION("%", instruction_pourcent);
! 248: INSTRUCTION("^", instruction_puissance);
! 249: INSTRUCTION("<", instruction_lt);
! 250: INSTRUCTION("=", instruction_egalite);
! 251: INSTRUCTION(">", instruction_gt);
! 252:
! 253: INSTRUCTION("CF", instruction_cf);
! 254: INSTRUCTION("CR", instruction_cr);
! 255: INSTRUCTION("DO", instruction_do);
! 256: INSTRUCTION("FP", instruction_fp);
! 257: INSTRUCTION("IF", instruction_if);
! 258: INSTRUCTION("IM", instruction_im);
! 259: INSTRUCTION("IN", instruction_in);
! 260: INSTRUCTION("IP", instruction_ip);
! 261: INSTRUCTION("LN", instruction_ln);
! 262: INSTRUCTION("LQ", instruction_lq);
! 263: INSTRUCTION("LU", instruction_lu);
! 264: INSTRUCTION("NS", instruction_ns);
! 265: INSTRUCTION("OR", instruction_or);
! 266: INSTRUCTION("PI", instruction_pi);
! 267: INSTRUCTION("QR", instruction_qr);
! 268: INSTRUCTION("RE", instruction_re);
! 269: INSTRUCTION("RL", instruction_rl);
! 270: INSTRUCTION("RR", instruction_rr);
! 271: INSTRUCTION("SF", instruction_sf);
! 272: INSTRUCTION("SL", instruction_sl);
! 273: INSTRUCTION("SQ", instruction_sq);
! 274: INSTRUCTION("SR", instruction_sr);
! 275: INSTRUCTION("SX", instruction_sx);
! 276: INSTRUCTION("SY", instruction_sy);
! 277: INSTRUCTION("S+", instruction_s_plus);
! 278: INSTRUCTION("S-", instruction_s_moins);
! 279: INSTRUCTION("->", instruction_fleche);
! 280: INSTRUCTION("*D", instruction_star_d);
! 281: INSTRUCTION("*H", instruction_star_h);
! 282: INSTRUCTION("*S", instruction_star_s);
! 283: INSTRUCTION("*W", instruction_star_w);
! 284: INSTRUCTION("**", instruction_puissance);
! 285: INSTRUCTION("%T", instruction_pourcent_t);
! 286: INSTRUCTION("<=", instruction_le);
! 287: INSTRUCTION("<<", instruction_vers_niveau_superieur);
! 288: INSTRUCTION("<>", instruction_ne);
! 289: INSTRUCTION("==", instruction_same);
! 290: INSTRUCTION("=>", instruction_ge);
! 291: INSTRUCTION("=<", instruction_le);
! 292: INSTRUCTION(">=", instruction_ge);
! 293: INSTRUCTION(">>", instruction_vers_niveau_inferieur);
! 294:
! 295: INSTRUCTION("ABS", instruction_abs);
! 296: INSTRUCTION("AND", instruction_and);
! 297: //INSTRUCTION("ARC")
! 298: //(centre, rayon, theta1, theta2 dans le sens trigonométrique)
! 299: INSTRUCTION("ARG", instruction_arg);
! 300: INSTRUCTION("ASL", instruction_asl);
! 301: INSTRUCTION("ASR", instruction_asr);
! 302: //INSTRUCTION("BAR")
! 303: //Instruction HP48 (sélectionne le type de graphique à barres)
! 304: //Chaque point est représenté par une barre verticale.
! 305: INSTRUCTION("BIN", instruction_bin);
! 306: //INSTRUCTION("BOX")
! 307: //(point 1, point 2)
! 308: INSTRUCTION("CHR", instruction_chr);
! 309: INSTRUCTION("CLS", instruction_cls);
! 310: INSTRUCTION("CON", instruction_con);
! 311: INSTRUCTION("COS", instruction_cos);
! 312: INSTRUCTION("COV", instruction_cov);
! 313: INSTRUCTION("DEC", instruction_dec);
! 314: INSTRUCTION("DEG", instruction_deg);
! 315: INSTRUCTION("DER", instruction_der);
! 316: INSTRUCTION("DET", instruction_det);
! 317: INSTRUCTION("DFT", instruction_dft);
! 318: INSTRUCTION("DOT", instruction_dot);
! 319: INSTRUCTION("DUP", instruction_dup);
! 320: INSTRUCTION("EGV", instruction_egv);
! 321: INSTRUCTION("END", instruction_end);
! 322: INSTRUCTION("ENG", instruction_eng);
! 323: INSTRUCTION("EXP", instruction_exp);
! 324: INSTRUCTION("FC?", instruction_fc_test);
! 325: INSTRUCTION("FFT", instruction_fft);
! 326: //INSTRUCTION("FIT")
! 327: //Extension RPL/2 (choix de la méthode de régression, par défaut, 'LINEAR'.
! 328: //Les types sont
! 329: //'LINEAR' => y = b + mx
! 330: //'LOGARITHMIC' => y = b + m ln(x)
! 331: //'EXPONENTIAL' => y = be^(mx) ou ln(y) = ln(b) + mx
! 332: //'POWER' => y = bx^m ou ln(y) = ln(b) + m ln(x)
! 333: INSTRUCTION("FIX", instruction_fix);
! 334: INSTRUCTION("FOR", instruction_for);
! 335: INSTRUCTION("FS?", instruction_fs_test);
! 336: INSTRUCTION("GET", instruction_get);
! 337: INSTRUCTION("HEX", instruction_hex);
! 338: INSTRUCTION("IDN", instruction_idn);
! 339: INSTRUCTION("IFT", instruction_ift);
! 340: INSTRUCTION("INT", instruction_int);
! 341: INSTRUCTION("INV", instruction_inv);
! 342: INSTRUCTION("KEY", instruction_key);
! 343: INSTRUCTION("LOG", instruction_log);
! 344: INSTRUCTION("LSQ", instruction_lsq);
! 345: INSTRUCTION("MAX", instruction_max);
! 346: INSTRUCTION("MEM", instruction_mem);
! 347: INSTRUCTION("MIN", instruction_min);
! 348: INSTRUCTION("MOD", instruction_mod);
! 349: INSTRUCTION("NEG", instruction_neg);
! 350: INSTRUCTION("NOT", instruction_not);
! 351: INSTRUCTION("NUM", instruction_num);
! 352: INSTRUCTION("OCT", instruction_oct);
! 353: INSTRUCTION("POS", instruction_pos);
! 354: INSTRUCTION("PR1", instruction_pr1);
! 355: INSTRUCTION("PUT", instruction_put);
! 356: INSTRUCTION("RAD", instruction_rad);
! 357: INSTRUCTION("RCI", instruction_rci);
! 358: INSTRUCTION("RCL", instruction_rcl);
! 359: INSTRUCTION("RDM", instruction_rdm);
! 360: INSTRUCTION("RDZ", instruction_rdz);
! 361: INSTRUCTION("RES", instruction_res);
! 362: INSTRUCTION("RLB", instruction_rlb);
! 363: INSTRUCTION("RND", instruction_rnd);
! 364: INSTRUCTION("ROT", instruction_rot);
! 365: INSTRUCTION("RRB", instruction_rrb);
! 366: INSTRUCTION("RSD", instruction_rsd);
! 367: INSTRUCTION("SCI", instruction_sci);
! 368: INSTRUCTION("SIN", instruction_sin);
! 369: INSTRUCTION("SLB", instruction_slb);
! 370: INSTRUCTION("SRB", instruction_srb);
! 371: INSTRUCTION("SST", instruction_sst);
! 372: INSTRUCTION("STD", instruction_std);
! 373: INSTRUCTION("STO", instruction_sto);
! 374: INSTRUCTION("SVD", instruction_svd);
! 375: INSTRUCTION("SVL", instruction_svl);
! 376: INSTRUCTION("SUB", instruction_sub);
! 377: INSTRUCTION("SWI", instruction_swi);
! 378: INSTRUCTION("SX2", instruction_sx2);
! 379: INSTRUCTION("SXY", instruction_sxy);
! 380: INSTRUCTION("SY2", instruction_sy2);
! 381: INSTRUCTION("TAN", instruction_tan);
! 382: INSTRUCTION("TOT", instruction_tot);
! 383: INSTRUCTION("TRN", instruction_trn);
! 384: INSTRUCTION("USE", instruction_use);
! 385: INSTRUCTION("VAR", instruction_var);
! 386: //INSTRUCTION("V->")
! 387: //Instruction HP48 (éclate un vecteur [ x y ] => x y quel que soit le
! 388: //système de
! 389: //coordonnées)
! 390: INSTRUCTION("XOR", instruction_xor);
! 391: INSTRUCTION("->Q", instruction_fleche_q);
! 392: INSTRUCTION("%CH", instruction_pourcent_ch);
! 393:
! 394: INSTRUCTION("ACOS", instruction_acos);
! 395: INSTRUCTION("ALOG", instruction_alog);
! 396: INSTRUCTION("ASIN", instruction_asin);
! 397: INSTRUCTION("ATAN", instruction_atan);
! 398: INSTRUCTION("AXES", instruction_axes);
! 399: INSTRUCTION("BEEP", instruction_beep);
! 400: INSTRUCTION("B->R", instruction_b_vers_r);
! 401: INSTRUCTION("CASE", instruction_case);
! 402: INSTRUCTION("CEIL", instruction_ceil);
! 403: INSTRUCTION("CLMF", instruction_clmf);
! 404: INSTRUCTION("CNRM", instruction_cnrm);
! 405: INSTRUCTION("COLS", instruction_cols);
! 406: INSTRUCTION("COL+", instruction_col_plus);
! 407: INSTRUCTION("COL-", instruction_col_moins);
! 408: INSTRUCTION("COMB", instruction_comb);
! 409: INSTRUCTION("COND", instruction_cond);
! 410: INSTRUCTION("CONJ", instruction_conj);
! 411: INSTRUCTION("CONT", instruction_cont);
! 412: INSTRUCTION("COPY", instruction_copy);
! 413: INSTRUCTION("CORR", instruction_corr);
! 414: INSTRUCTION("COSH", instruction_cosh);
! 415: INSTRUCTION("CSWP", instruction_cswp);
! 416: INSTRUCTION("C->R", instruction_c_vers_r);
! 417: INSTRUCTION("DATE", instruction_date);
! 418: INSTRUCTION("DECR", instruction_decr);
! 419: INSTRUCTION("DISP", instruction_disp);
! 420: INSTRUCTION("DRAW", instruction_draw);
! 421: INSTRUCTION("DRAX", instruction_drax);
! 422: INSTRUCTION("DROP", instruction_drop);
! 423: INSTRUCTION("DRWS", instruction_drws);
! 424: INSTRUCTION("DUP2", instruction_dup2);
! 425: INSTRUCTION("DUPN", instruction_dupn);
! 426: INSTRUCTION("D->R", instruction_d_vers_r);
! 427: INSTRUCTION("EDIT", instruction_edit);
! 428: INSTRUCTION("EGVL", instruction_egvl);
! 429: INSTRUCTION("ELSE", instruction_else);
! 430: INSTRUCTION("ERRM", instruction_errm);
! 431: INSTRUCTION("ERRN", instruction_errn);
! 432: INSTRUCTION("EVAL", instruction_eval);
! 433: INSTRUCTION("EXIT", instruction_exit);
! 434: INSTRUCTION("EXPM", instruction_expm);
! 435: INSTRUCTION("FACT", instruction_fact);
! 436: INSTRUCTION("FC?C", instruction_fc_test_c);
! 437: INSTRUCTION("FC?S", instruction_fc_test_s);
! 438: //INSTRUCTION("FORM")
! 439: INSTRUCTION("FS?C", instruction_fs_test_c);
! 440: INSTRUCTION("FS?S", instruction_fs_test_s);
! 441: INSTRUCTION("FUSE", instruction_fuse);
! 442: INSTRUCTION("GEGV", instruction_gegv);
! 443: INSTRUCTION("GETC", instruction_getc);
! 444: INSTRUCTION("GETI", instruction_geti);
! 445: INSTRUCTION("GETR", instruction_getr);
! 446: INSTRUCTION("HALT", instruction_halt);
! 447: INSTRUCTION("HEAD", instruction_head);
! 448: INSTRUCTION("HELP", instruction_help);
! 449: INSTRUCTION("HMS+", instruction_hms_plus);
! 450: INSTRUCTION("HMS-", instruction_hms_moins);
! 451: //INSTRUCTION("HOME");
! 452: INSTRUCTION("IDFT", instruction_idft);
! 453: INSTRUCTION("IFFT", instruction_ifft);
! 454: INSTRUCTION("IFTE", instruction_ifte);
! 455: INSTRUCTION("INCR", instruction_incr);
! 456: //INSTRUCTION("ISOL");
! 457: INSTRUCTION("ISWI", instruction_iswi);
! 458: INSTRUCTION("KILL", instruction_kill);
! 459: INSTRUCTION("KIND", instruction_kind);
! 460: INSTRUCTION("LAST", instruction_last);
! 461: INSTRUCTION("LEGV", instruction_legv);
! 462: INSTRUCTION("LINE", instruction_line);
! 463: INSTRUCTION("LNP1", instruction_lnp1);
! 464: INSTRUCTION("LOCK", instruction_lock);
! 465: INSTRUCTION("MANT", instruction_mant);
! 466: INSTRUCTION("MARK", instruction_mark);
! 467: //INSTRUCTION("MAXR")
! 468: INSTRUCTION("MAXS", instruction_maxs);
! 469: INSTRUCTION("MEAN", instruction_mean);
! 470: //INSTRUCTION("MINR");
! 471: INSTRUCTION("MINS", instruction_mins); // MAXDOUBLE/MINDOUBLE
! 472: INSTRUCTION("NEXT", instruction_next);
! 473: //INSTRUCTION("NUMX");
! 474: //INSTRUCTION("NUMY");
! 475: INSTRUCTION("OPEN", instruction_open);
! 476: INSTRUCTION("OVER", instruction_over);
! 477: //INSTRUCTION("PATH");
! 478: INSTRUCTION("PCOV", instruction_pcov);
! 479: INSTRUCTION("PEEK", instruction_peek);
! 480: INSTRUCTION("PERM", instruction_perm);
! 481: INSTRUCTION("PICK", instruction_pick);
! 482: INSTRUCTION("PLOT", instruction_plot);
! 483: INSTRUCTION("PMAX", instruction_pmax);
! 484: INSTRUCTION("PMIN", instruction_pmin);
! 485: INSTRUCTION("POKE", instruction_poke);
! 486: INSTRUCTION("PPAR", instruction_ppar);
! 487: INSTRUCTION("PRMD", instruction_prmd);
! 488: INSTRUCTION("PRST", instruction_prst);
! 489: INSTRUCTION("PUTC", instruction_putc);
! 490: INSTRUCTION("PUTI", instruction_puti);
! 491: INSTRUCTION("PUTR", instruction_putr);
! 492: INSTRUCTION("PVAR", instruction_pvar);
! 493: INSTRUCTION("P->R", instruction_p_vers_r);
! 494: //INSTRUCTION("QUAD");
! 495: INSTRUCTION("RAND", instruction_rand);
! 496: INSTRUCTION("RANK", instruction_rank);
! 497: //INSTRUCTION("RANM")
! 498: //Instruction HP48 (crée une matrice aléatoire
! 499: //{ nb_lignes nb_colonnes } ou tableau quelconque dont les éléments seront
! 500: //modifiés pour prendre des valeurs aléatoires entre -9 et 9)
! 501: INSTRUCTION("RCEQ", instruction_rceq);
! 502: INSTRUCTION("RCIJ", instruction_rcij);
! 503: INSTRUCTION("RCLF", instruction_rclf);
! 504: INSTRUCTION("RCLS", instruction_rcls);
! 505: INSTRUCTION("RCWS", instruction_rcws);
! 506: INSTRUCTION("RDGN", instruction_rdgn);
! 507: INSTRUCTION("READ", instruction_read);
! 508: INSTRUCTION("RECV", instruction_recv);
! 509: INSTRUCTION("REGV", instruction_regv);
! 510: INSTRUCTION("REPL", instruction_repl);
! 511: INSTRUCTION("RNRM", instruction_rnrm);
! 512: INSTRUCTION("ROLL", instruction_roll);
! 513: //INSTRUCTION("ROOT")
! 514: INSTRUCTION("ROW-", instruction_row_moins);
! 515: INSTRUCTION("ROW+", instruction_row_plus);
! 516: //INSTRUCTION("RREF")
! 517: //Instruction HP48 (transforme [A B] en [I C] par combinaisons linéaires
! 518: //de lignes)
! 519: INSTRUCTION("RSWP", instruction_rswp);
! 520: INSTRUCTION("R->B", instruction_r_vers_b);
! 521: INSTRUCTION("R->C", instruction_r_vers_c);
! 522: INSTRUCTION("R->D", instruction_r_vers_d);
! 523: INSTRUCTION("R->P", instruction_r_vers_p);
! 524: INSTRUCTION("SAME", instruction_same);
! 525: INSTRUCTION("SAVE", instruction_save);
! 526: INSTRUCTION("SCLS", instruction_scls);
! 527: INSTRUCTION("SDEV", instruction_sdev);
! 528: INSTRUCTION("SEND", instruction_send);
! 529: //INSTRUCTION("SHOW");
! 530: INSTRUCTION("SIGN", instruction_sign);
! 531: INSTRUCTION("SINH", instruction_sinh);
! 532: INSTRUCTION("SINV", instruction_sinv);
! 533: INSTRUCTION("SIZE", instruction_size);
! 534: INSTRUCTION("SNEG", instruction_sneg);
! 535: INSTRUCTION("SORT", instruction_sort);
! 536: INSTRUCTION("SPAR", instruction_spar);
! 537: INSTRUCTION("SQRT", instruction_sqrt);
! 538: //INSTRUCTION("SRAD");
! 539: //INSTRUCTION("SRNM")
! 540: //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une
! 541: //matrice,
! 542: //la norme spectrale est égale à sa plus grande valeur singulière. Pour un
! 543: //vecteur, la fonction est équivalente à ABS.
! 544: INSTRUCTION("STEP", instruction_step);
! 545: INSTRUCTION("STEQ", instruction_steq);
! 546: INSTRUCTION("STO*", instruction_sto_fois);
! 547: INSTRUCTION("STO+", instruction_sto_plus);
! 548: INSTRUCTION("STO-", instruction_sto_moins);
! 549: INSTRUCTION("STO/", instruction_sto_division);
! 550: INSTRUCTION("STOF", instruction_stof);
! 551: INSTRUCTION("STOP", instruction_stop);
! 552: INSTRUCTION("STOS", instruction_stos);
! 553: INSTRUCTION("STWS", instruction_stws);
! 554: INSTRUCTION("SWAP", instruction_swap);
! 555: INSTRUCTION("SYNC", instruction_sync);
! 556: INSTRUCTION("TAIL", instruction_tail);
! 557: INSTRUCTION("TANH", instruction_tanh);
! 558: INSTRUCTION("THEN", instruction_then);
! 559: INSTRUCTION("TIME", instruction_time);
! 560: INSTRUCTION("TRIM", instruction_trim);
! 561: INSTRUCTION("TRNC", instruction_trnc);
! 562: INSTRUCTION("TRUE", instruction_true);
! 563: INSTRUCTION("TYPE", instruction_type);
! 564: INSTRUCTION("UTPC", instruction_utpc);
! 565: INSTRUCTION("UTPF", instruction_utpf);
! 566: INSTRUCTION("UTPN", instruction_utpn);
! 567: INSTRUCTION("UTPT", instruction_utpt);
! 568: INSTRUCTION("VARS", instruction_vars);
! 569: INSTRUCTION("WAIT", instruction_wait);
! 570: INSTRUCTION("XCOL", instruction_xcol);
! 571: INSTRUCTION("XPON", instruction_xpon);
! 572: //INSTRUCTION("XRNG")
! 573: //INSTRUCTION("XVOL")
! 574: INSTRUCTION("YCOL", instruction_ycol);
! 575: //INSTRUCTION("YRNG")
! 576: //INSTRUCTION("YVOL")
! 577: //INSTRUCTION("ZVOL")
! 578: //INSTRUCTION("->V2")
! 579: //Instruction HP48 (combine deux réels x et y en un vecteur 2D en fonction
! 580: //du mode de coordonnées en cours => [ x y ] et ce quel que soit le système
! 581: //de coordonnées courant)
! 582: //INSTRUCTION("->V3")
! 583:
! 584: INSTRUCTION("ABORT", instruction_abort);
! 585: INSTRUCTION("ACOSH", instruction_acosh);
! 586: INSTRUCTION("ALARM", instruction_alarm);
! 587: INSTRUCTION("ASINH", instruction_asinh);
! 588: INSTRUCTION("ATANH", instruction_atanh);
! 589: //INSTRUCTION("BYTES");
! 590: INSTRUCTION("CENTR", instruction_centr);
! 591: //INSTRUCTION("CIRCL");
! 592: INSTRUCTION("CLEAR", instruction_clear);
! 593: INSTRUCTION("CLLCD", instruction_cllcd);
! 594: INSTRUCTION("CLOSE", instruction_close);
! 595: INSTRUCTION("CLUSR", instruction_clusr);
! 596: //INSTRUCTION("CLVAR");
! 597: //INSTRUCTION("COLCT")
! 598: INSTRUCTION("COL->", instruction_col_fleche);
! 599: //INSTRUCTION("CONIC")
! 600: //Instruction HP48 (sélectionne le type de tracé CONIC)
! 601: //Permet de tracer des coniques en fonction d'équations
! 602: //de type f(x, y) = 0.
! 603: //INSTRUCTION("CRDIR")
! 604: INSTRUCTION("CRMTX", instruction_crmtx);
! 605: INSTRUCTION("CROSS", instruction_cross);
! 606: INSTRUCTION("CRTAB", instruction_crtab);
! 607: INSTRUCTION("CSTOP", instruction_cstop);
! 608: INSTRUCTION("CYCLE", instruction_cycle);
! 609: //INSTRUCTION("CYLIN")
! 610: //Instruction HP48 (sélectionne le type de tracé CYLINDRIC)
! 611: INSTRUCTION("DEPND", instruction_depnd);
! 612: INSTRUCTION("DEPTH", instruction_depth);
! 613: //INSTRUCTION("DOSUB")
! 614: //Instruction HP48 (application séquentielle d'une fonction à une liste)
! 615: //liste nombre_elements_traites_a_chaque_iteration fonction DOSUB
! 616: //{ 1 2 3 4 5 }
! 617: //2
! 618: //<< + 2 / >>
! 619: //DOSUB
! 620: //=> { 1.5 2.5 3.5 4.5 }
! 621: INSTRUCTION("DGTIZ", instruction_dgtiz);
! 622: INSTRUCTION("DROP2", instruction_drop2);
! 623: INSTRUCTION("DROPN", instruction_dropn);
! 624: INSTRUCTION("ERASE", instruction_erase);
! 625: INSTRUCTION("EXGET", instruction_exget);
! 626: //INSTRUCTION("EXPAN");
! 627: INSTRUCTION("EXSUB", instruction_exsub);
! 628: INSTRUCTION("EYEPT", instruction_eyept);
! 629: INSTRUCTION("FALSE", instruction_false);
! 630: INSTRUCTION("FLOOR", instruction_floor);
! 631: INSTRUCTION("GAMMA", instruction_gamma);
! 632: INSTRUCTION("GEGVL", instruction_gegvl);
! 633: INSTRUCTION("GLEGV", instruction_glegv);
! 634: INSTRUCTION("GREGV", instruction_gregv);
! 635: INSTRUCTION("HMS->", instruction_hms_fleche);
! 636: INSTRUCTION("IFERR", instruction_iferr);
! 637: INSTRUCTION("INDEP", instruction_indep);
! 638: INSTRUCTION("INPUT", instruction_input);
! 639: INSTRUCTION("JDATE", instruction_jdate);
! 640: INSTRUCTION("LABEL", instruction_label);
! 641: INSTRUCTION("LCASE", instruction_lcase);
! 642: INSTRUCTION("LCHOL", instruction_lchol);
! 643: INSTRUCTION("LCD->", instruction_lcd_fleche);
! 644: //INSTRUCTION("NDIST")
! 645: //Instruction HP48 (distribution normale, prend la moyenne au niveau 3,
! 646: //la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité
! 647: //qu'une variable aléatoire normale soit égale à x dans une distribution
! 648: //normale).
! 649: INSTRUCTION("NRAND", instruction_nrand);
! 650: INSTRUCTION("OBGET", instruction_obget);
! 651: INSTRUCTION("OBSUB", instruction_obsub);
! 652: INSTRUCTION("PAPER", instruction_paper);
! 653: //INSTRUCTION("PCOEFF")
! 654: //INSTRUCTION("PEVAL")
! 655: //INSTRUCTION("PGDIR")
! 656: //INSTRUCTION("PIXEL")
! 657: //INSTRUCTION("PLIST")
! 658: //Instruction HP48 (produit des termes d'une liste)
! 659: INSTRUCTION("POLAR", instruction_polar);
! 660: INSTRUCTION("PRINT", instruction_print);
! 661: //INSTRUCTION("PREDV");
! 662: INSTRUCTION("PRLCD", instruction_prlcd);
! 663: //INSTRUCTION("PROOT")
! 664: //Instruction HP48 (calcule les racines d'un polynôme en fonction du tableau
! 665: //de coefficients)
! 666: INSTRUCTION("PRSTC", instruction_prstc);
! 667: INSTRUCTION("PRUSR", instruction_prusr);
! 668: INSTRUCTION("PRVAR", instruction_prvar);
! 669: INSTRUCTION("PSDEV", instruction_psdev);
! 670: INSTRUCTION("PURGE", instruction_purge);
! 671: INSTRUCTION("RDATE", instruction_rdate);
! 672: INSTRUCTION("RELAX", instruction_relax);
! 673: INSTRUCTION("RFUSE", instruction_rfuse);
! 674: INSTRUCTION("RSTOP", instruction_rstop);
! 675: INSTRUCTION("ROLLD", instruction_rolld);
! 676: INSTRUCTION("ROW->", instruction_row_fleche);
! 677: INSTRUCTION("SCALE", instruction_scale);
! 678: INSTRUCTION("SCHED", instruction_sched);
! 679: INSTRUCTION("SCHUR", instruction_schur);
! 680: INSTRUCTION("SCONJ", instruction_sconj);
! 681: INSTRUCTION("SLICE", instruction_slice);
! 682: //INSTRUCTION("SLIST")
! 683: //Instruction HP48 (somme des termes d'une liste)
! 684: INSTRUCTION("SPAWN", instruction_spawn);
! 685: INSTRUCTION("START", instruction_start);
! 686: INSTRUCTION("STORE", instruction_store);
! 687: INSTRUCTION("STR->", instruction_str_fleche);
! 688: INSTRUCTION("TAYLR", instruction_taylr);
! 689: INSTRUCTION("TITLE", instruction_title);
! 690: //INSTRUCTION("TRACE")
! 691: //INSTRUCTION("TRUTH")
! 692: INSTRUCTION("UCASE", instruction_ucase);
! 693: INSTRUCTION("UCHOL", instruction_uchol);
! 694: INSTRUCTION("UNTIL", instruction_until);
! 695: //INSTRUCTION("UPDIR")
! 696: INSTRUCTION("VISIT", instruction_visit);
! 697: INSTRUCTION("WFACK", instruction_wfack);
! 698: INSTRUCTION("WFSWI", instruction_wfswi);
! 699: INSTRUCTION("WHILE", instruction_while);
! 700: //INSTRUCTION("WIDTH")
! 701: INSTRUCTION("WRITE", instruction_write);
! 702: INSTRUCTION("XROOT", instruction_xroot);
! 703: INSTRUCTION("YIELD", instruction_yield);
! 704: INSTRUCTION("->COL", instruction_fleche_col);
! 705: INSTRUCTION("->HMS", instruction_fleche_hms);
! 706: INSTRUCTION("->LCD", instruction_fleche_lcd);
! 707: INSTRUCTION("->NUM", instruction_fleche_num);
! 708: INSTRUCTION("->ROW", instruction_fleche_row);
! 709: INSTRUCTION("->STR", instruction_fleche_str);
! 710:
! 711: INSTRUCTION("APPEND", instruction_append);
! 712: INSTRUCTION("ARRY->", instruction_array_fleche);
! 713: INSTRUCTION("BESSEL", instruction_bessel);
! 714: INSTRUCTION("CLRERR", instruction_clrerr);
! 715: INSTRUCTION("CLRMTX", instruction_clrmtx);
! 716: INSTRUCTION("CLRSWI", instruction_clrswi);
! 717: INSTRUCTION("CREATE", instruction_create);
! 718: INSTRUCTION("DELETE", instruction_delete);
! 719: INSTRUCTION("DETACH", instruction_detach);
! 720: INSTRUCTION("DIAG->", instruction_diag_fleche);
! 721: //INSTRUCTION("DOLIST")
! 722: //Instruction HP48 (application d'une fonction à une liste)
! 723: //liste(s) nombre_de_listes_a_traiter fonction DOLIST
! 724: //{ 1 2 3 }
! 725: //{ 4 5 6 }
! 726: //{ 7 8 9 }
! 727: //3
! 728: //<< * + >>
! 729: //DOLIST
! 730: //=> { 29 42 57 }
! 731: INSTRUCTION("ELSEIF", instruction_elseif);
! 732: INSTRUCTION("FORMAT", instruction_format);
! 733: //INSTRUCTION("HEIGHT")
! 734: INSTRUCTION("ITRACE", instruction_itrace);
! 735: INSTRUCTION("LIST->", instruction_list_fleche);
! 736: INSTRUCTION("LOGGER", instruction_logger);
! 737: INSTRUCTION("MCLRIN", instruction_mclrin);
! 738: INSTRUCTION("NRPROC", instruction_nrproc);
! 739: INSTRUCTION("PROMPT", instruction_prompt);
! 740: INSTRUCTION("RCLSWI", instruction_rclswi);
! 741: INSTRUCTION("RECALL", instruction_recall);
! 742: INSTRUCTION("RECODE", instruction_recode);
! 743: INSTRUCTION("REDRAW", instruction_redraw);
! 744: INSTRUCTION("REMOVE", instruction_remove);
! 745: INSTRUCTION("REPEAT", instruction_repeat);
! 746: INSTRUCTION("RETURN", instruction_return);
! 747: INSTRUCTION("REWIND", instruction_rewind);
! 748: //INSTRUCTION("SCREEN")
! 749: INSTRUCTION("SELECT", instruction_select);
! 750: //INSTRUCTION("SPHERE")
! 751: INSTRUCTION("SHARED", instruction_shared);
! 752: INSTRUCTION("SPLASH", instruction_splash);
! 753: INSTRUCTION("STATIC", instruction_static);
! 754: INSTRUCTION("STOSWI", instruction_stoswi);
! 755: //INSTRUCTION("STREAM", instruction_stream);
! 756: //{ 1 2 3 4 5 } << * >> STREAM => 120
! 757: INSTRUCTION("TARGET", instruction_target);
! 758: INSTRUCTION("UNLOCK", instruction_unlock);
! 759: INSTRUCTION("VERIFY", instruction_verify);
! 760: INSTRUCTION("WFDATA", instruction_wfdata);
! 761: INSTRUCTION("WFLOCK", instruction_wflock);
! 762: INSTRUCTION("WFPOKE", instruction_wfpoke);
! 763: INSTRUCTION("WFPROC", instruction_wfproc);
! 764: INSTRUCTION("WFSOCK", instruction_wfsock);
! 765: INSTRUCTION("->ARRY", instruction_fleche_array);
! 766: INSTRUCTION("->DIAG", instruction_fleche_diag);
! 767: INSTRUCTION("->LIST", instruction_fleche_list);
! 768:
! 769: INSTRUCTION("ARRAY->", instruction_array_fleche);
! 770: //INSTRUCTION("BARPLOT")
! 771: //INSTRUCTION("BESTFIT")
! 772: //Instruction HP48 (choisit le meilleur modèle de régression)
! 773: INSTRUCTION("CLRFUSE", instruction_clrfuse);
! 774: INSTRUCTION("CONVERT", instruction_convert);
! 775: INSTRUCTION("CRSMPHR", instruction_crsmphr);
! 776: INSTRUCTION("CURRENC", instruction_currenc);
! 777: INSTRUCTION("DEFAULT", instruction_default);
! 778: INSTRUCTION("EPSILON", instruction_epsilon);
! 779: //INSTRUCTION("GRIDMAP")
! 780: //Instruction HP48 (sélectionne le mode de tracé GRIDMAP)
! 781: //Le tracé GRIDMAP transforme la grille d'échantillonnage rectiligne
! 782: //en appliquant la fonction en cours à valeurs complexes.
! 783: //Les coordonnées de chaque point de la grille (un nombre complexe)
! 784: //constituent
! 785: //les données d'entrée de la fonction qui les projette ensuite dans le
! 786: //grille
! 787: //de sortie.
! 788: //f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une
! 789: //fonction paramétrique.
! 790: INSTRUCTION("INQUIRE", instruction_inquire);
! 791: INSTRUCTION("MTXLOCK", instruction_mtxlock);
! 792: INSTRUCTION("PERSIST", instruction_persist);
! 793: INSTRUCTION("PLOTTER", instruction_plotter);
! 794: INSTRUCTION("PRIVATE", instruction_private);
! 795: INSTRUCTION("PROTECT", instruction_protect);
! 796: INSTRUCTION("PSHPRFL", instruction_pshprfl);
! 797: INSTRUCTION("PULPRFL", instruction_pulprfl);
! 798: INSTRUCTION("REVLIST", instruction_revlist);
! 799: INSTRUCTION("SCATTER", instruction_scatter);
! 800: INSTRUCTION("SUSPEND", instruction_suspend);
! 801: INSTRUCTION("SWILOCK", instruction_swilock);
! 802: INSTRUCTION("SYSEVAL", instruction_syseval);
! 803: INSTRUCTION("TABLE->", instruction_table_fleche);
! 804: INSTRUCTION("VERSION", instruction_version);
! 805: INSTRUCTION("WORKDIR", instruction_workdir);
! 806: INSTRUCTION("->ARRAY", instruction_fleche_array);
! 807: INSTRUCTION("->TABLE", instruction_fleche_table);
! 808:
! 809: INSTRUCTION("CLRCNTXT", instruction_clrcntxt);
! 810: INSTRUCTION("CLRSMPHR", instruction_clrsmphr);
! 811: INSTRUCTION("CONTINUE", instruction_continue);
! 812: INSTRUCTION("DUPCNTXT", instruction_dupcntxt);
! 813: INSTRUCTION("FUNCTION", instruction_function);
! 814: INSTRUCTION("KEYLABEL", instruction_keylabel);
! 815: INSTRUCTION("KEYTITLE", instruction_keytitle);
! 816: INSTRUCTION("LOGSCALE", instruction_logscale);
! 817: INSTRUCTION("NEWPLANE", instruction_newplane);
! 818: INSTRUCTION("PSHCNTXT", instruction_pshcntxt);
! 819: INSTRUCTION("PULCNTXT", instruction_pulcntxt);
! 820: INSTRUCTION("SQLQUERY", instruction_sqlquery);
! 821: INSTRUCTION("SWIQUEUE", instruction_swiqueue);
! 822: INSTRUCTION("TOKENIZE", instruction_tokenize);
! 823: INSTRUCTION("VARIABLE", instruction_variable);
! 824: INSTRUCTION("VOLATILE", instruction_volatile);
! 825: INSTRUCTION("WARRANTY", instruction_warranty);
! 826:
! 827: INSTRUCTION("AUTOSCALE", instruction_autoscale);
! 828: INSTRUCTION("BACKSPACE", instruction_backspace);
! 829: INSTRUCTION("COPYRIGHT", instruction_copyright);
! 830: //INSTRUCTION("CYLINDRIC");
! 831: INSTRUCTION("DAEMONIZE", instruction_daemonize);
! 832: INSTRUCTION("DROPCNTXT", instruction_dropcntxt);
! 833: INSTRUCTION("EXTERNALS", instruction_externals);
! 834: INSTRUCTION("HISTOGRAM", instruction_histogram);
! 835: INSTRUCTION("MTXSTATUS", instruction_mtxstatus);
! 836: INSTRUCTION("MTXUNLOCK", instruction_mtxunlock);
! 837: INSTRUCTION("PARAMETER", instruction_parameter);
! 838: //INSTRUCTION("PSCONTOUR")
! 839: //INSTRUCTION("SCATRPLOT")
! 840: //(trace un nuage de points de SDAT et la courbe de régression)
! 841: INSTRUCTION("SMPHRDECR", instruction_smphrdecr);
! 842: INSTRUCTION("SMPHRGETV", instruction_smphrgetv);
! 843: INSTRUCTION("SMPHRINCR", instruction_smphrincr);
! 844: INSTRUCTION("SWAPCNTXT", instruction_swapcntxt);
! 845: INSTRUCTION("SWISTATUS", instruction_swistatus);
! 846: INSTRUCTION("SWIUNLOCK", instruction_swiunlock);
! 847: INSTRUCTION("UNPROTECT", instruction_unprotect);
! 848: INSTRUCTION("WIREFRAME", instruction_wireframe);
! 849:
! 850: INSTRUCTION("MTXTRYLOCK", instruction_mtxtrylock);
! 851: INSTRUCTION("PARAMETRIC", instruction_parametric);
! 852: //INSTRUCTION("PARSURFACE")
! 853: //Instruction HP48 (tracé PARSURFACE) Equation sous forme de liste
! 854: INSTRUCTION("SLICESCALE", instruction_slicescale);
! 855: INSTRUCTION("SQLCONNECT", instruction_sqlconnect);
! 856: //INSTRUCTION("SLOPEFIELD")
! 857: //Instruction HP48 (type de tracé)
! 858: //Tracé 3D en courbes de niveaux.
! 859: //Le type de tracé 'SLOPEFIELD' dessine un réseau de segments dont les
! 860: //pentes
! 861: //représentent la valeur de la fonction (x,y) en leur milieu.
! 862: //=> utile pour y'=F(x,y)
! 863:
! 864: INSTRUCTION("LOCALIZATION", instruction_localization);
! 865: INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr);
! 866:
! 867: INSTRUCTION("SQLDISCONNECT", instruction_sqldisconnect);
! 868: #undef INSTRUCTION
! 869:
! 870: return;
! 871: }
! 872:
! 873:
! 874: inline void *
! 875: analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr)
! 876: {
! 877: int pointeur;
! 878:
! 879: struct_instruction *l_instruction_courante;
! 880:
! 881: l_instruction_courante = (*s_etat_processus).arbre_instructions;
! 882:
! 883: while((*ptr) != d_code_fin_chaine)
! 884: {
! 885: pointeur = (*s_etat_processus).pointeurs_caracteres[*ptr];
! 886:
! 887: if (pointeur < 0)
! 888: {
! 889: // Caractère hors de l'alphabet des instructions
! 890:
! 891: return(NULL);
! 892: }
! 893:
! 894: if ((*l_instruction_courante).noeud[pointeur] == NULL)
! 895: {
! 896: // Le chemin de l'instruction candidate n'existe pas.
! 897:
! 898: return(NULL);
! 899: }
! 900:
! 901: l_instruction_courante = (*l_instruction_courante).noeud[pointeur];
! 902: ptr++;
! 903:
! 904: if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine))
! 905: {
! 906: // Le chemin de l'instruction candidate est incomplet.
! 907:
! 908: return(NULL);
! 909: }
! 910: }
! 911:
! 912: if ((*l_instruction_courante).feuille != NULL)
! 913: {
! 914: return((*l_instruction_courante).feuille);
! 915: }
! 916:
! 917: return(NULL);
! 918: }
! 919:
! 920:
! 921: void
! 922: analyse(struct_processus *s_etat_processus, void (*fonction)())
! 923: {
! 924: static logical1 initialisation = d_faux;
! 925:
! 926: real8 attente;
! 927: real8 pourcentage;
! 928: real8 temps_cpu;
! 929: real8 temps_reel;
! 930:
! 931: static struct timeval horodatage_initial;
! 932: struct timeval horodatage_final;
! 933:
! 934: static struct rusage usage_initial;
! 935: struct rusage usage_final;
! 936:
! 937: struct timespec temporisation;
! 938:
! 939: unsigned char *position;
! 940: unsigned char *bibliotheque_candidate;
! 941: unsigned char *instruction_majuscule;
! 942: unsigned char registre_instruction_valide;
! 943:
! 944: void (*instruction)();
! 945:
! 946: errno = 0;
! 947: (*s_etat_processus).var_volatile_exception_gsl = 0;
! 948:
! 949: (*s_etat_processus).instruction_valide = 'Y';
! 950: (*s_etat_processus).constante_symbolique = 'N';
! 951: (*s_etat_processus).nombre_arguments = -2;
! 952: (*s_etat_processus).instruction_intrinseque = 'I';
! 953:
! 954: /*
! 955: * On autorise l'exécution d'un fork() dans un thread concurrent.
! 956: */
! 957:
! 958: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
! 959: {
! 960: (*s_etat_processus).erreur_systeme = d_es_processus;
! 961: return;
! 962: }
! 963:
! 964: while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
! 965: {
! 966: if (errno != EINTR)
! 967: {
! 968: (*s_etat_processus).erreur_systeme = d_es_processus;
! 969: return;
! 970: }
! 971: }
! 972:
! 973: scrutation_injection(s_etat_processus);
! 974:
! 975: if (fonction == NULL)
! 976: {
! 977: if ((instruction_majuscule = conversion_majuscule(
! 978: (*s_etat_processus).instruction_courante)) == NULL)
! 979: {
! 980: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 981: return;
! 982: }
! 983:
! 984: instruction = analyse_instruction(s_etat_processus,
! 985: instruction_majuscule);
! 986:
! 987: if (instruction == NULL)
! 988: {
! 989: // L'instruction n'existe pas.
! 990:
! 991: (*s_etat_processus).instruction_valide = 'N';
! 992: }
! 993: else
! 994: {
! 995: // Exécution de l'instruction associée. Le drapeau
! 996: // (*s_etat_processus).instruction_valide peut passer à 'N'
! 997: // dans le cas d'instructions sensibles à la casse.
! 998:
! 999: if ((*s_etat_processus).niveau_profilage >= 2)
! 1000: {
! 1001: profilage(s_etat_processus, instruction_majuscule);
! 1002: }
! 1003:
! 1004: (*s_etat_processus).instruction_valide = 'Y';
! 1005: instruction(s_etat_processus);
! 1006:
! 1007: if ((*s_etat_processus).niveau_profilage >= 2)
! 1008: {
! 1009: profilage(s_etat_processus, NULL);
! 1010: }
! 1011: }
! 1012:
! 1013: free(instruction_majuscule);
! 1014: }
! 1015: else
! 1016: {
! 1017: if ((*s_etat_processus).niveau_profilage >= 2)
! 1018: {
! 1019: profilage(s_etat_processus,
! 1020: (*s_etat_processus).instruction_courante);
! 1021: }
! 1022:
! 1023: (*s_etat_processus).instruction_valide = 'Y';
! 1024: fonction(s_etat_processus);
! 1025:
! 1026: if ((*s_etat_processus).niveau_profilage >= 2)
! 1027: {
! 1028: profilage(s_etat_processus, NULL);
! 1029: }
! 1030: }
! 1031:
! 1032: if ((*s_etat_processus).instruction_valide == 'Y')
! 1033: {
! 1034: (*s_etat_processus).instruction_intrinseque = 'Y';
! 1035: }
! 1036:
! 1037: if ((*s_etat_processus).instruction_valide == 'N')
! 1038: {
! 1039: if ((position = index((*s_etat_processus).instruction_courante, '$'))
! 1040: != NULL)
! 1041: {
! 1042: if ((bibliotheque_candidate = malloc((position + 1
! 1043: - (*s_etat_processus).instruction_courante)
! 1044: * sizeof(unsigned char))) == NULL)
! 1045: {
! 1046: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 1047: return;
! 1048: }
! 1049:
! 1050: (*bibliotheque_candidate) = d_code_fin_chaine;
! 1051: strncat(bibliotheque_candidate,
! 1052: (*s_etat_processus).instruction_courante,
! 1053: position - (*s_etat_processus).instruction_courante);
! 1054:
! 1055: position++;
! 1056:
! 1057: if (execution_fonction_de_bibliotheque(s_etat_processus, position,
! 1058: bibliotheque_candidate) == d_vrai)
! 1059: {
! 1060: (*s_etat_processus).instruction_valide = 'Y';
! 1061: (*s_etat_processus).instruction_intrinseque = 'N';
! 1062: }
! 1063: else
! 1064: {
! 1065: (*s_etat_processus).instruction_valide = 'N';
! 1066: }
! 1067:
! 1068: free(bibliotheque_candidate);
! 1069: }
! 1070: else
! 1071: {
! 1072: if (execution_fonction_de_bibliotheque(s_etat_processus,
! 1073: (*s_etat_processus).instruction_courante, NULL)
! 1074: == d_vrai)
! 1075: {
! 1076: (*s_etat_processus).instruction_valide = 'Y';
! 1077: (*s_etat_processus).instruction_intrinseque = 'N';
! 1078: }
! 1079: else
! 1080: {
! 1081: (*s_etat_processus).instruction_valide = 'N';
! 1082: }
! 1083: }
! 1084: }
! 1085:
! 1086: /*
! 1087: --------------------------------------------------------------------------------
! 1088: Gestion des interruptions logicielles
! 1089: --------------------------------------------------------------------------------
! 1090: */
! 1091:
! 1092: if (((*s_etat_processus).erreur_systeme == d_es) &&
! 1093: ((*s_etat_processus).erreur_execution == d_ex) &&
! 1094: ((*s_etat_processus).exception == d_ep))
! 1095: {
! 1096: if ((*s_etat_processus).test_instruction == 'N')
! 1097: {
! 1098: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
! 1099: {
! 1100: affectation_interruptions_logicielles(s_etat_processus);
! 1101: }
! 1102:
! 1103: if (((*s_etat_processus).nombre_interruptions_en_queue != 0) &&
! 1104: ((*s_etat_processus).erreur_systeme == d_es) &&
! 1105: ((*s_etat_processus).erreur_execution == d_ex))
! 1106: {
! 1107:
! 1108: registre_instruction_valide =
! 1109: (*s_etat_processus).instruction_valide;
! 1110: traitement_interruptions_logicielles(s_etat_processus);
! 1111: (*s_etat_processus).instruction_valide =
! 1112: registre_instruction_valide;
! 1113: }
! 1114: }
! 1115: }
! 1116:
! 1117: /*
! 1118: --------------------------------------------------------------------------------
! 1119: Limitation du pourcetage de temps CPU
! 1120: --------------------------------------------------------------------------------
! 1121: */
! 1122:
! 1123: if ((*s_etat_processus).pourcentage_maximal_cpu < 100)
! 1124: {
! 1125: getrusage(RUSAGE_SELF, &usage_final);
! 1126: gettimeofday(&horodatage_final, NULL);
! 1127:
! 1128: if (initialisation == d_vrai)
! 1129: {
! 1130: temps_reel = ((real8) (horodatage_final.tv_sec -
! 1131: horodatage_initial.tv_sec)) +
! 1132: (((real8) (horodatage_final.tv_usec -
! 1133: horodatage_initial.tv_usec)) / ((real8) 1E6));
! 1134:
! 1135: if (temps_reel >= 0.1)
! 1136: {
! 1137: temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec +
! 1138: usage_final.ru_stime.tv_sec) -
! 1139: (usage_initial.ru_utime.tv_sec +
! 1140: usage_initial.ru_stime.tv_sec))) +
! 1141: (((real8) ((usage_final.ru_utime.tv_usec +
! 1142: usage_final.ru_stime.tv_usec) -
! 1143: (usage_initial.ru_utime.tv_usec +
! 1144: usage_initial.ru_stime.tv_usec))) / ((real8) 1E6));
! 1145:
! 1146: pourcentage = 100 * temps_cpu / temps_reel;
! 1147:
! 1148: if (pourcentage > 100)
! 1149: {
! 1150: pourcentage = 100;
! 1151: }
! 1152:
! 1153: if (pourcentage > (*s_etat_processus).pourcentage_maximal_cpu)
! 1154: {
! 1155: attente = ((pourcentage * temps_cpu) /
! 1156: (*s_etat_processus).pourcentage_maximal_cpu)
! 1157: - (pourcentage * temps_cpu / 100);
! 1158:
! 1159: temporisation.tv_sec = floor(attente);
! 1160: temporisation.tv_nsec = (attente - temporisation.tv_sec) *
! 1161: 1E9;
! 1162:
! 1163: nanosleep(&temporisation, NULL);
! 1164: }
! 1165:
! 1166: horodatage_initial = horodatage_final;
! 1167: usage_initial = usage_final;
! 1168: }
! 1169: }
! 1170: else
! 1171: {
! 1172: initialisation = d_vrai;
! 1173:
! 1174: horodatage_initial = horodatage_final;
! 1175: usage_initial = usage_final;
! 1176: }
! 1177: }
! 1178:
! 1179: /*
! 1180: --------------------------------------------------------------------------------
! 1181: Introduction des erreurs générées
! 1182: --------------------------------------------------------------------------------
! 1183: */
! 1184:
! 1185: if (((*s_etat_processus).test_instruction == 'N') &&
! 1186: ((*s_etat_processus).instruction_valide == 'Y'))
! 1187: {
! 1188: traitement_asynchrone_exceptions_gsl(s_etat_processus);
! 1189:
! 1190: if ((*s_etat_processus).erreur_processus_fils == d_vrai)
! 1191: {
! 1192: (*s_etat_processus).erreur_processus_fils = d_faux;
! 1193:
! 1194: (*s_etat_processus).erreur_systeme =
! 1195: (*s_etat_processus).erreur_systeme_processus_fils;
! 1196: (*s_etat_processus).erreur_execution =
! 1197: (*s_etat_processus).erreur_execution_processus_fils;
! 1198: (*s_etat_processus).arret_si_exception = d_vrai;
! 1199:
! 1200: if ((*s_etat_processus).pid_erreur_processus_fils == getpid())
! 1201: {
! 1202: (*s_etat_processus).invalidation_message_erreur = d_faux;
! 1203: }
! 1204: else
! 1205: {
! 1206: (*s_etat_processus).invalidation_message_erreur = d_vrai;
! 1207: }
! 1208: }
! 1209:
! 1210: if (((*s_etat_processus).erreur_execution != d_ex) ||
! 1211: ((*s_etat_processus).erreur_systeme != d_es) ||
! 1212: ((*s_etat_processus).exception != d_ep))
! 1213: {
! 1214: if ((*s_etat_processus).instruction_derniere_erreur != NULL)
! 1215: {
! 1216: free((*s_etat_processus).instruction_derniere_erreur);
! 1217: (*s_etat_processus).instruction_derniere_erreur = NULL;
! 1218: }
! 1219:
! 1220: (*s_etat_processus).niveau_derniere_erreur =
! 1221: (*s_etat_processus).niveau_courant;
! 1222:
! 1223: if ((*s_etat_processus).mode_execution_programme == 'Y')
! 1224: {
! 1225: if ((*s_etat_processus).instruction_courante == NULL)
! 1226: {
! 1227: if (((*s_etat_processus).instruction_derniere_erreur =
! 1228: malloc(16 * sizeof(unsigned char))) == NULL)
! 1229: {
! 1230: (*s_etat_processus).erreur_systeme =
! 1231: d_es_allocation_memoire;
! 1232: return;
! 1233: }
! 1234:
! 1235: strcpy((*s_etat_processus).instruction_derniere_erreur,
! 1236: "<not available>");
! 1237: }
! 1238: else
! 1239: {
! 1240: if (((*s_etat_processus).instruction_derniere_erreur =
! 1241: malloc((strlen((*s_etat_processus)
! 1242: .instruction_courante) + 1) *
! 1243: sizeof(unsigned char))) == NULL)
! 1244: {
! 1245: (*s_etat_processus).erreur_systeme =
! 1246: d_es_allocation_memoire;
! 1247: return;
! 1248: }
! 1249:
! 1250: strcpy((*s_etat_processus).instruction_derniere_erreur,
! 1251: (*s_etat_processus).instruction_courante);
! 1252: }
! 1253: }
! 1254: else
! 1255: {
! 1256: if (((*s_etat_processus).instruction_derniere_erreur =
! 1257: formateur(s_etat_processus, 0,
! 1258: (*s_etat_processus).objet_courant)) == NULL)
! 1259: {
! 1260: return;
! 1261: }
! 1262: }
! 1263: }
! 1264: }
! 1265:
! 1266: return;
! 1267: }
! 1268:
! 1269:
! 1270: /*
! 1271: ================================================================================
! 1272: Traitement asynchrone des erreurs de la bibliothèque GSL
! 1273: ================================================================================
! 1274: Entrées :
! 1275: --------------------------------------------------------------------------------
! 1276: Sorties :
! 1277: --------------------------------------------------------------------------------
! 1278: Effets de bord : néant
! 1279: ================================================================================
! 1280: */
! 1281:
! 1282: void
! 1283: traitement_asynchrone_exceptions_gsl(struct_processus *s_etat_processus)
! 1284: {
! 1285: if ((*s_etat_processus).var_volatile_exception_gsl != 0)
! 1286: {
! 1287: switch((*s_etat_processus).var_volatile_exception_gsl)
! 1288: {
! 1289: case GSL_EINVAL :
! 1290: {
! 1291: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
! 1292: break;
! 1293: }
! 1294:
! 1295: case GSL_EDOM :
! 1296: {
! 1297: (*s_etat_processus).exception = d_ep_domaine_definition;
! 1298: break;
! 1299: }
! 1300:
! 1301: case GSL_ERANGE :
! 1302: {
! 1303: (*s_etat_processus).exception = d_ep_resultat_indefini;
! 1304: break;
! 1305: }
! 1306:
! 1307: case GSL_EZERODIV :
! 1308: {
! 1309: (*s_etat_processus).exception = d_ep_division_par_zero;
! 1310: break;
! 1311: }
! 1312:
! 1313: case GSL_EUNDRFLW :
! 1314: {
! 1315: (*s_etat_processus).exception = d_ep_underflow;
! 1316: break;
! 1317: }
! 1318:
! 1319: case GSL_EOVRFLW :
! 1320: {
! 1321: (*s_etat_processus).exception = d_ep_overflow;
! 1322: break;
! 1323: }
! 1324:
! 1325: case GSL_ENOMEM :
! 1326: {
! 1327: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 1328: break;
! 1329: }
! 1330:
! 1331: case GSL_ELOSS :
! 1332: {
! 1333: (*s_etat_processus).exception = d_ep_perte_precision;
! 1334: break;
! 1335: }
! 1336:
! 1337: default :
! 1338: {
! 1339: (*s_etat_processus).erreur_execution =
! 1340: d_ex_routines_mathematiques;
! 1341: break;
! 1342: }
! 1343: }
! 1344:
! 1345: (*s_etat_processus).var_volatile_exception_gsl = 0;
! 1346: }
! 1347:
! 1348: return;
! 1349: }
! 1350:
! 1351: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>