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

String slices #4778

Closed
wants to merge 1 commit into from
Closed

String slices #4778

wants to merge 1 commit into from

Conversation

IGI-111
Copy link
Contributor

@IGI-111 IGI-111 commented Jul 9, 2023

Description

This change formalizes the str type to represent string data using string slices.

String literals now evaluate to dynamically sized string slices that contain a pointer to what used to the packed data representation and a length.

The standard library String and Bytes have had their interface changed to interact with strs idiomatically.

The __size_of_str intrinsic is removed as it is no longer needed.

Types and functions that carry the literal data for the string in IR generation have been renamed from String to StringData to avoid confusion.

Part of #4375

Fixes #1060

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@IGI-111 IGI-111 added lib: std Standard library compiler: ir IRgen and sway-ir including optimization passes language feature Core language features visible to end users breaking May cause existing user code to break. Requires a minor or major release. lib: core Core library compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser labels Jul 9, 2023
@IGI-111 IGI-111 requested a review from a team July 9, 2023 05:13
@IGI-111 IGI-111 marked this pull request as draft July 9, 2023 05:59
@IGI-111 IGI-111 self-assigned this Jul 9, 2023
@IGI-111 IGI-111 force-pushed the IGI-111/str branch 14 times, most recently from d6a9250 to ecd562a Compare July 14, 2023 16:09
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778

This also changes the way slices are coded in general by adding
a data section their pointer value indexes into.
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778

This also changes the way slices are coded in general by adding an explicit data section.
Dynamic data pointers are now always relative to the start of the data section, similar to Solidity's ABI spec.
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778

This also changes the way slices are coded in general by adding an explicit data section.
Dynamic data pointers are now always relative to the start of the data section, similar to Solidity's ABI spec.
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
@IGI-111 IGI-111 force-pushed the IGI-111/str branch 2 times, most recently from 42784c0 to e791811 Compare July 17, 2023 11:45
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 17, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 18, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 18, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
@anton-trunov
Copy link
Contributor

This issue looks like a related one: #1060

IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 20, 2023
Add support for `str` in prevision for FuelLabs/sway#4778
IGI-111 added a commit to FuelLabs/fuels-rs that referenced this pull request Jul 21, 2023
Add support for `str` in prevision for
FuelLabs/sway#4778


### Checklist
- [x] I have linked to any relevant issues.
- [x] I have updated the documentation.
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added necessary labels.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: hal3e <git@hal3e.io>
@IGI-111 IGI-111 force-pushed the IGI-111/str branch 4 times, most recently from 9c73736 to 38ba68f Compare August 10, 2023 07:26
@IGI-111 IGI-111 force-pushed the IGI-111/str branch 2 times, most recently from db1d75a to c1c8d76 Compare August 15, 2023 15:13
This change formalizes the `str` type to represent string data using
string slices.

String literals now evaluate to dynamically sized string slices
that contain a pointer to what used to the packed data representation
and a length.

The standard library `String` and `Bytes` have had their interface
changed to interact with `str`s idiomatically.

The `__size_of_str` intrinsic is removed as it is no longer needed.

Types and functions that carry the literal data for the string in IR
generation have been renamed from `String` to `StringData` to avoid
confusion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking May cause existing user code to break. Requires a minor or major release. compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: ir IRgen and sway-ir including optimization passes compiler: parser Everything to do with the parser language feature Core language features visible to end users lib: core Core library lib: std Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change str types to _not_ explicitly include the size.
3 participants