Skip to content

c: basic map implementation#337

Merged
serkonda7 merged 6 commits into
bait-lang:mainfrom
serkonda7:c-map-llm
Apr 28, 2026
Merged

c: basic map implementation#337
serkonda7 merged 6 commits into
bait-lang:mainfrom
serkonda7:c-map-llm

Conversation

@serkonda7

Copy link
Copy Markdown
Member

No description provided.

serkonda7 and others added 5 commits April 28, 2026 21:44
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.bt implementing a basic open-addressing map with insertion-order key tracking and keys().
  • Extend the C generator to support map literals (ast.MapInit), map type typedefs, and for ... in over maps.
  • Adjust tests/CI to account for moved tests and to cover new for-in and map.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.

Comment thread .github/workflows/ci.yml
Comment thread lib/bait/gen/c/expr.bt
Comment thread lib/bait/gen/c/type.bt Outdated
Comment thread lib/builtin/map.c.bt
@serkonda7 serkonda7 merged commit f738ffd into bait-lang:main Apr 28, 2026
3 checks passed
@serkonda7 serkonda7 deleted the c-map-llm branch April 28, 2026 22:18
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