-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds SBUniverse / SBMultiverse to save objects in a permutation (make…
…s things faster)
- Loading branch information
Showing
7 changed files
with
245 additions
and
99 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
Class { | ||
#name : #SBMultiverse, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'universes', | ||
'variants', | ||
'watches', | ||
'activeExamples', | ||
'allMethodBlocksContainingVariants', | ||
'allMethodBlocksContainingWatches', | ||
'sandblockEditor' | ||
], | ||
#category : #'Sandblocks-Babylonian' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
SBMultiverse class >> new [ | ||
|
||
"Use constructor with editor instead" | ||
self shouldNotImplement | ||
] | ||
|
||
{ #category : #'instance creation' } | ||
SBMultiverse class >> newInEditor: aSandblockEditor [ | ||
|
||
^ self basicNew | ||
sandblockEditor: aSandblockEditor; | ||
initialize; | ||
yourself | ||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> activeExamples [ | ||
|
||
^ activeExamples | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> allActiveExamples [ | ||
|
||
^ (self allCompiledMethodsContainingExamples | ||
collect: [:aCompiledMethod | | ||
"Only examples which are open in the editor can actually be active." | ||
self sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) | ||
ifOpen: [:existingMethodBlock | existingMethodBlock containedExamples select: #active] | ||
ifClosed: [#()]]) flatten | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> allCompiledMethodsContainingClass: aClass [ | ||
|
||
"aClass should have #matchingSelectors implemented" | ||
^ (((aClass matchingSelectors collect: [:aSelector | self systemNavigation allCallsOn: aSelector]) flatten) | ||
reject: [:aMethodReference | aMethodReference actualClass = aClass class]) | ||
collect: #compiledMethod | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> allCompiledMethodsContainingExampleWatches [ | ||
|
||
^ self allCompiledMethodsContainingClass: SBExampleWatch | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> allCompiledMethodsContainingExamples [ | ||
|
||
^ self allCompiledMethodsContainingClass: SBExample | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> allCompiledMethodsContainingVariants [ | ||
|
||
^ self allCompiledMethodsContainingClass: SBVariant | ||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> allMethodBlocksContainingVariants [ | ||
|
||
^ allMethodBlocksContainingVariants | ||
|
||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> allMethodBlocksContainingWatches [ | ||
|
||
^ allMethodBlocksContainingWatches | ||
|
||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> copyWatchesIn: aCollectionOfMethodBlocks [ | ||
|
||
^ (aCollectionOfMethodBlocks collect: [:aMethodBlock | | ||
aMethodBlock containedExampleWatches collect: #asInactiveCopy]) flatten | ||
] | ||
|
||
{ #category : #converting } | ||
SBMultiverse >> createUniverseFomPermutation: aSBPermutation [ | ||
|
||
^ SBUniverse | ||
newActive: aSBPermutation | ||
watches: (self copyWatchesIn: self allMethodBlocksContainingWatches) | ||
] | ||
|
||
{ #category : #collecting } | ||
SBMultiverse >> findExistingOrConvertToBlocks: aCollectionOfCompiledMethods [ | ||
|
||
^ aCollectionOfCompiledMethods | ||
collect: [:aCompiledMethod | | ||
self sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) | ||
ifOpen: [:existingMethodBlock | existingMethodBlock] | ||
ifClosed: [aCompiledMethod asSandblock]] | ||
] | ||
|
||
{ #category : #'initialize-release' } | ||
SBMultiverse >> initialize [ | ||
|
||
super initialize. | ||
|
||
"We are looking for already opened methods so that we can assign the | ||
variant there as the original in SBVariantProxy. That way, we immediately | ||
have consistency between changes." | ||
allMethodBlocksContainingVariants := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants. | ||
|
||
"We need existing originals to be noticed of changes." | ||
allMethodBlocksContainingWatches := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingExampleWatches. | ||
|
||
variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. | ||
activeExamples := self allActiveExamples. | ||
|
||
universes := (SBPermutation allPermutationsOf: variants) collect: [:aPermutation | | ||
self createUniverseFomPermutation: aPermutation]. | ||
|
||
|
||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> sandblockEditor [ | ||
|
||
^ sandblockEditor | ||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> sandblockEditor: aSandblockEditor [ | ||
|
||
sandblockEditor := aSandblockEditor | ||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> universes [ | ||
|
||
^ universes | ||
] | ||
|
||
{ #category : #accessing } | ||
SBMultiverse >> variants [ | ||
|
||
^ variants | ||
] |
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
Oops, something went wrong.