chiark / gitweb /
src/{lexer-{proto,impl},parser/floc-proto}.lisp: Conditionify parse errors.
[sod] / doc / layout.tex
1 %%% -*-latex-*-
2 %%%
3 %%% Class layout and method combination protocols
4 %%%
5 %%% (c) 2015 Straylight/Edgeware
6 %%%
7
8 %%%----- Licensing notice ---------------------------------------------------
9 %%%
10 %%% This file is part of the Sensible Object Design, an object system for C.
11 %%%
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
16 %%%
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 %%% GNU General Public License for more details.
21 %%%
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 \chapter{Class layout and method combination}
27
28 %%%--------------------------------------------------------------------------
29 \section{Class layout protocol} \label{sec:layout.instance}
30
31 \begin{describe}{fun}{islots-struct-tag @<class> @> @<string>}
32 \end{describe}
33
34 \begin{describe}{fun}{ichain-struct-tag @<class> @<chain-head> @> @<string>}
35 \end{describe}
36
37 \begin{describe}{fun}{ichain-union-tag @<class> @<chain-head> @> @<string>}
38 \end{describe}
39
40 \begin{describe}{fun}{ilayout-struct-tag @<class> @> @<string>}
41 \end{describe}
42
43 \begin{describe}{fun}{vtmsgs-struct-tag @<class> @<super> @> @<string>}
44 \end{describe}
45
46 \begin{describe}{fun}{vtable-union-tag @<class> @<chain-head> @> @<string>}
47 \end{describe}
48
49 \begin{describe}{fun}{vtable-struct-tag @<class> @<chain-head> @> @<string>}
50 \end{describe}
51
52 \begin{describe}{fun}{vtable-name @<class> @<chain-head> @> @<string>}
53 \end{describe}
54
55 \begin{describe}{fun}{message-macro-name @<class> @<entry> @> @<string>}
56 \end{describe}
57
58 \begin{describe}{cls}{effective-slot () \&key :class :slot :initializer}
59 \end{describe}
60
61 \begin{describe*}
62     {\dhead{gf}{effective-slot-class @<slot> @> @<class>}
63      \dhead{gf}{effective-slot-direct-slot @<slot> @> @<direct-slot>}
64      \dhead{gf}{effective-slot-initializer @<slot> @> @<init-or-nil>}}
65 \end{describe*}
66
67 \begin{describe}{gf}
68     {find-slot-initializer @<class> @<slot> @> @<init-or-nil>}
69 \end{describe}
70
71 \begin{describe}{gf}{find-slot-initargs @<class> @<slot> @> @<list>}
72 \end{describe}
73
74 \begin{describe}{gf}
75     {compute-effective-slot @<class> @<slot> @> @<effective-slot>}
76 \end{describe}
77
78 \begin{describe}{cls}
79     {sod-class-effective-slot (effective-slot) \\ \ind
80       \&key :class :slot :initializer-function :prepare-function}
81 \end{describe}
82
83 \begin{describe*}
84     {\dhead{gf}{effective-slot-initializer-function @<slot> @> @<function>}
85      \dhead{gf}{effective-slot-prepare-function @<slot> @> @<function>}}
86 \end{describe*}
87
88 \begin{describe}{cls}{islots () \&key :class :subclass :slots}
89 \end{describe}
90
91 \begin{describe*}
92     {\dhead{gf}{islots-class @<islots> @> @<class>}
93      \dhead{gf}{islots-subclass @<islots> @> @<class>}
94      \dhead{gf}{islots-slots @<islots> @> @<list>}}
95 \end{describe*}
96
97 \begin{describe}{gf}{compute-islots @<class> @<subclass> @> @<islots>}
98 \end{describe}
99
100 \begin{describe}{gf}{vtable-pointer () \&key :class :chain-head :chain-tail}
101 \end{describe}
102
103 \begin{describe*}
104     {\dhead{gf}{vtable-pointer-class @<vtable-pointer> @> @<class>}
105      \dhead{gf}{vtable-pointer-chain-head @<vtable-pointer> @> @<class>}
106      \dhead{gf}{vtable-pointer-chain-tail @<vtable-pointer> @> @<class>}}
107 \end{describe*}
108
109 \begin{describe}{gf}{ichain () \&key :class :chain-head :chain-tail :body}
110 \end{describe}
111
112 \begin{describe*}
113     {\dhead{gf}{ichain-class @<ichain> @> @<class>}
114      \dhead{gf}{ichain-chain-head @<ichain> @> @<class>}
115      \dhead{gf}{ichain-chain-tail @<ichain> @> @<class>}
116      \dhead{gf}{ichain-body @<ichain> @> @<list>}}
117 \end{describe*}
118
119 \begin{describe}{gf}{compute-ichain @<class> @<chain> @> @<ichain>}
120 \end{describe}
121
122 \begin{describe}{gf}{ilayout () \&key :class :ichains}
123 \end{describe}
124
125 \begin{describe*}
126     {\dhead{gf}{ilayout-class @<ilayout> @> @<class>}
127      \dhead{gf}{ilayout-ichains @<ilayout> @> @<list>}}
128 \end{describe*}
129
130 \begin{describe}{gf}{sod-class-ilayout <class> @> @<ilayout>}
131 \end{describe}
132
133 \begin{describe}{gf}{compute-ilayout @<class> @> @<ilayout>}
134 \end{describe}
135
136 \begin{describe}{cls}
137     {vtmsgs () \&key :class :subclass :chain-head :chain-tail :entries}
138 \end{describe}
139
140 \begin{describe*}
141     {\dhead{gf}{vtmsgs-class @<vtmsgs> @> @<class>}
142      \dhead{gf}{vtmsgs-subclass @<vtmsgs> @> @<class>}
143      \dhead{gf}{vtmsgs-chain-head @<vtmsgs> @> @<class>}
144      \dhead{gf}{vtmsgs-chain-tail @<vtmsgs> @> @<class>}
145      \dhead{gf}{vtmsgs-entries @<vtmsgs> @> @<list>}}
146 \end{describe*}
147
148 \begin{describe}{cls}
149     {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head}
150 \end{describe}
151
152 \begin{describe*}
153     {\dhead{gf}{class-pointer-class @<class-pointer> @> @<class>}
154      \dhead{gf}{class-pointer-chain-head @<class-pointer> @> @<class>}
155      \dhead{gf}{class-pointer-metaclass @<class-pointer> @> @<class>}
156      \dhead{gf}{class-pointer-meta-chain-head @<class-pointer> @> @<class>}}
157 \end{describe*}
158
159 \begin{describe}{fun}
160     {make-class-pointer @<class> @<chain-head>
161                         @<metaclass> @<meta-chain-head>
162       @> @<class-pointer>}
163 \end{describe}
164
165 \begin{describe}{cls}{base-offset () \&key :class :chain-head}
166 \end{describe}
167
168 \begin{describe*}
169     {\dhead{gf}{base-offset-class @<base-offset> @> @<class>}
170      \dhead{gf}{base-offset-chain-head @<base-offset> @> @<class>}}
171 \end{describe*}
172
173 \begin{describe}{fun}
174     {make-base-offset @<class> @<chain-head> @> @<base-offset>}
175 \end{describe}
176
177 \begin{describe}{cls}{chain-offset () \&key :class :chain-head :target-head}
178 \end{describe}
179
180 \begin{describe*}
181     {\dhead{gf}{chain-offset-class @<chain-offset> @> @<class>}
182      \dhead{gf}{chain-offset-chain-head @<chain-offset> @> @<class>}
183      \dhead{gf}{chain-offset-target-head @<chain-offset> @> @<class>}}
184 \end{describe*}
185
186 \begin{describe}{fun}
187     {make-chain-offset @<class> @<chain-head> @<target-head>
188       @> @<chain-offset>}
189 \end{describe}
190
191 \begin{describe}{gf}{vtable () \&key :class :chain-head :chain-tail :body}
192 \end{describe}
193
194 \begin{describe*}
195     {\dhead{gf}{vtable-class @<vtable> @> @<class>}
196      \dhead{gf}{vtable-chain-head @<vtable> @> @<class>}
197      \dhead{gf}{vtable-chain-tail @<vtable> @> @<class>}
198      \dhead{gf}{vtable-body @<vtable> @> @<list>}}
199 \end{describe*}
200
201 \begin{describe}{gf}
202     {compute-vtable-items @<class> @<super>
203                           @<chain-head> @<chain-tail>
204                           @<emit-function>}
205 \end{describe}
206
207 \begin{describe}{gf}{compute-vtable @<class> @<chain> @> @<vtable>}
208 \end{describe}
209
210 \begin{describe}{gf}{sod-class-vtables @<class> @> @<list>}
211 \end{describe}
212
213 \begin{describe}{gf}{compute-vtables @<class> @> @<list>}
214 \end{describe}
215
216 %%%--------------------------------------------------------------------------
217 \section{Method combination} \label{sec:layout.methods}
218
219 \begin{describe}{cls}{effective-method () \&key :message :class :keywords}
220 \end{describe}
221
222 \begin{describe*}
223     {\dhead{gf}{effective-method-message @<method> @> @<message>}
224      \dhead{gf}{effective-method-class @<method> @> @<class>}
225      \dhead{gf}{effective-method-keywords @<method> @> @<list>}}
226 \end{describe*}
227
228 \begin{describe}{gf}
229     {sod-message-effective-method-class @<message> @> @<class>}
230 \end{describe}
231
232 \begin{describe}{gf}{primary-method-class @<message> @> @<class>}
233 \end{describe}
234
235 \begin{describe}{gf}
236     {method-keyword-argument-lists @<method> @<direct-methods> @> @<list>}
237 \end{describe}
238
239 \begin{describe}{gf}
240     {compute-sod-effective-method @<message> @<class> @> @<method>}
241 \end{describe}
242
243 \begin{describe}{gf}{sod-class-effective-methods @<class> @> @<list>}
244 \end{describe}
245
246 \begin{describe}{gf}{compute-effective-methods @<class> @> @<list>}
247 \end{describe}
248
249 \begin{describe}{cls}
250     {method-entry () \&key :method :chain-head :chain-tail :role}
251 \end{describe}
252
253 \begin{describe*}
254     {\dhead{gf}{method-entry-effective-method @<method-entry> @> @<method>}
255      \dhead{gf}{method-entry-chain-head @<method-entry> @> @<class>}
256      \dhead{gf}{method-entry-chain-tail @<method-entry> @> @<class>}
257      \dhead{gf}{method-entry-role @<method-entry> @> @<role>}}
258 \end{describe*}
259
260 \begin{describe}{gf}
261     {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
262       @> @<list>}
263 \end{describe}
264
265
266 \begin{describe}{gf}{sod-message-argument-tail @<message> @> @<list>}
267 \end{describe}
268
269 \begin{describe}{gf}{sod-method-function-type @<method> @> @<c-type>}
270 \end{describe}
271
272 \begin{describe}{gf}{sod-method-next-method-type @<method> @> @<c-type>}
273 \end{describe}
274
275 \begin{describe}{gf}{sod-method-description @<method> @> @<string>}
276 \end{describe}
277
278 \begin{describe}{gf}{sod-method-function-name @<method> @> @<string>}
279 \end{describe}
280
281 \begin{describe}{fun}{varargs-message-p @<message> @> @<generalized-boolean>}
282 \end{describe}
283
284 \begin{describe}{fun}{keyword-message-p @<message> @> @<generalized-boolean>}
285 \end{describe}
286
287 \begin{describe}{gf}{method-entry-function-type @<entry> @> @<c-type>}
288 \end{describe}
289
290 \begin{describe}{gf}{method-entry-slot-name @<entry> @> @<string>}
291 \end{describe}
292
293 \begin{describe}{gf}
294     {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>}
295 \end{describe}
296
297 \begin{describe}{gf}
298     {effective-method-basic-argument-names @<method> @> @<list>}
299 \end{describe}
300
301 \begin{describe}{gf}
302     {effective-method-live-p @<method> @> @<generalized-boolean>}
303 \end{describe}
304
305
306 \begin{describe}{cls}
307     {method-codegen (codegen)                                   \\ \ind
308       \&key :vars :insts :temp-index
309             :message :class :method :target}
310 \end{describe}
311
312 \begin{describe*}
313     {\dhead{gf}{codegen-message @<codegen> @> @<message>}
314      \dhead{gf}{codegen-class @<codegen> @> @<class>}
315      \dhead{gf}{codegen-method @<codegen> @> @<method>}
316      \dhead{gf}{codegen-target @<codegen> @> @<target>}}
317 \end{describe*}
318
319 \begin{describe*}
320     {\dhead{cls}{convert-to-ilayout-inst (inst)}
321      \dhead{fun}
322        {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>}}
323   \begin{prog}
324     SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
325   \end{prog}
326 \end{describe*}
327
328
329 \begin{describe}{gf}
330     {compute-effective-method-body @<method> @<codegen> @<target>}
331 \end{describe}
332
333 \begin{describe}{gf}{simple-method-body @<method> @<codegen> @<target>}
334 \end{describe}
335
336 \begin{describe}{fun}
337     {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>}
338 \end{describe}
339
340 \begin{describe}{fun}{ensure-ilayout-var @<codegen> @<super>}
341 \end{describe}
342
343 \begin{describe}{fun}{make-trampoline @<codegen> @<super> @<body-func>}
344 \end{describe}
345
346 \begin{describe}{gf}{effective-method-function-name @<method> @> @<string>}
347 \end{describe}
348
349 \begin{describe}{gf}
350     {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>}
351 \end{describe}
352
353 \begin{describe}{gf}{compute-method-entry-functions @<method> @> @<list>}
354 \end{describe}
355
356 \begin{describe}{fun}
357     {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
358                              @<chain> @<kernel-func>}
359 \end{describe}
360
361 \begin{describe}{cls}
362     {basic-message (sod-message) \&key :name :location :class :type}
363 \end{describe}
364
365 \begin{describe}{cls}
366     {simple-message (basic-message) \&key :name :location :class :type}
367 \end{describe}
368
369 \begin{describe}{cls}
370     {basic-direct-method (sod-method)
371       \&key :message :location :class :type :body :role}
372 \end{describe}
373
374 \begin{describe}{gf}{sod-method-role @<method> @> @<role>}
375 \end{describe}
376
377 \begin{describe}{cls}
378     {daemon-direct-method (basic-direct-method)                 \\ \ind
379       \&key :message :location :class :type :body :role}
380 \end{describe}
381
382 \begin{describe}{cls}
383     {delegating-direct-method (basic-direct-method)             \\ \ind
384       \&key :message :location :class :type :body :role}
385 \end{describe}
386
387 \begin{describe}{cls}
388     {basic-effective-method (effective-method)                  \\ \ind
389       \&key :message :class :around-methods :before-methods :after-methods}
390 \end{describe}
391
392 \begin{describe*}
393     {\dhead{gf}
394        {effective-method-around-methods @<effective-method> @> @<list>}
395      \dhead{gf}
396        {effective-method-before-methods @<effective-method> @> @<list>}
397      \dhead{gf}
398        {effective-method-after-methods @<effective-method> @> @<list>}
399      \dhead{gf}{effective-method-functions @<effective-method> @> @<list>}}
400 \end{describe*}
401
402 \begin{describe}{cls}
403     {simple-effective-method (basic-effective-method)           \\ \ind
404       \&key :message :class
405             :around-methods :before-methods :after-methods :primary-methods}
406 \end{describe}
407
408 \begin{describe}{fun}
409     {basic-effective-method-body @<codegen> @<target> @<method> @<body>}
410 \end{describe}
411
412 \begin{describe}{cls}
413     {standard-message (simple-message) \&key :name :location :class :type}
414 \end{describe}
415
416 \begin{describe}{cls}
417     {standard-effective-method (simple-effective-method)        \\ \ind
418       \&key :message :class
419             :around-methods :before-methods :after-methods :primary-methods}
420 \end{describe}
421
422 \begin{describe}{cls}
423     {aggregating-message (simple-message)
424       \&key :name :location :class :type :combination}
425 \end{describe}
426
427 \begin{describe}{gf}
428     {aggregating-message-properties @<message> @<combination> @> @<plist>}
429 \end{describe}
430
431 \begin{describe}{gf}
432     {compute-aggregating-message-kernel
433       \=@<message> @<combination> @<target>                   \+\\
434         @<methods> @<arg-names> \&key}
435 \end{describe}
436
437 \begin{describe}{gf}
438     {check-aggregating-message-type @<message> @<combination> @<c-type>}
439 \end{describe}
440
441 \begin{describe}{cls}
442      {aggregating-effective-method (simple-effective-method)    \\ \ind
443       \&key :message :class
444             :around-methods :before-methods :after-methods :primary-methods}
445 \end{describe}
446
447 \begin{describe}{mac}
448     {define-aggregating-method-combination @<combination>       \\ \ind\ind
449         ((@<var-name>^*)
450          @[[ :codegen @<codegen-var> @!
451              :methods @<methods-var> @]])                     \-\\
452       @[[ \=:properties (@{ (@{ @<name> @! (@[@<keyword>@] @<name>) @}
453                              @<c-type>
454                              @[@<default>
455                                @[@<suppliedp-var>@]@]) @}^*) @! \+\\
456             :return-type @<c-type> @!                           \\
457             :around @<around-func> @!
458             :first-method @<first-method-func> @!
459             :method @<method-func> @]]}
460 \end{describe}
461
462 %%% the method combination story
463 %% compute-effective-methods --> compute-sod-effective-method
464
465 %% hook-output (basic-effective-method :c)
466 %%   basic-effective-method.functions
467 %%     compute-method-entry-functions
468 %%       compute-effective-method-body
469 %%
470 %% compute-effective-method-body (simple-effective-method)
471 %%   basic-effective-method-body
472 %%   simple-method-body (standard-effective-method)
473 %%   simple-method-body (aggregating-effective-method)
474 %%     message-kernel-function
475
476 %%%----- That's all, folks --------------------------------------------------
477
478 %%% Local variables:
479 %%% mode: LaTeX
480 %%% TeX-master: "sod.tex"
481 %%% TeX-PDF-mode: t
482 %%% End: