-
Notifications
You must be signed in to change notification settings - Fork 1
/
interp-Llambda-prime.rkt
38 lines (33 loc) · 1.27 KB
/
interp-Llambda-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
#lang racket
(require "interp-Lvec-prime.rkt")
(require "interp-Lfun-prime.rkt")
(require "interp-Llambda.rkt")
(require "utilities.rkt")
(require (prefix-in runtime-config: "runtime-config.rkt"))
(provide interp-Llambda-prime interp-Llambda-prime-mixin interp-Llambda-prime-class)
(define (interp-Llambda-prime-mixin super-class)
(class super-class
(super-new)
(define/override (interp-op op)
(verbose "Llambda'/interp-op" op)
(match op
['procedure-arity
(match-lambda
[`(function ,xs ,body ,env) (length xs)]
[(vector `(function ,xs ,body ,env) vs ... `(arity ,n)) n]
[v (error 'interp-op "Llambda'/expected function, not ~a" v)])]
[else (super interp-op op)]))
(define/override ((interp-exp env) e)
(verbose "Llambda'/interp-exp" e)
(match e
[(Closure arity args)
(define arg-vals (map (interp-exp env) args))
(apply vector (append arg-vals (list `(arity ,arity))))]
[else ((super interp-exp env) e)]))
))
(define interp-Llambda-prime-class
(interp-Llambda-prime-mixin
(interp-Lfun-prime-mixin
(interp-Lvec-prime-mixin interp-Llambda-class))))
(define (interp-Llambda-prime p)
(send (new interp-Llambda-prime-class) interp-program p))