c: basic map implementation#337
Merged
Merged
Conversation
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds initial C-backend support for Bait map by introducing a builtin C map implementation and extending the C code generator to emit map types, literals, and for ... in iteration over maps.
Changes:
- Add
lib/builtin/map.c.btimplementing a basic open-addressing map with insertion-order key tracking andkeys(). - Extend the C generator to support map literals (
ast.MapInit), map type typedefs, andfor ... inover maps. - Adjust tests/CI to account for moved tests and to cover new
for-inandmap.keys()behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/other/bitwise_test.bt | Removes old location of unsigned-not test (moved). |
| tests/int/bitwise_test.bt | Moves unsigned-not test here; updates SPDX header. |
| tests/for/labels_test.bt | SPDX header update only. |
| tests/for/for_in_test.bt | SPDX header update; includes map iteration test used by C CI. |
| lib/hash/fnv1a/fnv1a.bt | SPDX header update only. |
| lib/builtin/tests/map_test.bt | Adds assertion for deterministic keys() ordering after insertion. |
| lib/builtin/map.c.bt | New C-backend builtin map implementation (hashing, set/get, rehash, keys). |
| lib/bait/gen/c/type.bt | Adds Map typedef emission for map instantiations; updates type-name sanitization. |
| lib/bait/gen/c/stmt.bt | Implements for ... in over maps in C backend via Map_keys. |
| lib/bait/gen/c/expr.bt | Implements C codegen for map literals; fixes map set cast to Map*. |
| lib/bait/gen/c/cgen.bt | Updates C identifier sanitization to handle [/] in type names. |
| .github/workflows/ci.yml | Runs tests/for/for_in_test.bt for C; enables lib/os; bitwise test run is commented out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.