summaryrefslogtreecommitdiff
path: root/toc.c
diff options
context:
space:
mode:
Diffstat (limited to 'toc.c')
-rw-r--r--toc.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/toc.c b/toc.c
index cb01b34..152c6d7 100644
--- a/toc.c
+++ b/toc.c
@@ -4,7 +4,38 @@
You should have received a copy of the GNU General Public License along with toc. If not, see <https://www.gnu.org/licenses/>.
*/
-/* NOTE: all stages should use the same allocator! */
+
+/*
+ NOTE:
+ Structure of the toc compiler:
+ tokenizer => parser => typing (types.c) => cgen
+ (lexing)
+
+ toc tries to continue even after the first error.
+ It will not continue during cgen, but it will during tokenization,
+ parsing, and typing. If one stage fails, the following ones do not
+ start.
+
+ toc's memory management works using an allocator which never frees anything.
+ This is because most of toc's data is kept around until the end of the program anyways.
+ Use the allocator for "permanent" allocations, and err_malloc/calloc/realloc for temporary
+ allocations (to avoid having it take up space for a long time).
+
+ Because of this, memory leaks can happen if the compilation fails at any point, but they
+ should not happen if the compilation succeeds. Usually if there's an error
+ which causes a memory leak, it will be very small.
+
+ Functions which can fail (i.e. print an error message and stop) return a Status,
+ which is a bool, but GCC warns about not using the return value.
+
+ The fixed-width types U8/16/32/64 and I8/16/32/64 have been defined.
+ data_structures.c contains a dynamic array implementation which is very useful.
+ Many of the members of the types below are dynamic arrays.
+
+ It is assumed that the number of identifiers in a declaration, or parameters to a function
+ will fit in an int, since a function with (at least) 32768 parameters is ridiculous.
+*/
+
/* Includes all of toc's files */
#include <assert.h>
@@ -70,7 +101,6 @@ static void print_block_location(Block *b);
#define join3(a,b) a##b
#define join2(a,b) join3(a,b)
#define join(a,b) join2(a,b)
-#define eval(x) x
static void fprint_char_literal(FILE *f, char c) {
if (isprint(c))
@@ -137,7 +167,7 @@ static char *read_file_contents(Allocator *a, const char *filename, Location whe
#include "infer.c"
#include "types.c"
static bool cgen_decls_file(CGenerator *g, ParsedFile *f);
-static bool cgen_sdecls_file(CGenerator *g, ParsedFile *f);
+static void cgen_sdecls_file(CGenerator *g, ParsedFile *f);
#include "cgen.c"
#include "sdecls_cgen.c"
#include "decls_cgen.c"