op_calcul.miaou
← Le code · src/outil/miaou/op_calcul.miaou · 56 lignes
(node op_calcul
(params (c Evc) (x Forme) (a Ta) (k Nat) (p W) (q W))
(returns Ev)
(intent "l'opération de rang k (0 add, 1 sub, 2 mul, 3 div, 4 mod, 5 neg, 6 to_nat, 7 to_octet) de la forme x d'arbre a sur les valeurs p et q, bornée au type de x ; div et mod tronqués vers zéro, DIVISION_PAR_ZERO ; un arbre de décision équilibré, pour que le typeur ne double pas son travail à chaque niveau")
(origin "phase 8f6 : l'évaluateur en miaou, d'après ev_operation de l'outil inter")
(effects)
(uses ev_borner w_grand gr_add gr_sub gr_mul gr_neg gr_divmod faute_ev)
(requires
true)
(ensures
true)
(examples
(ex ((record Evc (chemin (list)) (compter false) (nom "n") (borne true) (defs (list)) (cache (list)) (monde (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list)))) (arguments (list)) (lisibles (list)) (fiches (list)) (lancements (list))) (quote x) (variant Ta vide) 0 (variant W w_ent (g (record Grand (neg false) (mots (list 2))))) (variant W w_bool (b true)))
(variant Ev
ev_ok
(m (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list))))
(w (variant W w_ent (g (record Grand (neg false) (mots (list 3))))))))
(ex ((record Evc (chemin (list)) (compter false) (nom "n") (borne true) (defs (list)) (cache (list)) (monde (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list)))) (arguments (list)) (lisibles (list)) (fiches (list)) (lancements (list))) (quote x) (variant Ta vide) 3 (variant W w_ent (g (record Grand (neg true) (mots (list 7))))) (variant W w_ent (g (record Grand (neg false) (mots (list 2))))))
(variant Ev
ev_ok
(m (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list))))
(w (variant W w_ent (g (record Grand (neg true) (mots (list 3))))))))
(ex ((record Evc (chemin (list)) (compter false) (nom "n") (borne true) (defs (list)) (cache (list)) (monde (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list)))) (arguments (list)) (lisibles (list)) (fiches (list)) (lancements (list))) (quote x) (variant Ta vide) 4 (variant W w_ent (g (record Grand (neg true) (mots (list 7))))) (variant W w_ent (g (record Grand (neg false) (mots (list 2))))))
(variant Ev
ev_ok
(m (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list))))
(w (variant W w_ent (g (record Grand (neg true) (mots (list 1))))))))
(ex ((record Evc (chemin (list)) (compter false) (nom "n") (borne true) (defs (list)) (cache (list)) (monde (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list)))) (arguments (list)) (lisibles (list)) (fiches (list)) (lancements (list))) (quote x) (variant Ta vide) 4 (variant W w_ent (g (record Grand (neg false) (mots (list 7))))) (variant W w_bool (b false)))
(variant Ev
ev_faute
(champs (list (record Champ (cle "code") (valeur (variant Valeur texte (t "DIVISION_PAR_ZERO")))) (record Champ (cle "node") (valeur (variant Valeur texte (t "n")))) (record Champ (cle "forme") (valeur (variant Valeur forme60 (f (quote x)))))))))
(ex ((record Evc (chemin (list)) (compter false) (nom "n") (borne true) (defs (list)) (cache (list)) (monde (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list)))) (arguments (list)) (lisibles (list)) (fiches (list)) (lancements (list))) (quote x) (variant Ta vide) 5 (variant W w_ent (g (record Grand (neg false) (mots (list 7))))) (variant W w_bool (b false)))
(variant Ev
ev_ok
(m (record Monde (hasard (record Mt (mots (list)) (i 624))) (branches (list)) (entree (list)) (sortie (list)) (ecrits (list)) (installes (list))))
(w (variant W w_ent (g (record Grand (neg true) (mots (list 7)))))))))
(equivalence exact)
(body.high
(if (lt k 4)
(if (lt k 2)
(if (eq k 0)
(ev_borner c (gr_add (w_grand p) (w_grand q)) x a)
(ev_borner c (gr_sub (w_grand p) (w_grand q)) x a))
(if (eq k 2)
(ev_borner c (gr_mul (w_grand p) (w_grand q)) x a)
(if (eq (len (get (w_grand q) mots)) 0)
(faute_ev "DIVISION_PAR_ZERO" (get c nom) false x)
(ev_borner c (get (gr_divmod (w_grand p) (w_grand q)) q) x a))))
(if (lt k 6)
(if (eq k 4)
(if (eq (len (get (w_grand q) mots)) 0)
(faute_ev "DIVISION_PAR_ZERO" (get c nom) false x)
(ev_borner c (get (gr_divmod (w_grand p) (w_grand q)) r) x a))
(ev_borner c (gr_neg (w_grand p)) x a))
(ev_borner c (w_grand p) x a))))
(end node op_calcul))