-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cypress-Definitions.pck
executable file
·1337 lines (1056 loc) · 33.9 KB
/
Cypress-Definitions.pck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From Cuis 4.0 of 21 April 2012 [latest update: #1308] on 15 June 2012 at 12:30:16 am'!
'Description Basic definitions for Cypress. Install first.'!
!classDefinition: #CypressDefinition category: #'Cypress-Definitions'!
Object subclass: #CypressDefinition
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressDefinition class' category: #'Cypress-Definitions'!
CypressDefinition class
instanceVariableNames: ''!
!classDefinition: #CypressClassDefinition category: #'Cypress-Definitions'!
CypressDefinition subclass: #CypressClassDefinition
instanceVariableNames: 'name superclassName category comment instVarNames classInstVarNames'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressClassDefinition class' category: #'Cypress-Definitions'!
CypressClassDefinition class
instanceVariableNames: ''!
!classDefinition: #CypressDefinitionIndex category: #'Cypress-Definitions'!
Object subclass: #CypressDefinitionIndex
instanceVariableNames: 'definitionMap'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressDefinitionIndex class' category: #'Cypress-Definitions'!
CypressDefinitionIndex class
instanceVariableNames: ''!
!classDefinition: #CypressDependencySorter category: #'Cypress-Definitions'!
Object subclass: #CypressDependencySorter
instanceVariableNames: 'required provided orderedItems'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressDependencySorter class' category: #'Cypress-Definitions'!
CypressDependencySorter class
instanceVariableNames: ''!
!classDefinition: #CypressLoader category: #'Cypress-Definitions'!
Object subclass: #CypressLoader
instanceVariableNames: 'additions removals unloadable provisions errors methodAdditions requirements'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressLoader class' category: #'Cypress-Definitions'!
CypressLoader class
instanceVariableNames: ''!
!classDefinition: #CypressMethodDefinition category: #'Cypress-Definitions'!
CypressDefinition subclass: #CypressMethodDefinition
instanceVariableNames: 'classIsMeta source category selector className timeStamp'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressMethodDefinition class' category: #'Cypress-Definitions'!
CypressMethodDefinition class
instanceVariableNames: ''!
!classDefinition: #CypressPackageDefinition category: #'Cypress-Definitions'!
Object subclass: #CypressPackageDefinition
instanceVariableNames: 'name'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressPackageDefinition class' category: #'Cypress-Definitions'!
CypressPackageDefinition class
instanceVariableNames: ''!
!classDefinition: #CypressPatch category: #'Cypress-Definitions'!
Object subclass: #CypressPatch
instanceVariableNames: 'operations'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressPatch class' category: #'Cypress-Definitions'!
CypressPatch class
instanceVariableNames: ''!
!classDefinition: #CypressPatchOperation category: #'Cypress-Definitions'!
Object subclass: #CypressPatchOperation
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressPatchOperation class' category: #'Cypress-Definitions'!
CypressPatchOperation class
instanceVariableNames: ''!
!classDefinition: #CypressAddition category: #'Cypress-Definitions'!
CypressPatchOperation subclass: #CypressAddition
instanceVariableNames: 'definition'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressAddition class' category: #'Cypress-Definitions'!
CypressAddition class
instanceVariableNames: ''!
!classDefinition: #CypressModification category: #'Cypress-Definitions'!
CypressPatchOperation subclass: #CypressModification
instanceVariableNames: 'obsoletion modification'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressModification class' category: #'Cypress-Definitions'!
CypressModification class
instanceVariableNames: ''!
!classDefinition: #CypressRemoval category: #'Cypress-Definitions'!
CypressPatchOperation subclass: #CypressRemoval
instanceVariableNames: 'definition'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressRemoval class' category: #'Cypress-Definitions'!
CypressRemoval class
instanceVariableNames: ''!
!classDefinition: #CypressSnapshot category: #'Cypress-Definitions'!
Object subclass: #CypressSnapshot
instanceVariableNames: 'definitions'
classVariableNames: ''
poolDictionaries: ''
category: 'Cypress-Definitions'!
!classDefinition: 'CypressSnapshot class' category: #'Cypress-Definitions'!
CypressSnapshot class
instanceVariableNames: ''!
!Class methodsFor: '*Cypress-Definitions' stamp: 'dkh 4/23/2012 20:54'!
asCypressClassDefinition
^CypressClassDefinition
name: self name
superclassName: self superclass name
category: self category
instVarNames: self instVarNames
classInstVarNames: self class instVarNames
comment: self comment
! !
!CompiledMethod methodsFor: '*Cypress-Definitions' stamp: 'jmv 6/14/2012 23:50'!
asCypressMethodDefinition
^CypressMethodDefinition
className: (self methodClass isMeta ifTrue: [ self methodClass theNonMetaClass ] ifFalse: [ self methodClass ]) name
classIsMeta: self methodClass isMeta
selector: self selector
category: self category
source: self getSource
timeStamp: self timeStamp
! !
!CypressAddition methodsFor: 'comparing'!
= aPatchOperation
^(super = aPatchOperation) and: [self definition = aPatchOperation definition]
! !
!CypressAddition methodsFor: 'applying'!
applyTo: aCypressLoader
aCypressLoader applyAddition: self
! !
!CypressAddition methodsFor: 'accessing'!
definition
^definition
! !
!CypressAddition methodsFor: 'initialization'!
definition: aDefinition
definition := aDefinition
! !
!CypressAddition methodsFor: 'accessing' stamp: 'dkh 4/23/2012 23:22'!
description
^ 'add: ' , self definition printString! !
!CypressAddition methodsFor: 'loading'!
loadClassDefinition
self definition loadClassDefinition
! !
!CypressAddition methodsFor: 'loading'!
loadMethodDefinition
self definition loadMethodDefinition
! !
!CypressAddition methodsFor: 'loading'!
postLoadDefinition
self definition postLoadOver: nil
! !
!CypressAddition methodsFor: 'printing' stamp: 'dkh 4/23/2012 20:24'!
printString
| str |
str := WriteStream on: String new.
str
nextPutAll: super printString;
nextPutAll: ' (';
nextPutAll: self description;
nextPutAll: ')'.
^str contents
! !
!CypressAddition methodsFor: 'dependency'!
provisions
"Answer list of global names defined by this definition"
^self definition provisions
! !
!CypressAddition methodsFor: 'dependency'!
requirements
"Answer list of global names required by this definition"
^self definition requirements
! !
!CypressAddition class methodsFor: 'instance creation'!
of: aDefinition
^ self new definition: aDefinition
! !
!CypressClassDefinition methodsFor: 'comparing'!
= aDefinition
^(super = aDefinition)
and: [superclassName = aDefinition superclassName
and: [category = aDefinition category
and: [instVarNames = aDefinition instVarNames
and: [classInstVarNames = aDefinition classInstVarNames
and: [comment = aDefinition comment]]]]]
! !
!CypressClassDefinition methodsFor: 'loading' stamp: 'jmv 6/7/2012 00:07'!
actualClass
^Smalltalk at: self name
! !
!CypressClassDefinition methodsFor: 'converting'!
asCypressClassDefinition
^self
! !
!CypressClassDefinition methodsFor: 'accessing'!
category
^category
! !
!CypressClassDefinition methodsFor: 'visiting'!
classDefinition: classBlock methodDefinition: methodBlock
classBlock value: self
! !
!CypressClassDefinition methodsFor: 'accessing'!
classInstVarNames
^classInstVarNames
! !
!CypressClassDefinition methodsFor: 'accessing'!
className
^self name
! !
!CypressClassDefinition methodsFor: 'accessing'!
comment
^comment
! !
!CypressClassDefinition methodsFor: 'loading' stamp: 'jmv 6/7/2012 00:07'!
createClass
| superClass |
superClass := Smalltalk at: self superclassName.
^ClassBuilder new
superclass: superClass
subclass: self name
instanceVariableNames: (self stringForVariables: self instVarNames)
classVariableNames: '' poolDictionaries: '' category: self category
! !
!CypressClassDefinition methodsFor: 'accessing'!
description
^ Array with: name
! !
!CypressClassDefinition methodsFor: 'comparing' stamp: 'dkh 4/23/2012 21:30'!
hash
| hash |
hash := String stringHash: name initialHash: 0.
hash := String stringHash: superclassName initialHash: hash.
hash := String stringHash: (category ifNil: [ '' ]) initialHash: hash.
instVarNames , classInstVarNames do: [ :vName | hash := String stringHash: vName initialHash: hash ].
^ hash! !
!CypressClassDefinition methodsFor: 'accessing'!
instVarNames
^instVarNames
! !
!CypressClassDefinition methodsFor: 'loading'!
loadClassDefinition
| cls |
cls := self createClass.
cls class instanceVariableNames: (self stringForVariables: self classInstVarNames).
self comment notEmpty ifTrue: [ cls comment: self comment ]
! !
!CypressClassDefinition methodsFor: 'accessing'!
name
^name
! !
!CypressClassDefinition methodsFor: 'initialization' stamp: 'jmv 6/7/2012 00:09'!
name: aClassName superclassName: aSuperclassName category: aCategory instVarNames: anInstanceVariableNames classInstVarNames: aClassInstanceVariableNames comment: aComment
name := aClassName asSymbol.
superclassName := aSuperclassName asSymbol.
category := aCategory asSymbol.
instVarNames := anInstanceVariableNames.
classInstVarNames := aClassInstanceVariableNames.
comment := aComment
! !
!CypressClassDefinition methodsFor: 'printString' stamp: 'dkh 4/23/2012 20:24'!
printString
| str |
str := WriteStream on: String new.
str
nextPutAll: super printString;
nextPutAll: ' (';
nextPutAll: self name;
nextPutAll: ')'.
^str contents
! !
!CypressClassDefinition methodsFor: 'dependency'!
provisions
"Answer list of global names defined by this definition"
^{ self name }
! !
!CypressClassDefinition methodsFor: 'dependency' stamp: 'jmv 6/7/2012 00:04'!
requirements
"Answer list of global names required by this definition"
^{self superclassName}
! !
!CypressClassDefinition methodsFor: 'printString'!
stringForVariables: aCollectionOfVariableNames
^ String streamContents:
[:stream |
aCollectionOfVariableNames
do: [:ea | stream nextPutAll: ea]
separatedBy: [stream space]]
! !
!CypressClassDefinition methodsFor: 'accessing'!
superclassName
^superclassName
! !
!CypressClassDefinition methodsFor: 'loading' stamp: 'jmv 6/7/2012 00:07'!
unloadDefinition
Smalltalk removeClass: self actualClass.
! !
!CypressClassDefinition class methodsFor: 'instance creation'!
name: aClassName
superclassName: aSuperclassName
category: aCategory
instVarNames: anInstanceVariableNames
classInstVarNames: aClassInstanceVariableNames
comment: aComment
^(self new)
name: aClassName
superclassName: aSuperclassName
category: aCategory
instVarNames: anInstanceVariableNames
classInstVarNames: aClassInstanceVariableNames
comment: aComment
! !
!CypressDefinition methodsFor: 'comparing'!
= aDefinition
^(aDefinition isKindOf: CypressDefinition) and: [self isRevisionOf: aDefinition]
! !
!CypressDefinition methodsFor: 'loading'!
actualClass
self subclassResponsibility
! !
!CypressDefinition methodsFor: 'visiting'!
classDefinition: classBlock methodDefinition: methodBlock
"default is noop"
! !
!CypressDefinition methodsFor: 'accessing'!
description
self subclassResponsibility
! !
!CypressDefinition methodsFor: 'testing'!
isRevisionOf: aDefinition
^ (aDefinition isKindOf: CypressDefinition) and: [aDefinition description = self description]
! !
!CypressDefinition methodsFor: 'testing'!
isSameRevisionAs: aDefinition
^ self = aDefinition
! !
!CypressDefinition methodsFor: 'loading'!
loadClassDefinition
"default is to do nothing"
! !
!CypressDefinition methodsFor: 'loading'!
loadMethodDefinition
"default is to do nothing"
! !
!CypressDefinition methodsFor: 'loading'!
postLoad
"noop"
! !
!CypressDefinition methodsFor: 'loading'!
postLoadOver: aDefinition
self postLoad
! !
!CypressDefinition methodsFor: 'dependency'!
provisions
"Answer list of global names defined by this definition"
^#()
! !
!CypressDefinition methodsFor: 'dependency'!
requirements
"Answer list of global names required by this definition"
^#()
! !
!CypressDefinition methodsFor: 'loading'!
unloadDefinition
self subclassResponsibility
! !
!CypressDefinitionIndex methodsFor: 'adding'!
add: aDefinition
^ self definitionMap at: aDefinition description put: aDefinition
! !
!CypressDefinitionIndex methodsFor: 'adding'!
addAll: aCollection
aCollection do: [:ea | self add: ea]
! !
!CypressDefinitionIndex methodsFor: 'querying'!
definitionLike: aDefinition ifPresent: foundBlock ifAbsent: errorBlock
| definition |
definition := self definitionMap at: aDefinition description ifAbsent: [].
^ definition
ifNil: errorBlock
ifNotNil: [foundBlock value: definition]
! !
!CypressDefinitionIndex methodsFor: 'accessing'!
definitionMap
definitionMap ifNil: [ definitionMap := Dictionary new ].
^ definitionMap
! !
!CypressDefinitionIndex methodsFor: 'accessing'!
definitions
^self definitionMap values
! !
!CypressDefinitionIndex methodsFor: 'removing'!
remove: aDefinition
self definitionMap removeKey: aDefinition description ifAbsent: []
! !
!CypressDefinitionIndex class methodsFor: 'instance creation'!
definitions: aCollection
^ self new addAll: aCollection
! !
!CypressDependencySorter methodsFor: 'building'!
add: aPatchOperation
| requirements |
requirements := self unresolvedRequirementsFor: aPatchOperation.
requirements isEmpty
ifTrue: [self addToOrder: aPatchOperation]
ifFalse: [self addRequirements: requirements for: aPatchOperation].
^ aPatchOperation
! !
!CypressDependencySorter methodsFor: 'building'!
addAll: aCollection
aCollection do: [:aPatchOperation | self add: aPatchOperation ]
! !
!CypressDependencySorter methodsFor: 'private'!
addExternalProvisions: aCollection
(aCollection intersection: self externalRequirements)
do: [:globalName | self addProvision: globalName]
! !
!CypressDependencySorter methodsFor: 'private'!
addProvision: aGlobalName
| newlySatisfied |
self provided add: aGlobalName.
newlySatisfied := self required removeKey: aGlobalName ifAbsent: [#()].
self addAll: newlySatisfied.
! !
!CypressDependencySorter methodsFor: 'private'!
addRequirement: globalName for: aPatchOperation
(self itemsRequiring: globalName) add: aPatchOperation
! !
!CypressDependencySorter methodsFor: 'private'!
addRequirements: aCollection for: aPatchOperation
aCollection do: [:globalName | self addRequirement: globalName for: aPatchOperation]
! !
!CypressDependencySorter methodsFor: 'private'!
addToOrder: aPatchOperation
self orderedItems add: aPatchOperation.
aPatchOperation provisions do: [:globalName | self addProvision: globalName ].
! !
!CypressDependencySorter methodsFor: 'accessing'!
externalRequirements
| unloaded providedByUnloaded |
unloaded := self itemsWithMissingRequirements.
providedByUnloaded := (unloaded gather: [:e | e provisions]) asSet.
^ self required keys reject: [:globalName | providedByUnloaded includes: globalName ]
! !
!CypressDependencySorter methodsFor: 'private'!
itemsRequiring: globalName
^ self required at: globalName ifAbsentPut: [Set new]
! !
!CypressDependencySorter methodsFor: 'accessing'!
itemsWithMissingRequirements
| patchOperations |
patchOperations := Set new.
self required values do: [:aSetOfPatchOperations | patchOperations addAll: aSetOfPatchOperations ].
^ patchOperations
! !
!CypressDependencySorter methodsFor: 'accessing'!
orderedItems
"ordered list of patch operations"
orderedItems ifNil: [ orderedItems := OrderedCollection new ].
^orderedItems
! !
!CypressDependencySorter methodsFor: 'accessing'!
provided
"set of global names provided by definitions already loaded"
provided ifNil: [ provided := Set new ].
^provided
! !
!CypressDependencySorter methodsFor: 'accessing'!
required
"dictionary of required global name mapped to list of definitions that require the global"
required ifNil: [ required := Dictionary new ].
^required
! !
!CypressDependencySorter methodsFor: 'private'!
unresolvedRequirementsFor: aPatchOperation
"Answer a list of global names that are required by <aPatchOperation>, but not
provided by patchOperations that have already been processed"
^ aPatchOperation requirements difference: self provided
! !
!CypressLoader methodsFor: 'accessing'!
additions
additions ifNil: [ additions := OrderedCollection new ].
^additions
! !
!CypressLoader methodsFor: 'loading'!
analyze
self
analyzeAdditions;
analyzeRemovals
! !
!CypressLoader methodsFor: 'loading'!
analyzeAdditions
| sorter |
sorter := CypressDependencySorter new
addAll: self additions;
addExternalProvisions: self provisions;
yourself.
additions := sorter orderedItems.
requirements := sorter externalRequirements.
unloadable := sorter itemsWithMissingRequirements.
! !
!CypressLoader methodsFor: 'loading'!
analyzeRemovals
| sorter |
sorter := CypressDependencySorter new
addAll: self removals;
yourself.
removals := sorter orderedItems reversed.
! !
!CypressLoader methodsFor: 'applying'!
applyAddition: aCypressPatchOperation
self additions add: aCypressPatchOperation
! !
!CypressLoader methodsFor: 'applying'!
applyModification: aCypressPatchOperation
self additions add: aCypressPatchOperation
! !
!CypressLoader methodsFor: 'applying'!
applyRemoval: aCypressPatchOperation
self removals add: aCypressPatchOperation
! !
!CypressLoader methodsFor: 'loading' stamp: 'dkh 4/23/2012 20:26'!
basicLoad
errors := OrderedCollection new.
self additions do: [:ea | self loadClassDefinition: ea ]. "load class definitions first"
self additions do: [:ea | self loadMethodDefinition: ea ] . "load method definitions now"
self removals do: [:ea | self unloadDefinition: ea ]. "now we can remove things"
self errors do: [:ea | ea addMethodAdditionTo: methodAdditions]. "not sure about methodAddtions...yet"
self methodAdditions do: [:ea | self loadMethodAddition: ea ]. "ditto"
self additions do: [:ea | self postLoad: ea ]. "this is where the obsoletion is taken into account ..."
! !
!CypressLoader methodsFor: 'accessing'!
errors
errors ifNil: [ errors := OrderedCollection new ].
^errors
! !
!CypressLoader methodsFor: 'error handling' stamp: 'dkh 4/24/2012 15:30'!
handleErrorFor: aPatchOperation during: aBlock
aBlock on: Error do: [:ex | self errors add: aPatchOperation ].
! !
!CypressLoader methodsFor: 'loading'!
load
self analyze.
self unloadable isEmpty ifFalse: [self unloadableDefinitionsError].
self basicLoad
! !
!CypressLoader methodsFor: 'operations'!
loadClassDefinition: aPatchOperation
self
handleErrorFor: aPatchOperation
during: [ aPatchOperation loadClassDefinition ]
! !
!CypressLoader methodsFor: 'operations'!
loadMethodDefinition: aPatchOperation
self
handleErrorFor: aPatchOperation
during: [ aPatchOperation loadMethodDefinition ]
! !
!CypressLoader methodsFor: 'accessing'!
methodAdditions
^#()
! !
!CypressLoader methodsFor: 'operations'!
postLoad: aPatchOperation
aPatchOperation postLoadDefinition
! !
!CypressLoader methodsFor: 'accessing' stamp: 'dkh 4/23/2012 21:03'!
provisions
^ provisions ifNil: [provisions := (Smalltalk classes collect: [:cl | cl name]) asSet ]
! !
!CypressLoader methodsFor: 'accessing'!
removals
removals ifNil: [ removals := OrderedCollection new ].
^removals
! !
!CypressLoader methodsFor: 'operations'!
unloadDefinition: aPatchOperation
self
handleErrorFor: aPatchOperation
during: [ aPatchOperation unloadDefinition ]
! !
!CypressLoader methodsFor: 'accessing'!
unloadable
unloadable ifNil: [ unloadable := OrderedCollection new ].
^unloadable
! !
!CypressLoader methodsFor: 'loading'!
updatePackage: aPackage withSnapshot: aSnapshot
| patch snapshot |
snapshot := aPackage snapshot.
patch := aSnapshot patchRelativeToBase: snapshot.
patch applyTo: self.
snapshot definitions do: [:ea | self provisions addAll: ea provisions]
! !
!CypressLoader class methodsFor: 'loading'!
updatePackage: aPackage withSnapshot: aSnapshot
self new
updatePackage: aPackage withSnapshot: aSnapshot;
load
! !
!CypressMethodDefinition methodsFor: 'comparing'!
= aDefinition
^ super = aDefinition
and: [ aDefinition source = self source
and: [ aDefinition category = self category ] ]
! !
!CypressMethodDefinition methodsFor: 'loading'!
actualClass
| cls |
cls := self theNonMetaClass.
^self classIsMeta
ifTrue: [ cls class ]
ifFalse: [ cls ].
! !
!CypressMethodDefinition methodsFor: 'converting'!
asCypressMethodDefinition
^self
! !
!CypressMethodDefinition methodsFor: 'accessing'!
category
^category
! !
!CypressMethodDefinition methodsFor: 'visiting'!
classDefinition: classBlock methodDefinition: methodBlock
methodBlock value: self
! !
!CypressMethodDefinition methodsFor: 'accessing'!
classIsMeta
^classIsMeta
! !
!CypressMethodDefinition methodsFor: 'accessing'!
className
^className
! !
!CypressMethodDefinition methodsFor: 'initialization' stamp: 'dkh 4/24/2012 00:27'!
className: aName classIsMeta: isMetaclass selector: aSelector category: aCategory source: aSource
className := aName asSymbol.
classIsMeta := isMetaclass.
selector := aSelector asSymbol.
category := aCategory asSymbol.
source := aSource withLineEndings: String lfString.
! !
!CypressMethodDefinition methodsFor: 'initialization' stamp: 'jmv 6/14/2012 23:49'!
className: aName classIsMeta: isMetaclass selector: aSelector category: aCategory source: aSource timeStamp: aTimeStamp
className := aName asSymbol.
classIsMeta := isMetaclass.
selector := aSelector asSymbol.
category := aCategory asSymbol.
source := aSource withLineEndings: String lfString.
timeStamp := aTimeStamp! !
!CypressMethodDefinition methodsFor: 'accessing'!
description
^ Array
with: className
with: selector
with: classIsMeta
! !
!CypressMethodDefinition methodsFor: 'comparing' stamp: 'dkh 4/23/2012 23:20'!
hash
| hash |
hash := String stringHash: classIsMeta asString initialHash: 0.
hash := String stringHash: source initialHash: hash.
hash := String stringHash: category initialHash: hash.
hash := String stringHash: className initialHash: hash.
^ hash! !
!CypressMethodDefinition methodsFor: 'visiting'!
instanceMethod: instanceBlock classMethod: classBlock
^(self classIsMeta
ifTrue: [ classBlock ]
ifFalse: [ instanceBlock ]) value: self
! !
!CypressMethodDefinition methodsFor: 'testing'!
isInitializer
^ self selector = 'initialize' and: [self classIsMeta]
! !
!CypressMethodDefinition methodsFor: 'loading' stamp: 'jmv 6/14/2012 23:48'!
loadMethodDefinition
self actualClass
compile: self source
classified: self category
withStamp: self timeStamp
notifying: nil.! !
!CypressMethodDefinition methodsFor: 'loading'!
postLoadOver: aDefinition
super postLoadOver: aDefinition.
(self isInitializer
and: [ aDefinition isNil or: [ self source ~= aDefinition source ]])
ifTrue: [ self theNonMetaClass initialize ].
! !
!CypressMethodDefinition methodsFor: 'printing' stamp: 'dkh 4/23/2012 20:24'!
printString
| str |
str := WriteStream on: String new.
str
nextPutAll: super printString;
nextPutAll: ' (';
nextPutAll: self className.
self classIsMeta
ifTrue: [ str nextPutAll: ' class' ].
str
nextPutAll: '>>';
nextPutAll: self selector;
nextPutAll: ')'.
^str contents
! !
!CypressMethodDefinition methodsFor: 'dependency'!
requirements
"Answer list of global names required by this definition"
^{self className}
! !
!CypressMethodDefinition methodsFor: 'accessing'!
selector
^selector
! !
!CypressMethodDefinition methodsFor: 'accessing'!
source
^source
! !
!CypressMethodDefinition methodsFor: 'loading' stamp: 'dkh 4/24/2012 15:26'!
theNonMetaClass
^Smalltalk at: self className
! !
!CypressMethodDefinition methodsFor: 'accessing' stamp: 'jmv 6/14/2012 23:57'!
timeStamp
^timeStamp
! !
!CypressMethodDefinition methodsFor: 'loading' stamp: 'dkh 4/24/2012 15:28'!
unloadDefinition
self actualClass removeSelector: self selector asSymbol
! !
!CypressMethodDefinition class methodsFor: 'instance creation'!
className: aName
classIsMeta: isMetaclass
selector: aSelector
category: aCategory
source: aSource
^(self new)
className: aName
classIsMeta: isMetaclass
selector: aSelector
category: aCategory
source: aSource
! !
!CypressMethodDefinition class methodsFor: 'instance creation' stamp: 'jmv 6/14/2012 23:54'!
className: aName
classIsMeta: isMetaclass
selector: aSelector
category: aCategory
source: aSource
timeStamp: aTimeStamp
^(self new)
className: aName
classIsMeta: isMetaclass
selector: aSelector
category: aCategory
source: aSource
timeStamp: aTimeStamp
! !
!CypressModification methodsFor: 'initialization'!
= aPatchOperation
^(super = aPatchOperation) and: [self obsoletion = aPatchOperation obsoletion and: [ self modification = aPatchOperation modification]]
! !
!CypressModification methodsFor: 'applying'!
applyTo: aCypressLoader
aCypressLoader applyModification: self
! !
!CypressModification methodsFor: 'initialization'!
base: base target: target
obsoletion := base.
modification := target.
! !
!CypressModification methodsFor: 'accessing' stamp: 'dkh 4/23/2012 23:22'!
description
^ 'modify from: ' , self obsoletion printString , ' to: ' , self modification printString! !
!CypressModification methodsFor: 'loading'!
loadClassDefinition
self modification loadClassDefinition