Changeset a04a05 in git for Singular/newstruct.cc


Ignore:
Timestamp:
Aug 1, 2012, 11:29:10 PM (11 years ago)
Author:
Alexander Dreyer <alexander.dreyer@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '1d362c315e551a5b527ab0759f8839cf0e94f3a5')
Children:
29fc84389b9713cdf07cc538bad5becf4758553e
Parents:
5ebd4bcf7ead1b205b12afeec0793f8bc29e16ec
Message:
chg: encapsulating newstruct's overloaded '=' and use in pyobject
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/newstruct.cc

    r5ebd4bc ra04a05  
    134134}
    135135
     136// Used by newstruct_Assign for overloaded '='
     137BOOLEAN newstruct_equal(int op, leftv l, leftv r)
     138{
     139  blackbox *ll=getBlackboxStuff(op);
     140  assume(ll->data != NULL);
     141  newstruct_desc nt=(newstruct_desc)ll->data;
     142  newstruct_proc p=nt->procs;
     143 
     144  while( (p!=NULL) && ((p->t!='=')||(p->args!=1)) ) p=p->next;
     145
     146  if (p!=NULL)
     147  {
     148    idrec hh;
     149    memset(&hh,0,sizeof(hh));
     150    hh.id=Tok2Cmdname(p->t);
     151    hh.typ=PROC_CMD;
     152    hh.data.pinf=p->p;
     153    sleftv tmp;
     154    memset(&tmp,0,sizeof(sleftv));
     155    tmp.Copy(r);
     156    leftv sl = iiMake_proc(&hh, NULL, &tmp);
     157    if (sl != NULL)
     158    {
     159      if (sl->Typ() == op) { l->Copy(sl); return FALSE;}
     160      else sl->CleanUp();
     161    }
     162  }
     163  return TRUE;
     164}
     165
    136166BOOLEAN newstruct_Assign(leftv l, leftv r)
    137167{
     
    193223  else if(l->Typ() > MAX_TOK)
    194224  {
    195     blackbox *ll=getBlackboxStuff(l->Typ());
    196     newstruct_desc nt=(newstruct_desc)ll->data;
    197     newstruct_proc p=nt->procs;
    198 
    199     while( (p!=NULL) && ((p->t!='=')||(p->args!=1)) ) p=p->next;
    200 
    201     if (p!=NULL)
    202     {
    203       idrec hh;
    204       memset(&hh,0,sizeof(hh));
    205       hh.id=Tok2Cmdname(p->t);
    206       hh.typ=PROC_CMD;
    207       hh.data.pinf=p->p;
    208       sleftv tmp;
    209       memset(&tmp,0,sizeof(sleftv));
    210       tmp.Copy(r);
    211       leftv sl = iiMake_proc(&hh, NULL, &tmp);
    212       if (sl != NULL)
    213       {
    214         if (sl->Typ()==l->Typ()) return newstruct_Assign(l, sl);
    215         else sl->CleanUp();
    216       }
    217     }
     225    assume(l->Typ() > MAX_TOK);
     226    sleftv tmp;
     227    if(!newstruct_equal(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
    218228  }
    219229  Werror("assign %s(%d) = %s(%d)",
Note: See TracChangeset for help on using the changeset viewer.