Ignore:
Timestamp:
May 11, 2011, 1:26:15 AM (11 years ago)
Author:
Sam Hocevar
Message:

lisp: merge the Lisp and LispGC classes and improve coding style.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r635 r636  
    4141static uint8_t *cstart, *cend, *collected_start, *collected_end;
    4242
    43 LArray *LispGC::CollectArray(LArray *x)
    44 {
    45     size_t s = x->len;
     43LArray *Lisp::CollectArray(LArray *x)
     44{
     45    size_t s = x->m_len;
    4646    LArray *a = LArray::Create(s, NULL);
    4747    LObject **src = x->GetData();
     
    5353}
    5454
    55 LList *LispGC::CollectList(LList *x)
     55LList *Lisp::CollectList(LList *x)
    5656{
    5757    LList *prev = NULL, *first = NULL;
     
    6060    {
    6161        LList *p = LList::Create();
    62         LObject *old_car = x->car;
     62        LObject *old_car = x->m_car;
    6363        LObject *old_x = x;
    6464        x = (LList *)CDR(x);
    65         ((LRedirect *)old_x)->type = L_COLLECTED_OBJECT;
    66         ((LRedirect *)old_x)->ref = p;
    67 
    68         p->car = CollectObject(old_car);
     65        ((LRedirect *)old_x)->m_type = L_COLLECTED_OBJECT;
     66        ((LRedirect *)old_x)->m_ref = p;
     67
     68        p->m_car = CollectObject(old_car);
    6969
    7070        if (prev)
    71             prev->cdr = p;
     71            prev->m_cdr = p;
    7272        else
    7373            first = p;
     
    7575    }
    7676    if (x)
    77         prev->cdr = CollectObject(x);
     77        prev->m_cdr = CollectObject(x);
    7878
    7979    return first; // we already set the collection pointers
    8080}
    8181
    82 LObject *LispGC::CollectObject(LObject *x)
     82LObject *Lisp::CollectObject(LObject *x)
    8383{
    8484    LObject *ret = x;
     
    9292            break;
    9393        case L_NUMBER:
    94             ret = LNumber::Create(((LNumber *)x)->num);
     94            ret = LNumber::Create(((LNumber *)x)->m_num);
    9595            break;
    9696        case L_SYS_FUNCTION:
     
    111111            break;
    112112        case L_CHARACTER:
    113             ret = LChar::Create(lcharacter_value(x));
     113            ret = LChar::Create(((LChar *)x)->m_ch);
    114114            break;
    115115        case L_C_FUNCTION:
     
    141141            break;
    142142        case L_OBJECT_VAR:
    143             ret = LObjectVar::Create(((LObjectVar *)x)->index);
     143            ret = LObjectVar::Create(((LObjectVar *)x)->m_index);
    144144            break;
    145145        case L_COLLECTED_OBJECT:
    146             ret = ((LRedirect *)x)->ref;
     146            ret = ((LRedirect *)x)->m_ref;
    147147            break;
    148148        default:
     
    150150            break;
    151151        }
    152         ((LRedirect *)x)->type = L_COLLECTED_OBJECT;
    153         ((LRedirect *)x)->ref = ret;
     152        ((LRedirect *)x)->m_type = L_COLLECTED_OBJECT;
     153        ((LRedirect *)x)->m_ref = ret;
    154154    }
    155155    else if ((uint8_t *)x < collected_start || (uint8_t *)x >= collected_end)
     
    172172}
    173173
    174 void LispGC::CollectSymbols(LSymbol *root)
     174void Lisp::CollectSymbols(LSymbol *root)
    175175{
    176176    if (!root)
    177177        return;
    178178
    179     root->value = CollectObject(root->value);
    180     root->function = CollectObject(root->function);
    181     root->name = (LString *)CollectObject(root->name);
    182     CollectSymbols(root->left);
    183     CollectSymbols(root->right);
    184 }
    185 
    186 void LispGC::CollectStacks()
     179    root->m_value = CollectObject(root->m_value);
     180    root->m_function = CollectObject(root->m_function);
     181    root->m_name = (LString *)CollectObject(root->m_name);
     182    CollectSymbols(root->m_left);
     183    CollectSymbols(root->m_right);
     184}
     185
     186void Lisp::CollectStacks()
    187187{
    188188    void **d = l_user_stack.sdata;
     
    205205}
    206206
    207 void LispGC::CollectSpace(LSpace *which_space, int grow)
     207void Lisp::CollectSpace(LSpace *which_space, int grow)
    208208{
    209209    LSpace *old_space = LSpace::Current;
Note: See TracChangeset for help on using the changeset viewer.