-
Notifications
You must be signed in to change notification settings - Fork 1
/
xar.rkt
54 lines (51 loc) · 1.61 KB
/
xar.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#lang racket
(require "xarta.rkt"
"xaraa.rkt"
"xarps.rkt"
"x-misc.rkt")
(define (uar:main src dst prog)
(define types #f)
(define (print-types types) (write (form-types types)) (newline))
(define (form-types types)
(map (lambda (fdescr)
(let ((type* (cdr fdescr)) (fname (car fdescr)))
`(,fname unquote (map form-type type*))))
types))
(define (form-type type)
(cond ((equal? type 'absent) '_)
((equal? type 'any) '_)
((equal? (car type) 'atom) (let ((a (cadr type))) a))
((equal? (car type) 'cons)
(let ((t2 (caddr type)) (t1 (cadr type)))
`(,(form-type t1) unquote (form-type t2))))
(else (error "SELECT: no match for" type))))
(newline)
(display "-- Arity Raising: ")
(display src)
(display " -> ")
(display dst)
(newline)
(newline)
(display "Analysis of the Argument Types")
(newline)
(display "Iterations: ")
(set! types (mpairs->pairs (uarta:analyze-argument-types prog))) ; converting back to regular pairs
(newline)
(display "Structure of Arguments:")
(newline)
(print-types types)
(display "Analysis of the Parameter Accesses")
(newline)
(display "Iterations: ")
(uaraa:analyze-parameter-access! prog (pairs->mpairs types)) ; converting to mutable
(newline)
(display "Structure of Arguments:")
(newline)
(print-types types)
(display "Splitting of Parameters")
(newline)
(set! prog (uarps:optimize prog types))
(display "-- Done --")
(newline)
prog)
(provide (all-defined-out))