Changeset 4a74cc in git for Singular/ipassign.cc


Ignore:
Timestamp:
Feb 5, 2015, 12:10:11 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
Children:
f5125c661ffed4886fe8c7ca685ccd0c38cbaa80
Parents:
aca790a522d4e3aedfed1659704188800436fcee
Message:
add: check (for lvalue) in assignment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipassign.cc

    raca790 r4a74cc  
    950950* assign a = b
    951951*/
    952 static BOOLEAN jiAssign_1(leftv l, leftv r)
     952static BOOLEAN jiAssign_1(leftv l, leftv r, BOOLEAN toplevel)
    953953{
    954954  int rt=r->Typ();
     
    960960
    961961  int lt=l->Typ();
    962   if (/*(*/ lt==0 /*)*/) /*&&(l->name!=NULL)*/
     962  if (lt==0)
    963963  {
    964964    if (!errorreported) Werror("left side `%s` is undefined",l->Fullname());
     
    10091009  }
    10101010  leftv ld=l;
    1011   if ((l->rtyp==IDHDL)&&(lt!=QRING_CMD)&&(lt!=RING_CMD))
    1012     ld=(leftv)l->data;
     1011  if (l->rtyp==IDHDL)
     1012  {
     1013    if ((lt!=QRING_CMD)&&(lt!=RING_CMD))
     1014      ld=(leftv)l->data;
     1015  }
     1016  else if (toplevel)
     1017  {
     1018    WerrorS("error in assign: left side is not an l-value");
     1019    return TRUE;
     1020  }
    10131021  if (lt>MAX_TOK)
    10141022  {
     
    11931201    h=l->next;
    11941202    l->next=NULL;
    1195     nok=jiAssign_1(l,&t);
     1203    nok=jiAssign_1(l,&t,TRUE);
    11961204    l->next=h;
    11971205    if (nok) return TRUE;
     
    12271235    h=l->next;
    12281236    l->next=NULL;
    1229     nok=jiAssign_1(l,&t);
     1237    nok=jiAssign_1(l,&t,TRUE);
    12301238    l->next=h;
    12311239    t.CleanUp();
     
    14651473      idhdl hh=NULL;
    14661474      if ((l->rtyp==IDHDL)&&(l->Typ()==DEF_CMD)) hh=(idhdl)l->data;
    1467       nok=jiAssign_1(l,&t);
     1475      nok=jiAssign_1(l,&t,TRUE);
    14681476      if (hh!=NULL) { ipMoveId(hh);hh=NULL;}
    14691477      l->next=h;
     
    15411549    h=l->next;
    15421550    l->next=NULL;
    1543     nok=jiAssign_1(l,&t);
     1551    nok=jiAssign_1(l,&t,TRUE);
    15441552    if (nok)
    15451553    {
     
    15991607    memset(&tmp,0,sizeof(sleftv));
    16001608    tmp.rtyp=DEF_CMD;
    1601     b=iiAssign(&tmp,r);
     1609    b=iiAssign(&tmp,r,FALSE);
    16021610    ld->CleanUp();
    16031611    memcpy(ld,&tmp,sizeof(sleftv));
     
    16111619    tmp.rtyp=r->Typ();
    16121620    tmp.data=(char*)idrecDataInit(r->Typ());
    1613     b=iiAssign(&tmp,r);
     1621    b=iiAssign(&tmp,r,FALSE);
    16141622    ld->CleanUp();
    16151623    memcpy(ld,&tmp,sizeof(sleftv));
     
    16171625  else
    16181626  {
    1619     b=iiAssign(ld,r);
     1627    b=iiAssign(ld,r,FALSE);
    16201628    if (l->e!=NULL) l->e->next=ld->e;
    16211629    ld->e=NULL;
     
    16461654  return b;
    16471655}
    1648 BOOLEAN iiAssign(leftv l, leftv r)
     1656BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
    16491657{
    16501658  if (errorreported) return TRUE;
     
    16641672    IDFLAG((idhdl)l->data)=0;
    16651673    l->attribute=NULL;
     1674    toplevel=FALSE;
    16661675  }
    16671676  else if (l->attribute!=NULL)
     
    17461755      &&((lt==rt)||(lt!=LIST_CMD)))
    17471756      {
    1748         b=jiAssign_1(l,r);
     1757        b=jiAssign_1(l,r,toplevel);
    17491758        if (l->rtyp==IDHDL)
    17501759        {
     
    17711780      )
    17721781      {
    1773         b=jiAssign_1(l,r);
     1782        b=jiAssign_1(l,r,toplevel);
    17741783        if((l->rtyp==IDHDL)&&(l->data!=NULL))
    17751784        {
     
    18581867      }
    18591868      if ((hh->next==NULL)&&(hh->Typ()==IDEAL_CMD))
    1860         return jiAssign_1(l,hh); /* map-assign: map f=r,i; */
     1869        return jiAssign_1(l,hh,toplevel); /* map-assign: map f=r,i; */
    18611870      //no break, handle the rest like an ideal:
    18621871      map_assign=TRUE;
Note: See TracChangeset for help on using the changeset viewer.