summaryrefslogtreecommitdiff
path: root/src/ir/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/layout.rs')
-rw-r--r--src/ir/layout.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ir/layout.rs b/src/ir/layout.rs
new file mode 100644
index 00000000..d672ebea
--- /dev/null
+++ b/src/ir/layout.rs
@@ -0,0 +1,26 @@
+
+/// A type that represents the struct layout of a type.
+#[derive(Debug, Clone, Copy)]
+pub struct Layout {
+ pub size: usize,
+ pub align: usize,
+ pub packed: bool,
+}
+
+impl Layout {
+ pub fn new(size: usize, align: usize) -> Self {
+ Layout {
+ size: size,
+ align: align,
+ packed: false,
+ }
+ }
+
+ pub fn is_zero(&self) -> bool {
+ self.size == 0 && self.align == 0
+ }
+
+ pub fn zero() -> Self {
+ Self::new(0, 0)
+ }
+}