void codegen_local_lifetime_end(compile_t* c, const char* name) { compile_frame_t* frame = c->frame; compile_local_t k; k.name = name; size_t index = HASHMAP_UNKNOWN; while(frame != NULL) { compile_local_t* p = compile_locals_get(&frame->locals, &k, &index); if(p != NULL && p->alive) { gencall_lifetime_end(c, p->alloca); p->alive = false; return; } if(frame->is_function) return; frame = frame->prev; } }
LLVMValueRef codegen_getlocal(compile_t* c, const char* name) { compile_frame_t* frame = c->frame; compile_local_t k; k.name = name; while(frame != NULL) { compile_local_t* p = compile_locals_get(&frame->locals, &k); if(p != NULL) return p->alloca; if(frame->is_function) return NULL; frame = frame->prev; } return NULL; }