Beispiel #1
0
int GCAddValue(VALUE value,
                GC_DATA_MANAGEMENT* gc) 
{
    if (value.type == VAL_STRING &&
        value.const_string == 0 &&
        value.data.string)
    {
        return GCAddString((char*)value.data.string, gc);
    }
    else if (value.type == VAL_REFERENCE &&
             value.data.reference)
    {
        return GCAddContext(value.data.reference, gc);
    }
    else if (value.type == VAL_FUNCTION &&
             value.data.function)
    {
        return GCAddFunction(value.data.function, gc);
    }
    else if (value.type == VAL_DICTIONARY &&
             value.data.dictionary)
    {
        return GCAddDictionary(value.data.dictionary, gc);
    }
    return 0;
}
Beispiel #2
0
int CallGCRecurseFunction(FUNCTION* function, 
                          GC_DATA_MANAGEMENT* managed)
{
    int result = 0;
    if (function && GCAddFunction(function, managed)) 
    {
        result = 1;
        
        CallGCRecurseContext(function->closure, managed);
    }
    return result;
}
Beispiel #3
0
VALUE CreateFunction(int (*function)(int, void*))
{
    VALUE record;
    record.type = VAL_FUNCTION;
    record.data.function = (FUNCTION*)ALLOC(sizeof(FUNCTION));
    record.data.function->parameters = NULL; // ??
    record.data.function->body = NULL;
    record.data.function->closure = gCurrentContext;
    record.data.function->built_in = 1;
    record.data.function->functor = function;
    record.data.function->ref_count = -1;
  //record.data.function->fn_name = "[built-in]";
    record.data.function->fn_name = "function";
    record.data.function->func_data = NULL;

    GCAddFunction(record.data.function, &gGCManager);

    return record;
}