Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Boxes#12

Merged
fergalwalsh merged 6 commits into
mainfrom
boxes
Jan 12, 2023
Merged

Boxes#12
fergalwalsh merged 6 commits into
mainfrom
boxes

Conversation

@fergalwalsh

Copy link
Copy Markdown
Collaborator

This PR adds high level support for Boxes with a new box<struct> type and some functions for creating/opening boxes.

Where Item is a previously defined struct:

box<Item> item1 = CreateBox("a") # asserts box does not already exist
box<Item> item1 = OpenBox("a")   # asserts box does already exist and has the correct size for the struct
box<Item> item1 = Box("a")       # makes no assertions about the box

Example:

struct Item:
    id: int
    foo: int
    name: bytes[10]
end

box<Item> item1 = CreateBox("a")

item1.id = 1
item1.foo = 111
item1.name = "xyz"

log(itob(item1.foo))

See the included example for more details.

Box field assignments use box_replace while box field access uses box_extract to ensure support for large boxes - the total box size can be up to the 32K bytes limit but individual fields can be up to 4096 to allow them to fit on the stack. Future enhancements to Tealish may add support for arrays and nested structs. It would then be possible to have larger fields if only portions were assigned/accessed.

Note: This PR also includes an update to the langspec.json to sync with go-algorand/master including avm8 opcodes.

@fergalwalsh fergalwalsh changed the base branch from structs to main November 23, 2022 16:29
@aorumbayev

Copy link
Copy Markdown
Contributor

Curious to know when this is planning to be merged :-) @fergalwalsh

@fergalwalsh

Copy link
Copy Markdown
Collaborator Author

Curious to know when this is planning to be merged :-) @fergalwalsh

Was just waiting for me to get some time for docs & tests. I have added these now so I think it is good to merge.

@fergalwalsh fergalwalsh merged commit 73b9593 into main Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants