From 2b7ed342c58d1e671728248fe2b41776ff6d9617 Mon Sep 17 00:00:00 2001 From: biouman Date: Sun, 29 Apr 2001 00:21:39 +0000 Subject: *** empty log message *** --- lib/pile.c | 43 ++++++++++++++++++++++++++++++++----------- lib/polynom.c | 1 + 2 files changed, 33 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/pile.c b/lib/pile.c index f6760a0..3d4bb93 100644 --- a/lib/pile.c +++ b/lib/pile.c @@ -64,6 +64,7 @@ void push_pile(char *st) void push_pile_poly(polynome poly) { + pushcontext("entree dans push_pile_poly"); if (pile_ptr != PILE_MAX) { pile[pile_ptr].type = T_POLY; pile[pile_ptr].poly = poly; @@ -71,11 +72,16 @@ void push_pile_poly(polynome poly) } else { exception(1, _("push_pile_poly: Stack Overflow")); } - + pushcontext("sortie de push_pile_poly"); + popcontext(); + popcontext(); } void push_pile_int(int val) { + + pushcontext("appel a push_pile_int"); + fprintf(stderr,"%d",val); if (pile_ptr != PILE_MAX) { pile[pile_ptr].type = T_INT; pile[pile_ptr].val = val; @@ -83,11 +89,16 @@ void push_pile_int(int val) } else { exception(1, _("push_pile_int: Stack Overflow")); } + pushcontext("sortie de push-pile_int"); + popcontext(); + popcontext(); + } void push_pile_string(char *st) { + pushcontext("appel a push_pile_string"); if (pile_ptr != PILE_MAX) { pile[pile_ptr].type = T_STRING; pile[pile_ptr].label = Estrdup(st); @@ -95,6 +106,10 @@ void push_pile_string(char *st) } else { exception(1, _("push_pile_string: Stack Overflow")); } + pushcontext("sortie de push_pile_string"); + popcontext(); + popcontext(); + } @@ -234,7 +249,7 @@ void act_pile(int func) exception(1, _("act_pile: OP_EXP invalid arguments")); } break; - case OP_ASSIGN: /* FIXME: sens de l evaluation ? poly label sto ou label poly sto */ + case OP_ASSIGN: operande1 = pop_pile(1); operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_STRING)) { @@ -242,8 +257,6 @@ void act_pile(int func) InsererVarDansTab(&variables, CreerElement(operande2.label, (void *) operande1.poly)); - if (operande1.poly) - ply_destruct(operande1.poly); free(operande2.label); } else { exception(1, _("act_pile: OP_ASSIGN empty string")); @@ -272,13 +285,21 @@ void act_pile(int func) operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { if (operande2.poly) { - if (operande2.poly->degre == 0) { - push_pile_poly(ply_constr - (rat_constr_from_double - (ply_valuation - (operande1.poly, - rat_to_double(operande2.poly-> - coef))), 1)); + if (operande1.poly->degre == 0) { + double soja, soja2; + rationnel rat; + polynome pl; + fprintf(stderr,"soja"); + soja=rat_to_double(operande1.poly->coef); + fprintf(stderr,"%f",soja); + soja2=ply_valuation(operande2.poly,soja); + fprintf(stderr,"%f", soja2); + rat=rat_constr_from_double(soja2); + fprintf(stderr,"pl"); + pl=ply_constr(rat, 1); +/* +push_pile_poly(ply_constr(rat_constr_from_double(ply_valuation(operande2.poly,rat_to_double(operande1.poly->coef))), 1)); +*/ if (operande1.poly) ply_destruct(operande1.poly); ply_destruct(operande2.poly); diff --git a/lib/polynom.c b/lib/polynom.c index 8e15297..72f02bf 100644 --- a/lib/polynom.c +++ b/lib/polynom.c @@ -257,6 +257,7 @@ double ply_valuation(polynome poly, double point) while (poly) { result += rat_to_double(poly->coef) * pow(point, (double) (poly->degre)); + poly++; } return result; } -- cgit v1.2.3