Clean up `GDBVariable(Object) >> #value` and `#valueString`
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 26 Feb 2019 09:27:50 +0000
changeset 178 71baafd9bbcb
parent 177 e7bd05df3d6b
child 179 c43cece06442
Clean up `GDBVariable(Object) >> #value` and `#valueString` The distionction was hard to understand, confusing and largelu unnecessary. This commit removes `#valueString` and leaves only `#value` with explanatory comment.
GDBVariable.st
GDBVariableObject.st
--- a/GDBVariable.st	Mon Feb 25 17:55:20 2019 +0000
+++ b/GDBVariable.st	Tue Feb 26 09:27:50 2019 +0000
@@ -110,13 +110,29 @@
 !
 
 value
+    "Retun an up-to-date pretty-printed string representation of this variable's value."
+
     | vobj |
 
+    "/ The code below tries to avoid creating an varobj if 
+    "/ possible since creation of varobj might be costly.
+    "/ 
+    "/ THerefore we check whether `value` instvar (cached
+    "/ string representation) is not nil and varobj is nil
+    "/ (i.e., has not yet been created). If so, return
+    "/ cached `value` without creating varobj. Otherwise,
+    "/ create varobj and ask it for a value.
+
+    varobj == VarobjUnavailable ifTrue:[ ^ value ].
+    (varobj isNil and: [value notNil])  ifTrue:[ ^ value ].
+
     vobj := self varobj.
-    ^ vobj notNil ifTrue:[ vobj value ] ifFalse: [ value ].
+    vobj notNil ifTrue:[ ^ vobj value ].
+
+    ^ self class classResources string:'<could not read value>'
 
     "Created: / 27-02-2015 / 23:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 05-07-2018 / 12:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-02-2019 / 16:58:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 visualizer: aString   
--- a/GDBVariableObject.st	Mon Feb 25 17:55:20 2019 +0000
+++ b/GDBVariableObject.st	Tue Feb 26 09:27:50 2019 +0000
@@ -250,12 +250,15 @@
 !
 
 value
+    "Retun an up-to-date pretty-printed string representation of this varobj's value."
+
     changed value. "/ to force update if necessary
     self isValid ifFalse:[ ^ self class classResources string: '<invalid>' ].
     self inScope ifFalse:[ ^ self class classResources string: '<out-of-scope>' ].
     ^ value
 
     "Modified: / 12-02-2018 / 22:00:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 25-02-2019 / 14:36:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 valueFormatted: aGDBOutputFormat