|
@@ -44,11 +44,11 @@ end
|
|
|
let macro_enable_cache = ref false
|
|
|
let macro_interp_cache = ref None
|
|
|
|
|
|
-let safe_decode v expected t p f =
|
|
|
+let safe_decode ctx v expected t p f =
|
|
|
try
|
|
|
f ()
|
|
|
with MacroApi.Invalid_expr | EvalContext.RunTimeException _ ->
|
|
|
- let path = ["dump";"decoding_error"] in
|
|
|
+ let path = [dump_path ctx.com;"decoding_error"] in
|
|
|
let ch = Path.create_file false ".txt" [] path in
|
|
|
let errors = Interp.handle_decoding_error (output_string ch) v t in
|
|
|
List.iter (fun (s,i) -> Printf.fprintf ch "\nline %i: %s" i s) (List.rev errors);
|
|
@@ -306,7 +306,7 @@ let make_macro_api ctx p =
|
|
|
let mctx = (match ctx.g.macros with None -> assert false | Some (_,mctx) -> mctx) in
|
|
|
let ttype = Typeload.load_instance mctx (cttype,p) false in
|
|
|
let f () = Interp.decode_type_def v in
|
|
|
- let m, tdef, pos = safe_decode v "TypeDefinition" ttype p f in
|
|
|
+ let m, tdef, pos = safe_decode ctx v "TypeDefinition" ttype p f in
|
|
|
let add is_macro ctx =
|
|
|
let mdep = Option.map_default (fun s -> TypeloadModule.load_module ctx (parse_path s) pos) ctx.m.curmod mdep in
|
|
|
let mnew = TypeloadModule.type_module ctx m mdep.m_extra.m_file [tdef,pos] pos in
|
|
@@ -720,7 +720,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
|
|
|
Some (EBlock [],p)
|
|
|
)
|
|
|
in
|
|
|
- safe_decode v expected mret p process
|
|
|
+ safe_decode ctx v expected mret p process
|
|
|
in
|
|
|
let e = if ctx.in_macro then
|
|
|
Some (EThrow((EConst(String("macro-in-macro",SDoubleQuotes))),p),p)
|