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

Implemented mSlice on the VM allowing toOpenArray to work at compile time. #20586

Merged
merged 11 commits into from
Oct 20, 2022

Conversation

beef331
Copy link
Collaborator

@beef331 beef331 commented Oct 17, 2022

This is requisite for changes to the stdlib to use openArray[char] more. There is an issue with static openArray[T], but oa[a..b] does work so can be used in place.

@beef331 beef331 marked this pull request as ready for review October 17, 2022 21:00
Copy link
Contributor

@zerbina zerbina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already discussed some of the changes via real-time chat, so I thought I'd do a second round of review here.


You also need to handle the case of creating slices from slices (e.g. toOpenArray(toOpenArray(x, 1, 4), 1, 2). My recommendation would be to prevent nested slices by unwrapping them as part of opcSlice.

The tyOpenArray handling in ccgexprs.genBracedInit also needs to be adjusted - it currently expects an nkBracket.

compiler/ast.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
compiler/vmgen.nim Outdated Show resolved Hide resolved
compiler/vmgen.nim Outdated Show resolved Hide resolved
compiler/vm.nim Outdated Show resolved Hide resolved
@Varriount Varriount requested a review from Araq October 18, 2022 18:59
@Varriount Varriount added the Requires Araq To Merge PR should only be merged by Araq label Oct 18, 2022
@Araq
Copy link
Member

Araq commented Oct 20, 2022

Irrelevant CI failure, merging.

@Araq Araq merged commit 4aa67ad into nim-lang:devel Oct 20, 2022
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 4aa67ad

Hint: mm: orc; opt: speed; options: -d:release
163574 lines; 8.623s; 613.672MiB peakmem

narimiran pushed a commit that referenced this pull request Oct 24, 2022
…ile time. (#20586)

* Implemented opcSlice to make 'toOpenArray' work on the VM

* Added nkOpenArray for VM to reduce bodgeness

* Fixed range issues and erraneous comments

* Range check correctly for openArrays in opcLdArr

* Inverted logic for ldArr checking

* vm now supports slicing strings

* Added string tests

* Removed usage of 'nkOpenArray' and redundant operations

* Refactored vmSlice implementation, removing redundant and incorrect code

* Made tuples go throw opcWrObj for field assignment

* All strkinds should be considered for openarrays

(cherry picked from commit 4aa67ad)
capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
…ile time. (nim-lang#20586)

* Implemented opcSlice to make 'toOpenArray' work on the VM

* Added nkOpenArray for VM to reduce bodgeness

* Fixed range issues and erraneous comments

* Range check correctly for openArrays in opcLdArr

* Inverted logic for ldArr checking

* vm now supports slicing strings

* Added string tests

* Removed usage of 'nkOpenArray' and redundant operations

* Refactored vmSlice implementation, removing redundant and incorrect code

* Made tuples go throw opcWrObj for field assignment

* All strkinds should be considered for openarrays
bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
…ile time. (nim-lang#20586)

* Implemented opcSlice to make 'toOpenArray' work on the VM

* Added nkOpenArray for VM to reduce bodgeness

* Fixed range issues and erraneous comments

* Range check correctly for openArrays in opcLdArr

* Inverted logic for ldArr checking

* vm now supports slicing strings

* Added string tests

* Removed usage of 'nkOpenArray' and redundant operations

* Refactored vmSlice implementation, removing redundant and incorrect code

* Made tuples go throw opcWrObj for field assignment

* All strkinds should be considered for openarrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requires Araq To Merge PR should only be merged by Araq
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants