author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 31 Aug 2015 14:01:56 +0100 | |
changeset 3 | ed5aae792d24 |
parent 2 | e439b82dda7d |
child 5 | 5cc2caa88b23 |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/ring' }" |
2 |
||
3 |
"{ NameSpace: Smalltalk }" |
|
4 |
||
5 |
RGElementDefinition subclass:#RGMethodDefinition |
|
6 |
instanceVariableNames:'protocol sourceCode stamp package' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Ring-Core-Kernel' |
|
10 |
! |
|
11 |
||
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
12 |
RGMethodDefinition comment:'RGMethodDefinition is a concrete representation of methods. It can be used to build browser for methods that are not in the image. It is polymorphic with CompiledMethod. |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
13 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
14 |
* We can ask a RGMethodDefinition for its selector using the selector message. |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
15 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
16 |
(Point>>#dist:) asRingDefinition selector |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
17 |
-> #dist |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
18 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
19 |
We can also ask the ring object representation of its class or the Smalltalk class actually implementing the corresponding compiledMethod. |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
20 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
21 |
* To access the ring class definition name, use parentName |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
22 |
aRGMethodDefinition parentName |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
23 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
24 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
25 |
(Point>>#dist:) asRingDefinition parentName |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
26 |
-> #Point |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
27 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
28 |
* If you have a complete model where classes and methods are ring definition, to access the ring class definition , use parent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
29 |
aRGMethodDefinition parent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
30 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
31 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
32 |
aRGMethodDefinition(Point>>#dist:) parent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
33 |
-> aRGClassDefinition(Point) |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
34 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
35 |
* If you want to access the smalltalk class that contains the compiledMethod that is represented by a ringMethodDefinition, use realParent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
36 |
aRGMethodDefinition realParent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
37 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
38 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
39 |
(Point>>#dist:) asRingDefinition realParent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
40 |
-> Point |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
41 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
42 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
43 |
Now a RingEntityDefinition offers two APIs: one that is generic and works for all the source code entities and this is the one we just |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
44 |
presented: parent, parentName and realParent. Having such interface is important to build generic tools that could manipulate |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
45 |
any entities in a polymorphic way (yes no isKindOf: everywhere). |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
46 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
47 |
In addition, a ring method definition offers a specific interface that should only be used when you know that you are solely manipulate |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
48 |
specific entity such as class element: method definition, class comment, and variables. |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
49 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
50 |
Here is the equivalence table |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
51 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
52 |
realParent realClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
53 |
parent ringClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
54 |
parentName className |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
55 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
56 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
57 |
* The message class returns the class of the object :). |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
58 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
59 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
60 |
(Point>>#dist:) asRingDefinition class |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
61 |
-> RingMethodDefinition |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
62 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
63 |
* The message className returns the name of the ring class defining the reingMethodDefinition. |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
64 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
65 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
66 |
(Point>>#dist:) asRingDefinition className |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
67 |
-> #Point |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
68 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
69 |
* If you have a complete model where classes and methods are ring definition, to access the ring class definition , use parent |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
70 |
aRGMethodDefinition ringClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
71 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
72 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
73 |
aRGMethodDefinition(Point>>#dist:) ringClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
74 |
-> aRGClassDefinition(Point) |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
75 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
76 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
77 |
* If you want to access the smalltalk class that contains the compiledMethod that is represented by a ringMethodDefinition, use realClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
78 |
aRGMethodDefinition realClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
79 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
80 |
Example: |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
81 |
(Point>>#dist:) asRingDefinition realClass |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
82 |
-> Point |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
83 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
84 |
' |
0 | 85 |
! |
86 |
||
87 |
!RGMethodDefinition class methodsFor:'instance creation'! |
|
88 |
||
89 |
class: aRGBehaviorDefinition selector: aString |
|
90 |
"Create a ring method definition from a ring class and a selector" |
|
91 |
||
92 |
^(self class: aRGBehaviorDefinition) |
|
93 |
selector: aString asSymbol; |
|
94 |
yourself |
|
95 |
! |
|
96 |
||
97 |
className: aString selector: aSelector isMetaSide: aBoolean |
|
98 |
||
99 |
^ (self class: (RGClassDefinition named: aString) selector: aSelector) isMetaSide: aBoolean; yourself |
|
100 |
! |
|
101 |
||
102 |
realClass: aClass selector: aString |
|
103 |
"Creates a ring method definition from a Smalltalk class and a selector <compiledMethod>" |
|
104 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
105 |
^(aClass >> aString asSymbol) asActiveRingDefinition |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
106 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
107 |
"Modified (format): / 29-08-2015 / 10:25:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 108 |
! ! |
109 |
||
110 |
!RGMethodDefinition class methodsFor:'categories'! |
|
111 |
||
112 |
unclassifiedProtocolName |
|
113 |
"Return the string labeling the unclassified protocol." |
|
114 |
||
115 |
^ 'as yet unclassified' |
|
116 |
! ! |
|
117 |
||
118 |
!RGMethodDefinition class methodsFor:'elements-annotations'! |
|
119 |
||
120 |
isExtensionKey |
|
121 |
||
122 |
^#isExtension |
|
123 |
! ! |
|
124 |
||
125 |
!RGMethodDefinition methodsFor:'accessing'! |
|
126 |
||
127 |
ast |
|
3
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
128 |
^ self parseTree |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
129 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
130 |
"Modified: / 29-08-2015 / 11:20:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 131 |
! |
132 |
||
133 |
compiledMethod |
|
134 |
"Retrieves the compiled method of this definition if exists" |
|
135 |
||
136 |
| rClass | |
|
137 |
(rClass := self realClass) notNil |
|
138 |
ifTrue: [ (rClass includesSelector: self selector) |
|
139 |
ifTrue: [ ^rClass >> self selector ] ]. |
|
140 |
||
141 |
^nil |
|
142 |
! |
|
143 |
||
144 |
fullName |
|
145 |
"Keeps a unique description for the receiver. As annotation to avoid converting each time is invoked" |
|
146 |
||
147 |
^self annotationNamed: self class fullNameKey |
|
148 |
ifAbsentPut: [ (self parentName, '>>', self selector) asSymbol ] |
|
149 |
! |
|
150 |
||
151 |
isExtension |
|
152 |
"The receiver is an extension when is defined in a different package to the one of its parent. |
|
153 |
Ring allows to set this property. If not assigned tries to find its value " |
|
154 |
||
155 |
^self |
|
156 |
annotationNamed: self class isExtensionKey |
|
157 |
ifAbsent: [ |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
158 |
(self parent notNil and:[ self package notNil ]) ifTrue: [ |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
159 |
| value | |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
160 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
161 |
value := self parent package ~= self package. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
162 |
self annotationNamed: self class isExtensionKey put: value. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
163 |
value |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
164 |
] ifFalse: [ |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
165 |
self isActive ifTrue:[ |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
166 |
| cm | |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
167 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
168 |
cm := self compiledMethod. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
169 |
cm isExtension. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
170 |
] ifFalse:[ |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
171 |
false |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
172 |
]. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
173 |
] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
174 |
] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
175 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
176 |
"Modified: / 29-08-2015 / 10:23:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 177 |
! |
178 |
||
179 |
isExtension: aBoolean |
|
180 |
"Explicitily set that the receiver is an extension" |
|
181 |
||
182 |
self annotationNamed: self class isExtensionKey put: aBoolean |
|
183 |
! |
|
184 |
||
185 |
origin |
|
186 |
"Return the real oring of this method." |
|
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
187 |
| mthd | |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
188 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
189 |
^ (mthd := self compiledMethod) |
0 | 190 |
ifNil: [ self methodClass ] |
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
191 |
ifNotNil: [ mthd origin ] |
0 | 192 |
! |
193 |
||
194 |
package |
|
195 |
"Retrieves the package in which this class is contained, if exists" |
|
196 |
||
197 |
^package |
|
198 |
! |
|
199 |
||
200 |
package: aRGPackage |
|
201 |
||
202 |
package:= aRGPackage |
|
203 |
! |
|
204 |
||
3
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
205 |
parseTree |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
206 |
"raise an error: this method should be implemented (TODO)" |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
207 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
208 |
^ RBParser parseMethod: self sourceCode |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
209 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
210 |
"Created: / 29-08-2015 / 11:20:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
211 |
! |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
212 |
|
0 | 213 |
protocol |
214 |
||
215 |
self isActive |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
216 |
ifTrue: [ ^ self compiledMethod ifNil: [ protocol ] ifNotNil: [ self compiledMethod category ]]. |
0 | 217 |
self isHistorical |
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
218 |
ifTrue: [ ^ self protocolAtPointer ifNil: [ | cm | (cm := self compiledMethod) ifNil: [ protocol ] ifNotNil:[ cm category ] ] ]. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
219 |
^ protocol |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
220 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
221 |
"Modified: / 29-08-2015 / 08:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 222 |
! |
223 |
||
224 |
protocol: anObject |
|
225 |
||
226 |
protocol := anObject |
|
227 |
! |
|
228 |
||
229 |
selector |
|
230 |
"Retrieves the name of the method" |
|
231 |
||
3
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
232 |
name isNil ifTrue:[ |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
233 |
| src | |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
234 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
235 |
src := self sourceCode. |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
236 |
src notNil ifTrue:[ |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
237 |
name := RBParser parseMethodPattern: src. |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
238 |
]. |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
239 |
]. |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
240 |
^ name |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
241 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
242 |
"Modified: / 29-08-2015 / 11:37:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 243 |
! |
244 |
||
245 |
selector: aSymbol |
|
246 |
"The name of a method is known as #selector" |
|
247 |
||
248 |
name := aSymbol |
|
249 |
! |
|
250 |
||
3
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
251 |
source |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
252 |
^self sourceCode |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
253 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
254 |
"Created: / 29-08-2015 / 11:19:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
255 |
! |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
256 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
257 |
source: aString |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
258 |
self sourceCode: aString |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
259 |
|
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
260 |
"Created: / 29-08-2015 / 11:34:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
261 |
! |
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
262 |
|
0 | 263 |
sourceCode |
264 |
||
265 |
self isActive |
|
266 |
ifTrue: [ ^ self compiledMethod ifNil:[ sourceCode ] ifNotNil: [ self compiledMethod sourceCode ]]. |
|
267 |
^ sourceCode |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
268 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
269 |
"Modified: / 29-08-2015 / 08:03:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 270 |
! |
271 |
||
272 |
sourceCode: anObject |
|
273 |
||
274 |
sourceCode := anObject |
|
275 |
! |
|
276 |
||
277 |
stamp |
|
278 |
||
279 |
self isActive |
|
280 |
ifTrue: [ ^ self compiledMethod timeStamp ]. |
|
281 |
^ stamp |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
282 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
283 |
"Modified: / 29-08-2015 / 08:03:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 284 |
! |
285 |
||
286 |
stamp: anObject |
|
287 |
"stores an author alias and a timestamp" |
|
288 |
||
289 |
stamp := anObject |
|
290 |
! ! |
|
291 |
||
292 |
!RGMethodDefinition methodsFor:'backward compatibility'! |
|
293 |
||
294 |
category |
|
295 |
||
296 |
^ self protocol |
|
297 |
! |
|
298 |
||
299 |
messages |
|
300 |
||
301 |
^ self method messages |
|
302 |
! |
|
303 |
||
304 |
method |
|
305 |
||
306 |
^self compiledMethod |
|
307 |
! |
|
308 |
||
309 |
methodClass |
|
310 |
"Return the class to which the receiver belongs to." |
|
311 |
||
312 |
^ self realClass |
|
313 |
! |
|
314 |
||
315 |
symbolic |
|
316 |
||
317 |
^ self method symbolic |
|
318 |
! ! |
|
319 |
||
320 |
!RGMethodDefinition methodsFor:'comparing'! |
|
321 |
||
322 |
<= aRGMethodDefinition |
|
323 |
"Sort method definitions according to: 1. class name - 2. class comment - 3. method selector - 4. timestamp" |
|
324 |
||
325 |
self parentName < aRGMethodDefinition parentName ifTrue: [^true]. |
|
326 |
self parentName > aRGMethodDefinition parentName ifTrue: [^false]. |
|
327 |
||
328 |
self flag: 'This ugly test is needed right now because the old system is used to represent |
|
329 |
class comment as method with Comment selector. And to mix comment and methods'. |
|
330 |
aRGMethodDefinition isComment ifTrue: [^false]. |
|
331 |
||
332 |
^(self selector < aRGMethodDefinition selector) |
|
333 |
or: [ (self selector == aRGMethodDefinition selector) and: [ |
|
334 |
self timeStamp <= aRGMethodDefinition timeStamp ]] |
|
335 |
! |
|
336 |
||
337 |
= aRGMethodDefinition |
|
338 |
"This method look for equality of the key properties of the receiver" |
|
339 |
||
340 |
||
341 |
^(super = aRGMethodDefinition) |
|
342 |
and: [ self selector == aRGMethodDefinition selector] |
|
343 |
! |
|
344 |
||
345 |
hash |
|
346 |
||
347 |
^super hash bitXor: self selector hash |
|
348 |
! ! |
|
349 |
||
350 |
!RGMethodDefinition methodsFor:'managing container'! |
|
351 |
||
352 |
addInContainer: aRGContainer |
|
353 |
||
354 |
aRGContainer addMethod: self |
|
355 |
||
356 |
! |
|
357 |
||
358 |
isIncludedInContainer: aRGContainer |
|
359 |
||
360 |
^aRGContainer includesMethod: self |
|
361 |
! |
|
362 |
||
363 |
removeFromContainer: aRGContainer |
|
364 |
||
365 |
aRGContainer removeMethod: self |
|
366 |
! ! |
|
367 |
||
368 |
!RGMethodDefinition methodsFor:'metrics'! |
|
369 |
||
370 |
numberOfLinesOfCode |
|
371 |
||
372 |
^ self annotationNamed: #numberOfLinesOfCode ifAbsentPut: [ self sourceCode lineCount ] |
|
373 |
! ! |
|
374 |
||
375 |
!RGMethodDefinition methodsFor:'operations'! |
|
376 |
||
377 |
recompile |
|
378 |
self method recompile |
|
379 |
! ! |
|
380 |
||
381 |
!RGMethodDefinition methodsFor:'printing'! |
|
382 |
||
383 |
printOn: aStream |
|
384 |
||
385 |
self parentName ifNotNil: [ |
|
386 |
aStream nextPutAll: self parentName; |
|
387 |
nextPutAll: '>>' ]. |
|
388 |
aStream print: self selector |
|
389 |
! ! |
|
390 |
||
391 |
!RGMethodDefinition methodsFor:'source pointers'! |
|
392 |
||
393 |
getPreambleFrom: aFileStream at: position |
|
394 |
^ SourceFiles getPreambleFrom: aFileStream at: position |
|
395 |
! |
|
396 |
||
397 |
protocolAtPointer |
|
398 |
"A RGMethodDefinition that was set as historical will retrieve the protocol using the sourcePointer" |
|
399 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
400 |
self shouldNotImplement. "/ No source pointers in Smalltalk/X |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
401 |
"/ ^ self sourcePointer notNil |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
402 |
"/ ifTrue: [ SourceFiles protocolAt: self sourcePointer ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
403 |
"/ ifFalse:[ nil ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
404 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
405 |
"Modified: / 29-08-2015 / 08:02:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 406 |
! |
407 |
||
408 |
sourceCodeAtPointer |
|
409 |
"A RGMethodDefinition that was set as historical will retrieve the sourceCode using the sourcePointer" |
|
410 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
411 |
self shouldNotImplement. "/ No source pointers in Smalltalk/X |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
412 |
"/ ^ self sourcePointer notNil |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
413 |
"/ ifTrue: [ SourceFiles sourceCodeAt: self sourcePointer ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
414 |
"/ ifFalse:[ nil ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
415 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
416 |
"Modified: / 29-08-2015 / 08:02:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 417 |
! |
418 |
||
419 |
sourcePointer |
|
420 |
"Retrieves the sourcePointer for this definition if exists" |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
421 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
422 |
self shouldNotImplement. "/ No source pointers in Smalltalk/X |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
423 |
"/ ^self annotationNamed: self class sourcePointerKey |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
424 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
425 |
"Modified: / 29-08-2015 / 08:02:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 426 |
! |
427 |
||
428 |
sourcePointer: aNumber |
|
429 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
430 |
self shouldNotImplement. "/ No source pointers in Smalltalk/X |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
431 |
"/ self annotationNamed: self class sourcePointerKey put: aNumber |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
432 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
433 |
"Modified: / 29-08-2015 / 08:02:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 434 |
! |
435 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
436 |
stampAtPointer |
0 | 437 |
"A RGMethodDefinition that was set as historical will retrieve the stamp using the sourcePointer" |
438 |
||
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
439 |
self shouldNotImplement. "/ No source pointers in Smalltalk/X |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
440 |
"/ ^ self sourcePointer notNil |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
441 |
"/ ifTrue: [ SourceFiles timeStampAt: self sourcePointer ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
442 |
"/ ifFalse:[ nil ] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
443 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
444 |
"Modified: / 29-08-2015 / 08:03:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 445 |
! ! |
446 |
||
447 |
!RGMethodDefinition methodsFor:'stamp values'! |
|
448 |
||
449 |
author |
|
450 |
||
451 |
^self |
|
452 |
annotationNamed: self class authorKey |
|
453 |
ifAbsentPut: [ self class parseAuthorAliasFrom: self stamp ] |
|
454 |
! |
|
455 |
||
456 |
author: aString |
|
457 |
||
458 |
self annotationNamed: self class authorKey put: aString |
|
459 |
! |
|
460 |
||
461 |
timeStamp |
|
462 |
||
463 |
^self annotationNamed: self class timeStampKey |
|
464 |
ifAbsentPut: [ self class |
|
465 |
parseTimestampFrom: self stamp |
|
466 |
default: (DateAndTime epoch) ] |
|
467 |
! |
|
468 |
||
469 |
timeStamp: aTimestamp |
|
470 |
||
471 |
self annotationNamed: self class timeStampKey put: aTimestamp |
|
472 |
! ! |
|
473 |
||
474 |
!RGMethodDefinition methodsFor:'testing'! |
|
475 |
||
476 |
hasStamp |
|
477 |
||
478 |
^stamp isEmptyOrNil not |
|
479 |
! |
|
480 |
||
481 |
isAbstract |
|
482 |
^ self compiledMethod isAbstract |
|
483 |
! |
|
484 |
||
485 |
isDefined |
|
486 |
"Answer whether the receiver exists in the environment" |
|
487 |
||
488 |
| rClass | |
|
489 |
self selector isDoIt ifTrue:[ ^false ]. |
|
490 |
rClass := self realClass. |
|
491 |
^rClass notNil and: [ rClass includesSelector: self selector ] |
|
492 |
! |
|
493 |
||
494 |
isFromTrait |
|
495 |
||
496 |
"Return true for methods that have been included from Traits" |
|
497 |
^ self origin isTrait and: [ self origin ~= self methodClass ] |
|
498 |
! |
|
499 |
||
500 |
isLocalSelector |
|
501 |
"Answer whether the receiver exists in the environment as a local implementation" |
|
502 |
||
503 |
| rClass | |
|
504 |
rClass:= self realClass. |
|
505 |
^rClass notNil and: [ rClass includesLocalSelector: self selector ] |
|
506 |
! |
|
507 |
||
508 |
isMethod |
|
509 |
||
510 |
^true |
|
511 |
! |
|
512 |
||
513 |
isOverridden |
|
514 |
^ self compiledMethod isOverridden |
|
515 |
! |
|
516 |
||
517 |
isSameRevisionAs: aRGMethodDefinition |
|
518 |
"This method look for equality of the properties of the receiver" |
|
519 |
"Stamp is ignored as in many cases a method is saved without containing any change. However it appears as changed due to a different stamp" |
|
520 |
self flag: 'needs to be evaluated'. |
|
521 |
||
522 |
^(super isSameRevisionAs: aRGMethodDefinition) |
|
523 |
and: [ self selector = aRGMethodDefinition selector |
|
524 |
and: [ self protocol = aRGMethodDefinition protocol |
|
525 |
and: [ self sourceCode = aRGMethodDefinition sourceCode ] ] ] |
|
526 |
! ! |
|
527 |
||
528 |
!RGMethodDefinition methodsFor:'to remove as soon as possible'! |
|
529 |
||
530 |
classIsMeta |
|
531 |
||
532 |
^self isMetaSide |
|
533 |
! |
|
534 |
||
535 |
isValid |
|
536 |
"verifies that the receiver is locally defined in the class and that is not a DoIt" |
|
537 |
||
538 |
^self isDefined |
|
539 |
! ! |
|
540 |
||
541 |
!RGMethodDefinition methodsFor:'traits'! |
|
542 |
||
543 |
argumentNames |
|
544 |
"Return an array with the argument names of the method's selector" |
|
545 |
||
546 |
^ self compiledMethod argumentNames |
|
547 |
! |
|
548 |
||
549 |
isBinarySelector |
|
550 |
^self selector |
|
551 |
allSatisfy: [:each | each isSpecial] |
|
552 |
! ! |
|
553 |
||
554 |
!RGMethodDefinition methodsFor:'type of methods'! |
|
555 |
||
556 |
asActive |
|
557 |
||
558 |
"Sets the receiver as active object, which will allow itself to retrieve its data from the compiled method" |
|
559 |
self annotationNamed: self class statusKey put: #active |
|
560 |
! |
|
561 |
||
562 |
asHistorical |
|
563 |
"Sets the receiver as historical object, which will allow itself to retrieve its data using the sourcePointer" |
|
564 |
self annotationNamed: self class statusKey put: #historical. |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
565 |
sourceCode isNil ifTrue:[ |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
566 |
| compiledMethod | |
0 | 567 |
compiledMethod := self compiledMethod. |
568 |
compiledMethod notNil ifTrue: [ |
|
2
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
569 |
sourceCode := compiledMethod sourceCode |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
570 |
]. |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
571 |
] |
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
572 |
|
e439b82dda7d
Fixed some tests. Not all pass, though,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
573 |
"Modified: / 29-08-2015 / 08:00:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 574 |
! |
575 |
||
576 |
asPassive |
|
577 |
||
578 |
"Sets the receiver as passive object, which will allow itself to retrieve its data that was assigned in its creation" |
|
579 |
self annotationNamed: self class statusKey put: #passive |
|
580 |
! |
|
581 |
||
582 |
fromActiveToHistorical |
|
583 |
"If the receiver was generated as an active method, it can be converted to a historical one by reading the data of the compiled method (if exists)" |
|
584 |
||
585 |
self isActive ifTrue: [ |
|
586 |
self asHistorical ] |
|
587 |
! |
|
588 |
||
589 |
fromActiveToPassive |
|
590 |
"If the receiver was generated as an active method, it can be converted to a passive one by reading the data of the compiled method (if exists)" |
|
591 |
||
592 |
| compiledMethod | |
|
593 |
self isActive |
|
594 |
ifFalse: [ ^ self ]. |
|
595 |
compiledMethod := self compiledMethod. |
|
596 |
compiledMethod notNil |
|
597 |
ifTrue: [ |
|
598 |
self protocol: compiledMethod category. |
|
599 |
self sourceCode: compiledMethod sourceCode. |
|
600 |
self stamp: compiledMethod timeStamp ]. |
|
601 |
self asPassive |
|
602 |
! |
|
603 |
||
604 |
isActive |
|
605 |
||
606 |
"A ring method isActive when it needs to access the compiledMethod for retrieving its data" |
|
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
607 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
608 |
| status | |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
609 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
610 |
^(status := self annotationNamed: self class statusKey) isNil |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
611 |
ifTrue:[ false ] |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
612 |
ifFalse:[ status == #active ] |
0 | 613 |
! |
614 |
||
615 |
isHistorical |
|
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
616 |
"A ring method can be used to point an old version of the receiver, in this case it will use the sourcePointer to retrieve its information" |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
617 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
618 |
| status | |
0 | 619 |
|
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
620 |
^(status := self annotationNamed: self class statusKey) isNil |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
621 |
ifTrue:[ false ] |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
622 |
ifFalse:[ status == #historical ] |
0 | 623 |
! |
624 |
||
625 |
isPassive |
|
626 |
"A ring method isPassive when it retrieves the data that was assigned in its creation. |
|
627 |
By default is passive" |
|
1
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
628 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
629 |
| status | |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
630 |
|
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
631 |
^(status := self annotationNamed: self class statusKey) isNil |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
632 |
ifTrue:[ false ] |
24b88532f6ef
Fixes to make it stc-compilable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
633 |
ifFalse:[ status == #passive ] |
0 | 634 |
! ! |
635 |
||
3
ed5aae792d24
More Smalltalk/X API methods. Better RGClassDefinition creation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
636 |