Diff for /rpl/src/gestion_variables.c between versions 1.59 and 1.60

version 1.59, 2012/10/04 15:21:26 version 1.60, 2012/10/05 13:12:39
Line 432  ajout_variable(struct_processus *s_etat_ Line 432  ajout_variable(struct_processus *s_etat_
         (*(*s_etat_processus).s_arbre_variables).noeud_pere = NULL;          (*(*s_etat_processus).s_arbre_variables).noeud_pere = NULL;
   
         if (((*(*s_etat_processus).s_arbre_variables).noeuds =          if (((*(*s_etat_processus).s_arbre_variables).noeuds =
                     allocation_tableau_noeuds(s_etat_processus)) == NULL)                  allocation_tableau_noeuds(s_etat_processus)) == NULL)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
             return(d_erreur);              return(d_erreur);
Line 1791  int Line 1791  int
 nombre_variables(struct_processus *s_etat_processus,  nombre_variables(struct_processus *s_etat_processus,
         struct_arbre_variables *l_element_courant)          struct_arbre_variables *l_element_courant)
 {  {
     int                     i;      int                                 i;
     int                     n;      int                                 n;
   
     struct_liste_variables  *l_variable;      struct_liste_variables              *l_variable;
       struct_liste_variables_statiques    *l_variable_statique;
   
     n = 0;      n = 0;
   
Line 1809  nombre_variables(struct_processus *s_eta Line 1810  nombre_variables(struct_processus *s_eta
         } while(l_variable != (*l_element_courant).feuille);          } while(l_variable != (*l_element_courant).feuille);
     }      }
   
       if ((*l_element_courant).feuille_statique != NULL)
       {
           l_variable_statique = (*l_element_courant).feuille_statique;
   
           do
           {
               // Si le pointeur est nul, la variable est accessible et a été
               // copiée dans l'arbre des variables.
   
               if ((*(*l_variable_statique).variable).objet != NULL)
               {
                   n++;
               }
   
               l_variable_statique = (*l_variable_statique).suivant;
           } while(l_variable_statique != NULL);
       }
   
     for(i = 0; i < (*s_etat_processus).nombre_caracteres_variables; i++)      for(i = 0; i < (*s_etat_processus).nombre_caracteres_variables; i++)
     {      {
         if ((*l_element_courant).noeuds[i] != NULL)          if ((*l_element_courant).noeuds[i] != NULL)
Line 1827  liste_variables(struct_processus *s_etat Line 1846  liste_variables(struct_processus *s_etat
         struct_tableau_variables *tableau, int position,          struct_tableau_variables *tableau, int position,
         struct_arbre_variables *l_element_courant)          struct_arbre_variables *l_element_courant)
 {  {
     int                     i;      int                                 i;
   
     struct_liste_variables  *l_variable;      struct_liste_variables              *l_variable;
       struct_liste_variables_statiques    *l_variable_statique;
   
     if ((*l_element_courant).feuille != NULL)      if ((*l_element_courant).feuille != NULL)
     {      {
Line 1847  liste_variables(struct_processus *s_etat Line 1867  liste_variables(struct_processus *s_etat
                     (*(*l_variable).variable).variable_statique;                      (*(*l_variable).variable).variable_statique;
             tableau[position].variable_partagee =              tableau[position].variable_partagee =
                     (*(*l_variable).variable).variable_partagee;                      (*(*l_variable).variable).variable_partagee;
               tableau[position].variable_masquee = d_faux;
   
             position++;              position++;
             l_variable = (*l_variable).suivant;              l_variable = (*l_variable).suivant;
         } while(l_variable != (*l_element_courant).feuille);          } while(l_variable != (*l_element_courant).feuille);
     }      }
   
       if ((*l_element_courant).feuille_statique != NULL)
       {
           l_variable_statique = (*l_element_courant).feuille_statique;
   
           do
           {
               if ((*(*l_variable_statique).variable).objet != NULL)
               {
                   tableau[position].origine = 'E';
                   tableau[position].nom = (*(*l_variable_statique).variable).nom;
                   tableau[position].niveau =
                           (*(*l_variable_statique).variable).niveau;
                   tableau[position].objet =
                           (*(*l_variable_statique).variable).objet;
                   tableau[position].variable_verrouillee = d_faux;
                   tableau[position].variable_statique =
                           (*(*l_variable_statique).variable).variable_statique;
                   tableau[position].variable_partagee.pointeur = NULL;
                   tableau[position].variable_masquee = d_vrai;
   
                   position++;
               }
   
               l_variable_statique = (*l_variable_statique).suivant;
           } while(l_variable_statique != NULL);
       }
   
     for(i = 0; i < (*s_etat_processus).nombre_caracteres_variables; i++)      for(i = 0; i < (*s_etat_processus).nombre_caracteres_variables; i++)
     {      {
         if ((*l_element_courant).noeuds[i] != NULL)          if ((*l_element_courant).noeuds[i] != NULL)
Line 1895  copie_arbre_variables(struct_processus * Line 1943  copie_arbre_variables(struct_processus *
     // structure. Les variables de niveau 0 étant non modifiables, elles      // structure. Les variables de niveau 0 étant non modifiables, elles
     // ne sont pas dupliquées.      // ne sont pas dupliquées.
   
     int                             i;      int                                 i;
   
     logical1                        niveau_0_traite;      logical1                            niveau_0_traite;
     logical1                        niveau_1_traite;      logical1                            niveau_1_traite;
   
     struct_liste_chainee            *l_element_courant;      struct_arbre_variables              *l_variable_courante;
   
     struct_liste_variables          *l_niveau_courant;      struct_liste_chainee                *l_element_courant;
   
     struct_variable                 s_variable;      struct_liste_variables              *l_niveau_courant;
       struct_liste_variables_statiques    *l_element_statique_courant;
   
       struct_variable                     s_variable;
   
       unsigned char                       *ptr;
   
     (*s_nouvel_etat_processus).s_arbre_variables = NULL;      (*s_nouvel_etat_processus).s_arbre_variables = NULL;
     (*s_nouvel_etat_processus).l_liste_variables_par_niveau = NULL;      (*s_nouvel_etat_processus).l_liste_variables_par_niveau = NULL;
Line 2002  copie_arbre_variables(struct_processus * Line 2055  copie_arbre_variables(struct_processus *
         l_niveau_courant = (*l_niveau_courant).precedent;          l_niveau_courant = (*l_niveau_courant).precedent;
     }      }
   
       // Copie des variables statiques
   
       l_element_statique_courant = (*s_etat_processus)
               .l_liste_variables_statiques;
   
       while(l_element_statique_courant != NULL)
       {
           // Création des branches de l'arbre si nécessaire.
   
           if ((*s_nouvel_etat_processus).s_arbre_variables == NULL)
           {
               if (((*s_nouvel_etat_processus).s_arbre_variables =
                           allocation_noeud(s_nouvel_etat_processus)) == NULL)
               {
                   (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   return;
               }
   
               (*(*s_nouvel_etat_processus).s_arbre_variables).feuille = NULL;
               (*(*s_nouvel_etat_processus).s_arbre_variables).feuille_statique
                       = NULL;
               (*(*s_nouvel_etat_processus).s_arbre_variables).noeuds_utilises = 0;
               (*(*s_nouvel_etat_processus).s_arbre_variables).indice_tableau_pere
                       = -1;
               (*(*s_nouvel_etat_processus).s_arbre_variables).noeud_pere = NULL;
   
               if (((*(*s_nouvel_etat_processus).s_arbre_variables).noeuds =
                       allocation_tableau_noeuds(s_nouvel_etat_processus)) == NULL)
               {
                   (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   return;
               }
   
               for(i = 0; i < (*s_nouvel_etat_processus)
                       .nombre_caracteres_variables; i++)
               {
                   (*(*s_nouvel_etat_processus).s_arbre_variables).noeuds[i]
                           = NULL;
               }
           }
   
           l_variable_courante = (*s_nouvel_etat_processus).s_arbre_variables;
           ptr = (*(*l_element_statique_courant).variable).nom;
   
           while((*ptr) != d_code_fin_chaine)
           {
               BUG((*s_nouvel_etat_processus).pointeurs_caracteres_variables
                       [*ptr] < 0, uprintf("Variable=\"%s\", (*ptr)='%c'\n",
                       (*(*l_element_statique_courant).variable).nom, *ptr));
   
               if ((*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                       .pointeurs_caracteres_variables[*ptr]] == NULL)
               {
                   // Le noeud n'existe pas encore, on le crée et on le marque
                   // comme utilisé dans la structure parente.
   
                   if (((*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]] =
                           allocation_noeud(s_nouvel_etat_processus)) == NULL)
                   {
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return;
                   }
   
                   (*l_variable_courante).noeuds_utilises++;
   
                   // La feuille est par défaut vide et aucun élément du tableau
                   // noeuds (les branches qui peuvent être issues de ce nouveau
                   // noeud) n'est encore utilisée.
   
                   (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]]).feuille = NULL;
                   (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]]).feuille_statique
                           = NULL;
                   (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]]).noeuds_utilises
                           = 0;
   
                   // Le champ noeud_pere de la structure créée pointe sur
                   // la structure parente et l'indice tableau_pere correspond à la
                   // position réelle dans le tableau noeuds[] de la structure
                   // parente du noeud courant. Cette valeur sera utilisée lors de
                   // la destruction du noeud pour annuler le pointeur contenu dans
                   // le tableau noeuds[] de la structure parente.
   
                   (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]]).noeud_pere =
                           l_variable_courante;
                   (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]])
                           .indice_tableau_pere = (*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr];
   
                   // Allocation du tableau noeuds[] et initialisation à zéro de
                   // tous les pointeurs.
   
                   if (((*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                           .pointeurs_caracteres_variables[*ptr]]).noeuds =
                           allocation_tableau_noeuds(s_nouvel_etat_processus))
                           == NULL)
                   {
                       (*s_etat_processus).erreur_systeme
                               = d_es_allocation_memoire;
                       return;
                   }
   
                   for(i = 0; i < (*s_nouvel_etat_processus)
                           .nombre_caracteres_variables; i++)
                   {
                       (*(*l_variable_courante).noeuds[(*s_nouvel_etat_processus)
                               .pointeurs_caracteres_variables[*ptr]]).noeuds[i]
                               = NULL;
                   }
               }
   
               l_variable_courante = (*l_variable_courante).noeuds
                       [(*s_nouvel_etat_processus).pointeurs_caracteres_variables
                       [*ptr]];
   
               ptr++;
           }
   
           if (creation_variable_statique(s_nouvel_etat_processus,
                   (*l_element_statique_courant).variable) == d_erreur)
           {
               (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
               return;
           }
   
           l_element_statique_courant = (*l_element_statique_courant).suivant;
       }
   
     return;      return;
 }  }
   

Removed from v.1.59  
changed lines
  Added in v.1.60


CVSweb interface <joel.bertrand@systella.fr>