diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2020-11-24 21:55:52 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2020-11-30 13:45:03 -0800 |
commit | f85940fe05b4ce99d77ce796b4f693a50d772e82 (patch) | |
tree | 3bef53ed8c6c4f75357ccb87216d7be6caea0984 /modules/script | |
parent | e76f9ae52ce940e83e47ce70aeda64069f8d572a (diff) | |
download | gjs-f85940fe05b4ce99d77ce796b4f693a50d772e82.tar.gz |
debugger: Make '$$' mean the last value
The debugger already stores the result of each printed expression in
variables named $1, $2, etc., so you can refer to them later. This change
makes the variable '$$' always refer to the last printed value.
Adds a bit of documentation explaining how these variables can be printed,
and adds a test for $$ as well as $1, $2, etc.
Based on a commit from Mozilla's original jorendb:
https://hg.mozilla.org/mozilla-central/rev/fe52996292bb6d1acd51a983f9a7ac6faa7724f6
(The GJS debugger was originally based on jorendb and I was looking to see
if any new improvements had been made since I had forked it)
Diffstat (limited to 'modules/script')
-rw-r--r-- | modules/script/_bootstrap/debugger.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js index ddf13ddc..601035cd 100644 --- a/modules/script/_bootstrap/debugger.js +++ b/modules/script/_bootstrap/debugger.js @@ -79,6 +79,7 @@ function debuggeeValueToString(dv, style = {pretty: options.pretty}) { function showDebuggeeValue(dv, style = {pretty: options.pretty}) { const i = nextDebuggeeValueIndex++; debuggeeValues[`$${i}`] = dv; + debuggeeValues['$$'] = dv; const [brief, full] = debuggeeValueToString(dv, style); print(`$${i} = ${brief}`); if (full !== undefined) @@ -263,7 +264,10 @@ printCommand.helpText = `USAGE PARAMETER · expr: expression to be printed · pretty|p: prettify the output - · brief|b: brief output`; + · brief|b: brief output + +expr may also reference the variables $1, $2, ... for already printed +expressions, or $$ for the most recently printed expression.`; function keysCommand(rest) { return doPrint(`Object.keys(${rest})`); |