Révision 139 pobysoC-4.0/src/pobyso.c
pobyso.c (revision 139) | ||
---|---|---|
39 | 39 |
sollya_lib_autoprint(objSo, NULL); |
40 | 40 |
} /* End pobyso_autoprint. */ |
41 | 41 |
|
42 |
int |
|
43 |
pobyso_evaluate_constant(pobyso_func_exp_t functionSo, |
|
44 |
mpfr_t argumentMp, |
|
45 |
mpfr_t evaluationMp) |
|
46 |
{ |
|
47 |
int outcome = 0; |
|
48 |
sollya_obj_t argumentSo = NULL; |
|
49 |
sollya_obj_t evaluationSo = NULL; |
|
50 |
mpfr_t evaluationTmpMp = NULL; |
|
51 |
|
|
52 |
/* Test argument. */ |
|
53 |
if (functionSo == NULL || argumentMp == NULL || evaluationMp == NULL) |
|
54 |
{ |
|
55 |
pobyso_error_message("pobyso_evaluate_constant", |
|
56 |
"NULL_POINTER_ARGUMENT", |
|
57 |
"One of the arguments is a NULL pointer"); |
|
58 |
return 1; |
|
59 |
} |
|
60 |
if (! sollya_lib_obj_is_function(functionSo)) |
|
61 |
{ |
|
62 |
pobyso_error_message("pobyso_evaluate_constant", |
|
63 |
"INVALID_TYPE_ARGUMENT", |
|
64 |
"The functionSo argument is not a functional expression"); |
|
65 |
return 1; |
|
66 |
} |
|
67 |
argumentSo = sollya_lib_constant(argumentMp); |
|
68 |
evaluationSo = sollya_lib_evaluate(functionSo, argumentSo); |
|
69 |
//TODO: finish this function! |
|
70 |
// Check evaluationSo. |
|
71 |
// Depending on its type and value, convert to a MPFR number and/or |
|
72 |
// return an error value. |
|
73 |
sollya_lib_clear_obj(argumentSo); |
|
74 |
sollya_lib_clear_obj(evaluationSo); |
|
75 |
return 0; |
|
76 |
} |
|
77 |
/* End pobyso_evaluate_constant. */ |
|
78 |
|
|
42 | 79 |
/* @see pobyso.h#pobyso_get_verbosity */ |
43 | 80 |
int |
44 | 81 |
pobyso_get_verbosity() |
... | ... | |
72 | 109 |
return 0; |
73 | 110 |
} |
74 | 111 |
initial_verbosity_level = pobyso_set_verbosity_off(); |
75 |
|
|
112 |
/* In Sollya, constant are functional expressions. */ |
|
76 | 113 |
if (! sollya_lib_obj_is_function(obj_to_test)) |
77 | 114 |
{ |
78 | 115 |
pobyso_set_verbosity_to(initial_verbosity_level); |
... | ... | |
82 | 119 |
/* Call to previous Sollya function resets verbosity. */ |
83 | 120 |
/* Todo: change verbosity suppression strategy with a message call back. */ |
84 | 121 |
pobyso_set_verbosity_off(); |
122 |
/* Try to convert the would be constant into an MPFR number. */ |
|
123 |
/* If OK, we indeed have a constant. If the conversion fails, return 0. */ |
|
85 | 124 |
test = sollya_lib_get_constant(dummy, obj_to_test); |
86 | 125 |
pobyso_set_verbosity_to(initial_verbosity_level); |
87 | 126 |
if (test) |
... | ... | |
99 | 138 |
} |
100 | 139 |
else |
101 | 140 |
{ |
141 |
mpfr_clear(dummy); |
|
102 | 142 |
return 0; |
103 | 143 |
} |
104 | 144 |
} /* End pobyso_is_constant_expression. */ |
Formats disponibles : Unified diff