|
109 | 109 | ;; return a lambda expression representing a thunk for a top-level expression
|
110 | 110 | ;; note: expansion of stuff inside module is delayed, so the contents obey
|
111 | 111 | ;; toplevel expansion order (don't expand until stuff before is evaluated).
|
112 |
| -(define (expand-toplevel-expr-- e file line) |
| 112 | +(define (lower-toplevel-expr-- e file line) |
113 | 113 | (let ((lno (first-lineno e))
|
114 | 114 | (ex0 (julia-expand-macroscope e)))
|
115 | 115 | (if (and lno (or (not (length= lno 3)) (not (atom? (caddr lno))))) (set! lno #f))
|
|
118 | 118 | ex0
|
119 | 119 | (if lno `(toplevel ,lno ,ex0) ex0))
|
120 | 120 | (let* ((linenode (if (and lno (or (= line 0) (eq? file 'none))) lno `(line ,line ,file)))
|
121 |
| - (ex (julia-expand0 ex0 linenode)) |
122 |
| - (th (julia-expand1 |
| 121 | + (ex (julia-lower0 ex0 linenode)) |
| 122 | + (th (julia-lower1 |
123 | 123 | `(lambda () ()
|
124 | 124 | (scope-block
|
125 | 125 | ,(blockify ex lno)))
|
|
142 | 142 | error incomplete))
|
143 | 143 | (and (memq (car e) '(global const)) (every symbol? (cdr e))))))
|
144 | 144 |
|
145 |
| -(define *in-expand* #f) |
| 145 | +(define *in-lowering* #f) |
146 | 146 |
|
147 |
| -(define (expand-toplevel-expr e file line) |
| 147 | +(define (lower-toplevel-expr e file line) |
148 | 148 | (cond ((or (atom? e) (toplevel-only-expr? e))
|
149 | 149 | (if (underscore-symbol? e)
|
150 | 150 | (error "all-underscore identifiers are write-only and their values cannot be used in expressions"))
|
151 | 151 | e)
|
152 | 152 | (else
|
153 |
| - (let ((last *in-expand*)) |
| 153 | + (let ((last *in-lowering*)) |
154 | 154 | (if (not last)
|
155 | 155 | (begin (reset-gensyms)
|
156 |
| - (set! *in-expand* #t))) |
157 |
| - (begin0 (expand-toplevel-expr-- e file line) |
158 |
| - (set! *in-expand* last)))))) |
| 156 | + (set! *in-lowering* #t))) |
| 157 | + (begin0 (lower-toplevel-expr-- e file line) |
| 158 | + (set! *in-lowering* last)))))) |
159 | 159 |
|
160 | 160 | ;; used to collect warnings during lowering, which are usually discarded
|
161 | 161 | ;; unless logging is requested
|
162 | 162 | (define lowering-warning (lambda lst (void)))
|
163 | 163 |
|
164 | 164 | ;; expand a piece of raw surface syntax to an executable thunk
|
165 | 165 |
|
166 |
| -(define (expand-to-thunk- expr file line) |
| 166 | +(define (lower-to-thunk- expr file line) |
167 | 167 | (error-wrap (lambda ()
|
168 |
| - (expand-toplevel-expr expr file line)))) |
| 168 | + (lower-toplevel-expr expr file line)))) |
169 | 169 |
|
170 |
| -(define (expand-to-thunk-stmt- expr file line) |
171 |
| - (expand-to-thunk- (if (toplevel-only-expr? expr) |
| 170 | +(define (lower-to-thunk-stmt- expr file line) |
| 171 | + (lower-to-thunk- (if (toplevel-only-expr? expr) |
172 | 172 | expr
|
173 | 173 | `(block ,expr (null)))
|
174 | 174 | file line))
|
|
188 | 188 | (file (if (eq? warn_file 'none) file warn_file)))
|
189 | 189 | (set! warnings (cons (list* 'warn level group (symbol (string file line)) file line lst) warnings))))))
|
190 | 190 | (let ((thunk (if stmt
|
191 |
| - (expand-to-thunk-stmt- expr file line) |
192 |
| - (expand-to-thunk- expr file line)))) |
| 191 | + (lower-to-thunk-stmt- expr file line) |
| 192 | + (lower-to-thunk- expr file line)))) |
193 | 193 | `(,thunk ,(reverse warnings))))))
|
194 | 194 |
|
195 | 195 | (define (jl-expand-macroscope expr)
|
196 | 196 | (error-wrap (lambda ()
|
197 | 197 | (julia-expand-macroscope expr))))
|
198 | 198 |
|
199 | 199 | (define (jl-default-inner-ctor-body field-kinds file line)
|
200 |
| - (expand-to-thunk- (default-inner-ctor-body (cdr field-kinds) file line) file line)) |
| 200 | + (lower-to-thunk- (default-inner-ctor-body (cdr field-kinds) file line) file line)) |
201 | 201 |
|
202 | 202 | (define (jl-default-outer-ctor-body args file line)
|
203 |
| - (expand-to-thunk- (default-outer-ctor-body (cadr args) (caddr args) (cadddr args) file line) file line)) |
| 203 | + (lower-to-thunk- (default-outer-ctor-body (cadr args) (caddr args) (cadddr args) file line) file line)) |
204 | 204 |
|
205 | 205 | ; run whole frontend on a string. useful for testing.
|
206 | 206 | (define (fe str)
|
207 |
| - (expand-toplevel-expr (julia-parse str) 'none 0)) |
| 207 | + (lower-toplevel-expr (julia-parse str) 'none 0)) |
208 | 208 |
|
209 | 209 | (define (profile-e s)
|
210 | 210 | (with-exception-catcher
|
|
0 commit comments