4 ms·
Just a few small suggestions: 1. Some code seems to be duplicated (although with slightly different formatting) across multiple files, like dd/dw/db in elf.c a
by thamer 5y ago
Just a few small suggestions:
1. Some code seems to be duplicated (although with slightly different formatting) across multiple files, like dd/dw/db in elf.c and x86.c for example. I'd suggest consolidating those.
2. It helps to define types when you have variables that can take a limited set of possible values; typedef works but enums are better. I'm thinking of variables like the `type` parameter to `primitive_data_type_size`, for example. The compiler can help you detect a missing case statement if you use an enum, but not an int.
3. It's a matter of preference, but typedef'ing your structs can make your code more concise and not have it littered with struct keywords.
4. You seem to have a mix of tabs and spaces in some files (e.g. in `elf.c`). I would recommend configuring your editor to use just one of the two or it'll start to be an issue as your code base grows.
5. On a related point, I'd suggest picking a formatting style and sticking to it. You have functions like `accept` in `ast.c` declared without spaces after the opening `(` and others like `read_file` in the same file that has spaces.
Good luck! This is a great way to learn.