Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ clean: FORCE remise_a_zero_versionnage
rm -f doc/doc.html
dune clean

test:
_build/default/src/main.exe tests/mlang/${test}.m -A test --mpp_function test_args --dgfip_options='' --run_test tests/mlang/${test}.irj --debug

c:
_build/default/src/main.exe tests/mlang/${test}.m -A app -b dgfip_c --mpp_function target --dgfip_options='' --output output/${test}.c --debug

t:
dune exec src/main.exe --profile release -- -A iliad --display_time --precision double --income-year=2020 --comparison_error_margin=0.000001 --mpp_function=enchainement_primitif_interpreteur ir-calcul/sources2020m_6_5/tgvI.m ir-calcul/sources2020m_6_5/errI.m ir-calcul/sources2020m_6_5/chap-1.m ir-calcul/sources2020m_6_5/chap-2.m ir-calcul/sources2020m_6_5/chap-3.m ir-calcul/sources2020m_6_5/chap-4.m ir-calcul/sources2020m_6_5/chap-51.m ir-calcul/sources2020m_6_5/chap-52.m ir-calcul/sources2020m_6_5/chap-6.m ir-calcul/sources2020m_6_5/chap-7.m ir-calcul/sources2020m_6_5/chap-81.m ir-calcul/sources2020m_6_5/chap-82.m ir-calcul/sources2020m_6_5/chap-83.m ir-calcul/sources2020m_6_5/chap-84.m ir-calcul/sources2020m_6_5/chap-85.m ir-calcul/sources2020m_6_5/chap-86.m ir-calcul/sources2020m_6_5/chap-87.m ir-calcul/sources2020m_6_5/chap-88.m ir-calcul/sources2020m_6_5/chap-aff.m ir-calcul/sources2020m_6_5/chap-cinr.m ir-calcul/sources2020m_6_5/chap-cmajo.m ir-calcul/sources2020m_6_5/chap-cor.m ir-calcul/sources2020m_6_5/chap-ctl.m ir-calcul/sources2020m_6_5/chap-ini.m ir-calcul/sources2020m_6_5/chap-inr.m ir-calcul/sources2020m_6_5/chap-isf.m ir-calcul/sources2020m_6_5/chap-majo.m ir-calcul/sources2020m_6_5/chap-perp.m ir-calcul/sources2020m_6_5/chap-plaf.m ir-calcul/sources2020m_6_5/chap-taux.m ir-calcul/sources2020m_6_5/chap-teff.m ir-calcul/sources2020m_6_5/chap-thr.m ir-calcul/sources2020m_6_5/chap-tl.m ir-calcul/sources2020m_6_5/coc1.m ir-calcul/sources2020m_6_5/coc2.m ir-calcul/sources2020m_6_5/coc3.m ir-calcul/sources2020m_6_5/coc4.m ir-calcul/sources2020m_6_5/coc5.m ir-calcul/sources2020m_6_5/coc7.m ir-calcul/sources2020m_6_5/coi1.m ir-calcul/sources2020m_6_5/coi2.m ir-calcul/sources2020m_6_5/coi3.m ir-calcul/sources2020m_6_5/horizoc.m ir-calcul/sources2020m_6_5/horizoi.m ir-calcul/sources2020m_6_5/res-ser1.m ir-calcul/sources2020m_6_5/res-ser2.m m_ext/2020/cibles.m --run_test='tests/2020/fuzzing/fuzzer_1423.m_test' --dgfip_options='' --debug
2 changes: 1 addition & 1 deletion ir-calcul
Submodule ir-calcul updated from 7af2b7 to f52184
4 changes: 2 additions & 2 deletions irj_checker.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "1.1.0"
version: "%%VERSION%%"
synopsis: "IRJ test validation tool"
description:
"This standalone module performs a syntactic validation of the DGFiP IRJ test format"
Expand All @@ -10,7 +10,7 @@ license: "GPL-3.0-or-later"
homepage: "https://github.com/MLanguage/mlang"
bug-reports: "https://github.com/MLanguage/mlang/issues"
depends: [
"ocaml" {>= "4.13.0"}
"ocaml" {>= "4.11.2"}
"dune" {build}
"odoc" {>= "1.5.3"}
"ocamlformat" {= "0.24.1"}
Expand Down
2 changes: 1 addition & 1 deletion mlang.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "1.1.0"
version: "%%VERSION%%"
synopsis: "Compiler for DGFiP's M language"
description: """
The Direction Générale des Finances Publiques (DGFiP)
Expand Down
8 changes: 8 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@
(:standard
(:include linking-flags-mlang.sexp)))
(libraries mlang))

(executable
(name server)
(package mlang)
(public_name server)
(preprocess
(pps lwt_ppx ppx_yojson_conv))
(libraries mlang dream))
2 changes: 1 addition & 1 deletion src/irj_checker/irj_checker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let irj_checker (f : string) (message_format : message_format_enum)
if not (Sys.file_exists f && not (Sys.is_directory f)) then
Errors.raise_error
(Format.asprintf "%s: this path is not a valid file in the filesystem" f);
let test_data = Mlang.Irj_file.parse_file f in
let test_data = Mlang.Irj_file.parse_file (Filename f) in
let test_data =
match validation_mode with
| Primitive ->
Expand Down
5 changes: 3 additions & 2 deletions src/mlang/backend_compilers/bir_to_dgfip_c.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

module D = DecoupledExpr
module VID = Dgfip_varid
module Dgfip_options = Config.Dgfip_options

let str_escape str =
let l = String.length str in
Expand Down Expand Up @@ -397,9 +398,9 @@ and generate_c_expr (p : Mir.program) (e : Mir.expression Pos.marked) :
let value_comp = D.dinstr res_val in
D.build_transitive_composition { set_vars; def_test; value_comp }
| FuncCall _ -> assert false (* should not happen *)
| Literal (Float f) ->
| Literal { lit = Float f; _ } ->
{ set_vars = []; def_test = D.dtrue; value_comp = D.lit f }
| Literal Undefined ->
| Literal { lit = Undefined; _ } ->
{ set_vars = []; def_test = D.dfalse; value_comp = D.lit 0. }
| Var (VarAccess (m_sp_opt, var)) ->
let def_test = D.m_var m_sp_opt var Def in
Expand Down
2 changes: 1 addition & 1 deletion src/mlang/backend_compilers/bir_to_dgfip_c.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
of the output, is built in {!DecoupledExpr}. *)

val generate_c_program :
Dgfip_options.flags -> Mir.program -> (* filename *) string -> unit
Config.Dgfip_options.flags -> Mir.program -> (* filename *) string -> unit
1 change: 1 addition & 0 deletions src/mlang/backend_compilers/decoupledExpr.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module VID = Dgfip_varid
module Dgfip_options = Config.Dgfip_options

let generate_variable ?(def_flag = false) ?(trace_flag = false)
(m_sp_opt : Com.var_space) (var : Com.Var.t) : string =
Expand Down
7 changes: 5 additions & 2 deletions src/mlang/backend_compilers/decoupledExpr.mli
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ val build_expression :
val format_local_declarations : Format.formatter -> local_decls -> unit

val format_assign :
Dgfip_options.flags -> string -> Format.formatter -> t -> unit
Config.Dgfip_options.flags -> string -> Format.formatter -> t -> unit

val format_set_vars :
Dgfip_options.flags -> Format.formatter -> (dflag * string * t) list -> unit
Config.Dgfip_options.flags ->
Format.formatter ->
(dflag * string * t) list ->
unit
4 changes: 3 additions & 1 deletion src/mlang/backend_compilers/dgfip_compir_files.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>. *)

module Dgfip_options = Config.Dgfip_options

let open_file filename =
let folder = Filename.dirname !Cli.output_file in
let folder = Filename.dirname !Config.output_file in
let oc = open_out (Filename.concat folder filename) in
let fmt = Format.formatter_of_out_channel oc in
(oc, fmt)
Expand Down
10 changes: 6 additions & 4 deletions src/mlang/backend_compilers/dgfip_gen_files.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>. *)

module Dgfip_options = Config.Dgfip_options

let open_file filename =
let folder = Filename.dirname !Cli.output_file in
let folder = Filename.dirname !Config.output_file in
let oc = open_out (Filename.concat folder filename) in
let fmt = Format.formatter_of_out_channel oc in
(oc, fmt)
Expand Down Expand Up @@ -270,7 +272,7 @@ typedef struct S_varinfo_map {
attrs

let is_valid_app apps =
StrMap.exists (fun app _ -> List.mem app !Cli.application_names) apps
StrMap.exists (fun app _ -> List.mem app !Config.application_names) apps

let gen_erreurs_c fmt flags (cprog : Mir.program) =
Pp.fpr fmt {|/****** LICENCE CECIL *****/
Expand Down Expand Up @@ -347,7 +349,7 @@ let gen_conf_h fmt (cprog : Mir.program) flags =
FLG_TRACE_IRDATA\n"; *)
if flags.flg_debug then Pp.fpr fmt "#define FLG_DEBUG\n";
Pp.fpr fmt "#define NB_DEBUG_C %d\n" flags.nb_debug_c;
Pp.fpr fmt "#define EPSILON %f\n" !Cli.comparison_error_margin;
Pp.fpr fmt "#define EPSILON %f\n" !Config.comparison_error_margin;
let count loc =
StrMap.fold
(fun _ var nb ->
Expand Down Expand Up @@ -593,7 +595,7 @@ extern void free_erreur();
#define min(a,b) (((a) <= (b)) ? (a) : (b))
#define max(a,b) (((a) >= (b)) ? (a) : (b))
|};
Pp.fpr fmt "#define EPSILON %f" !Cli.comparison_error_margin;
Pp.fpr fmt "#define EPSILON %f" !Config.comparison_error_margin;
Pp.fpr fmt
{|
#define GT_E(a,b) ((a) > (b) + EPSILON)
Expand Down
Loading
Loading