-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathir-anf-ast.rkt
29 lines (22 loc) · 987 Bytes
/
ir-anf-ast.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
#lang typed/racket/base
(provide (all-defined-out) unique)
(require "primop.rkt" "types.rkt" "unique.rkt")
(struct: program ((expr : expression) (type : type)) #:transparent)
(define-type expression (U return conditional bind-primop bind-rec))
(struct: return ((name : unique)) #:transparent)
(struct: conditional
((condition : unique)
(t-branch : expression)
(f-branch : expression)
(type : type)) #:transparent)
(struct: bind-primop
((name : unique)
(type : type)
(op : primop)
(args : (Listof unique))
(body : expression)) #:transparent)
(struct: bind-rec ((functions : (Listof (Pair unique function))) (body : expression)) #:transparent)
(struct: function ((name : unique) (args : (Listof (Pair unique type))) (return-type : type) (body : expression)) #:transparent)
(: function->function-type (function -> function-type))
(define (function->function-type fun)
(make-function-type (map (inst cdr unique type) (function-args fun)) (function-return-type fun)))