Changeset 638


Ignore:
Timestamp:
May 11, 2011, 1:13:42 PM (7 years ago)
Author:
Sam Hocevar
Message:

lisp: fix a confusion in the `assoc' lisp implementation usage, and
make it a LList method to avoid future breakage.

Location:
abuse/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/chars.cpp

    r636 r638  
    337337    if (f==l_abil)
    338338    {
    339       LObject *l = CDR(CAR(field));
     339      LList *l = (LList *)CDR(CAR(field));
    340340      PtrRef r4(l);
    341341      for (i=0; i<TOTAL_ABILITIES; i++)
    342342      {
    343     Cell *ab = LSymbol::FindOrCreate(ability_names[i])->Assoc(l);
     343    Cell *ab = l->Assoc(LSymbol::FindOrCreate(ability_names[i]));
    344344    PtrRef r5(ab);
    345345    if (!NILP(ab))
     
    348348    } else if (f==l_funs)
    349349    {
    350       LObject *l = CDR(CAR(field));
     350      LList *l = (LList *)CDR(CAR(field));
    351351      PtrRef r4(l);
    352352      for (i=0; i<TOTAL_OFUNS; i++)
    353353      {
    354     Cell *ab = LSymbol::FindOrCreate(ofun_names[i])->Assoc(l);
     354    Cell *ab = l->Assoc(LSymbol::FindOrCreate(ofun_names[i]));
    355355    PtrRef r5(ab);
    356356    if (!NILP(ab) && lcar(lcdr(ab)))
     
    359359    } else if (f==l_flags)
    360360    {
    361       LObject *l = CDR(CAR(field));
     361      LList *l = (LList *)CDR(CAR(field));
    362362      PtrRef r4(l);
    363363      for (i=0; i<TOTAL_CFLAGS; i++)
    364364      {
    365365
    366     Cell *ab = LSymbol::FindOrCreate(cflag_names[i])->Assoc(l);
     366    Cell *ab = l->Assoc(LSymbol::FindOrCreate(cflag_names[i]));
    367367    PtrRef r5(ab);
    368368    if (!NILP(ab) && lcar(lcdr(ab))->Eval())
     
    457457
    458458
    459   Cell *mrph = l_morph->Assoc(desc);     // check for morph info
     459  Cell *mrph = desc->Assoc(l_morph);     // check for morph info
    460460  morph_power=0;
    461461  if (!NILP(mrph))
     
    466466  } else morph_mask=-1;
    467467
    468   Cell *sa = l_state_art->Assoc(desc);
     468  Cell *sa = desc->Assoc(l_state_art);
    469469  if (NILP(sa))
    470470  {
     
    485485  }
    486486
    487   Cell *range = l_range->Assoc(desc);
     487  Cell *range = desc->Assoc(l_range);
    488488  if (!NILP(range))
    489489  {
     
    499499
    500500
    501   Cell *mf = l_fields->Assoc(desc);
     501  Cell *mf = desc->Assoc(l_fields);
    502502  if (!NILP(mf))
    503503  {
     
    513513      if (find<0)
    514514      {
    515     lprint(l_fields->Assoc(desc));
     515    lprint(desc->Assoc(l_fields));
    516516    printf("fields : no such var name \"%s\"\n",name);
    517517    printf("current possiblities are : \n");
     
    530530
    531531
    532   Cell *lg = l_logo->Assoc(desc);
     532  Cell *lg = desc->Assoc(l_logo);
    533533  if (NILP(lg))
    534534  {
  • abuse/trunk/src/lisp/lisp.cpp

    r637 r638  
    846846}
    847847
    848 LObject *LObject::Assoc(LObject *item)
    849 {
    850     if (item_type(this) != L_CONS_CELL)
    851         return NULL;
    852 
    853     LObject *list = this;
    854     while (list)
     848LList *LList::Assoc(LObject *item)
     849{
     850    LList *list = this;
     851    while (list && item_type(list) == L_CONS_CELL
     852                && item_type(CAR(list)) == L_CONS_CELL)
    855853    {
    856854        if (lisp_eq(CAR(CAR(list)), item))
    857             return lcar(list);
    858         list = CDR(list);
     855            return (LList *)CAR(list);
     856        list = (LList *)CDR(list);
    859857    }
    860858
  • abuse/trunk/src/lisp/lisp.h

    r636 r638  
    6666    /* Methods */
    6767    LObject *Eval();
    68     LObject *Assoc(LObject *item);
    6968    void Print();
    7069
     
    8988    /* Methods */
    9089    size_t GetLength();
     90    LList *Assoc(LObject *item);
    9191
    9292    /* Members */
Note: See TracChangeset for help on using the changeset viewer.