From 7e1a78361df3c82c8583796fa94905215b103646 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Thu, 22 Aug 2019 21:57:24 -0400 Subject: generating function declarations & definitions --- blocks.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 blocks.c (limited to 'blocks.c') diff --git a/blocks.c b/blocks.c deleted file mode 100644 index 5c06a6e..0000000 --- a/blocks.c +++ /dev/null @@ -1,49 +0,0 @@ -/* identifies identifiers in this block */ -static bool block_enter(Block *b) { - bool ret = true; - arr_foreach(&b->stmts, Statement, stmt) { - if (stmt->kind == STMT_DECL) { - Declaration *decl = &stmt->decl; - arr_foreach(&decl->idents, Identifier, ident) { - Array *decls = &(*ident)->decls; - if (decls->item_sz) { - /* check that it hasn't been declared in this block */ - IdentDecl *prev = decls->last; - if (prev->scope == b) { - err_print(decl->where, "Re-declaration of identifier in the same block."); - info_print(prev->decl->where, "Previous declaration was here."); - ret = false; - continue; - } - } else { - /* array not initialized yet */ - arr_create(&(*ident)->decls, sizeof(IdentDecl)); - } - IdentDecl *ident_decl = arr_add(decls); - ident_decl->decl = decl; - ident_decl->scope = b; - } - } - } - return ret; -} - -/* de-identifies identifiers in this block */ -static bool block_exit(Block *b) { - /* OPTIM: figure out some way of not re-iterating over everything */ - bool ret = true; - arr_foreach(&b->stmts, Statement, stmt) { - if (stmt->kind == STMT_DECL) { - Declaration *decl = &stmt->decl; - arr_foreach(&decl->idents, Identifier, ident) { - Array *decls = &(*ident)->decls; - assert(decls->item_sz); - IdentDecl *last_decl = decls->last; - if (last_decl->scope == b) - arr_remove_last(decls); /* remove that declaration */ - - } - } - } - return ret; -} -- cgit v1.2.3