--- rpl/src/instructions_i4.c 2011/07/25 07:44:57 1.29 +++ rpl/src/instructions_i4.c 2011/08/01 08:07:55 1.30 @@ -330,4 +330,104 @@ instruction_implicit(struct_processus *s return; } + +/* +================================================================================ + Fonction 'infinity' +================================================================================ + Entrées : +-------------------------------------------------------------------------------- + Sorties : +-------------------------------------------------------------------------------- + Effets de bord : néant +================================================================================ +*/ + +void +instruction_sensible_infinity(struct_processus *s_etat_processus) +{ + if (strcmp((*s_etat_processus).instruction_courante, "infinity") == 0) + { + instruction_infinity(s_etat_processus); + } + else + { + (*s_etat_processus).instruction_valide = 'N'; + } + + return; +} + +void +instruction_infinity(struct_processus *s_etat_processus) +{ + struct_objet *s_objet; + + if ((*s_etat_processus).affichage_arguments == 'Y') + { + printf("\n infinity "); + + if ((*s_etat_processus).langue == 'F') + { + printf("(infini)\n\n"); + } + else + { + printf("(infinity constant)\n\n"); + } + + printf("-> 1: %s\n", d_REL); + + return; + } + else if ((*s_etat_processus).test_instruction == 'Y') + { + (*s_etat_processus).constante_symbolique = 'Y'; + (*s_etat_processus).nombre_arguments = -1; + return; + } + + /* Indicateur 35 armé => évaluation symbolique */ + if (test_cfsf(s_etat_processus, 35) == d_vrai) + { + if ((s_objet = allocation(s_etat_processus, NOM)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + if (((*((struct_nom *) (*s_objet).objet)).nom = + malloc(9 * sizeof(unsigned char))) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + strcpy((*((struct_nom *) (*s_objet).objet)).nom, "infinity"); + (*((struct_nom *) (*s_objet).objet)).symbole = d_faux; + } + else + { + if ((s_objet = allocation(s_etat_processus, REL)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + +# ifdef FP_INFINITE + (*((real8 *) (*s_objet).objet)) = (double) INFINITY; +# else + (*((real8 *) (*s_objet).objet)) = HUGE_VAL; +# endif + } + + if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), + s_objet) == d_erreur) + { + return; + } + + return; +} + // vim: ts=4