diff options
author | Vincent Ambo <mail@tazj.in> | 2023-02-22T11·18+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-03-03T10·52+0000 |
commit | fb4c197b39910d3278cc5859eaffda0b8f6ffe88 (patch) | |
tree | 87756bda9c6d08953b0c96bad5e0a86fdecfce05 /tvix/eval/src/chunk.rs | |
parent | dbca46d05205bdaab07d4faf1899a6452f34dd0f (diff) |
refactor(tvix/eval): enhance debug output for bytecode dumps r/5868
This adds addresses of thunk and closure chunks to the debug output displayed when dumping bytecode. This makes it possible to see in the dump which thunks are referenced by constants in other thunks. Change-Id: I2c98de5227e7cb415666cd3134c947a56979dc80 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8137 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/chunk.rs')
-rw-r--r-- | tvix/eval/src/chunk.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tvix/eval/src/chunk.rs b/tvix/eval/src/chunk.rs index 35fd7e78e674..04b58bde20fd 100644 --- a/tvix/eval/src/chunk.rs +++ b/tvix/eval/src/chunk.rs @@ -143,7 +143,15 @@ impl Chunk { } match self[idx] { - OpCode::OpConstant(idx) => writeln!(writer, "OpConstant({}@{})", self[idx], idx.0), + OpCode::OpConstant(idx) => { + let val_str = match &self[idx] { + Value::Thunk(t) => t.debug_repr(), + Value::Closure(c) => format!("closure({:p})", c.lambda), + val => format!("{}", val), + }; + + writeln!(writer, "OpConstant({}@{})", val_str, idx.0) + } op => writeln!(writer, "{:?}", op), }?; |