Changeset 8d7e70 in git


Ignore:
Timestamp:
Apr 28, 2015, 11:00:40 AM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
83be7dfc51c13a18f6bca476b88acc9d12583eb9
Parents:
e48d44131e042866a7de7e865f1b975111f408eb
Message:
avoid forward decl. of newstruct_Op1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/newstruct.cc

    re48d441 r8d7e70  
    244244}
    245245
    246 BOOLEAN newstruct_Assign(leftv l, leftv r)
    247 {
    248   assume(l->Typ() > MAX_TOK);
    249   if (l->Typ()==r->Typ())
    250   {
    251     return newstruct_Assign_same(l,r);
    252   }
    253   // is there an overloading '=' ?
    254   sleftv tmp;
    255   if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
    256   // not, try to find an equal type or parent newstruct
    257   if (r->Typ()>MAX_TOK)
    258   {
    259     blackbox *rr=getBlackboxStuff(r->Typ());
    260     if (l->Typ()!=r->Typ())
    261     {
    262       newstruct_desc rrn=(newstruct_desc)rr->data;
    263 
    264       if (!rrn)
    265       {
    266         Werror("custom type %s(%d) cannot be assigned to newstruct %s(%d)",
    267                Tok2Cmdname(r->Typ()), r->Typ(), Tok2Cmdname(l->Typ()), l->Typ());
    268         return TRUE;
    269       }
    270 
    271       newstruct_desc rrp=rrn->parent;
    272       while ((rrp!=NULL)&&(rrp->id!=l->Typ())) rrp=rrp->parent;
    273       if (rrp!=NULL)
    274       {
    275         if (l->rtyp==IDHDL)
    276         {
    277           IDTYP((idhdl)l->data)=r->Typ();
    278         }
    279         else
    280         {
    281           l->rtyp=r->Typ();
    282         }
    283       }
    284       else                      // unrelated types - look for custom conversion
    285       {
    286         sleftv tmp;
    287         BOOLEAN newstruct_Op1(int, leftv, leftv);  // forward declaration
    288         if (! newstruct_Op1(l->Typ(), &tmp, r))  return newstruct_Assign(l, &tmp);
    289       }
    290       if (l->Typ()==r->Typ())
    291         return newstruct_Assign_same(l,r);
    292     }
    293   }
    294   Werror("assign %s(%d) = %s(%d)",
    295         Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
    296   return TRUE;
    297 }
    298 
    299246BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
    300247{
     
    329276}
    330277
    331 
     278BOOLEAN newstruct_Assign(leftv l, leftv r)
     279{
     280  assume(l->Typ() > MAX_TOK);
     281  if (l->Typ()==r->Typ())
     282  {
     283    return newstruct_Assign_same(l,r);
     284  }
     285  if (r->Typ()>MAX_TOK)
     286  {
     287    blackbox *rr=getBlackboxStuff(r->Typ());
     288    if (l->Typ()!=r->Typ())
     289    {
     290      newstruct_desc rrn=(newstruct_desc)rr->data;
     291
     292      if (rrn==NULL) // this is not a newstruct
     293      {
     294        Werror("custom type %s(%d) cannot be assigned to newstruct %s(%d)",
     295               Tok2Cmdname(r->Typ()), r->Typ(), Tok2Cmdname(l->Typ()), l->Typ());
     296        return TRUE;
     297      }
     298
     299      // try to find a parent newstruct:
     300      newstruct_desc rrp=rrn->parent;
     301      while ((rrp!=NULL)&&(rrp->id!=l->Typ())) rrp=rrp->parent;
     302      if (rrp!=NULL)
     303      {
     304        if (l->rtyp==IDHDL)
     305        {
     306          IDTYP((idhdl)l->data)=r->Typ();
     307        }
     308        else
     309        {
     310          l->rtyp=r->Typ();
     311        }
     312      }
     313      else                      // unrelated types - look for custom conversion
     314      {
     315        sleftv tmp;
     316        if (! newstruct_Op1(l->Typ(), &tmp, r))  return newstruct_Assign(l, &tmp);
     317        if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
     318      }
     319    }
     320    if (l->Typ()==r->Typ())
     321    {
     322      return  newstruct_Assign_same(l,r);
     323    }
     324  }
     325  else
     326  {
     327    sleftv tmp;
     328    if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
     329  }
     330  Werror("assign %s(%d) = %s(%d)",
     331        Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
     332  return TRUE;
     333}
    332334
    333335BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Note: See TracChangeset for help on using the changeset viewer.