Annotation of rpl/src/instructions_n2.c, revision 1.22

1.1       bertrand    1: /*
                      2: ================================================================================
1.22    ! bertrand    3:   RPL/2 (R) version 4.1.0.prerelease.2
1.15      bertrand    4:   Copyright (C) 1989-2011 Dr. BERTRAND Joël
1.1       bertrand    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: 
1.11      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   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:    struct_objet                *s_objet_resultat;
                    153: 
                    154:    (*s_etat_processus).erreur_execution = d_ex;
                    155: 
                    156:    if ((*s_etat_processus).affichage_arguments == 'Y')
                    157:    {
                    158:        printf("\n  NS ");
                    159: 
                    160:        if ((*s_etat_processus).langue == 'F')
                    161:        {
                    162:            printf("(nombre de données dans la matrice statistique\n\n");
                    163:        }
                    164:        else
                    165:        {
                    166:            printf("(number of data elements in statistical matrix)\n\n");
                    167:        }
                    168: 
                    169:        printf("->  1: %s\n", d_INT);
                    170: 
                    171:        return;
                    172:    }
                    173:    else if ((*s_etat_processus).test_instruction == 'Y')
                    174:    {
                    175:        (*s_etat_processus).nombre_arguments = -1;
                    176:        return;
                    177:    }
                    178: 
                    179:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
                    180:    {
                    181:        if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
                    182:        {
                    183:            return;
                    184:        }
                    185:    }
                    186: 
                    187:    if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
                    188:    {
                    189:        (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    190:        return;
                    191:    }
                    192: 
1.19      bertrand  193:    if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux)
1.1       bertrand  194:    {
                    195:        /*
                    196:         * Aucune variable SIGMA
                    197:         */
                    198: 
                    199:        (*s_etat_processus).erreur_systeme = d_es;
1.19      bertrand  200:        (*s_etat_processus).erreur_execution = d_ex;
                    201: 
1.1       bertrand  202:        (*((integer8 *) (*s_objet_resultat).objet)) = 0;
                    203:    }
                    204:    else
                    205:    {
1.19      bertrand  206:        if (((*(*(*s_etat_processus).pointeur_variable_courante).objet)
                    207:                .type != MIN) && ((*(*(*s_etat_processus)
                    208:                .pointeur_variable_courante).objet).type != MRL))
1.1       bertrand  209:        {
1.19      bertrand  210:            liberation(s_etat_processus, s_objet_resultat);
1.1       bertrand  211: 
1.19      bertrand  212:            (*s_etat_processus).erreur_execution =
                    213:                    d_ex_matrice_statistique_invalide;
                    214:            return;
1.1       bertrand  215:        }
                    216: 
1.19      bertrand  217:        (*((integer8 *) (*s_objet_resultat).objet)) =
                    218:                (*((struct_matrice *) (*(*(*s_etat_processus)
                    219:                .pointeur_variable_courante).objet).objet)).nombre_lignes;
1.1       bertrand  220:    }
                    221: 
                    222:    if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
                    223:            s_objet_resultat) == d_erreur)
                    224:    {
                    225:        return;
                    226:    }
                    227: 
                    228:    return;
                    229: }
                    230: 
                    231: 
                    232: /*
                    233: ================================================================================
                    234:   Fonction 'newplane'
                    235: ================================================================================
                    236:   Entrées : structure processus
                    237: --------------------------------------------------------------------------------
                    238:   Sorties :
                    239: --------------------------------------------------------------------------------
                    240:   Effets de bord : néant
                    241: ================================================================================
                    242: */
                    243: 
                    244: void
                    245: instruction_newplane(struct_processus *s_etat_processus)
                    246: {
                    247:    (*s_etat_processus).erreur_execution = d_ex;
                    248: 
                    249:    if ((*s_etat_processus).affichage_arguments == 'Y')
                    250:    {
                    251:        printf("\n  NEWPLANE ");
                    252: 
                    253:        if ((*s_etat_processus).langue == 'F')
                    254:        {
                    255:            printf("(nouveau plan graphique)\n\n");
                    256:            printf("  Aucun argument\n");
                    257:        }
                    258:        else
                    259:        {
                    260:            printf("(new graphic plane)\n\n");
                    261:            printf("  No argument\n");
                    262:        }
                    263: 
                    264:        return;
                    265:    }
                    266:    else if ((*s_etat_processus).test_instruction == 'Y')
                    267:    {
                    268:        (*s_etat_processus).nombre_arguments = -1;
                    269:        return;
                    270:    }
                    271:    
                    272:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
                    273:    {
                    274:        if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
                    275:        {
                    276:            return;
                    277:        }
                    278:    }
                    279: 
                    280:    (*s_etat_processus).requete_nouveau_plan = d_vrai;
                    281: 
                    282:    return;
                    283: }
                    284: 
                    285: 
                    286: /*
                    287: ================================================================================
                    288:   Fonction 'nrproc'
                    289: ================================================================================
                    290:   Entrées : structure processus
                    291: --------------------------------------------------------------------------------
                    292:   Sorties :
                    293: --------------------------------------------------------------------------------
                    294:   Effets de bord : néant
                    295: ================================================================================
                    296: */
                    297: 
                    298: void
                    299: instruction_nrproc(struct_processus *s_etat_processus)
                    300: {
                    301:    (*s_etat_processus).erreur_execution = d_ex;
                    302: 
                    303:    if ((*s_etat_processus).affichage_arguments == 'Y')
                    304:    {
                    305:        printf("\n  NRPROC ");
                    306: 
                    307:        if ((*s_etat_processus).langue == 'F')
                    308:        {
                    309:            printf("(nouvelle racine des processus)\n\n");
                    310:            printf("  Aucun argument\n");
                    311:        }
                    312:        else
                    313:        {
                    314:            printf("(new root process)\n\n");
                    315:            printf("  No argument\n");
                    316:        }
                    317: 
                    318:        return;
                    319:    }
                    320:    else if ((*s_etat_processus).test_instruction == 'Y')
                    321:    {
                    322:        (*s_etat_processus).nombre_arguments = -1;
                    323:        return;
                    324:    }
                    325:    
                    326:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
                    327:    {
                    328:        if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
                    329:        {
                    330:            return;
                    331:        }
                    332:    }
                    333: 
                    334:    (*s_etat_processus).var_volatile_processus_pere = -1;
                    335:    (*s_etat_processus).pid_processus_pere = getpid();
                    336:    (*s_etat_processus).tid_processus_pere = pthread_self();
                    337: 
                    338:    return;
                    339: }
                    340: 
                    341: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>