Commit 051d1a17 authored by erwan's avatar erwan
Browse files

Fix: lv6 -exec was raising a spurious runtime error

parent fe2e657b
(* Time-stamp: <modified the 12/03/2020 (at 11:45) by Erwan Jahier> *)
(* Time-stamp: <modified the 15/03/2021 (at 12:28) by Erwan Jahier> *)
open AstV6
open Lxm
......@@ -324,12 +324,12 @@ could try one the options: -2c, -2c-exec, -exec, -ec, -lic, or -h for more optio
| Parse_error ->
print_compile_error (Lxm.last_made ()) "Syntax error"; my_exit opt 1
| Unknown_var(lxm,id) ->
print_compile_error lxm ("unknown variable (" ^ (Lv6Id.to_string id) ^")");
print_runtime_error lxm ("unknown variable (" ^ (Lv6Id.to_string id) ^")");
my_exit opt 1
| Unknown_constant(lxm,str) ->
print_compile_error lxm ("unknown constant (" ^ str ^")");
print_runtime_error lxm ("unknown constant (" ^ str ^")");
my_exit opt 1
| Compile_error(lxm,msg) -> print_compile_error lxm msg; my_exit opt 1
| Compile_error(lxm,msg) -> print_runtime_error lxm msg; my_exit opt 1
| L2lCheckLoops.Error(lxm,msg,lic_prg) ->
(* Sometime it helps to see the current state of the faulty program *)
LicPrg.to_file opt lic_prg main_node;
......@@ -337,7 +337,10 @@ could try one the options: -2c, -2c-exec, -exec, -ec, -lic, or -h for more optio
print_compile_error lxm msg;
my_exit opt 1
| SocExec.AssertViolation lxm ->
print_compile_error lxm "An assertion is violated in the Lustre program";
print_runtime_error lxm "An assertion is violated in the Lustre program";
my_exit opt 1
| Failure msg ->
Printf.eprintf "\nRuntime Error: %s\n" msg;
my_exit opt 1
| Assert_failure (file, line, col) ->
prerr_string (
......
(* Time-stamp: <modified the 29/08/2019 (at 14:17) by Erwan Jahier> *)
(* Time-stamp: <modified the 15/03/2021 (at 12:22) by Erwan Jahier> *)
(** *)
......@@ -105,6 +105,9 @@ Formatage standard des erreurs de compil
let compile_error_string lxm msg = (
Printf.sprintf "\nError: %s:\nError: %s\n" (Lxm.details lxm) msg
)
let runtime_error_string lxm msg = (
Printf.sprintf "\nRuntime Error: %s:\nError: %s\n" (Lxm.details lxm) msg
)
(** ---------------------------------------------------------------------
Message d'erreur (associé à un lexeme) sur stderr
......@@ -114,6 +117,11 @@ let print_compile_error lxm msg = (
flush stderr
)
let print_runtime_error lxm msg = (
Printf.eprintf "%s\n" (compile_error_string lxm msg);
flush stderr
)
(** ---------------------------------------------------------------------
Warning (associé à un lexeme) sur stderr
----------------------------------------------------------------------*)
......
(* Time-stamp: <modified the 06/03/2020 (at 13:30) by Erwan Jahier> *)
(* Time-stamp: <modified the 15/03/2021 (at 15:44) by Erwan Jahier> *)
let dbg = (Lv6Verbose.get_flag "exec")
......@@ -285,11 +285,17 @@ let rec (get_value : ctx -> var_expr -> Data.v) =
| Field(ve,fn,_t) ->
let s = get_value ctx ve in
(match s with
| S fl -> (
try List.assoc fn fl
with Not_found -> assert false (* should not occur *)
| U -> U
| S fl -> (
try List.assoc fn fl
with Not_found -> assert false (* should not occur *)
)
| _ -> assert false (* should not occur *)
| _ ->
let msg = Printf.sprintf "'%s' is not a struct\n"
(SocUtils.string_of_filter ve)
in
failwith msg
(* assert false (* should not occur *) *)
)
| Index(ve,i,_vt) -> (
let a = get_value ctx ve in
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment