Commit 6fbbef6
committed
first draft: function calls
We have implemented function calls in a way which should facilitate
closures and interfaces a great deal.
rather than the traditional Anderson copy/transfer constraints
of arguments to parameters and function results to caller
local results, we
1. represent each function in contiguous memory as a sequence (p0, p1,
..., pn, r0, r1, ..., rm) where each pi is a pointer to
an object of type of parameter i, and each ri is a pointer to an
object of type of return i.
2. upon analyzing a function we take *pi as the starting value of
the parameter.
3. Upon calling a function, we set *pi = argi and resi = *ri.
Now, given 2 functions f, g of the same signature, we have
copy/transfer constraints (fp0, fp1, ..., fpn, fr0, fr1, ..., frm) =
(gp0, gp1, ..., gpn, gr0, gr1, ..., grn). then the points-to
of each parameter and result are transfered to f from g.
In this way, dynamic dispatch should be a cinch: just call the
function object associated with the node, it will have all
the loads/stores of any function assigned to it.
Something similar should work for interfaces: we just keep a struct
of function objects defined as above, and on assignment to an interface
value, we assign the functions from the concrete type.
Likewise, this should facilitate closures by adding a free variables
component like the pi,ri components.1 parent 2d2291b commit 6fbbef6
4 files changed
+109
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
149 | 160 | | |
150 | 161 | | |
151 | 162 | | |
| |||
180 | 191 | | |
181 | 192 | | |
182 | 193 | | |
183 | | - | |
| 194 | + | |
184 | 195 | | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
188 | | - | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
214 | 225 | | |
215 | 226 | | |
216 | 227 | | |
217 | | - | |
| 228 | + | |
218 | 229 | | |
219 | 230 | | |
220 | 231 | | |
| |||
223 | 234 | | |
224 | 235 | | |
225 | 236 | | |
226 | | - | |
| 237 | + | |
227 | 238 | | |
228 | 239 | | |
229 | 240 | | |
| |||
233 | 244 | | |
234 | 245 | | |
235 | 246 | | |
236 | | - | |
| 247 | + | |
237 | 248 | | |
238 | 249 | | |
239 | 250 | | |
240 | | - | |
| 251 | + | |
241 | 252 | | |
242 | 253 | | |
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
246 | 257 | | |
247 | 258 | | |
248 | | - | |
249 | | - | |
| 259 | + | |
| 260 | + | |
250 | 261 | | |
| 262 | + | |
251 | 263 | | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
255 | | - | |
| 267 | + | |
| 268 | + | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
259 | 272 | | |
260 | | - | |
| 273 | + | |
| 274 | + | |
261 | 275 | | |
262 | 276 | | |
263 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
164 | 165 | | |
165 | | - | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | | - | |
169 | 168 | | |
170 | 169 | | |
171 | 170 | | |
| |||
335 | 334 | | |
336 | 335 | | |
337 | 336 | | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
| 442 | + | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
| 507 | + | |
507 | 508 | | |
508 | | - | |
| 509 | + | |
509 | 510 | | |
510 | 511 | | |
511 | 512 | | |
| |||
517 | 518 | | |
518 | 519 | | |
519 | 520 | | |
520 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
521 | 524 | | |
522 | | - | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
| |||
542 | 544 | | |
543 | 545 | | |
544 | 546 | | |
545 | | - | |
| 547 | + | |
546 | 548 | | |
547 | 549 | | |
548 | 550 | | |
| |||
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
554 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
555 | 574 | | |
556 | 575 | | |
557 | 576 | | |
| |||
0 commit comments