version 1.8, 2010/04/07 13:45:00
|
version 1.32, 2010/09/23 15:27:34
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.14 |
RPL/2 (R) version 4.0.20 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 46 creation_instruction(struct_processus *s
|
Line 46 creation_instruction(struct_processus *s
|
|
|
unsigned char *ptr; |
unsigned char *ptr; |
|
|
|
BUG(strlen(instruction) >= d_longueur_maximale_instruction, |
|
printf("%s -> %d >= %d\n", instruction, (int) strlen(instruction), |
|
d_longueur_maximale_instruction)); |
|
|
if ((*s_etat_processus).arbre_instructions == NULL) |
if ((*s_etat_processus).arbre_instructions == NULL) |
{ |
{ |
if (((*s_etat_processus).arbre_instructions = |
if (((*s_etat_processus).arbre_instructions = |
Line 455 initialisation_instructions(struct_proce
|
Line 459 initialisation_instructions(struct_proce
|
INSTRUCTION("INCR", instruction_incr); |
INSTRUCTION("INCR", instruction_incr); |
//INSTRUCTION("ISOL"); |
//INSTRUCTION("ISOL"); |
INSTRUCTION("ISWI", instruction_iswi); |
INSTRUCTION("ISWI", instruction_iswi); |
|
# ifndef OS2 |
INSTRUCTION("KILL", instruction_kill); |
INSTRUCTION("KILL", instruction_kill); |
|
# endif |
INSTRUCTION("KIND", instruction_kind); |
INSTRUCTION("KIND", instruction_kind); |
INSTRUCTION("LAST", instruction_last); |
INSTRUCTION("LAST", instruction_last); |
INSTRUCTION("LEGV", instruction_legv); |
INSTRUCTION("LEGV", instruction_legv); |
Line 482 initialisation_instructions(struct_proce
|
Line 488 initialisation_instructions(struct_proce
|
INSTRUCTION("PLOT", instruction_plot); |
INSTRUCTION("PLOT", instruction_plot); |
INSTRUCTION("PMAX", instruction_pmax); |
INSTRUCTION("PMAX", instruction_pmax); |
INSTRUCTION("PMIN", instruction_pmin); |
INSTRUCTION("PMIN", instruction_pmin); |
|
# ifndef OS2 |
INSTRUCTION("POKE", instruction_poke); |
INSTRUCTION("POKE", instruction_poke); |
|
# endif |
INSTRUCTION("PPAR", instruction_ppar); |
INSTRUCTION("PPAR", instruction_ppar); |
INSTRUCTION("PRMD", instruction_prmd); |
INSTRUCTION("PRMD", instruction_prmd); |
INSTRUCTION("PRST", instruction_prst); |
INSTRUCTION("PRST", instruction_prst); |
Line 548 initialisation_instructions(struct_proce
|
Line 556 initialisation_instructions(struct_proce
|
INSTRUCTION("STO-", instruction_sto_moins); |
INSTRUCTION("STO-", instruction_sto_moins); |
INSTRUCTION("STO/", instruction_sto_division); |
INSTRUCTION("STO/", instruction_sto_division); |
INSTRUCTION("STOF", instruction_stof); |
INSTRUCTION("STOF", instruction_stof); |
|
# ifndef OS2 |
INSTRUCTION("STOP", instruction_stop); |
INSTRUCTION("STOP", instruction_stop); |
|
# endif |
INSTRUCTION("STOS", instruction_stos); |
INSTRUCTION("STOS", instruction_stos); |
INSTRUCTION("STWS", instruction_stws); |
INSTRUCTION("STWS", instruction_stws); |
INSTRUCTION("SWAP", instruction_swap); |
INSTRUCTION("SWAP", instruction_swap); |
Line 681 initialisation_instructions(struct_proce
|
Line 691 initialisation_instructions(struct_proce
|
INSTRUCTION("SLICE", instruction_slice); |
INSTRUCTION("SLICE", instruction_slice); |
//INSTRUCTION("SLIST") |
//INSTRUCTION("SLIST") |
//Instruction HP48 (somme des termes d'une liste) |
//Instruction HP48 (somme des termes d'une liste) |
|
# ifndef OS2 |
INSTRUCTION("SPAWN", instruction_spawn); |
INSTRUCTION("SPAWN", instruction_spawn); |
|
# endif |
INSTRUCTION("START", instruction_start); |
INSTRUCTION("START", instruction_start); |
INSTRUCTION("STORE", instruction_store); |
INSTRUCTION("STORE", instruction_store); |
INSTRUCTION("STR->", instruction_str_fleche); |
INSTRUCTION("STR->", instruction_str_fleche); |
Line 710 initialisation_instructions(struct_proce
|
Line 722 initialisation_instructions(struct_proce
|
|
|
INSTRUCTION("APPEND", instruction_append); |
INSTRUCTION("APPEND", instruction_append); |
INSTRUCTION("ARRY->", instruction_array_fleche); |
INSTRUCTION("ARRY->", instruction_array_fleche); |
|
INSTRUCTION("ATEXIT", instruction_atexit); |
|
INSTRUCTION("ATPOKE", instruction_atpoke); |
INSTRUCTION("BESSEL", instruction_bessel); |
INSTRUCTION("BESSEL", instruction_bessel); |
INSTRUCTION("CLRERR", instruction_clrerr); |
INSTRUCTION("CLRERR", instruction_clrerr); |
INSTRUCTION("CLRMTX", instruction_clrmtx); |
INSTRUCTION("CLRMTX", instruction_clrmtx); |
INSTRUCTION("CLRSWI", instruction_clrswi); |
INSTRUCTION("CLRSWI", instruction_clrswi); |
INSTRUCTION("CREATE", instruction_create); |
INSTRUCTION("CREATE", instruction_create); |
INSTRUCTION("DELETE", instruction_delete); |
INSTRUCTION("DELETE", instruction_delete); |
|
# ifndef OS2 |
INSTRUCTION("DETACH", instruction_detach); |
INSTRUCTION("DETACH", instruction_detach); |
|
# endif |
INSTRUCTION("DIAG->", instruction_diag_fleche); |
INSTRUCTION("DIAG->", instruction_diag_fleche); |
//INSTRUCTION("DOLIST") |
//INSTRUCTION("DOLIST") |
//Instruction HP48 (application d'une fonction à une liste) |
//Instruction HP48 (application d'une fonction à une liste) |
Line 736 initialisation_instructions(struct_proce
|
Line 752 initialisation_instructions(struct_proce
|
INSTRUCTION("LOGGER", instruction_logger); |
INSTRUCTION("LOGGER", instruction_logger); |
INSTRUCTION("MCLRIN", instruction_mclrin); |
INSTRUCTION("MCLRIN", instruction_mclrin); |
INSTRUCTION("NRPROC", instruction_nrproc); |
INSTRUCTION("NRPROC", instruction_nrproc); |
|
INSTRUCTION("PROCID", instruction_procid); |
INSTRUCTION("PROMPT", instruction_prompt); |
INSTRUCTION("PROMPT", instruction_prompt); |
INSTRUCTION("RCLSWI", instruction_rclswi); |
INSTRUCTION("RCLSWI", instruction_rclswi); |
INSTRUCTION("RECALL", instruction_recall); |
INSTRUCTION("RECALL", instruction_recall); |
Line 788 initialisation_instructions(struct_proce
|
Line 805 initialisation_instructions(struct_proce
|
//f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une |
//f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une |
//fonction paramétrique. |
//fonction paramétrique. |
INSTRUCTION("INQUIRE", instruction_inquire); |
INSTRUCTION("INQUIRE", instruction_inquire); |
|
INSTRUCTION("MEMLOCK", instruction_memlock); |
INSTRUCTION("MTXLOCK", instruction_mtxlock); |
INSTRUCTION("MTXLOCK", instruction_mtxlock); |
INSTRUCTION("PERSIST", instruction_persist); |
INSTRUCTION("PERSIST", instruction_persist); |
INSTRUCTION("PLOTTER", instruction_plotter); |
INSTRUCTION("PLOTTER", instruction_plotter); |
Line 808 initialisation_instructions(struct_proce
|
Line 826 initialisation_instructions(struct_proce
|
|
|
INSTRUCTION("CLRCNTXT", instruction_clrcntxt); |
INSTRUCTION("CLRCNTXT", instruction_clrcntxt); |
INSTRUCTION("CLRSMPHR", instruction_clrsmphr); |
INSTRUCTION("CLRSMPHR", instruction_clrsmphr); |
|
# ifndef OS2 |
INSTRUCTION("CONTINUE", instruction_continue); |
INSTRUCTION("CONTINUE", instruction_continue); |
|
# endif |
INSTRUCTION("DUPCNTXT", instruction_dupcntxt); |
INSTRUCTION("DUPCNTXT", instruction_dupcntxt); |
INSTRUCTION("FUNCTION", instruction_function); |
INSTRUCTION("FUNCTION", instruction_function); |
INSTRUCTION("IMPLICIT", instruction_implicit); |
INSTRUCTION("IMPLICIT", instruction_implicit); |
Line 827 initialisation_instructions(struct_proce
|
Line 847 initialisation_instructions(struct_proce
|
|
|
INSTRUCTION("AUTOSCALE", instruction_autoscale); |
INSTRUCTION("AUTOSCALE", instruction_autoscale); |
INSTRUCTION("BACKSPACE", instruction_backspace); |
INSTRUCTION("BACKSPACE", instruction_backspace); |
|
INSTRUCTION("BACKTRACE", instruction_backtrace); |
|
INSTRUCTION("CLRATEXIT", instruction_clratexit); |
|
INSTRUCTION("CLRATPOKE", instruction_clratpoke); |
INSTRUCTION("COPYRIGHT", instruction_copyright); |
INSTRUCTION("COPYRIGHT", instruction_copyright); |
//INSTRUCTION("CYLINDRIC"); |
//INSTRUCTION("CYLINDRIC"); |
INSTRUCTION("DAEMONIZE", instruction_daemonize); |
INSTRUCTION("DAEMONIZE", instruction_daemonize); |
INSTRUCTION("DROPCNTXT", instruction_dropcntxt); |
INSTRUCTION("DROPCNTXT", instruction_dropcntxt); |
INSTRUCTION("EXTERNALS", instruction_externals); |
INSTRUCTION("EXTERNALS", instruction_externals); |
INSTRUCTION("HISTOGRAM", instruction_histogram); |
INSTRUCTION("HISTOGRAM", instruction_histogram); |
|
INSTRUCTION("MEMUNLOCK", instruction_memunlock); |
INSTRUCTION("MTXSTATUS", instruction_mtxstatus); |
INSTRUCTION("MTXSTATUS", instruction_mtxstatus); |
INSTRUCTION("MTXUNLOCK", instruction_mtxunlock); |
INSTRUCTION("MTXUNLOCK", instruction_mtxunlock); |
INSTRUCTION("PARAMETER", instruction_parameter); |
INSTRUCTION("PARAMETER", instruction_parameter); |
Line 872 initialisation_instructions(struct_proce
|
Line 896 initialisation_instructions(struct_proce
|
} |
} |
|
|
|
|
inline void * |
#ifndef OS2 |
|
extern inline |
|
#endif |
|
void * |
analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) |
analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) |
{ |
{ |
int pointeur; |
int pointeur; |
Line 939 analyse(struct_processus *s_etat_process
|
Line 966 analyse(struct_processus *s_etat_process
|
|
|
unsigned char *position; |
unsigned char *position; |
unsigned char *bibliotheque_candidate; |
unsigned char *bibliotheque_candidate; |
unsigned char *instruction_majuscule; |
unsigned char instruction_majuscule |
|
[d_longueur_maximale_instruction]; |
unsigned char registre_instruction_valide; |
unsigned char registre_instruction_valide; |
|
|
void (*instruction)(); |
void (*instruction)(); |
Line 956 analyse(struct_processus *s_etat_process
|
Line 984 analyse(struct_processus *s_etat_process
|
* On autorise l'exécution d'un fork() dans un thread concurrent. |
* On autorise l'exécution d'un fork() dans un thread concurrent. |
*/ |
*/ |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
Line 970 analyse(struct_processus *s_etat_process
|
Line 999 analyse(struct_processus *s_etat_process
|
return; |
return; |
} |
} |
} |
} |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
scrutation_injection(s_etat_processus); |
while(sem_wait((*s_etat_processus).semaphore_fork) == -1) |
|
|
if (fonction == NULL) |
|
{ |
{ |
if ((instruction_majuscule = conversion_majuscule( |
if (errno != EINTR) |
(*s_etat_processus).instruction_courante)) == NULL) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
} |
|
# endif |
|
|
|
scrutation_injection(s_etat_processus); |
|
|
|
if (fonction == NULL) |
|
{ |
|
conversion_majuscule_limitee((*s_etat_processus).instruction_courante, |
|
instruction_majuscule, d_longueur_maximale_instruction); |
instruction = analyse_instruction(s_etat_processus, |
instruction = analyse_instruction(s_etat_processus, |
instruction_majuscule); |
instruction_majuscule); |
|
|
Line 1010 analyse(struct_processus *s_etat_process
|
Line 1050 analyse(struct_processus *s_etat_process
|
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
} |
} |
} |
} |
|
|
free(instruction_majuscule); |
|
} |
} |
else |
else |
{ |
{ |
Line 1121 analyse(struct_processus *s_etat_process
|
Line 1159 analyse(struct_processus *s_etat_process
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
|
# ifndef OS2 |
if ((*s_etat_processus).pourcentage_maximal_cpu < 100) |
if ((*s_etat_processus).pourcentage_maximal_cpu < 100) |
{ |
{ |
getrusage(RUSAGE_SELF, &usage_final); |
getrusage(RUSAGE_SELF, &usage_final); |
Line 1176 analyse(struct_processus *s_etat_process
|
Line 1215 analyse(struct_processus *s_etat_process
|
usage_initial = usage_final; |
usage_initial = usage_final; |
} |
} |
} |
} |
|
# endif |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 1212 analyse(struct_processus *s_etat_process
|
Line 1252 analyse(struct_processus *s_etat_process
|
((*s_etat_processus).erreur_systeme != d_es) || |
((*s_etat_processus).erreur_systeme != d_es) || |
((*s_etat_processus).exception != d_ep)) |
((*s_etat_processus).exception != d_ep)) |
{ |
{ |
if ((*s_etat_processus).instruction_derniere_erreur != NULL) |
|
{ |
|
free((*s_etat_processus).instruction_derniere_erreur); |
|
(*s_etat_processus).instruction_derniere_erreur = NULL; |
|
} |
|
|
|
(*s_etat_processus).niveau_derniere_erreur = |
(*s_etat_processus).niveau_derniere_erreur = |
(*s_etat_processus).niveau_courant; |
(*s_etat_processus).niveau_courant; |
|
|
if ((*s_etat_processus).mode_execution_programme == 'Y') |
if ((*s_etat_processus).mode_execution_programme == 'Y') |
{ |
{ |
|
if ((*s_etat_processus).instruction_derniere_erreur != NULL) |
|
{ |
|
free((*s_etat_processus).instruction_derniere_erreur); |
|
(*s_etat_processus).instruction_derniere_erreur = NULL; |
|
} |
|
|
if ((*s_etat_processus).instruction_courante == NULL) |
if ((*s_etat_processus).instruction_courante == NULL) |
{ |
{ |
if (((*s_etat_processus).instruction_derniere_erreur = |
if (((*s_etat_processus).instruction_derniere_erreur = |
Line 1254 analyse(struct_processus *s_etat_process
|
Line 1294 analyse(struct_processus *s_etat_process
|
} |
} |
else |
else |
{ |
{ |
if (((*s_etat_processus).instruction_derniere_erreur = |
if ((*s_etat_processus).objet_courant != NULL) |
formateur(s_etat_processus, 0, |
|
(*s_etat_processus).objet_courant)) == NULL) |
|
{ |
{ |
return; |
if ((*s_etat_processus).instruction_derniere_erreur != NULL) |
|
{ |
|
free((*s_etat_processus).instruction_derniere_erreur); |
|
(*s_etat_processus).instruction_derniere_erreur = NULL; |
|
} |
|
|
|
if (((*s_etat_processus).instruction_derniere_erreur = |
|
formateur(s_etat_processus, 0, |
|
(*s_etat_processus).objet_courant)) == NULL) |
|
{ |
|
return; |
|
} |
|
|
|
(*s_etat_processus).objet_courant = NULL; |
} |
} |
} |
} |
} |
} |