/* ================================================================================ RPL/2 (R) version 4.0.15 Copyright (C) 1989-2010 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl.conv.h" /* ================================================================================ Fonction 'num' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_num(struct_processus *s_etat_processus) { struct_objet *s_objet_argument; struct_objet *s_objet_resultat; (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n NUM "); if ((*s_etat_processus).langue == 'F') { printf("(conversion d'un caractère en entier)\n\n"); } else { printf("(character to integer conversion)\n\n"); } printf(" 1: %s\n", d_CHN); printf("-> 1: 0 <= %s <= 255\n", d_INT); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 1) == d_erreur) { return; } } if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_argument) == d_erreur) { (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; } /* -------------------------------------------------------------------------------- Chaîne de caractères -------------------------------------------------------------------------------- */ if ((*s_objet_argument).type == CHN) { if (strlen((unsigned char *) (*s_objet_argument).objet) != 1) { liberation(s_etat_processus, s_objet_argument); (*s_etat_processus).erreur_execution = d_ex_argument_invalide; return; } if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((integer8 *) (*s_objet_resultat).objet)) = (integer8) ((unsigned char *) (*s_objet_argument).objet)[0]; } /* -------------------------------------------------------------------------------- Type invalide -------------------------------------------------------------------------------- */ else { liberation(s_etat_processus, s_objet_argument); (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } liberation(s_etat_processus, s_objet_argument); if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_resultat) == d_erreur) { return; } return; } /* ================================================================================ Fonction 'ns' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_ns(struct_processus *s_etat_processus) { logical1 presence_variable; long i; struct_objet *s_objet_resultat; (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n NS "); if ((*s_etat_processus).langue == 'F') { printf("(nombre de données dans la matrice statistique\n\n"); } else { printf("(number of data elements in statistical matrix)\n\n"); } printf("-> 1: %s\n", d_INT); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 0) == d_erreur) { return; } } if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (recherche_variable(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA */ (*s_etat_processus).erreur_systeme = d_es; (*((integer8 *) (*s_objet_resultat).objet)) = 0; } else { /* * Il existe une variable locale SIGMA. Reste à vérifier l'existence * d'une variable SIGMA globale... */ i = (*s_etat_processus).position_variable_courante; presence_variable = d_faux; while(i >= 0) { if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, ds_sdat) == 0) && ((*s_etat_processus) .s_liste_variables[i].niveau == 1)) { presence_variable = d_vrai; break; } i--; } if (presence_variable == d_faux) { (*((integer8 *) (*s_objet_resultat).objet)) = 0; } else { (*s_etat_processus).position_variable_courante = i; if (((*s_etat_processus).s_liste_variables[i]).objet == NULL) { liberation(s_etat_processus, s_objet_resultat); (*s_etat_processus).erreur_execution = d_ex_variable_partagee; return; } if (((*((*s_etat_processus).s_liste_variables [(*s_etat_processus).position_variable_courante].objet)) .type != MIN) && ((*((*s_etat_processus) .s_liste_variables[(*s_etat_processus) .position_variable_courante].objet)).type != MRL)) { liberation(s_etat_processus, s_objet_resultat); (*s_etat_processus).erreur_execution = d_ex_matrice_statistique_invalide; return; } (*((integer8 *) (*s_objet_resultat).objet)) = (*((struct_matrice *) (*((*s_etat_processus) .s_liste_variables[(*s_etat_processus) .position_variable_courante].objet)).objet)) .nombre_lignes; } } if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_resultat) == d_erreur) { return; } return; } /* ================================================================================ Fonction 'newplane' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_newplane(struct_processus *s_etat_processus) { (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n NEWPLANE "); if ((*s_etat_processus).langue == 'F') { printf("(nouveau plan graphique)\n\n"); printf(" Aucun argument\n"); } else { printf("(new graphic plane)\n\n"); printf(" No argument\n"); } return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 0) == d_erreur) { return; } } (*s_etat_processus).requete_nouveau_plan = d_vrai; return; } /* ================================================================================ Fonction 'nrproc' ================================================================================ Entrées : structure processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_nrproc(struct_processus *s_etat_processus) { (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n NRPROC "); if ((*s_etat_processus).langue == 'F') { printf("(nouvelle racine des processus)\n\n"); printf(" Aucun argument\n"); } else { printf("(new root process)\n\n"); printf(" No argument\n"); } return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 0) == d_erreur) { return; } } (*s_etat_processus).var_volatile_processus_pere = -1; (*s_etat_processus).pid_processus_pere = getpid(); (*s_etat_processus).tid_processus_pere = pthread_self(); return; } // vim: ts=4