Skip to content

Commit

Permalink
add smalltalk packages and trace serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover committed May 26, 2023
1 parent 1244a6b commit cce2128
Show file tree
Hide file tree
Showing 40 changed files with 280 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'srcDirectory' : 'packages'
}
4 changes: 4 additions & 0 deletions .squot
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OrderedDictionary {
'packages/BaselineOfTrace4D.package' : #SquotCypressCodeSerializer,
'packages/Trace4D.package' : #SquotCypressCodeSerializer
}
4 changes: 4 additions & 0 deletions packages/BaselineOfTrace4D.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
6 changes: 6 additions & 0 deletions packages/BaselineOfTrace4D.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ '09c330835f4dcf498290c4053f7a0de1' ],
#objectsReplacedByNames : true,
#serializer : #SquotCypressCodeSerializer
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
baseline
baseline: spec
<baseline>

spec for: #common do: [
"dependencies"
spec
baseline: 'TraceDebugger' with: [
spec
repository: 'github://hpi-swa-lab/squeak-tracedebugger';
loads: 'TraceDebugger']].

"packages"
spec
package: 'Trace4D' with: [
spec requires: 'TraceDebugger'].

"groups"
spec
group: #default with: #('Trace4D').
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
projectClass

^ MetacelloCypressBaselineProject
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"baseline:" : "ct 5/27/2023 01:26",
"projectClass" : "ct 5/27/2023 01:23" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "BaselineOfTrace4D",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "BaselineOfTrace4D",
"pools" : [
],
"super" : "BaselineOf",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SystemOrganization addCategory: #BaselineOfTrace4D!
Empty file.
2 changes: 2 additions & 0 deletions packages/BaselineOfTrace4D.package/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
4 changes: 4 additions & 0 deletions packages/Trace4D.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
6 changes: 6 additions & 0 deletions packages/Trace4D.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ 'd6cbd64ac6ce3a4396ba426e0334d4f9' ],
#objectsReplacedByNames : true,
#serializer : #SquotCypressCodeSerializer
}
Empty file.
4 changes: 4 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/class/cursorClass.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
cursorClass

^ TDBCursor
5 changes: 5 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/class/forBlock..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
forBlock: aBlock

^ self forCursor:
(self cursorClass traceForBlock: aBlock)
4 changes: 4 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/class/forCursor..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
forCursor: aTDBCursor

^ self new cursor: aTDBCursor
12 changes: 12 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/buildClasses.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
building
buildClasses

| classes |
classes := self makeContainer.
classNames keysAndValuesDo: [:class :name |
classes at: name put:
(self makeContainer
category: class category;
package: (class packageInfo ifNotNil: [:package | package name]);
yourself)].
^ classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
building
buildFieldHistoryFor: anObject field: field

| slice |
slice := self cursor object: anObject collect: [:object |
| value error |
[value := field value: object] ifError: [:err | error := err].
error
ifNotNil: ['<error: {1}>' format: {error}]
ifNil: [self idOrStringFor: value]].
slice intervals size > 1 ifFalse: [^ nil].
^ self makeContainer
times: (slice intervals allButLast collect: [:interval | interval stop + 1]);
values: (slice values allButLast collect: [:value | value copy tdbproxyYourself]);
yourself
18 changes: 18 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/buildJson.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
building
buildJson

| trace objects classes |
objectIds := PluggableDictionary
hashBlock: [:a | a perform: #identityHash]
equalBlock: [:a :b | a tdbIdentical: b].
classNames := Dictionary new.

trace := self buildTrace.
objects := self buildObjects.
classes := self buildClasses.

^ self makeContainer
objects: objects;
classes: classes;
trace: trace;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
building
buildObjectFor: anObject

| fields |
fields := self fieldsFor: anObject.
^ self makeContainer
class: (self nameForClass: (anObject perform: #class));
name: (self stringFor: anObject);
fields:
(fields
collect: [:field | field key -> (self idOrStringFor: (field value value: anObject))]
as: self containerClass);
historicFields:
(fields
collect: [:field | field key -> (self buildFieldHistoryFor: anObject field: field value)]
as: self containerClass);
yourself
10 changes: 10 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/buildObjects.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
building
buildObjects

| objects |
objects := self makeContainer.
objectIds keysAndValuesDo: [:object :id |
objects at: id put:
(self buildObjectFor:
(self cursor object: object atTime: self cursor maxTimeIndex))].
^ objects
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
building
buildTrace

^ self buildTraceFor:
(self cursor contextAtTime: 0)
19 changes: 19 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/buildTraceFor..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
building
buildTraceFor: aContext

| trace |
trace := self makeContainer
receiver: (self objectIdFor: aContext receiver);
message: aContext tdbBlockAndSelectorString;
arguments:
((aContext arguments collect: [:ea | self idOrStringFor: ea])
copy collect: [:ea | ea tdbproxyYourself]) tdbproxyYourself;
yourself.
self cursor returnValueFor: aContext ifPresent: [:value |
trace answer: (self idOrStringFor: value)].
trace
startTime: (self cursor minTimeIndexFor: aContext);
endTime: (self cursor maxTimeIndexFor: aContext);
children: ((self cursor childContextsFor: aContext)
collect: [:childContext | self buildTraceFor: childContext]).
^ trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
containerClass

^ OrderedJsonObject
4 changes: 4 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/cursor..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
cursor: aTDBCursor

cursor := aTDBCursor.
4 changes: 4 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/cursor.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
cursor

^ cursor
10 changes: 10 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/instance/fieldsFor..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
building
fieldsFor: anObject

| inspector inspectorFields |
inspector := Inspector inspect: anObject.
inspectorFields := Array streamContents: [:stream |
[inspector streamVariableFieldsOn: stream]
ifError: [inspector streamError: #error on: stream]].
^ inspectorFields collect: [:inspectorField |
inspectorField name asString -> inspectorField valueGetter]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
building
idOrStringFor: anObject

^ objectIds at: anObject ifAbsent:
[(self stringFor: anObject) ifNotEmpty: [:string |
('@\' includes: string first)
ifTrue: [string copyWithFirst: $\]
ifFalse: [string]]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
makeContainer

^ self containerClass new
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
building
nameForClass: aClass

^ classNames at: aClass ifAbsentPut:
[aClass name]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
building
objectIdFor: anObject

^ objectIds at: anObject ifAbsentPut:
['@' , UUID new]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
writing
storeJsonInFileNamed: fileName

| json |
json := self buildJson.
FileStream newFileNamed: fileName do: [:stream |
json jsonWriteOn: stream].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
building
stringFor: anObject

^ [anObject printString] ifError: [:error | '<printString error: {1}>' format: {error}]
23 changes: 23 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"class" : {
"cursorClass" : "ct 5/26/2023 00:40",
"forBlock:" : "ct 5/21/2023 17:39",
"forCursor:" : "ct 5/21/2023 17:39" },
"instance" : {
"buildClasses" : "ct 5/21/2023 18:36",
"buildFieldHistoryFor:field:" : "ct 5/26/2023 00:45",
"buildJson" : "ct 5/21/2023 18:37",
"buildObjectFor:" : "ct 5/27/2023 01:20",
"buildObjects" : "ct 5/21/2023 18:48",
"buildTrace" : "ct 5/21/2023 18:30",
"buildTraceFor:" : "ct 5/21/2023 20:01",
"containerClass" : "ct 5/21/2023 18:36",
"cursor" : "ct 5/21/2023 17:39",
"cursor:" : "ct 5/21/2023 17:39",
"fieldsFor:" : "ct 5/21/2023 18:40",
"idOrStringFor:" : "ct 5/21/2023 18:54",
"makeContainer" : "ct 5/21/2023 18:36",
"nameForClass:" : "ct 5/21/2023 19:57",
"objectIdFor:" : "ct 5/21/2023 17:53",
"storeJsonInFileNamed:" : "ct 5/21/2023 20:05",
"stringFor:" : "ct 5/21/2023 18:34" } }
16 changes: 16 additions & 0 deletions packages/Trace4D.package/T4DTrace.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"category" : "Trace4D",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"cursor",
"objectIds",
"classNames" ],
"name" : "T4DTrace",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
1 change: 1 addition & 0 deletions packages/Trace4D.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SystemOrganization addCategory: #Trace4D!
Empty file.
2 changes: 2 additions & 0 deletions packages/Trace4D.package/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit cce2128

Please sign in to comment.