-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate interop source location APIs
- Add interop messages and ForeignObject>>#getSource - Display members and source if available in PolyglotInspector
- Loading branch information
Showing
23 changed files
with
111 additions
and
37 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/TruffleSqueak-Core.package/ForeignObject.class/instance/getSource.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source code management | ||
getSource | ||
^ (Interop hasSourceLocation: self) | ||
ifFalse: [ nil ] | ||
ifTrue: [ (Interop getSourceLocation: self) getCharacters asString ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/TruffleSqueak-Core.package/Interop.class/class/getSourceLocation..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
primitives meta-data | ||
getSourceLocation: anObject | ||
<primitive: 'primitiveGetSourceLocation' module: 'PolyglotPlugin'> | ||
(self hasSourceLocation: anObject) | ||
ifFalse: [ self error: 'Object has no source location' ] | ||
ifTrue: [ self primitiveFailed ] |
4 changes: 4 additions & 0 deletions
4
src/TruffleSqueak-Core.package/Interop.class/class/hasSourceLocation..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
primitives meta-data | ||
hasSourceLocation: anObject | ||
<primitive: 'primitiveHasSourceLocation' module: 'PolyglotPlugin'> | ||
self primitiveFailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/aboutToStyle..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
overrides | ||
morphic ui | ||
aboutToStyle: aStyler | ||
"Do not use styler for now" | ||
^true |
10 changes: 10 additions & 0 deletions
10
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/arrayFieldList.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
accessing | ||
arrayFieldList | ||
^ (Interop hasArrayElements: object) | ||
ifFalse: [#()] | ||
ifTrue: [ | ||
(object basicSize <= (self i1 + self i2) | ||
ifTrue: [(1 to: object basicSize) | ||
collect: [:i | i printString]] | ||
ifFalse: [(1 to: self i1) , (object basicSize-(self i2-1) to: object basicSize) | ||
collect: [:i | i printString]])] |
6 changes: 2 additions & 4 deletions
6
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/baseFieldList.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
overrides | ||
accessing | ||
baseFieldList | ||
"Answer an Array consisting of 'self' | ||
and the members of the inspected object." | ||
|
||
^ Array with: 'self' with: 'members' | ||
^ #('self') |
5 changes: 5 additions & 0 deletions
5
...ffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/calculateOptionalFields.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
selecting | ||
calculateOptionalFields | ||
optionalFields := #(). | ||
(self hasMembers: object) ifTrue: [ optionalFields := optionalFields, #('members') ]. | ||
(Interop hasSourceLocation: object) ifTrue: [ optionalFields := optionalFields, #('source') ] |
4 changes: 4 additions & 0 deletions
4
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/contentsIsString.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
selecting | ||
contentsIsString | ||
|
||
^ (selectionIndex = 0) | (selectionIndex between: 2 and: (1 + self optionalFieldList size)) |
2 changes: 1 addition & 1 deletion
2
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/exploreObject.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
overrides | ||
toolbuilder | ||
exploreObject | ||
"Switch to an explorer tool." | ||
|
||
|
11 changes: 2 additions & 9 deletions
11
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/fieldList.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
overrides | ||
accessing | ||
fieldList | ||
"Answer the base field list plus an abbreviated list of indices." | ||
|
||
(Interop hasArrayElements: object) ifFalse: [^ self baseFieldList]. | ||
^ self baseFieldList , | ||
(object basicSize <= (self i1 + self i2) | ||
ifTrue: [(1 to: object basicSize) | ||
collect: [:i | i printString]] | ||
ifFalse: [(1 to: self i1) , (object basicSize-(self i2-1) to: object basicSize) | ||
collect: [:i | i printString]]) | ||
^ self baseFieldList, self optionalFieldList, self arrayFieldList |
11 changes: 11 additions & 0 deletions
11
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/getMemberList..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
helpers | ||
getMemberList: anObject | ||
^ String streamContents: [:aStream | | ||
(Interop getMembers: anObject) sorted doWithIndex: | ||
[ :member :index | | ||
aStream nextPutAll: member; | ||
nextPut: $:; | ||
space; | ||
tab. | ||
(Interop readMember: anObject member: member) printOn: aStream. | ||
aStream cr ] ] |
5 changes: 5 additions & 0 deletions
5
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/getSource..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
helpers | ||
getSource: anObject | ||
^ (Interop hasSourceLocation: anObject) | ||
ifTrue: [ (Interop getSourceLocation: anObject) getCharacters asString ] | ||
ifFalse: [ 'object has no source location' ]. |
3 changes: 3 additions & 0 deletions
3
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/hasMembers..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
helpers | ||
hasMembers: anObject | ||
^ (Interop hasMembers: anObject) and: [ (Interop getMemberSize: anObject) > 0 ] |
4 changes: 4 additions & 0 deletions
4
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
initialize-release | ||
initialize | ||
super initialize. | ||
self calculateOptionalFields |
2 changes: 1 addition & 1 deletion
2
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/inspect..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 3 additions & 12 deletions
15
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/longPrintStringFor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
helpers | ||
longPrintStringFor: anObject | ||
((Interop hasMembers: anObject) and: | ||
[ (Interop getMemberSize: anObject) > 0 ]) | ||
ifFalse: [ ^ 'object has no members' ]. | ||
^ String streamContents: [:aStream | | ||
(Interop getMembers: anObject) sorted doWithIndex: | ||
[ :member :index | | ||
aStream nextPutAll: member; | ||
nextPut: $:; | ||
space; | ||
tab. | ||
(Interop readMember: anObject member: member) printOn: aStream. | ||
aStream cr ] ] | ||
^ (self hasMembers: anObject) | ||
ifTrue: [ self getMemberList: anObject ] | ||
ifFalse: [ 'object has no members' ] |
18 changes: 18 additions & 0 deletions
18
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/mainFieldListMenu..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
menu commands | ||
mainFieldListMenu: aMenu | ||
"Arm the supplied menu with items for the field-list of the receiver" | ||
|
||
aMenu addStayUpItemSpecial. | ||
|
||
aMenu addList: #( | ||
('inspect (i)' inspectSelection) | ||
('explore (I)' exploreSelection)). | ||
self addCollectionItemsTo: aMenu. | ||
aMenu addList: #( | ||
- | ||
('copy name (c)' copyName) | ||
('basic inspect' inspectBasic)). | ||
^ aMenu |
3 changes: 3 additions & 0 deletions
3
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/optionalFieldList.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
accessing | ||
optionalFieldList | ||
^ optionalFields |
9 changes: 5 additions & 4 deletions
9
src/TruffleSqueak-Tools-Core.package/PolyglotInspector.class/instance/selection.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
overrides | ||
selecting | ||
selection | ||
"The receiver has a list of variables of its inspected object. | ||
One of these is selected. Answer the value of the selected variable." | ||
| basicIndex | | ||
selectionIndex = 0 ifTrue: [^ '']. | ||
selectionIndex = 1 ifTrue: [^ object]. | ||
selectionIndex = 2 ifTrue: [^ self longPrintStringFor: object]. | ||
basicIndex := selectionIndex - 2. | ||
(object basicSize <= (self i1 + self i2) or: [basicIndex <= self i1]) | ||
selectionIndex = (1 + (self optionalFieldList indexOf: 'members')) ifTrue: [^ self longPrintStringFor: object]. | ||
selectionIndex = (1 + (self optionalFieldList indexOf: 'source')) ifTrue: [^ self getSource: object]. | ||
basicIndex := selectionIndex - 1 - self optionalFieldList size. | ||
(object basicSize <= (self i1 + self i2) or: [basicIndex <= self i1]) | ||
ifTrue: [^ object basicAt: basicIndex] | ||
ifFalse: [^ object basicAt: object basicSize - (self i1 + self i2) + basicIndex] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters