File:  [local] / rpl / src / analyse.c
Revision 1.95: download - view: text, annotated - select for diffs - revision graph
Thu Jul 17 08:07:15 2014 UTC (9 years, 9 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
En route pour la 4.1.19.

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

CVSweb interface <joel.bertrand@systella.fr>