[gjs: 1/6] automatically adding () to the expression to be printed
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/6] automatically adding () to the expression to be printed
- Date: Mon, 25 Jul 2022 03:38:21 +0000 (UTC)
commit d1b9de1c7530e982482fb4775bef56608ab5a18f
Author: Nasah <nasahnash19 gmail com>
Date: Fri Jul 15 22:24:48 2022 +0100
automatically adding () to the expression to be printed
An expression like {a:2} is ambiguous since it can be an object literal with property a and value 2 or a
statement block with label a and one expression inside, 2. Adding () disambiguates {}.
installed-tests/debugger/print.debugger | 1 +
installed-tests/debugger/print.debugger.js | 3 ++-
installed-tests/debugger/print.debugger.output | 5 ++++-
modules/script/_bootstrap/debugger.js | 2 ++
4 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/installed-tests/debugger/print.debugger b/installed-tests/debugger/print.debugger
index 814983337..6008b7a7e 100644
--- a/installed-tests/debugger/print.debugger
+++ b/installed-tests/debugger/print.debugger
@@ -20,4 +20,5 @@ p k
p/b k
p l
p m
+p n
c
diff --git a/installed-tests/debugger/print.debugger.js b/installed-tests/debugger/print.debugger.js
index 989fa891a..ba2857f55 100644
--- a/installed-tests/debugger/print.debugger.js
+++ b/installed-tests/debugger/print.debugger.js
@@ -14,5 +14,6 @@ const j = new Set([5, 6, 7]);
const k = class J {};
const l = new GObject.Object();
const m = new Error('message');
+const n = {a:1};
debugger;
-void (a, b, c, d, e, f, g, h, i, j, k, l, m);
+void (a, b, c, d, e, f, g, h, i, j, k, l, m, n);
diff --git a/installed-tests/debugger/print.debugger.output b/installed-tests/debugger/print.debugger.output
index 88cf96c90..73316e799 100644
--- a/installed-tests/debugger/print.debugger.output
+++ b/installed-tests/debugger/print.debugger.output
@@ -2,7 +2,7 @@ GJS debugger. Type "help" for help
db> # SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
db> # SPDX-FileCopyrightText: 2018 Philip Chimento <philip chimento gmail com>
db> c
-Debugger statement, toplevel at print.debugger.js:17:0
+Debugger statement, toplevel at print.debugger.js:18:0
db> # Simple types
db> print a
$1 = undefined
@@ -83,5 +83,8 @@ $16 = [object GObject_Object]
db> p m
$17 = [object Error]
Error: message
+db> p n
+$18 = [object Object]
+{ a: 1 }
db> c
Program exited with code 0
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js
index 6ae0d9c2d..dc42228f5 100644
--- a/modules/script/_bootstrap/debugger.js
+++ b/modules/script/_bootstrap/debugger.js
@@ -324,10 +324,12 @@ function splitPrintOptions(s, style) {
function doPrint(expr, style) {
// This is the real deal.
+ expr = `(${expr})`;
const cv = saveExcursion(
() => focusedFrame === null
? debuggeeGlobalWrapper.executeInGlobalWithBindings(expr, debuggeeValues)
: focusedFrame.evalWithBindings(expr, debuggeeValues));
+
if (cv === null) {
print('Debuggee died.');
} else if ('return' in cv) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]