Beispiel #1
0
static inline void 
unit_merge(malloc_unit_t *unit1, malloc_unit_t *unit2)
{
	DPRINTF("\n");
	unit_dump(unit1);
	DPRINTF("\n");
	unit_dump(unit2);
	unit1->next = unit2->next;
	unit1->size += sizeof(malloc_unit_t) + unit2->size;
	DPRINTF("\n");
	unit_dump(unit1);
}
Beispiel #2
0
// Affichage debug d'unité
void unit_dump(Unit *u) {

    Linked_list *ll = u->statements;
    debug_pr_lvl(), puts(">unit :");

    debug_pr_lvl(), puts("  statements : ");
    debug_lvl++;

    while(ll) {
        switch(ll->type) {
            case LLT_UNIT :
                unit_dump((Unit*)(ll->value));
                break;
            case LLT_OPERATION :
                op_dump((Operation*)(ll->value));
                break;
            case LLT_VARIABLE :
                var_dump((Variable*)(ll->value));
                break;
            case LLT_CONDITION :
                unit_cond_dump((Unit_conditional*)(ll->value));
                break;
            case LLT_LOOP :
                unit_loop_dump((Unit_loop*)(ll->value));
                break;
            default :
                debug_pr_lvl(), puts(">(error type statement)");
        }
        ll = ll->next;
    }

    debug_lvl--;
}
Beispiel #3
0
// Affichage debug variable
void var_dump(Variable *v) {
    debug_pr_lvl(), fputs(">variable", stdout);
    if(v) {
        if(v->container) fputs(" <attr>", stdout); else fputs(" <var>", stdout);
        if(v->name) printf(" '%s' :\n", v->name);
        else puts(" <anonymous> :");
        debug_pr_lvl(), printf("  name_h : %ld\n", (long unsigned)v->name_h);
        debug_pr_lvl(), printf("  type : %s\n", language_type_debug(v->type));
        debug_pr_lvl(),  fputs("  value : ", stdout);

        switch(v->type) {
            case T_TYPE:
                printf("%s\n", language_type_debug(v->value.v_type));
                break;
            case T_NUM:
                printf("%lf\n", v->value.v_num);
                break;
            case T_BOOL:
                v->value.v_bool ? puts("True") : puts("False");
                break;
            case T_NULL:
                puts("null");
                break;
            case T_NONEXISTENT:
                puts("non-existent");
                break;
            case T_LINKEDLIST:
                puts("linked list");
                // todo
                break;
            case T_FUNCTION_BUILTIN:
                puts("(compiled code)");
                break;
            case T_FUNCTION:
                puts("function : ");
                debug_lvl++;
                unit_dump(v->value.v_func);
                debug_lvl--;
                break;
            case T_OBJECT:
                puts("object : ");
                debug_lvl++;
                var_obj_dump(v->value.v_obj);
                debug_lvl--;
                break;
            case T_ARGS:
                puts("arguments : ");
                debug_lvl++;
                debug_pr_lvl(), puts("(todo)");
                //var_obj_dump(v->value.v_obj);
                debug_lvl--;
                break;
            default :
                puts("(Error type)");
        }
    } else
        debug_pr_lvl(), puts(" <null> : \n\t(null)");
}
Beispiel #4
0
void unit_loop_dump(Unit_loop *ul) {

    Linked_list* ll = ul->statements;

    debug_pr_lvl(), puts(">loop unit");
    debug_pr_lvl(), puts("  start statement :");
        if(ul->start_action) {
            debug_lvl++;
            op_dump(ul->start_action);
            debug_lvl--;
        } else
            debug_pr_lvl(), puts("  (none)");

    debug_pr_lvl(), puts("  start condition :");
        if(ul->start_condition) {
            debug_lvl++;
            op_dump(ul->start_condition);
            debug_lvl--;
        } else
            debug_pr_lvl(), puts("  (none)");

    debug_pr_lvl(), puts("  end condition :");
        if(ul->end_condition) {
            debug_lvl++;
            op_dump(ul->end_condition);
            debug_lvl--;
        } else
            debug_pr_lvl(), puts("  (none)");

    debug_pr_lvl(), puts("  statements : ");
    debug_lvl++;

    while(ll) {
        switch(ll->type) {
            case LLT_UNIT :
                unit_dump((Unit*)(ll->value));
                break;
            case LLT_OPERATION :
                op_dump((Operation*)(ll->value));
                break;
            case LLT_VARIABLE :
                var_dump((Variable*)(ll->value));
                break;
            case LLT_CONDITION :
                unit_cond_dump((Unit_conditional*)(ll->value));
                break;
            case LLT_LOOP :
                // a faire
                break;
            default :
                debug_pr_lvl(), puts(">(error type statement)");
        }
        ll = ll->next;
    }

    debug_lvl--;
}
Beispiel #5
0
void 
malloc_dump(void)
{
	malloc_unit_t *unit = unit_list_head;
	do
	{
		DPRINTF("\n");
		unit_dump(unit);
	} while ((unit = unit->next));
}
Beispiel #6
0
size_t
memory_init(void)
{
	DPRINTF("memory_head:%p\n", md_memory_head());
	DPRINTF("memory_tail:%p\n", md_memory_tail());
	unit_list_head = (malloc_unit_t *)md_memory_head();
#ifdef DEBUG
	unit_list_head->magic = 0xdeadbeef;
#endif
	unit_list_head->next = 0;
	unit_list_head->prev = 0;
        unit_list_head->size = md_memory_tail() - (char *)unit_list_head - sizeof(malloc_unit_t);
	unit_list_head->allocated = false;
	DPRINTF("\n");
	unit_dump(unit_list_head);
	return unit_list_head->size;
}