|
533 | 533 | ,@(if (null? vararg) '()
|
534 | 534 | (list `(... ,(arg-name (car vararg))))))
|
535 | 535 | ;; otherwise add to rest keywords
|
536 |
| - `(ccall 'jl_array_ptr_1d_push Void (tuple Any Any) |
537 |
| - ,rkw (tuple ,elt |
| 536 | + `(foreigncall 'jl_array_ptr_1d_push (core Void) (call (core svec) Any Any) |
| 537 | + ,rkw 0 (tuple ,elt |
538 | 538 | (call (core arrayref) ,kw
|
539 |
| - (call (top +) ,ii 1))))) |
| 539 | + (call (top +) ,ii 1))) 0)) |
540 | 540 | (map list vars vals flags))))
|
541 | 541 | ;; set keywords that weren't present to their default values
|
542 | 542 | ,@(apply append
|
|
897 | 897 | (if (or (null? F) (null? A))
|
898 | 898 | `(block
|
899 | 899 | ,.(reverse! stmts)
|
900 |
| - (call (core ccall) ,name ,RT (call (core svec) ,@(dots->vararg atypes)) |
| 900 | + (foreigncall ,name ,RT (call (core svec) ,@(dots->vararg atypes)) |
901 | 901 | ,.(reverse! C)
|
902 | 902 | ,@A))
|
903 | 903 | (let* ((a (car A))
|
|
1206 | 1206 | (= ,err true)))
|
1207 | 1207 | (= ,finally-exception (the_exception))
|
1208 | 1208 | ,finalb
|
1209 |
| - (if ,err (ccall 'jl_rethrow_other Void (tuple Any) ,finally-exception)) |
| 1209 | + (if ,err (foreigncall 'jl_rethrow_other (core Void) (call (core svec) Any) ,finally-exception 0)) |
1210 | 1210 | ,(if hasret
|
1211 | 1211 | (if ret
|
1212 | 1212 | `(if ,ret (return ,retval) ,val)
|
|
1411 | 1411 | (if (null? stmts)
|
1412 | 1412 | (loop (cdr kw) (list* (caddr arg) `(quote ,(cadr arg)) initial-kw) stmts #t)
|
1413 | 1413 | (loop (cdr kw) initial-kw
|
1414 |
| - (cons `(ccall 'jl_array_ptr_1d_push2 Void (tuple Any Any Any) |
1415 |
| - ,container |
1416 |
| - (|::| (quote ,(cadr arg)) (core Symbol)) |
1417 |
| - ,(caddr arg)) |
| 1414 | + (cons `(foreigncall 'jl_array_ptr_1d_push2 (core Void) (call (core svec) Any Any Any) |
| 1415 | + ,container 0 |
| 1416 | + (|::| (quote ,(cadr arg)) (core Symbol)) 0 |
| 1417 | + ,(caddr arg) 0) |
1418 | 1418 | stmts)
|
1419 | 1419 | #t)))
|
1420 | 1420 | (else
|
1421 | 1421 | (loop (cdr kw) initial-kw
|
1422 | 1422 | (cons (let* ((k (make-ssavalue))
|
1423 | 1423 | (v (make-ssavalue))
|
1424 |
| - (push-expr `(ccall 'jl_array_ptr_1d_push2 Void (tuple Any Any Any) |
1425 |
| - ,container |
1426 |
| - (|::| ,k (core Symbol)) |
1427 |
| - ,v))) |
| 1424 | + (push-expr `(foreigncall 'jl_array_ptr_1d_push2 (core Void) (call (core svec) Any Any Any) |
| 1425 | + ,container 0 |
| 1426 | + (|::| ,k (core Symbol)) 0 |
| 1427 | + ,v 0))) |
1428 | 1428 | (if (vararg? arg)
|
1429 | 1429 | `(for (= (tuple ,k ,v) ,(cadr arg))
|
1430 | 1430 | ,push-expr)
|
|
1957 | 1957 | (let ((f (cadr e)))
|
1958 | 1958 | (cond ((dotop? f)
|
1959 | 1959 | (expand-fuse-broadcast '() `(|.| ,(undotop f) (tuple ,@(cddr e)))))
|
| 1960 | + ((and (eq? f 'ccall) (length> e 4)) |
| 1961 | + (let* ((cconv (cadddr e)) |
| 1962 | + (have-cconv (memq cconv '(cdecl stdcall fastcall thiscall llvmcall))) |
| 1963 | + (after-cconv (if have-cconv (cddddr e) (cdddr e))) |
| 1964 | + (name (caddr e)) |
| 1965 | + (RT (car after-cconv)) |
| 1966 | + (argtypes (cadr after-cconv)) |
| 1967 | + (args (cddr after-cconv))) |
| 1968 | + (begin |
| 1969 | + (if (not (and (pair? argtypes) |
| 1970 | + (eq? (car argtypes) 'tuple))) |
| 1971 | + (if (and (pair? RT) |
| 1972 | + (eq? (car RT) 'tuple)) |
| 1973 | + (error "ccall argument types must be a tuple; try \"(T,)\" and check if you specified a correct return type") |
| 1974 | + (error "ccall argument types must be a tuple; try \"(T,)\""))) |
| 1975 | + (expand-forms |
| 1976 | + (lower-ccall name RT (cdr argtypes) |
| 1977 | + (if have-cconv (append args (list (list cconv))) args)))))) ;; place (callingconv) at end of arglist |
1960 | 1978 | ((and (pair? (caddr e))
|
1961 | 1979 | (eq? (car (caddr e)) 'parameters))
|
1962 | 1980 | ;; (call f (parameters . kwargs) ...)
|
|
2169 | 2187 | '|'| (lambda (e) `(call ctranspose ,(expand-forms (cadr e))))
|
2170 | 2188 | '|.'| (lambda (e) `(call transpose ,(expand-forms (cadr e))))
|
2171 | 2189 |
|
2172 |
| - 'ccall |
2173 |
| - (lambda (e) |
2174 |
| - (if (length> e 3) |
2175 |
| - (let ((name (cadr e)) |
2176 |
| - (RT (caddr e)) |
2177 |
| - (argtypes (cadddr e)) |
2178 |
| - (args (cddddr e))) |
2179 |
| - (begin |
2180 |
| - (if (not (and (pair? argtypes) |
2181 |
| - (eq? (car argtypes) 'tuple))) |
2182 |
| - (if (and (pair? RT) |
2183 |
| - (eq? (car RT) 'tuple)) |
2184 |
| - (error "ccall argument types must be a tuple; try \"(T,)\" and check if you specified a correct return type") |
2185 |
| - (error "ccall argument types must be a tuple; try \"(T,)\""))) |
2186 |
| - (expand-forms |
2187 |
| - (lower-ccall name RT (cdr argtypes) args)))) |
2188 |
| - e)) |
2189 |
| - |
2190 | 2190 | 'generator
|
2191 | 2191 | (lambda (e)
|
2192 | 2192 | (let* ((expr (cadr e))
|
@@ -3255,18 +3255,17 @@ f(x) = yt(x)
|
3255 | 3255 | ((and (pair? e) (eq? (car e) 'globalref)) (emit e) #f) ;; keep globals for undefined-var checking
|
3256 | 3256 | (else #f)))
|
3257 | 3257 | (case (car e)
|
3258 |
| - ((call new) |
3259 |
| - (let* ((ccall? (and (eq? (car e) 'call) (equal? (cadr e) '(core ccall)))) |
3260 |
| - (args (if ccall? |
| 3258 | + ((call new foreigncall) |
| 3259 | + (let* ((args (if (eq? (car e) 'foreigncall) |
3261 | 3260 | ;; NOTE: 2nd and 3rd arguments of ccall must be left in place
|
3262 | 3261 | ;; the 1st should be compiled if an atom.
|
3263 |
| - (append (list (cadr e)) |
3264 |
| - (cond (atom? (caddr e) (compile-args (list (caddr e)) break-labels)) |
3265 |
| - (else (caddr e))) |
3266 |
| - (list-head (cdddr e) 2) |
3267 |
| - (compile-args (list-tail e 5) break-labels)) |
| 3262 | + (append (list) |
| 3263 | + (cond (atom? (cadr e) (compile-args (list (cadr e)) break-labels)) |
| 3264 | + (else (cadr e))) |
| 3265 | + (list-head (cddr e) 2) |
| 3266 | + (compile-args (list-tail e 4) break-labels)) |
3268 | 3267 | (compile-args (cdr e) break-labels)))
|
3269 |
| - (callex (cons (car e) args))) |
| 3268 | + (callex (if (eq? (car e) 'foreigncall) (cons 'call (cons `(core ccall) args)) (cons (car e) args)))) |
3270 | 3269 | (cond (tail (emit-return callex))
|
3271 | 3270 | (value callex)
|
3272 | 3271 | ((eq? (car e) 'new) #f)
|
|
0 commit comments