gen: use voidptr key methods: map_get_1, map_set_1, map_get_and_set_1 #7390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #6991.
Use 3 of the voidptr key map methods added in #7377 in cgen and gen/json.v.
Add a test for map equality.
Use a pointer receiver for map methods
get_1
andexists_1
for efficiency.This change breaks a case in a test where indexing a map rvalue (e.g. result of a function producing a map) did work, but in several other cases this did not work anyway. I tried to keep support for that case but it seems too awkward to do in this pull.Update: I've fixed that case.
Also add a cgen macro ADDR to take the address of an rvalue. This helps keep code readable and makes it easy to support rvalue references without having to remember the C99 trick.