@@ -52,15 +52,13 @@ module type S = sig
5252 (custom_float value , Com.Var .t ) Com .event_value
5353end
5454
55- module Make (N : Mir_number.NumberInterface ) (RF : Mir_roundops.RoundOpsFunctor ) :
56- S with type custom_float = N. t = struct
55+ module Make (N : Types.Number ) : S with type custom_float = N. t = struct
5756 (* Careful : this behavior mimics the one imposed by the original Mlang
5857 compiler... *)
5958
60- module R = RF (N )
61- module Funs = Functions. Make (N ) (R )
59+ module Funs = Functions. Make (N )
6260 module C = Context. Make (N )
63- module Print = Print. Make (N ) ( C )
61+ module Print = Print. Make (N )
6462
6563 type custom_float = N .t
6664
@@ -72,7 +70,7 @@ module Make (N : Mir_number.NumberInterface) (RF : Mir_roundops.RoundOpsFunctor)
7270
7371 exception BlockingError
7472
75- let roundf (x : N.t ) = R . roundf x
73+ let roundf (x : N.t ) = N . roundf x
7674
7775 let literal_to_value (l : Com.literal ) : value =
7876 match l with
@@ -312,8 +310,14 @@ module Make (N : Mir_number.NumberInterface) (RF : Mir_roundops.RoundOpsFunctor)
312310 (fun (arg : Com.Var.t Com.print_arg Pos.marked ) ->
313311 match Pos. unmark arg with
314312 | PrintString s -> Print. string pctx s
315- | PrintAccess (info , m_a ) ->
316- Print. access ~eval: evaluate_expr pctx info (Pos. unmark m_a)
313+ | PrintAccess (info , m_a ) -> (
314+ match
315+ C. get_access_var ~eval: evaluate_expr pctx.ctx (Pos. unmark m_a)
316+ with
317+ | None -> ()
318+ | Some (vsd , var , _ ) ->
319+ let _, v, _ = C. get_var pctx.ctx None var in
320+ Print. access pctx info vsd v)
317321 | PrintIndent e -> Print. indent pctx (evaluate_expr pctx.ctx e)
318322 | PrintExpr (e , mi , ma ) ->
319323 Print. value pctx mi ma (evaluate_expr pctx.ctx e))
@@ -789,61 +793,21 @@ module Make (N : Mir_number.NumberInterface) (RF : Mir_roundops.RoundOpsFunctor)
789793 | Stop_instruction SKTarget -> (* May not be caught by anything else *) ()
790794end
791795
792- module BigIntPrecision = struct
793- let scaling_factor_bits = ref 64
794- end
795-
796- module MainframeLongSize = struct
797- let max_long = ref Int64. max_int
798- end
799-
800- module FloatDefInterp =
801- Make (Mir_number. RegularFloatNumber ) (Mir_roundops. DefaultRoundOps )
802- module FloatMultInterp =
803- Make (Mir_number. RegularFloatNumber ) (Mir_roundops. MultiRoundOps )
804- module FloatMfInterp =
805- Make
806- (Mir_number. RegularFloatNumber )
807- (Mir_roundops. MainframeRoundOps (MainframeLongSize ))
808- module MPFRDefInterp =
809- Make (Mir_number. MPFRNumber ) (Mir_roundops. DefaultRoundOps )
810- module MPFRMultInterp =
811- Make (Mir_number. MPFRNumber ) (Mir_roundops. MultiRoundOps )
812- module MPFRMfInterp =
813- Make
814- (Mir_number. MPFRNumber )
815- (Mir_roundops. MainframeRoundOps (MainframeLongSize ))
816- module BigIntDefInterp =
817- Make
818- (Mir_number. BigIntFixedPointNumber
819- (BigIntPrecision ))
820- (Mir_roundops. DefaultRoundOps )
821- module BigIntMultInterp =
822- Make
823- (Mir_number. BigIntFixedPointNumber
824- (BigIntPrecision ))
825- (Mir_roundops. MultiRoundOps )
826- module BigIntMfInterp =
827- Make
828- (Mir_number. BigIntFixedPointNumber
829- (BigIntPrecision ))
830- (Mir_roundops. MainframeRoundOps (MainframeLongSize ))
831- module IntvDefInterp =
832- Make (Mir_number. IntervalNumber ) (Mir_roundops. DefaultRoundOps )
833- module IntvMultInterp =
834- Make (Mir_number. IntervalNumber ) (Mir_roundops. MultiRoundOps )
835- module IntvMfInterp =
836- Make
837- (Mir_number. IntervalNumber )
838- (Mir_roundops. MainframeRoundOps (MainframeLongSize ))
839- module RatDefInterp =
840- Make (Mir_number. RationalNumber ) (Mir_roundops. DefaultRoundOps )
841- module RatMultInterp =
842- Make (Mir_number. RationalNumber ) (Mir_roundops. MultiRoundOps )
843- module RatMfInterp =
844- Make
845- (Mir_number. RationalNumber )
846- (Mir_roundops. MainframeRoundOps (MainframeLongSize ))
796+ module FloatDefInterp = Make (Number. FloatDef )
797+ module FloatMultInterp = Make (Number. FloatMult )
798+ module FloatMfInterp = Make (Number. FloatMf )
799+ module MPFRDefInterp = Make (Number. MPFRDef )
800+ module MPFRMultInterp = Make (Number. MPFRMult )
801+ module MPFRMfInterp = Make (Number. MPFRMf )
802+ module BigIntDefInterp = Make (Number. BigIntDef )
803+ module BigIntMultInterp = Make (Number. BigIntMult )
804+ module BigIntMfInterp = Make (Number. BigIntMf )
805+ module IntvDefInterp = Make (Number. IntvDef )
806+ module IntvMultInterp = Make (Number. IntvMult )
807+ module IntvMfInterp = Make (Number. IntvMf )
808+ module RatDefInterp = Make (Number. RatDef )
809+ module RatMultInterp = Make (Number. RatMult )
810+ module RatMfInterp = Make (Number. RatMf )
847811
848812let get_interp (sort : Config.value_sort ) (roundops : Config.round_ops ) :
849813 (module S) =
@@ -864,31 +828,11 @@ let get_interp (sort : Config.value_sort) (roundops : Config.round_ops) :
864828 | Rational , ROMulti -> (module RatMultInterp )
865829 | Rational , ROMainframe _ -> (module RatMfInterp )
866830
867- let prepare_interp (sort : Config.value_sort ) (roundops : Config.round_ops ) :
868- unit =
869- begin
870- match sort with
871- | MPFR prec -> Mpfr. set_default_prec prec
872- | BigInt prec -> BigIntPrecision. scaling_factor_bits := prec
873- | Interval -> Mpfr. set_default_prec 64
874- | _ -> ()
875- end ;
876- match roundops with
877- | ROMainframe long_size ->
878- let max_long =
879- if long_size = 32 then Int64. of_int32 Int32. max_int
880- else if long_size = 64 then Int64. max_int
881- else assert false
882- (* checked when parsing command line *)
883- in
884- MainframeLongSize. max_long := max_long
885- | _ -> ()
886-
887831let evaluate_program ~(p : Mir.program ) ~(inputs : Com.literal Com.Var.Map.t )
888832 ~(events : (Com.literal, Com.Var.t) Com.event_value StrMap.t list )
889833 ~(sort : Config.value_sort ) ~(round_ops : Config.round_ops ) :
890834 Com. literal Com.Var.Map. t * Com.Error.Set. t =
891- prepare_interp sort round_ops;
835+ Number. setup_precision sort round_ops;
892836 let module Interp = (val get_interp sort round_ops : S ) in
893837 let ctx =
894838 let inputs = Com.Var.Map. map Interp. literal_to_value inputs in
0 commit comments