Exemple #1
0
EEL_symbol *eel_finder_go(EEL_finder *f)
{
	EEL_symbol *hit = NULL;
	if(!f->symtab)
		return NULL;
	DBG3(printf("Searching for '%s' in '%s'...\n",
			f->name ? eel_o2s(f->name) : "<unnamed symbols>",
			f->symtab->name ? eel_o2s(f->symtab->name) :
			"<unnamed symbol table>");)
	while(!hit)
Exemple #2
0
/*
 * The real destructor!
 * We can't install this as a normal destructor, since we abuse
 * the module 'destruct' metamethod for module GC triggering.
 */
static EEL_xno m_real_destruct(EEL_object *eo)
{
	EEL_vm *vm = eo->vm;
	int i;
	EEL_xno x;
	EEL_module *m = o2EEL_module(eo);
	EEL_object_p_da *o = &m->objects;
#ifdef	EEL_PROFILING
	const char *modname = eel_table_getss(m->exports, "__modname");
#endif
	if(m->unload)
	{
		x = (m->unload)(eo, VMP->is_closing);
		if(x && !VMP->is_closing)
			return x;
	}

	if(m->refsum != -1)
	{
		int refs = eel_module_countref(eo);
		if(refs != m->refsum)
		{
#if DBG12(1)+0 == 1
			if(m->exports)
				fprintf(stderr, "Module %s refused to destruct! "
						"Refsum: %d  Recorded: %d\n",
						eel_table_getss(m->exports, "__modname"),
						refs, m->refsum);
			else
				fprintf(stderr, "Module %p refused to destruct! "
						"Refsum: %d  Recorded: %d\n",
						eo, refs, m->refsum);
#endif
			return EEL_XREFUSE;
		}
	}

#ifdef	EEL_PROFILING
	for(i = 0; i < o->size; ++i)
	{
		EEL_function *f;
		if(o->array[i]->type != EEL_CFUNCTION)
			continue;
		f = o2EEL_function(o->array[i]);
		if(!f->common.ccount)
			continue;
		printf("%s\t%s\t%ld\t%d\t%f\n",
		       		modname,
				eel_o2s(f->common.name),
				f->common.rtime,
				f->common.ccount,
				(double)f->common.rtime / f->common.ccount);
	}
#endif
	DBG1(if(m->exports)
		printf("Unloading module \"%s\". (ID %d)\n",
				eel_table_getss(m->exports, "__modname"), m->id);)