-
Notifications
You must be signed in to change notification settings - Fork 1
/
type-check-Cany.rkt
41 lines (35 loc) · 1.41 KB
/
type-check-Cany.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
#lang racket
(require "utilities.rkt")
(require "type-check-Cvar.rkt")
(require "type-check-Cif.rkt")
(require "type-check-Rvec.rkt")
(require "type-check-Cvec.rkt")
(require "type-check-Cfun.rkt")
(require "type-check-Rany.rkt")
(provide type-check-Cany type-check-Cany-mixin type-check-Cany-class)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; type-check-Cany
(define (type-check-Cany-mixin super-class)
(class super-class
(super-new)
(inherit type-check-exp check-type-equal? combine-types)
(define/override ((type-check-tail env block-env G) t)
(match t
[(IfStmt cnd tail1 tail2)
(define-values (c Tc) ((type-check-exp env) cnd))
(check-type-equal? Tc 'Boolean t)
(define T1 ((type-check-tail env block-env G) tail1))
(define T2 ((type-check-tail env block-env G) tail2))
(check-type-equal? T1 T2 t)
(combine-types T1 T2)]
[(Exit) '_]
[else ((super type-check-tail env block-env G) t)]))
))
(define type-check-Cany-class (type-check-Cany-mixin
(type-check-Cfun-mixin
(type-check-Cvec-mixin
(type-check-Cif-mixin
(type-check-Cvar-mixin
type-check-Rany-class))))))
(define (type-check-Cany p)
(send (new type-check-Cany-class) type-check-program p))