175
175
,(if (equal? rett ' (core Any))
176
176
body
177
177
(let ((meta (take-while (lambda (x ) (and (pair? x)
178
- (memq (car x) ' (line meta))))
178
+ (memq (car x) ' (lineinfo line meta))))
179
179
(cdr body)))
180
180
(R (make-ssavalue)))
181
181
`(,(car body) ,@meta
@@ -3652,12 +3652,22 @@ f(x) = yt(x)
3652
3652
(loop (cdr xs))
3653
3653
elt)))))
3654
3654
3655
+ ; try to ignore some metadata expressions for implicit return sometimes
3656
+ (define (only-meta? blk )
3657
+ (let loop ((xs blk))
3658
+ (if (null? xs)
3659
+ #t
3660
+ (let ((elt (car xs)))
3661
+ (if (and (pair? elt) (memq (car elt) ' (lineinfo line loopinfo)))
3662
+ (loop (cdr xs))
3663
+ #f )))))
3664
+
3655
3665
; ; return `body` with `stmts` inserted after any meta nodes
3656
3666
(define (insert-after-meta body stmts )
3657
3667
(if (null? stmts)
3658
3668
body
3659
3669
(let ((meta (take-while (lambda (x ) (and (pair? x)
3660
- (memq (car x) ' (line meta))))
3670
+ (memq (car x) ' (lineinfo line meta))))
3661
3671
(cdr body))))
3662
3672
`(,(car body)
3663
3673
,@meta
@@ -3689,7 +3699,7 @@ f(x) = yt(x)
3689
3699
(lambda (x ) (and (pair? x) (not (eq? (car x) 'lambda )))))))
3690
3700
3691
3701
(define lambda-opt-ignored-exprs
3692
- (Set ' (quote top core line inert local-def unnecessary copyast
3702
+ (Set ' (quote top core lineinfo line inert local-def unnecessary copyast
3693
3703
meta inbounds boundscheck loopinfo decl aliasscope popaliasscope
3694
3704
thunk with-static-parameters toplevel-only
3695
3705
global globalref outerref const-if-global thismodule
@@ -3919,7 +3929,7 @@ f(x) = yt(x)
3919
3929
((atom? e) e)
3920
3930
(else
3921
3931
(case (car e)
3922
- ((quote top core globalref outerref thismodule line break inert module toplevel null true false meta) e)
3932
+ ((quote top core globalref outerref thismodule lineinfo line break inert module toplevel null true false meta) e)
3923
3933
((toplevel-only)
3924
3934
; ; hack to avoid generating a (method x) expr for struct types
3925
3935
(if (eq? (cadr e) 'struct )
@@ -4553,12 +4563,14 @@ f(x) = yt(x)
4553
4563
(file-diff (not (eq? fname last-fname)))
4554
4564
; ; don't need a filename node for start of function
4555
4565
(need-meta (and file-diff last-fname
4556
- (not (eq? e (lam:body lam))))))
4566
+ (not (eq? e (lam:body lam)))))
4567
+ (emit-final-meta (lambda ())))
4557
4568
(if file-diff (set! filename fname))
4558
4569
(if need-meta (emit `(meta push_loc ,fname)))
4559
4570
(let ((v (let loop ((xs (cdr e)))
4560
- (if (null? (cdr xs))
4561
- (compile (car xs) break-labels value tail)
4571
+ (if (only-meta? (cdr xs))
4572
+ (begin (set! emit-final-meta (lambda () (map (lambda (v ) (compile v break-labels #f #f )) (cdr xs))))
4573
+ (compile (car xs) break-labels value tail))
4562
4574
(begin (compile (car xs) break-labels #f #f )
4563
4575
(loop (cdr xs)))))))
4564
4576
(if need-meta
@@ -4574,16 +4586,20 @@ f(x) = yt(x)
4574
4586
(let ((tmp (make-ssavalue)))
4575
4587
(emit `(= ,tmp ,retv))
4576
4588
(set! retv tmp)))
4589
+ (emit-final-meta)
4577
4590
(emit ' (meta pop_loc))
4578
4591
(emit `(return ,retv)))
4579
4592
(emit ' (meta pop_loc))))
4580
4593
((and v value (not (simple-atom? v)))
4581
4594
(let ((tmp (make-ssavalue)))
4582
4595
(emit `(= ,tmp ,v))
4583
4596
(set! v tmp)
4597
+ (emit-final-meta)
4584
4598
(emit `(meta pop_loc))))
4585
4599
(else
4586
- (emit `(meta pop_loc)))))
4600
+ (emit-final-meta)
4601
+ (emit `(meta pop_loc))))
4602
+ (emit-final-meta))
4587
4603
(if file-diff (set! filename last-fname))
4588
4604
v)))
4589
4605
((return)
@@ -4829,7 +4845,7 @@ f(x) = yt(x)
4829
4845
(cons (car e) args)))
4830
4846
4831
4847
; ; metadata expressions
4832
- ((line meta inbounds loopinfo gc_preserve_end aliasscope popaliasscope inline noinline)
4848
+ ((lineinfo line meta inbounds loopinfo gc_preserve_end aliasscope popaliasscope inline noinline)
4833
4849
(let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return ))))
4834
4850
(cond ((eq? (car e) 'line )
4835
4851
(set! current-loc e)
0 commit comments