--- rpl/src/simplification.c 2014/10/20 19:01:35 1.51 +++ rpl/src/simplification.c 2014/10/27 07:52:24 1.52 @@ -66,16 +66,9 @@ transcription_arbre(struct_processus *s_ } } - if ((l_liste = allocation_maillon(s_etat_processus)) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); - } + // Ajout des fonctions - // Ajout de la fonction - - (*l_liste).suivant = NULL; - (*l_liste).donnee = (*s_arbre).feuille; + l_liste = (*s_arbre).feuille; free((*s_arbre).branches); free(s_arbre); @@ -130,8 +123,35 @@ inversion_fonctions_arbre(struct_arbre * static void simplification_arbre(struct_processus *s_etat_processus, - struct_arbre **s_arbre) + struct_arbre *s_arbre) { + integer8 i; + + if ((*(*(*s_arbre).feuille).donnee).type != FCT) + { + // L'objet formant le noeud n'est pas une fonction. Il n'y a aucune + // simplification possible. + + return; + } + + if ((strcmp((*((struct_fonction *) (*(*(*s_arbre).feuille).donnee).objet)) + .nom_fonction, "+") == 0) || (strcmp((*((struct_fonction *) + (*(*(*s_arbre).feuille).donnee).objet)).nom_fonction, "-") == 0)) + { + for(i = 0; i < (*s_arbre).nombre_branches; i++) + { + } + } + else if ((strcmp((*((struct_fonction *) (*(*(*s_arbre).feuille).donnee) + .objet)).nom_fonction, "*") == 0) || (strcmp((*((struct_fonction *) + (*(*(*s_arbre).feuille).donnee).objet)).nom_fonction, "/") == 0)) + { + for(i = 0; i < (*s_arbre).nombre_branches; i++) + { + } + } + return; } @@ -210,10 +230,20 @@ simplification(struct_processus *s_etat_ return(NULL); } - (*s_arbre).inversion = d_faux; (*s_arbre).nombre_branches = nombre_arguments; - (*s_arbre).feuille = copie_objet(s_etat_processus, - (*l_element_courant).donnee, 'P'); + + if (((*s_arbre).feuille = allocation_maillon( + s_etat_processus)) == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return(NULL); + } + + (*(*s_arbre).feuille).donnee = copie_objet( + s_etat_processus, (*l_element_courant).donnee, + 'P'); + (*(*s_arbre).feuille).suivant = NULL; if (((*s_arbre).branches = malloc(((size_t) (*s_arbre) .nombre_branches) * sizeof(struct_arbre *))) @@ -283,9 +313,17 @@ simplification(struct_processus *s_etat_ return(NULL); } - (*s_arbre).feuille = copie_objet(s_etat_processus, - (*l_element_courant).donnee, 'P'); - (*s_arbre).inversion = d_faux; + if (((*s_arbre).feuille = allocation_maillon( + s_etat_processus)) == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return(NULL); + } + + (*(*s_arbre).feuille).donnee = copie_objet( + s_etat_processus, (*l_element_courant).donnee, 'P'); + (*(*s_arbre).feuille).suivant = NULL; (*s_arbre).nombre_branches = 0; (*s_arbre).branches = NULL; @@ -322,7 +360,7 @@ simplification(struct_processus *s_etat_ */ # ifdef EXPERIMENTAL_CODE - simplification_arbre(s_etat_processus, &s_arbre); + simplification_arbre(s_etat_processus, s_arbre); if ((*s_etat_processus).erreur_systeme != d_es) {