11#lang scribble/manual
22
3- @(require (for-label (except-in racket ... )))
3+ @(require (for-label (except-in racket compile ... ) a86 ))
44@(require redex/pict
55 racket/runtime-path
66 scribble/examples
1010
1111@(define codeblock-include (make-codeblock-include #'h ))
1212
13- @(for-each (λ (f) (ev `(require (file ,(path->string (build-path notes "knock " f))))))
14- '("interp.rkt " "compile.rkt " "syntax.rkt " "asm/interp.rkt " "asm/printer.rkt " ))
13+ @(ev '(require rackunit a86))
14+ @(ev `(current-directory ,(path->string (build-path notes "knock " ))))
15+ @(void (ev '(with-output-to-string (thunk (system "make runtime.o " )))))
16+ @(for-each (λ (f) (ev `(require (file ,f))))
17+ '("interp.rkt " "compile.rkt " "ast.rkt " "parse.rkt " "types.rkt " ))
1518
1619@title[#:tag "Knock " ]{Knock: first-class function (pointers)}
1720
@@ -139,8 +142,9 @@ We can verify that the compiler works for programs that use functions
139142like before:
140143
141144@ex[
145+ (current-objs '("runtime.o " ))
142146(asm-interp
143- (compile (sexpr->prog '(begin (define (f x)
147+ (compile (parse '(begin (define (f x)
144148 (if (zero? x)
145149 0
146150 (add1 (call (fun f) (sub1 x)))))
@@ -150,16 +154,18 @@ like before:
150154But it also works when functions are put in lists:
151155
152156@ex[
157+ (current-objs '("runtime.o " ))
153158(asm-interp
154- (compile (sexpr->prog '(begin (define (f x) x)
159+ (compile (parse '(begin (define (f x) x)
155160 (call (car (cons (fun f) '() )) 7 )))))
156161]
157162
158163And functions that produce functions:
159164
160165@ex[
166+ (current-objs '("runtime.o " ))
161167(asm-interp
162- (compile (sexpr->prog '(begin (define (f x) (fun h))
168+ (compile (parse '(begin (define (f x) (fun h))
163169 (define (h y) y)
164170 (call (call (fun f) 5 ) 9 )))))
165171]
0 commit comments