-
Notifications
You must be signed in to change notification settings - Fork 1
/
interp-Lany-prime.rkt
43 lines (38 loc) · 1.34 KB
/
interp-Lany-prime.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
#lang racket
(require "interp-Lvec-prime.rkt")
(require "interp-Lfun-prime.rkt")
(require "interp-Llambda-prime.rkt")
(require "interp-Lany.rkt")
(require "utilities.rkt")
(require (prefix-in runtime-config: "runtime-config.rkt"))
(provide interp-Lany-prime interp-Lany-prime-class interp-Lany-prime-mixin)
(define (interp-Lany-prime-mixin super-class)
(class super-class
(super-new)
(define/override (interp-op op)
(verbose "Lany-prime/interp-op" op)
(match op
['make-any (lambda (v tg) (Tagged v tg))]
['tag-of-any
(match-lambda
[(Tagged v^ tg) tg]
[v (error 'interp-op "expected tagged value, not ~a" v)])]
[else (super interp-op op)]))
(define/override ((interp-exp env) e)
(define recur (interp-exp env))
(verbose "Lany-prime/interp-exp" e)
(match e
[(ValueOf e ty)
(match (recur e)
[(Tagged v^ tg) v^]
[v (error 'interp-op "expected tagged value, not ~a" v)])]
[(Exit) (error 'interp-exp "exiting")]
[else ((super interp-exp env) e)]))
))
(define interp-Lany-prime-class
(interp-Lany-prime-mixin
(interp-Llambda-prime-mixin
(interp-Lfun-prime-mixin
(interp-Lvec-prime-mixin interp-Lany-class)))))
(define (interp-Lany-prime p)
(send (new interp-Lany-prime-class) interp-program p))