Annotation of rpl/src/gestion_niveaux.c, revision 1.70

1.1       bertrand    1: /*
                      2: ================================================================================
1.69      bertrand    3:   RPL/2 (R) version 4.1.30
1.70    ! bertrand    4:   Copyright (C) 1989-2019 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.12      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: 
                     26: /*
                     27: ================================================================================
                     28:   Fonction '<<'
                     29: ================================================================================
                     30:   Entrées :
                     31: --------------------------------------------------------------------------------
                     32:   Sorties :
                     33: --------------------------------------------------------------------------------
                     34:   Effets de bord : néant
                     35: ================================================================================
                     36: */
                     37: 
                     38: void
                     39: instruction_vers_niveau_superieur(struct_processus *s_etat_processus)
                     40: {
                     41:    (*s_etat_processus).erreur_execution = d_ex;
                     42: 
                     43:    if ((*s_etat_processus).affichage_arguments == 'Y')
                     44:    {
                     45:        return;
                     46:    }
                     47:    else if ((*s_etat_processus).test_instruction == 'Y')
                     48:    {
                     49:        (*s_etat_processus).instruction_valide = 'Y';
                     50:        (*s_etat_processus).nombre_arguments = -1;
                     51:        return;
                     52:    }
                     53: 
                     54:    empilement_pile_systeme(s_etat_processus);
                     55: 
                     56:    if ((*s_etat_processus).erreur_systeme != d_es)
                     57:    {
                     58:        return;
                     59:    }
                     60: 
                     61:    if ((*s_etat_processus).mode_execution_programme == 'I')
                     62:    {
                     63:        (*(*s_etat_processus).l_base_pile_systeme).niveau_courant =
                     64:                (*s_etat_processus).niveau_courant;
                     65:        (*(*s_etat_processus).l_base_pile_systeme)
                     66:                .origine_routine_evaluation = 'Y';
                     67:        (*s_etat_processus).mode_execution_programme = 'N';
                     68:    }
                     69: 
                     70:    (*s_etat_processus).niveau_courant++;
                     71:    (*s_etat_processus).autorisation_empilement_programme = 'Y';
                     72: 
                     73:    if ((*s_etat_processus).debug == d_vrai)
                     74:        if (((*s_etat_processus).type_debug &
                     75:                d_debug_niveaux) != 0)
                     76:    {
                     77:        if ((*s_etat_processus).langue == 'F')
                     78:        {
1.44      bertrand   79:            printf("[%d] Initialisation du niveau %lld\n", (int) getpid(),
1.1       bertrand   80:                    (*s_etat_processus).niveau_courant);
                     81:        }
                     82:        else
                     83:        {
1.44      bertrand   84:            printf("[%d] Initialization of level %lld\n", (int) getpid(),
1.1       bertrand   85:                    (*s_etat_processus).niveau_courant);
                     86:        }
                     87: 
                     88:        fflush(stdout);
                     89:    }
                     90: 
                     91:    return;
                     92: }
                     93: 
                     94: 
                     95: /*
                     96: ================================================================================
                     97:   Fonction '>>'
                     98: ================================================================================
                     99:   Entrées :
                    100: --------------------------------------------------------------------------------
                    101:   Sorties :
                    102: --------------------------------------------------------------------------------
                    103:   Effets de bord : néant
                    104: ================================================================================
                    105: */
                    106: 
                    107: void
                    108: instruction_vers_niveau_inferieur(struct_processus *s_etat_processus)
                    109: {
                    110:    (*s_etat_processus).erreur_execution = d_ex;
                    111: 
                    112:    if ((*s_etat_processus).affichage_arguments == 'Y')
                    113:    {
                    114:        return;
                    115:    }
                    116:    else if ((*s_etat_processus).test_instruction == 'Y')
                    117:    {
                    118:        (*s_etat_processus).instruction_valide = 'Y';
                    119:        (*s_etat_processus).nombre_arguments = -1;
                    120:        return;
                    121:    }
                    122: 
                    123:    if ((*s_etat_processus).debug == d_vrai)
                    124:        if (((*s_etat_processus).type_debug &
                    125:                d_debug_niveaux) != 0)
                    126:    {
                    127:        if ((*s_etat_processus).langue == 'F')
                    128:        {
1.44      bertrand  129:            printf("[%d] Fermeture du niveau %lld\n", (int) getpid(),
1.1       bertrand  130:                    (*s_etat_processus).niveau_courant);
                    131:        }
                    132:        else
                    133:        {
1.44      bertrand  134:            printf("[%d] Closing of level %lld\n", (int) getpid(),
1.1       bertrand  135:                    (*s_etat_processus).niveau_courant);
                    136:        }
                    137: 
                    138:        fflush(stdout);
                    139:    }
                    140: 
                    141:    (*s_etat_processus).niveau_courant--;
                    142:    depilement_pile_systeme(s_etat_processus);
                    143: 
                    144:    if ((*s_etat_processus).erreur_systeme != d_es)
                    145:    {
                    146:        return;
                    147:    }
                    148: 
                    149:    if ((*(*s_etat_processus).l_base_pile_systeme).retour_definition == 'Y')
                    150:    {
                    151:        if ((*s_etat_processus).debug == d_vrai)
                    152:            if (((*s_etat_processus).type_debug &
                    153:                    d_debug_appels_fonctions) != 0)
                    154:        {
                    155:            if ((*s_etat_processus).niveau_recursivite == 0)
                    156:            {
                    157:                if ((*s_etat_processus).langue == 'F')
                    158:                {
                    159:                    printf("[%d] Retour\n", (int) getpid());
                    160:                }
                    161:                else
                    162:                {
                    163:                    printf("[%d] Return\n", (int) getpid());
                    164:                }
                    165:            }
                    166:            else
                    167:            {
                    168:                if ((*s_etat_processus).langue == 'F')
                    169:                {
                    170:                    printf("[%d] Retour récursif de niveau "
1.44      bertrand  171:                            "%lld\n", (int) getpid(), (*s_etat_processus)
1.1       bertrand  172:                            .niveau_recursivite);
                    173:                }
                    174:                else
                    175:                {
1.44      bertrand  176:                    printf("[%d] Level %lld recursive "
1.1       bertrand  177:                            "return\n", (int) getpid(), (*s_etat_processus)
                    178:                            .niveau_recursivite);
                    179:                }
                    180:            }
                    181: 
                    182:            fflush(stdout);
                    183:        }
                    184: 
                    185:        if ((*s_etat_processus).l_base_pile_systeme != NULL)
                    186:        {
                    187:            if ((*(*s_etat_processus).l_base_pile_systeme)
                    188:                    .origine_routine_evaluation == 'N')
                    189:            {
                    190:                (*s_etat_processus).position_courante =
                    191:                        (*(*s_etat_processus).l_base_pile_systeme)
                    192:                        .adresse_retour;
                    193: 
                    194:                if ((*s_etat_processus).profilage == d_vrai)
                    195:                {
                    196:                    profilage(s_etat_processus, NULL);
                    197:                }
                    198: 
                    199:                depilement_pile_systeme(s_etat_processus);
                    200: 
                    201:                if ((*s_etat_processus).erreur_systeme != d_es)
                    202:                {
                    203:                    return;
                    204:                }
                    205:            }
                    206:            else
                    207:            {
                    208:                (*s_etat_processus).retour_routine_evaluation = 'Y';
                    209:            }
                    210:        }
                    211:    }
                    212: 
                    213:    /*
                    214:     * Destruction des variables locales
                    215:     * de niveau supérieur au niveau courant.
                    216:     */
                    217: 
                    218:    if (((*s_etat_processus).niveau_recursivite == 0) && ((*s_etat_processus)
                    219:            .gel_liste_variables == d_faux))
                    220:    {
1.46      bertrand  221:        if (retrait_variables_par_niveau(s_etat_processus) == d_erreur)
1.1       bertrand  222:        {
1.46      bertrand  223:            return;
1.1       bertrand  224:        }
                    225:    }
                    226: 
                    227:    return;
                    228: }
                    229: 
                    230: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>