Diff for /rpl/src/simplification.c between versions 1.50 and 1.58

version 1.50, 2014/10/13 07:12:54 version 1.58, 2015/11/26 11:44:43
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.19    RPL/2 (R) version 4.1.24
   Copyright (C) 1989-2014 Dr. BERTRAND Joël    Copyright (C) 1989-2015 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 66  transcription_arbre(struct_processus *s_ Line 66  transcription_arbre(struct_processus *s_
         }          }
     }      }
   
     if ((l_liste = allocation_maillon(s_etat_processus)) == NULL)      // Ajout des fonctions
     {  
         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;  
         return(NULL);  
     }  
   
     // Ajout de la fonction      l_liste = (*s_arbre).feuille;
   
     (*l_liste).suivant = NULL;  
     (*l_liste).donnee = (*s_arbre).feuille;  
   
     free((*s_arbre).branches);      free((*s_arbre).branches);
     free(s_arbre);      free(s_arbre);
Line 111  transcription_arbre(struct_processus *s_ Line 104  transcription_arbre(struct_processus *s_
   
 /*  /*
 ================================================================================  ================================================================================
     Fonction de simplification d'un arbre
   ================================================================================
     Entrées : pointeur sur une structure struct_processus
   --------------------------------------------------------------------------------
     Sorties :
   --------------------------------------------------------------------------------
     Effets de bord : néant
   ================================================================================
   */
   
   static void
   inversion_fonctions_arbre(struct_arbre *s_arbre)
   {
       return;
   }
   
   
   static void
   simplification_arbre(struct_processus *s_etat_processus,
           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;
   }
   
   
   /*
   ================================================================================
   Fonction 'simplification' (ne libère pas les paramètres)    Fonction 'simplification' (ne libère pas les paramètres)
 ================================================================================  ================================================================================
   Entrées : pointeur sur une structure struct_processus    Entrées : pointeur sur une structure struct_processus
Line 126  simplification(struct_processus *s_etat_ Line 173  simplification(struct_processus *s_etat_
 {  {
     struct_objet                *s_objet_simplifie;      struct_objet                *s_objet_simplifie;
   
 #   ifdef   EXPERIMENTAL_CODE   
   
     integer8                    i;      integer8                    i;
     integer8                    nombre_arguments;      integer8                    nombre_arguments;
   
Line 185  simplification(struct_processus *s_etat_ Line 230  simplification(struct_processus *s_etat_
                             return(NULL);                              return(NULL);
                         }                          }
   
                         (*s_arbre).inversion = d_faux;  
                         (*s_arbre).nombre_branches = nombre_arguments;                          (*s_arbre).nombre_branches = nombre_arguments;
   
                           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)                          if (((*s_arbre).branches = malloc(((size_t) (*s_arbre)
                                 .nombre_branches) * sizeof(struct_arbre *)))                                  .nombre_branches) * sizeof(struct_arbre *)))
                                 == NULL)                                  == NULL)
Line 197  simplification(struct_processus *s_etat_ Line 254  simplification(struct_processus *s_etat_
                             return(NULL);                              return(NULL);
                         }                          }
   
                         for(i = 0; i < nombre_arguments; i++)                          for(i = nombre_arguments - 1; i >= 0; i--)
                         {                          {
                             if (l_liste_locale == NULL)                              if (l_liste_locale == NULL)
                             {                              {
Line 206  simplification(struct_processus *s_etat_ Line 263  simplification(struct_processus *s_etat_
                                 return(NULL);                                  return(NULL);
                             }                              }
   
                             if (((*s_arbre).branches[i] = malloc(                              (*s_arbre).branches[i] = (struct_arbre *)
                                     sizeof(struct_arbre))) == NULL)  
                             {  
                                 (*s_etat_processus).erreur_systeme =  
                                         d_es_allocation_memoire;  
                                 return(NULL);  
                             }  
   
                             (*(*s_arbre).branches[i]).feuille =  
                                     (*l_liste_locale).donnee;                                      (*l_liste_locale).donnee;
                             (*(*s_arbre).branches[i]).inversion = d_faux;  
                             (*(*s_arbre).branches[i]).nombre_branches = 0;  
                             (*(*s_arbre).branches[i]).branches = NULL;  
   
                             l_ancienne_liste_locale = l_liste_locale;                              l_ancienne_liste_locale = l_liste_locale;
                             l_liste_locale = (*l_liste_locale).suivant;                              l_liste_locale = (*l_liste_locale).suivant;
Line 267  simplification(struct_processus *s_etat_ Line 313  simplification(struct_processus *s_etat_
                         return(NULL);                          return(NULL);
                     }                      }
   
                     (*s_arbre).feuille = copie_objet(s_etat_processus,                      if (((*s_arbre).feuille = allocation_maillon(
                             (*l_element_courant).donnee, 'P');                              s_etat_processus)) == NULL)
                     (*s_arbre).inversion = d_faux;                      {
                           (*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).nombre_branches = 0;
                     (*s_arbre).branches = NULL;                      (*s_arbre).branches = NULL;
   
Line 305  simplification(struct_processus *s_etat_ Line 359  simplification(struct_processus *s_etat_
          * Simplification de l'arbre           * Simplification de l'arbre
          */           */
   
 #       if 0  #       ifdef   EXPERIMENTAL_CODE 
         simplification_arbre();          simplification_arbre(s_etat_processus, s_arbre);
   
           if ((*s_etat_processus).erreur_systeme != d_es)
           {
               return(NULL);
           }
 #       endif  #       endif
   
         /*          /*
Line 397  simplification(struct_processus *s_etat_ Line 456  simplification(struct_processus *s_etat_
                 .nom_fonction, ">>");                  .nom_fonction, ">>");
     }      }
     else      else
 #   endif  
     {      {
         s_objet_simplifie = copie_objet(s_etat_processus, s_objet, 'P');          s_objet_simplifie = copie_objet(s_etat_processus, s_objet, 'P');
     }      }

Removed from v.1.50  
changed lines
  Added in v.1.58


CVSweb interface <joel.bertrand@systella.fr>