Diff for /rpl/src/interface_cas.cpp between versions 1.5 and 1.9

version 1.5, 2011/06/24 20:31:41 version 1.9, 2011/07/22 07:38:40
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.0.prerelease.4    RPL/2 (R) version 4.1.1
   Copyright (C) 1989-2011 Dr. BERTRAND Joël    Copyright (C) 1989-2011 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
Line 20 Line 20
 */  */
   
   
 #include "giac.h"  #ifdef RPLCAS
   #   include "giac.h"
   
 #undef PACKAGE  #   undef PACKAGE
 #undef PACKAGE_NAME  #   undef PACKAGE_NAME
 #undef PACKAGE_STRING  #   undef PACKAGE_STRING
 #undef PACKAGE_TARNAME  #   undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION  #   undef PACKAGE_VERSION
 #undef VERSION  #   undef VERSION
   #endif
   
 extern "C"  extern "C"
 {  {
Line 38  extern "C" Line 40  extern "C"
 #include <iostream>  #include <iostream>
   
 using namespace std;  using namespace std;
 using namespace giac;  
   #ifdef RPLCAS
       using namespace giac;
   #endif
   
   
 static unsigned char *  static unsigned char *
Line 95  conversion_rpl_vers_cas(struct_processus Line 100  conversion_rpl_vers_cas(struct_processus
             {              {
                 unsigned char       *ptr;                  unsigned char       *ptr;
   
                 ptr = reinterpret_cast<unsigned char *>(((struct_fonction *)                  ptr = reinterpret_cast<unsigned char *>(
                           reinterpret_cast<struct_fonction *>(
                         l_element_courant->donnee->objet)->nom_fonction);                          l_element_courant->donnee->objet)->nom_fonction);
   
                 while((*ptr) != d_code_fin_chaine)                  while((*ptr) != d_code_fin_chaine)
Line 152  conversion_cas_vers_rpl(struct_processus Line 158  conversion_cas_vers_rpl(struct_processus
                 // qui n'est pas reconnu comme un mot-clef du RPL/2. S'il                  // qui n'est pas reconnu comme un mot-clef du RPL/2. S'il
                 // s'agit d'un mot-clef de GIAC, on le convertit.                  // s'agit d'un mot-clef de GIAC, on le convertit.
   
                 if (strcmp(const_cast<const char *>(reinterpret_cast<char *>(                  if (strcmp((const char *)
                         ((struct_fonction *) l_element_courant->donnee                          reinterpret_cast<struct_fonction *>(l_element_courant
                         ->objet)->nom_fonction)), "quote") == 0)                          ->donnee->objet)->nom_fonction, "quote") == 0)
                 {                  {
                     liberation(s_etat_processus, l_element_courant->donnee);                      liberation(s_etat_processus, l_element_courant->donnee);
   
Line 176  conversion_cas_vers_rpl(struct_processus Line 182  conversion_cas_vers_rpl(struct_processus
                         return;                          return;
                     }                      }
   
                     strcpy(reinterpret_cast<char *>(((struct_fonction *)                      strcpy(reinterpret_cast<char *>(
                               reinterpret_cast<struct_fonction *>(
                             l_element_courant->donnee->objet)->nom_fonction),                              l_element_courant->donnee->objet)->nom_fonction),
                             "RELAX");                              "RELAX");
                 }                  }
Line 208  void Line 215  void
 interface_cas(struct_processus *s_etat_processus,  interface_cas(struct_processus *s_etat_processus,
         enum t_rplcas_commandes commande)          enum t_rplcas_commandes commande)
 {  {
   #   ifdef RPLCAS
     struct_objet            *s_objet_argument_1;      struct_objet            *s_objet_argument_1;
     struct_objet            *s_objet_argument_2;      struct_objet            *s_objet_argument_2;
   
Line 251  interface_cas(struct_processus *s_etat_p Line 259  interface_cas(struct_processus *s_etat_p
             liberation(s_etat_processus, s_objet_argument_1);              liberation(s_etat_processus, s_objet_argument_1);
             liberation(s_etat_processus, s_objet_argument_2);              liberation(s_etat_processus, s_objet_argument_2);
   
             gen variable(string(reinterpret_cast<const char *>(argument_1)),              try
                     giac::context0);              {
             gen expression(string(reinterpret_cast<const char *>(argument_2)),                  giac::context   contexte;
                     giac::context0);  
   
             free(argument_1);  
             free(argument_2);  
   
             gen resultat = integrate(expression, variable, giac::context0);                  gen variable(
             string chaine = "'" + resultat.print() + "'";                          string(reinterpret_cast<const char *>(argument_1)),
                           &contexte);
                   gen expression(
                           string(reinterpret_cast<const char *>(argument_2)),
                           &contexte);
   
                   gen resultat = integrate(expression, variable, &contexte);
                   string chaine = "'" + resultat.print() + "'";
   
                   registre = s_etat_processus->instruction_courante;
                   s_etat_processus->instruction_courante =
                           reinterpret_cast<unsigned char *>(const_cast<char *>
                           (chaine.c_str()));
   
             registre = s_etat_processus->instruction_courante;                  recherche_type(s_etat_processus);
             s_etat_processus->instruction_courante =  
                     reinterpret_cast<unsigned char*>(const_cast<char *>  
                     (chaine.c_str()));  
   
             recherche_type(s_etat_processus);                  if (s_etat_processus->l_base_pile != NULL)
                   {
                       conversion_cas_vers_rpl(s_etat_processus,
                               s_etat_processus->l_base_pile->donnee);
                   }
   
             if (s_etat_processus->l_base_pile != NULL)                  s_etat_processus->instruction_courante = registre;
               }
               catch(bad_alloc exception)
               {
                   s_etat_processus->erreur_systeme = d_es_allocation_memoire;
               }
               catch(...)
             {              {
                 conversion_cas_vers_rpl(s_etat_processus,                  s_etat_processus->erreur_execution = d_ex_erreur_interne_rplcas;
                         s_etat_processus->l_base_pile->donnee);  
             }              }
   
             s_etat_processus->instruction_courante = registre;              free(argument_1);
               free(argument_2);
   
             break;              break;
         }          }
Line 287  interface_cas(struct_processus *s_etat_p Line 310  interface_cas(struct_processus *s_etat_p
     }      }
   
     return;      return;
   
   #else
   
       if (s_etat_processus->langue == 'F')
       {
           printf("+++Attention : RPL/CAS non compilé !\n");
       }
       else
       {
           printf("+++Warning : RPL/CAS not available !\n");
       }
   
       fflush(stdout);
   
       return;
   
   #endif
 }  }
   
 // vim: ts=4  // vim: ts=4

Removed from v.1.5  
changed lines
  Added in v.1.9


CVSweb interface <joel.bertrand@systella.fr>