1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.36
4: Copyright (C) 1989-2025 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 'limit'
29: ================================================================================
30: Entrées : pointeur sur une struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_limit(struct_processus *s_etat_processus)
40: {
41: struct_liste_chainee *l_element_courant;
42:
43: struct_objet *s_objet_argument_1;
44: struct_objet *s_objet_argument_2;
45:
46: (*s_etat_processus).erreur_execution = d_ex;
47:
48: if ((*s_etat_processus).affichage_arguments == 'Y')
49: {
50: printf("\n LIMIT ");
51:
52: if ((*s_etat_processus).langue == 'F')
53: {
54: printf("(limite d'une fonction)\n\n");
55: }
56: else
57: {
58: printf("(function limit)\n\n");
59: }
60:
61: printf(" 2: %s, %s, %s, %s\n", d_INT, d_REL, d_NOM, d_ALG);
62: printf(" 1: %s\n", d_LST);
63: printf("-> 1: %s, %s, %s, %s\n\n", d_INT, d_REL, d_NOM, d_ALG);
64:
65: if ((*s_etat_processus).langue == 'F')
66: {
67: printf(" Utilisation :\n\n");
68: }
69: else
70: {
71: printf(" Usage:\n\n");
72: }
73:
74: printf(" 'SIN(X)/X' { 'X' 0 } LIMIT\n");
75: printf(" '1/X' { 'X' 0 + } LIMIT\n");
76: printf(" 'SQRT(X+SQRT(X+SQRT(X)))-SQRT(X)' { 'X' '+infinity' } "
77: "LIMIT\n");
78: return;
79: }
80: else if ((*s_etat_processus).test_instruction == 'Y')
81: {
82: (*s_etat_processus).nombre_arguments = -1;
83: return;
84: }
85:
86: if (test_cfsf(s_etat_processus, 31) == d_vrai)
87: {
88: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
89: {
90: return;
91: }
92: }
93:
94: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
95: &s_objet_argument_1) == d_erreur)
96: {
97: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
98: return;
99: }
100:
101: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
102: &s_objet_argument_2) == d_erreur)
103: {
104: liberation(s_etat_processus, s_objet_argument_1);
105:
106: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
107: return;
108: }
109:
110: if (((*s_objet_argument_1).type == LST) &&
111: (((*s_objet_argument_2).type == NOM) ||
112: ((*s_objet_argument_2).type == ALG) ||
113: ((*s_objet_argument_2).type == REL) ||
114: ((*s_objet_argument_2).type == INT)))
115: {
116: l_element_courant = (*s_objet_argument_1).objet;
117:
118: if (l_element_courant == NULL)
119: {
120: liberation(s_etat_processus, s_objet_argument_1);
121: liberation(s_etat_processus, s_objet_argument_2);
122:
123: (*s_etat_processus).erreur_execution =
124: d_ex_erreur_type_argument;
125: return;
126: }
127:
128: if ((*(*l_element_courant).donnee).type != NOM)
129: {
130: liberation(s_etat_processus, s_objet_argument_1);
131: liberation(s_etat_processus, s_objet_argument_2);
132:
133: (*s_etat_processus).erreur_execution =
134: d_ex_erreur_type_argument;
135: return;
136: }
137:
138: l_element_courant = (*l_element_courant).suivant;
139:
140: if (l_element_courant == NULL)
141: {
142: liberation(s_etat_processus, s_objet_argument_1);
143: liberation(s_etat_processus, s_objet_argument_2);
144:
145: (*s_etat_processus).erreur_execution =
146: d_ex_erreur_type_argument;
147: return;
148: }
149:
150: if (((*(*l_element_courant).donnee).type != INT) &&
151: ((*(*l_element_courant).donnee).type != REL) &&
152: ((*(*l_element_courant).donnee).type != NOM) &&
153: ((*(*l_element_courant).donnee).type != ALG))
154: {
155: liberation(s_etat_processus, s_objet_argument_1);
156: liberation(s_etat_processus, s_objet_argument_2);
157:
158: (*s_etat_processus).erreur_execution =
159: d_ex_erreur_type_argument;
160: return;
161: }
162:
163: l_element_courant = (*l_element_courant).suivant;
164:
165: if (l_element_courant != NULL)
166: {
167: // S'il y a un troisième argument, il ne peut être
168: // que + ou -.
169:
170: if ((*(*l_element_courant).donnee).type != FCT)
171: {
172: liberation(s_etat_processus, s_objet_argument_1);
173: liberation(s_etat_processus, s_objet_argument_2);
174:
175: (*s_etat_processus).erreur_execution =
176: d_ex_erreur_type_argument;
177: return;
178: }
179:
180: if ((strcmp((*((struct_fonction *) (*(*l_element_courant).donnee)
181: .objet)).nom_fonction, "-") != 0) &&
182: (strcmp((*((struct_fonction *) (*(*l_element_courant)
183: .donnee).objet)).nom_fonction, "+") != 0))
184: {
185: liberation(s_etat_processus, s_objet_argument_1);
186: liberation(s_etat_processus, s_objet_argument_2);
187:
188: (*s_etat_processus).erreur_execution =
189: d_ex_argument_invalide;
190: return;
191: }
192:
193: if ((*l_element_courant).suivant != NULL)
194: {
195: liberation(s_etat_processus, s_objet_argument_1);
196: liberation(s_etat_processus, s_objet_argument_2);
197:
198: (*s_etat_processus).erreur_execution =
199: d_ex_erreur_type_argument;
200: return;
201: }
202: }
203:
204: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
205: s_objet_argument_2) == d_erreur)
206: {
207: return;
208: }
209:
210: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
211: s_objet_argument_1) == d_erreur)
212: {
213: return;
214: }
215:
216: interface_cas(s_etat_processus, RPLCAS_LIMITE);
217: }
218: else
219: {
220: liberation(s_etat_processus, s_objet_argument_1);
221: liberation(s_etat_processus, s_objet_argument_2);
222:
223: (*s_etat_processus).erreur_execution =
224: d_ex_erreur_type_argument;
225: return;
226: }
227:
228: return;
229: }
CVSweb interface <joel.bertrand@systella.fr>