-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcallmap.rkt
35 lines (28 loc) · 864 Bytes
/
callmap.rkt
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
#lang racket
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The call map, Label -> (set Label).
;; Maps lambda's and primitives to the sites where they may be called.
;; Implemented as a vector of sets.
(require "library.rkt"
"mutrec.rkt")
(provide call-map init-call-map!
index-call-map extend-call-map!
total-call-map-size)
(define call-map (vector empty-set))
(define init-call-map!
(lambda ()
(set! call-map (make-vector n-labels empty-set))))
(define index-call-map
(lambda (l)
(vector-ref call-map l)))
(define extend-call-map!
(lambda (l call-site)
(vector-set! call-map l
(union2 (vector-ref call-map l) (set call-site)))))
(define total-call-map-size
(lambda ()
(natural-foldl
(lambda (sum l)
(+ sum (length (index-call-map l))))
0
n-labels)))