Beispiel #1
0
void ClearAllGC()
{
    unsigned int index;
    /* contexts */
    for (index = 0;
         index < gGCManager.ctx_size;
         index++)
    {
        CONTEXT* context = gGCManager.contexts[index];
        ClearContext(context);
    }

    /* functions */
    for (index = 0;
         index < gGCManager.func_size;
         index++)
    {
        FUNCTION* function = gGCManager.functions[index];
        ClearFunction(function);
    }

    /* dictionaries */
    for (index = 0;
         index < gGCManager.table_size;
         index++)
    {
        HASH_TABLE* table = gGCManager.tables[index];
        ClearDictionary(table);
    }

    /* strings */
    for (index = 0;
         index < gGCManager.str_size;
         index++)
    {
        char* string = gGCManager.strings[index];
        ClearString(string);
    }

    /* parse tree */
    AST_STORE *cur_ast, *next_ast;
    cur_ast = gGCManager.parseTrees;
    while (cur_ast) {
        next_ast = cur_ast->next;
        FreeParseTree(cur_ast->parseTree);
        free(cur_ast);
        cur_ast = next_ast;
    }

    /* lexings */
    LEXING_STORE *cur_lex, *next_lex;
    cur_lex = gGCManager.lexings;
    while (cur_lex) {
        next_lex = cur_lex->next;
        FreeLexing(cur_lex->tokens, cur_lex->buffer);
        free(cur_lex);
        cur_lex = next_lex;
    }
}
void
JXExprWidget::JXExprEditorX()
{
	// required by JXGetCurrColormap
	assert( GetWindow()->GetColormap() == GetDisplay()->GetColormap() );

	// insure that we have a JFunction to display
	// (also calls EIPBoundsChanged and EIPAdjustNeedTab)

	ClearFunction();
	EIPDeactivate();
}
void
JXExprEditor::JXExprEditorX()
{
	// required by JXGetCurrColormap
	assert( (GetWindow())->GetColormap() == (GetDisplay())->GetColormap() );

	itsEPSPrinter = new JXEPSPrinter(GetDisplay());
	assert( itsEPSPrinter != NULL );
	ListenTo(itsEPSPrinter);

	// insure that we have a JFunction to display
	// (also calls EIPBoundsChanged and EIPAdjustNeedTab)

	ClearFunction();
}
Beispiel #4
0
void CallGCTraceRoot(CONTEXT* root,
                     VALUE    curExpr)
{
    //printf("RUNNING GARBAGE COLLECTOR\n");
    //printf(".");

    GC_DATA_MANAGEMENT  managed;
    unsigned int index;

    managed = InitGC(/*managed*/);

    GCAddValue(curExpr, &managed);
//    CallGCRecurseContext(root, &managed);
    CallGCRecurseContext(gCurrentContext, &managed);

    CONTEXT_STACK* stack = gExecutionStack;
    while (stack) {
        CallGCRecurseContext(stack->context, &managed);
        stack = stack->next;
    }
    //CallGCRecurseContext(gGlobalContext, &managed);

    // find elements in gGCManager that are not
    // members of gc managed
    // then remove those elements and free()
    // their memory
    
    /* contexts */
    for (index = 0;
         index < gGCManager.ctx_size;
         index++)
    {
        CONTEXT* context = gGCManager.contexts[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.contexts,
                                    managed.ctx_size,
                                    (void*)context))
        {
            ClearContext(context);
            gGCManager.contexts[index] = NULL;
            gGCManager.contexts[index] = gGCManager.contexts[gGCManager.ctx_size-1];
            gGCManager.ctx_size--;
            index--;
        }
    }

    /* functions */
    for (index = 0;
         index < gGCManager.func_size;
         index++)
    {
        FUNCTION* function = gGCManager.functions[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.functions,
                                    managed.func_size,
                                    (void*)function))
        {
            ClearFunction(function);
            gGCManager.functions[index] = NULL;
            gGCManager.functions[index] = gGCManager.functions[gGCManager.func_size-1];
            gGCManager.func_size--;
            index--;
        }
    }

    /* dictionaries */
    for (index = 0;
         index < gGCManager.table_size;
         index++)
    {
        HASH_TABLE* table = gGCManager.tables[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.tables,
                                    managed.table_size,
                                    (void*)table))
        {
            ClearDictionary(table);
            gGCManager.tables[index] = NULL;
            gGCManager.tables[index] = gGCManager.tables[gGCManager.table_size-1];
            gGCManager.table_size--;
            index--;
        }
    }

    /* strings */
    for (index = 0;
         index < gGCManager.str_size;
         index++)
    {
        char* string = gGCManager.strings[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.strings,
                                    managed.str_size,
                                    (void*)string))
        {
            ClearString(string);
            gGCManager.strings[index] = NULL;
            gGCManager.strings[index] = gGCManager.strings[gGCManager.str_size-1];
            gGCManager.str_size--;
            index--;
        }
    }

    FreeGCMgmtObject(managed);
}