| Crates.io | swamp-layout |
| lib.rs | swamp-layout |
| version | 0.0.2 |
| created_at | 2025-09-05 11:49:03.932412+00 |
| updated_at | 2025-09-22 09:59:46.038885+00 |
| description | Memory layout calculation for Swamp ABI types, handling size, alignment, and efficient representation of data structures |
| homepage | |
| repository | https://github.com/swamp/abi |
| max_upload_size | |
| id | 1825397 |
| size | 98,762 |
This crate is responsible for mapping high-level Swamp language types to their
low-level memory representations for the Swamp ABI. It serves as a
crucial bridge between the abstract type system defined in swamp-types and the
concrete memory layouts needed by the ABI.
The swamp-layout crate:
Computes memory layouts for all Swamp types, determining their size, alignment, and field offsets
Handles type lowering by mapping high-level types to their concrete memory representations
Manages memory layout deduplication for structurally identical types
Ensures proper alignment and memory padding according to Swamp ABI requirements (similar to C ABI, but with special handling for zero size structs)
LayoutCacheThe core structure that manages type layout information with two primary caches:
id_to_layout: Maps TypeId to BasicTypeRef, containing one entry per
unique TypeId
kind_to_layout: Maps TypeKind to BasicTypeRef, enabling sharing layouts
between structurally identical types
The crate provides specialized layout functions for different type categories:
This crate is primarily intended for use within the Swamp compiler toolchain and VM implementation, usually not for direct use by Swamp language users.
[dependencies]
swamp-layout = "0.0.1"
This project is licensed under the MIT License - see the LICENSE file for details.
We do not accept contributions. You are however welcome to:
Should you encounter bugs or have enhancement ideas, please don't hesitate to open an issue. While I'm unable to accept contributions, your insights are valuable to the project's improvement.
I appreciate your understanding and interest in this work. 🙏
Copyright (c) 2025 Peter Bjorklund. All rights reserved.