File:  [local] / rpl / src / instructions_n2.c
Revision 1.16.2.2: download - view: text, annotated - select for diffs - revision graph
Thu Apr 14 08:46:44 2011 UTC (13 years ago) by bertrand
Branches: rpl-4_0
CVS tags: rpl-4_0_24
Diff to: branchpoint 1.16: preferred, colored
En route pour la 4.0.23.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.0.23
    4:   Copyright (C) 1989-2011 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl-conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Fonction 'num'
   29: ================================================================================
   30:   Entrées : structure processus
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_num(struct_processus *s_etat_processus)
   40: {
   41:     struct_objet                *s_objet_argument;
   42:     struct_objet                *s_objet_resultat;
   43: 
   44:     (*s_etat_processus).erreur_execution = d_ex;
   45: 
   46:     if ((*s_etat_processus).affichage_arguments == 'Y')
   47:     {
   48:         printf("\n  NUM ");
   49: 
   50:         if ((*s_etat_processus).langue == 'F')
   51:         {
   52:             printf("(conversion d'un caractère en entier)\n\n");
   53:         }
   54:         else
   55:         {
   56:             printf("(character to integer conversion)\n\n");
   57:         }
   58: 
   59:         printf("    1: %s\n", d_CHN);
   60:         printf("->  1: 0 <= %s <= 255\n", d_INT);
   61: 
   62:         return;
   63:     }
   64:     else if ((*s_etat_processus).test_instruction == 'Y')
   65:     {
   66:         (*s_etat_processus).nombre_arguments = -1;
   67:         return;
   68:     }
   69: 
   70:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
   71:     {
   72:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
   73:         {
   74:             return;
   75:         }
   76:     }
   77: 
   78:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
   79:             &s_objet_argument) == d_erreur)
   80:     {
   81:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
   82:         return;
   83:     }
   84: 
   85: /*
   86: --------------------------------------------------------------------------------
   87:   Chaîne de caractères
   88: --------------------------------------------------------------------------------
   89: */
   90: 
   91:     if ((*s_objet_argument).type == CHN)
   92:     {
   93:         if (strlen((unsigned char *) (*s_objet_argument).objet) != 1)
   94:         {
   95:             liberation(s_etat_processus, s_objet_argument);
   96: 
   97:             (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
   98:             return;
   99:         }
  100: 
  101:         if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
  102:         {
  103:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  104:             return;
  105:         }
  106: 
  107:         (*((integer8 *) (*s_objet_resultat).objet)) =
  108:                 (integer8) ((unsigned char *) (*s_objet_argument).objet)[0];
  109:     }
  110: 
  111: /*
  112: --------------------------------------------------------------------------------
  113:   Type invalide
  114: --------------------------------------------------------------------------------
  115: */
  116: 
  117:     else
  118:     {
  119:         liberation(s_etat_processus, s_objet_argument);
  120: 
  121:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  122:         return;
  123:     }
  124: 
  125:     liberation(s_etat_processus, s_objet_argument);
  126: 
  127:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  128:             s_objet_resultat) == d_erreur)
  129:     {
  130:         return;
  131:     }
  132: 
  133:     return;
  134: }
  135: 
  136: 
  137: /*
  138: ================================================================================
  139:   Fonction 'ns'
  140: ================================================================================
  141:   Entrées : structure processus
  142: --------------------------------------------------------------------------------
  143:   Sorties :
  144: --------------------------------------------------------------------------------
  145:   Effets de bord : néant
  146: ================================================================================
  147: */
  148: 
  149: void
  150: instruction_ns(struct_processus *s_etat_processus)
  151: {
  152:     logical1                    presence_variable;
  153: 
  154:     long                        i;
  155: 
  156:     struct_objet                *s_objet_resultat;
  157: 
  158:     (*s_etat_processus).erreur_execution = d_ex;
  159: 
  160:     if ((*s_etat_processus).affichage_arguments == 'Y')
  161:     {
  162:         printf("\n  NS ");
  163: 
  164:         if ((*s_etat_processus).langue == 'F')
  165:         {
  166:             printf("(nombre de données dans la matrice statistique\n\n");
  167:         }
  168:         else
  169:         {
  170:             printf("(number of data elements in statistical matrix)\n\n");
  171:         }
  172: 
  173:         printf("->  1: %s\n", d_INT);
  174: 
  175:         return;
  176:     }
  177:     else if ((*s_etat_processus).test_instruction == 'Y')
  178:     {
  179:         (*s_etat_processus).nombre_arguments = -1;
  180:         return;
  181:     }
  182: 
  183:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  184:     {
  185:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  186:         {
  187:             return;
  188:         }
  189:     }
  190: 
  191:     if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
  192:     {
  193:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  194:         return;
  195:     }
  196: 
  197:     if (recherche_variable(s_etat_processus, ds_sdat) == d_faux)
  198:     {
  199:         /*
  200:          * Aucune variable SIGMA
  201:          */
  202: 
  203:         (*s_etat_processus).erreur_systeme = d_es;
  204:         (*((integer8 *) (*s_objet_resultat).objet)) = 0;
  205:     }
  206:     else
  207:     {
  208:         /*
  209:          * Il existe une variable locale SIGMA. Reste à vérifier l'existence
  210:          * d'une variable SIGMA globale...
  211:          */
  212: 
  213:         i = (*s_etat_processus).position_variable_courante;
  214:         presence_variable = d_faux;
  215: 
  216:         while(i >= 0)
  217:         {
  218:             if ((strcmp((*s_etat_processus).s_liste_variables[i].nom,
  219:                     ds_sdat) == 0) && ((*s_etat_processus)
  220:                     .s_liste_variables[i].niveau == 1))
  221:             {
  222:                 presence_variable = d_vrai;
  223:                 break;
  224:             }
  225: 
  226:             i--;
  227:         }
  228: 
  229:         if (presence_variable == d_faux)
  230:         {
  231:             (*((integer8 *) (*s_objet_resultat).objet)) = 0;
  232:         }
  233:         else
  234:         {
  235:             (*s_etat_processus).position_variable_courante = i;
  236: 
  237:             if (((*s_etat_processus).s_liste_variables[i]).objet == NULL)
  238:             {
  239:                 liberation(s_etat_processus, s_objet_resultat);
  240: 
  241:                 (*s_etat_processus).erreur_execution = d_ex_variable_partagee;
  242:                 return;
  243:             }
  244: 
  245:             if (((*((*s_etat_processus).s_liste_variables
  246:                     [(*s_etat_processus).position_variable_courante].objet))
  247:                     .type != MIN) && ((*((*s_etat_processus)
  248:                     .s_liste_variables[(*s_etat_processus)
  249:                     .position_variable_courante].objet)).type != MRL))
  250:             {
  251:                 liberation(s_etat_processus, s_objet_resultat);
  252: 
  253:                 (*s_etat_processus).erreur_execution =
  254:                         d_ex_matrice_statistique_invalide;
  255:                 return;
  256:             }
  257: 
  258:             (*((integer8 *) (*s_objet_resultat).objet)) =
  259:                     (*((struct_matrice *) (*((*s_etat_processus)
  260:                     .s_liste_variables[(*s_etat_processus)
  261:                     .position_variable_courante].objet)).objet))
  262:                     .nombre_lignes;
  263:         }
  264:     }
  265: 
  266:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  267:             s_objet_resultat) == d_erreur)
  268:     {
  269:         return;
  270:     }
  271: 
  272:     return;
  273: }
  274: 
  275: 
  276: /*
  277: ================================================================================
  278:   Fonction 'newplane'
  279: ================================================================================
  280:   Entrées : structure processus
  281: --------------------------------------------------------------------------------
  282:   Sorties :
  283: --------------------------------------------------------------------------------
  284:   Effets de bord : néant
  285: ================================================================================
  286: */
  287: 
  288: void
  289: instruction_newplane(struct_processus *s_etat_processus)
  290: {
  291:     (*s_etat_processus).erreur_execution = d_ex;
  292: 
  293:     if ((*s_etat_processus).affichage_arguments == 'Y')
  294:     {
  295:         printf("\n  NEWPLANE ");
  296: 
  297:         if ((*s_etat_processus).langue == 'F')
  298:         {
  299:             printf("(nouveau plan graphique)\n\n");
  300:             printf("  Aucun argument\n");
  301:         }
  302:         else
  303:         {
  304:             printf("(new graphic plane)\n\n");
  305:             printf("  No argument\n");
  306:         }
  307: 
  308:         return;
  309:     }
  310:     else if ((*s_etat_processus).test_instruction == 'Y')
  311:     {
  312:         (*s_etat_processus).nombre_arguments = -1;
  313:         return;
  314:     }
  315:     
  316:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  317:     {
  318:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  319:         {
  320:             return;
  321:         }
  322:     }
  323: 
  324:     (*s_etat_processus).requete_nouveau_plan = d_vrai;
  325: 
  326:     return;
  327: }
  328: 
  329: 
  330: /*
  331: ================================================================================
  332:   Fonction 'nrproc'
  333: ================================================================================
  334:   Entrées : structure processus
  335: --------------------------------------------------------------------------------
  336:   Sorties :
  337: --------------------------------------------------------------------------------
  338:   Effets de bord : néant
  339: ================================================================================
  340: */
  341: 
  342: void
  343: instruction_nrproc(struct_processus *s_etat_processus)
  344: {
  345:     (*s_etat_processus).erreur_execution = d_ex;
  346: 
  347:     if ((*s_etat_processus).affichage_arguments == 'Y')
  348:     {
  349:         printf("\n  NRPROC ");
  350: 
  351:         if ((*s_etat_processus).langue == 'F')
  352:         {
  353:             printf("(nouvelle racine des processus)\n\n");
  354:             printf("  Aucun argument\n");
  355:         }
  356:         else
  357:         {
  358:             printf("(new root process)\n\n");
  359:             printf("  No argument\n");
  360:         }
  361: 
  362:         return;
  363:     }
  364:     else if ((*s_etat_processus).test_instruction == 'Y')
  365:     {
  366:         (*s_etat_processus).nombre_arguments = -1;
  367:         return;
  368:     }
  369:     
  370:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  371:     {
  372:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  373:         {
  374:             return;
  375:         }
  376:     }
  377: 
  378:     (*s_etat_processus).var_volatile_processus_pere = -1;
  379:     (*s_etat_processus).pid_processus_pere = getpid();
  380:     (*s_etat_processus).tid_processus_pere = pthread_self();
  381: 
  382:     return;
  383: }
  384: 
  385: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>