--- rpl/src/instructions_c2.c 2012/08/22 10:47:15 1.36 +++ rpl/src/instructions_c2.c 2012/09/29 17:53:02 1.37 @@ -98,7 +98,8 @@ instruction_cycle(struct_processus *s_et while((l_element_pile_systeme != NULL) && (presence_boucle == d_faux)) { if (((*l_element_pile_systeme).type_cloture == 'S') || - ((*l_element_pile_systeme).type_cloture == 'F')) + ((*l_element_pile_systeme).type_cloture == 'F') || + ((*l_element_pile_systeme).type_cloture == 'A')) { presence_boucle = d_vrai; } @@ -132,200 +133,110 @@ instruction_cycle(struct_processus *s_et return; } - if (recherche_variable(s_etat_processus, - (*s_etat_processus).instruction_courante) == d_vrai) + instruction_majuscule = conversion_majuscule( + (*s_etat_processus).instruction_courante); + + if (instruction_majuscule == NULL) { - instruction_majuscule = conversion_majuscule(""); + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - if ((*(*s_etat_processus).pointeur_variable_courante).objet - == NULL) + /* + * Traitement de la pile système par les + * différentes instructions. + */ + + if ((strcmp(instruction_majuscule, "IF") == 0) || + (strcmp(instruction_majuscule, "IFERR") == 0) || + (strcmp(instruction_majuscule, "DO") == 0) || + (strcmp(instruction_majuscule, "WHILE") == 0) || + (strcmp(instruction_majuscule, "FOR") == 0) || + (strcmp(instruction_majuscule, "START") == 0) || + (strcmp(instruction_majuscule, "SELECT") == 0) + || (strcmp(instruction_majuscule, "CRITICAL") == 0) + || (strcmp(instruction_majuscule, "CASE") == 0) + || (strcmp(instruction_majuscule, "<<") == 0)) + { + if (strcmp(instruction_majuscule, "<<") == 0) { - // Variable partagée - - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - - if (recherche_variable_partagee(s_etat_processus, - (*(*s_etat_processus).pointeur_variable_courante) - .nom, (*(*s_etat_processus) - .pointeur_variable_courante).variable_partagee, - 'E') == d_vrai) - { - if ((*((*(*s_etat_processus) - .s_liste_variables_partagees).table - [(*(*s_etat_processus) - .s_liste_variables_partagees) - .position_variable]) - .objet).type == ADR) - { - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) - != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } - - return; - } - - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) - ((*(*(*s_etat_processus) - .pointeur_variable_courante).objet) - .objet))); - - (*s_etat_processus) - .autorisation_empilement_programme = 'N'; - } - } - - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } + analyse(s_etat_processus, NULL); } else { - // Variable privée - - if ((*(*(*s_etat_processus).pointeur_variable_courante) - .objet).type == ADR) + if ((strcmp(instruction_majuscule, "FOR") == 0) || + (strcmp(instruction_majuscule, "START") == 0)) { - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + niveau++; + } - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) ((*(*(*s_etat_processus) - .pointeur_variable_courante).objet).objet))); + empilement_pile_systeme(s_etat_processus); - (*s_etat_processus).autorisation_empilement_programme - = 'N'; + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } - else + else if ((strcmp(instruction_majuscule, "END") == 0) || + (strcmp(instruction_majuscule, "NEXT") == 0) || + (strcmp(instruction_majuscule, "STEP") == 0) || + (strcmp(instruction_majuscule, ">>") == 0)) { - (*s_etat_processus).erreur_systeme = d_es; - instruction_majuscule = conversion_majuscule( - (*s_etat_processus).instruction_courante); - - if (instruction_majuscule == NULL) + if (strcmp(instruction_majuscule, ">>") == 0) { - (*s_etat_processus).erreur_systeme = - d_es_allocation_memoire; - return; - } + analyse(s_etat_processus, NULL); - /* - * Traitement de la pile système par les - * différentes instructions. - */ - - if ((strcmp(instruction_majuscule, "IF") == 0) || - (strcmp(instruction_majuscule, "IFERR") == 0) || - (strcmp(instruction_majuscule, "DO") == 0) || - (strcmp(instruction_majuscule, "WHILE") == 0) || - (strcmp(instruction_majuscule, "FOR") == 0) || - (strcmp(instruction_majuscule, "START") == 0) || - (strcmp(instruction_majuscule, "SELECT") == 0) - || (strcmp(instruction_majuscule, "CASE") == 0) - || (strcmp(instruction_majuscule, "<<") == 0)) - { - if (strcmp(instruction_majuscule, "<<") == 0) - { - analyse(s_etat_processus, NULL); - } - else + if ((*s_etat_processus).retour_routine_evaluation + == 'Y') { - if ((strcmp(instruction_majuscule, "FOR") == 0) || - (strcmp(instruction_majuscule, "START") == 0)) - { - niveau++; - } + drapeau_presence_fin_boucle = d_faux; + free((*s_etat_processus).instruction_courante); - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + break; } } - else if ((strcmp(instruction_majuscule, "END") == 0) || - (strcmp(instruction_majuscule, "NEXT") == 0) || - (strcmp(instruction_majuscule, "STEP") == 0) || - (strcmp(instruction_majuscule, ">>") == 0)) + else { - if (strcmp(instruction_majuscule, ">>") == 0) + if ((strcmp(instruction_majuscule, "NEXT") == 0) || + (strcmp(instruction_majuscule, "STEP") == 0)) { - analyse(s_etat_processus, NULL); + niveau--; - if ((*s_etat_processus).retour_routine_evaluation - == 'Y') + if (niveau != 0) { - drapeau_presence_fin_boucle = d_faux; - free((*s_etat_processus).instruction_courante); - - break; + depilement_pile_systeme(s_etat_processus); } } else { - if ((strcmp(instruction_majuscule, "NEXT") == 0) || - (strcmp(instruction_majuscule, "STEP") == 0)) + if ((*s_etat_processus).l_base_pile_systeme == NULL) { - niveau--; + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } - if (niveau != 0) + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') + { + if (pthread_mutex_unlock( + &mutex_sections_critiques) != 0) { - depilement_pile_systeme(s_etat_processus); + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; } - } - else - { - depilement_pile_systeme(s_etat_processus); - } - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; + (*s_etat_processus).sections_critiques--; } + + depilement_pile_systeme(s_etat_processus); + } + + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } @@ -384,6 +295,7 @@ instruction_cycle(struct_processus *s_et (fonction == instruction_start) || (fonction == instruction_select) || (fonction == instruction_case) || + (fonction == instruction_critical) || (fonction == instruction_vers_niveau_superieur)) { if (fonction == instruction_vers_niveau_superieur) @@ -436,6 +348,27 @@ instruction_cycle(struct_processus *s_et } else { + if ((*s_etat_processus).l_base_pile_systeme == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') + { + if (pthread_mutex_unlock(&mutex_sections_critiques) + != 0) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + (*s_etat_processus).sections_critiques--; + } + depilement_pile_systeme(s_etat_processus); }