소스 검색

[eval] add -D eval-print-depth (#10952)

Rudy Ges 2 년 전
부모
커밋
660947b76d
4개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 0
      src-json/define.json
  2. 1 0
      src/macro/eval/evalContext.ml
  3. 1 0
      src/macro/eval/evalMain.ml
  4. 1 1
      src/macro/eval/evalPrinting.ml

+ 7 - 0
src-json/define.json

@@ -159,6 +159,13 @@
 		"doc": "Support debugger in macro/interp mode. Allows `host:port` value to open a socket. Implies eval-stack.",
 		"platforms": ["eval"]
 	},
+	{
+		"name": "EvalPrintDepth",
+		"define": "eval-print-depth",
+		"doc": "Set maximum print depth (before replacing with '<...>') for eval. (default: 5)",
+		"platforms": ["eval"],
+		"params": ["depth"]
+	},
 	{
 		"name": "EvalStack",
 		"define": "eval-stack",

+ 1 - 0
src/macro/eval/evalContext.ml

@@ -287,6 +287,7 @@ and context = {
 	mutable evals : eval IntMap.t;
 	mutable exception_stack : (pos * env_kind) list;
 	max_stack_depth : int;
+	max_print_depth : int;
 }
 
 module GlobalState = struct

+ 1 - 0
src/macro/eval/evalMain.ml

@@ -129,6 +129,7 @@ let create com api is_macro =
 		evals = evals;
 		exception_stack = [];
 		max_stack_depth = int_of_string (Common.defined_value_safe ~default:"1000" com Define.EvalCallStackDepth);
+		max_print_depth = int_of_string (Common.defined_value_safe ~default:"5" com Define.EvalPrintDepth);
 	} in
 	if debug.support_debugger && not !GlobalState.debugger_initialized then begin
 		(* Let's wait till the debugger says we're good to continue. This allows it to finish configuration.

+ 1 - 1
src/macro/eval/evalPrinting.ml

@@ -107,7 +107,7 @@ and s_value depth v =
 		let vf = field_raise v EvalHash.key_toString in
 		s_value (depth + 1) (call_value_on v vf [])
 	in
-	if depth > 5 then rstop
+	if depth > (get_ctx()).max_print_depth then rstop
 	else match v with
 	| VNull -> rnull
 	| VInt32 i32 -> create_ascii(Int32.to_string i32)