BlockContext's caller is now stored in sender field
[panda.git] / st / Behavior.st
blob8ec4d27f7187242d0a35f98ad0cd434fac4f91c9
2 "instance creation"
4 Behavior method!
5 new
6         ^ self basicNew initialize!
8 Behavior method!
9 new: size
10         ^ (self basicNew: size) initialize!
12 Behavior method!
13 basicNew
14         <primitive: 'Behavior_new'>
15         self primitiveFailed!
17 Behavior method!
18 basicNew: anInteger
19         <primitive: 'Behavior_newSize'>
20         self primitiveFailed!
23 "accessing"
25 Class method!
26 name
27         ^ name!
29 Metaclass method!
30 name
31         ^ instanceClass name, ' class'!
33 Behavior method!
34 format
35         ^ format!
37 Behavior method!
38 superclass
39         ^ superclass!
41 Behavior method!
42 instanceSize
43         ^ instanceSize!
45 Behavior method!
46 methodDictionary
47         ^ methodDictionary!
49 Behavior method!
50 instanceVariableNames
51         ^ instanceVariableNames!
53 "methods"
55 Behavior method!
56 addSelector: aSymbol withMethod: aMethod
57         methodDictionary at: aSymbol put: aMethod!
59 Behavior method!
60 removeSelector: aSymbol
61         methodDictionary removeKey: aSymbol!
63 Behavior method!
64 selectors
65         ^ methodDictionary keys!
67 Behavior method!
68 allSelectors
69         | class selectors |
71         selectors := Set new.
73         class := self.
74         [class ~~ nil]
75                 whileTrue:
76                         [selectors includeAll: class selectors.
77                          class := class superclass].
79         ^ selectors!
81 Behavior method!
82 hasMethods
83         ^ methodDictionary isEmpty not!
85 Behavior method!
86 includesSelector: aSymbol
87         ^ methodDictionary includes: aSymbol!
89 Behavior method!
90 canUnderstand: aSymbol
91         | class |
93         class := self.
94         [class ~~ nil]
95                 whileTrue:
96                         [(methodDictionary includesKey: aSymbol) ifTrue: [^ true].
97                          class := class superclass].
99         ^ false!
101 Behavior method!
102 inheritsFrom: aClass
103         | class |
105         class := self.
106         [class ~~ nil]
107                 whileTrue:
108                         [class == aClass ifTrue: [^ true].
109                          class := class superclass].
111         ^ false!
114 "compilation"
116 Behavior method!
117 compile: aString
118         <primitive: 'Behavior_compile'>
119         self error: 'could not compile code'!
121 "printing"
123 Behavior method!
124 printOn: aStream
125         aStream nextPutAll: self name!
128