|
148 | 148 | ;; GF method does not need to keep decl expressions on lambda args
|
149 | 149 | ;; except for rest arg
|
150 | 150 | (define (method-lambda-expr argl body rett)
|
151 |
| - (let ((argl (map arg-name argl)) |
| 151 | + (let ((argl (map (lambda (x) |
| 152 | + (let ((n (arg-name x))) |
| 153 | + (if (underscore-symbol? n) UNUSED n))) |
| 154 | + argl)) |
152 | 155 | (body (blockify body)))
|
153 | 156 | `(lambda ,argl ()
|
154 | 157 | (scope-block
|
|
324 | 327 | (append req opt vararg) rett)))))
|
325 | 328 | ;; no optional positional args
|
326 | 329 | (let ((names (map car sparams))
|
327 |
| - (anames (llist-vars argl))) |
| 330 | + (anames (map (lambda (x) (if (underscore-symbol? x) UNUSED x)) |
| 331 | + (llist-vars argl)))) |
328 | 332 | (if (has-dups (filter (lambda (x) (not (eq? x UNUSED))) anames))
|
329 | 333 | (error "function argument names not unique"))
|
330 | 334 | (if (has-dups names)
|
|
337 | 341 | (let* ((gen (generated-version body))
|
338 | 342 | (nongen (non-generated-version body))
|
339 | 343 | (gname (symbol (string (gensy) "#" (current-julia-module-counter))))
|
340 |
| - (gf (make-generator-function gname names (llist-vars argl) gen)) |
| 344 | + (gf (make-generator-function gname names anames gen)) |
341 | 345 | (loc (function-body-lineno body)))
|
342 | 346 | (set! body (insert-after-meta
|
343 | 347 | nongen
|
|
2387 | 2391 | ((=)
|
2388 | 2392 | (let ((v (decl-var (cadr e)))
|
2389 | 2393 | (rest (find-assigned-vars (caddr e) env)))
|
2390 |
| - (if (or (ssavalue? v) (memq v env) (globalref? v)) |
| 2394 | + (if (or (ssavalue? v) (memq v env) (globalref? v) (underscore-symbol? v)) |
2391 | 2395 | rest
|
2392 | 2396 | (cons v rest))))
|
2393 | 2397 | (else
|
|
2400 | 2404 | (cond ((memq (car e) '(lambda scope-block module toplevel))
|
2401 | 2405 | '())
|
2402 | 2406 | ((eq? (car e) kind)
|
2403 |
| - (list (decl-var (cadr e)))) |
| 2407 | + (if (underscore-symbol? (cadr e)) |
| 2408 | + '() |
| 2409 | + (list (decl-var (cadr e))))) |
2404 | 2410 | (else
|
2405 | 2411 | (apply append! (map (lambda (x) (find-decls kind x))
|
2406 | 2412 | e))))))
|
|
2415 | 2421 | (find-assigned-vars e env)))
|
2416 | 2422 |
|
2417 | 2423 | (define (unbound-vars e bound tab)
|
2418 |
| - (cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED)) tab) |
| 2424 | + (cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED) (underscore-symbol? e)) tab) |
2419 | 2425 | ((symbol? e) (if (not (memq e bound)) (put! tab e #t)) tab)
|
2420 | 2426 | ((or (not (pair? e)) (quoted? e)) tab)
|
2421 | 2427 | ((memq (car e) '(lambda scope-block module toplevel)) tab)
|
|
2556 | 2562 |
|
2557 | 2563 | ;; compute set of variables referenced in a lambda but not bound by it
|
2558 | 2564 | (define (free-vars- e tab)
|
2559 |
| - (cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED)) tab) |
| 2565 | + (cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED) (underscore-symbol? e)) tab) |
2560 | 2566 | ((symbol? e) (put! tab e #t))
|
2561 | 2567 | ((and (pair? e) (eq? (car e) 'outerref)) tab)
|
2562 | 2568 | ((and (pair? e) (eq? (car e) 'break-block)) (free-vars- (caddr e) tab))
|
@@ -3577,20 +3583,22 @@ f(x) = yt(x)
|
3577 | 3583 | (value callex)
|
3578 | 3584 | (else (emit callex)))))
|
3579 | 3585 | ((=)
|
3580 |
| - (let* ((rhs (compile (caddr e) break-labels #t #f)) |
3581 |
| - (lhs (cadr e)) |
3582 |
| - (lhs (if (and arg-map (symbol? lhs)) |
3583 |
| - (get arg-map lhs lhs) |
3584 |
| - lhs))) |
3585 |
| - (if (and value rhs) |
3586 |
| - (let ((rr (if (or (atom? rhs) (ssavalue? rhs) (eq? (car rhs) 'null)) |
3587 |
| - rhs (make-ssavalue)))) |
3588 |
| - (if (not (eq? rr rhs)) |
3589 |
| - (emit `(= ,rr ,rhs))) |
3590 |
| - (emit `(= ,lhs ,rr)) |
3591 |
| - (if tail (emit-return rr)) |
3592 |
| - rr) |
3593 |
| - (emit-assignment lhs rhs)))) |
| 3586 | + (let ((lhs (cadr e))) |
| 3587 | + (if (and (symbol? lhs) (underscore-symbol? lhs)) |
| 3588 | + (compile (caddr e) break-labels value tail) |
| 3589 | + (let* ((rhs (compile (caddr e) break-labels #t #f)) |
| 3590 | + (lhs (if (and arg-map (symbol? lhs)) |
| 3591 | + (get arg-map lhs lhs) |
| 3592 | + lhs))) |
| 3593 | + (if (and value rhs) |
| 3594 | + (let ((rr (if (or (atom? rhs) (ssavalue? rhs) (eq? (car rhs) 'null)) |
| 3595 | + rhs (make-ssavalue)))) |
| 3596 | + (if (not (eq? rr rhs)) |
| 3597 | + (emit `(= ,rr ,rhs))) |
| 3598 | + (emit `(= ,lhs ,rr)) |
| 3599 | + (if tail (emit-return rr)) |
| 3600 | + rr) |
| 3601 | + (emit-assignment lhs rhs)))))) |
3594 | 3602 | ((block)
|
3595 | 3603 | (let* ((last-fname filename)
|
3596 | 3604 | (fnm (first-non-meta e))
|
|
0 commit comments