Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add immutable-vector, immutable-vector-copy, etc. #789

Merged
merged 10 commits into from
Jan 24, 2024
Prev Previous commit
Next Next commit
fold vector-length on immutable vector
owaddell-beckman authored and mflatt committed Jan 24, 2024
commit b454a40452b62fd5f2a193802f877a75c317cc81
8 changes: 8 additions & 0 deletions s/cp0.ss
Original file line number Diff line number Diff line change
@@ -5168,6 +5168,14 @@
[else #f])
(tryref ctxt ?x ?i 'vector #f))])

(define-inline 2 vector-length
[(?x)
(nanopass-case (Lsrc Expr) (result-exp (value-visit-operand! ?x))
[(immutable-vector (,e* ...) ,e)
(residualize-seq '() (app-opnds ctxt) ctxt)
`(quote ,(length e*))]
[else #f])])

(define-inline 2 string-ref
[(?x ?i) (tryref ctxt ?x ?i 'string char?)])

2 changes: 1 addition & 1 deletion s/primdata.ss
Original file line number Diff line number Diff line change
@@ -327,7 +327,7 @@
(vector? [sig [(ptr) -> (boolean)]] [pred vector] [flags pure unrestricted mifoldable discard ieee r5rs])
(make-vector [sig [(length) (length ptr) -> (vector)]] [flags alloc ieee r5rs])
(vector [sig [(ptr ...) -> (vector)]] [flags unrestricted alloc ieee r5rs cp02])
(vector-length [sig [(vector) -> (length)]] [flags pure true ieee r5rs mifoldable discard safeongoodargs])
(vector-length [sig [(vector) -> (length)]] [flags pure true ieee r5rs mifoldable discard safeongoodargs cp02])
(vector-ref [sig [(nonempty-vector sub-index) -> (ptr)]] [flags ieee r5rs mifoldable discard cp02])
(vector-set! [sig [(nonempty-vector sub-index ptr) -> (void)]] [flags true ieee r5rs cptypes2])
(vector->list [sig [(vector) -> (list)]] [flags alloc safeongoodargs ieee r5rs])