diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-02 02:34:19 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-02 02:34:19 -0500 |
| commit | ae3638402a41f1c75f59aa1da923d6f7ffd058ac (patch) | |
| tree | d1f985eb73ce3def8aa3caa6220687af71a4d125 /src/ast.c | |
| parent | Modify how types are stored. (diff) | |
| download | cup-ae3638402a41f1c75f59aa1da923d6f7ffd058ac.tar.xz cup-ae3638402a41f1c75f59aa1da923d6f7ffd058ac.zip | |
Add `size_for_type()` helper instead of hard-coding variable sizes
Diffstat (limited to 'src/ast.c')
| -rw-r--r-- | src/ast.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -55,6 +55,16 @@ char *data_type_to_str(DataType type) } } +i64 size_for_type(Type *type) +{ + switch (type->type) + { + case TYPE_INT: return 8; + case TYPE_PTR: return 8; + default: assert(false && "Unreachable type"); + } +} + Type *type_new(DataType type) { Type *t = calloc(sizeof(Type), 1); |