From 1a8f96c65f94227faa9747ef876a60f3c313c6f1 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Wed, 2 Feb 2022 07:20:53 -0500 Subject: Type checking of expressions / functions! This is a bit of a chonky commit, but it adds in the basics of checking the types of expressions / function calls / return types. There's still a lot of work to be done, including: (1) Adding new core types, and casting between allowed types automatically (2) Picking the corrent output type based on input types (for instance float+int == float) (3) We need much better error reporting, the error messages are really vague and unhelpful as-is (4) We also need to work to ensure that a function with a return type actually returns (5) Possible re-factoring to make stuff less hacky when we have more types / structs / arrays / etc. --- src/utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index dfc018c..7718c1c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -9,4 +9,7 @@ void _die_location(char *file, int line, Location loc, const char *fmt, ...); i64 i64max(i64 a, i64 b); i64 i64min(i64 a, i64 b); +// Assumes alignment is a power of 2 +i64 align_up(i64 val, i64 align); + #define die_location(loc, ...) _die_location(__FILE__, __LINE__, loc, __VA_ARGS__) \ No newline at end of file -- cgit v1.2.3