Changeset c4dab4 in git


Ignore:
Timestamp:
Mar 15, 2011, 1:31:39 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
dd5534a607684bd18fa828b336e69ddaf1ce55d1
Parents:
aa2a4e7bda99071f7c4636b115e0c2f765522836
Message:
copy/deleting attributes of all types

git-svn-id: file:///usr/local/Singular/svn/trunk@13972 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/attrib.cc

    raa2a4e rc4dab4  
    5858static void attr_free(attr h, const ring r=currRing)
    5959{
    60   switch (h->atyp)
    61   {
    62   case INTVEC_CMD:
    63   case INTMAT_CMD:
    64     delete (intvec *)(h->data);
    65     break;
    66   case IDEAL_CMD:
    67   case MODUL_CMD:
    68   case MATRIX_CMD:
    69     id_Delete((ideal *)&(h->data),r);
    70     break;
    71   case POLY_CMD:
    72   case VECTOR_CMD:
    73     p_Delete((poly *)&(h->data),r);
    74     break;
    75   case INT_CMD:
    76     break;
    77   case STRING_CMD:
    78     omFree((ADDRESS)(h->data));
    79     break;
    80 #ifdef TEST
    81   default:
    82     ::Print("atKill: unknown type(%s [%d]) of attribute >>%s<<\n", Tok2Cmdname(h->atyp), h->atyp, h->name);  /* DEBUG */
    83 #endif
    84   } /* end switch: (atyp) */
     60  s_internalDelete(h->atyp,h->data,r);
    8561  h->data=NULL;
    8662}
     
    180156  if (root!=NULL)
    181157  {
    182     root->attribute=root->attribute->set(name,data,typ);
     158    if ((IDTYP(root)!=RING_CMD)
     159    && (IDTYP(root)!=QRING_CMD)
     160    && (!RingDependend(IDTYP(root)))&&(RingDependend(typ)))
     161      WerrorS("cannot set ring-dependend objects at this type");
     162    else 
     163      root->attribute=root->attribute->set(name,data,typ);
    183164  }
    184165}
     
    194175    else
    195176    {
     177      int rt=root->Typ();
     178      if ((rt!=RING_CMD)
     179      && (rt!=QRING_CMD)
     180      && (!RingDependend(rt))&&(RingDependend(typ)))
     181        WerrorS("cannot set ring-dependend objects at this type");
     182      else 
    196183      if (root->rtyp==IDHDL)
    197184      {
    198185        idhdl h=(idhdl)root->data;
    199186        h->attribute=h->attribute->set(name,data,typ);
    200         //??// root->attribute=h->attribute;
    201187      }
    202188      else
     
    223209  {
    224210    temp1 = temp->next;
     211    omCheckAddr(temp);
    225212    temp->kill(r);
    226213    temp = temp1;
  • Singular/attrib.h

    raa2a4e rc4dab4  
    1616{
    1717  public:
    18     void Init() { memset(this,0,sizeof(*this)); }
     18    inline void Init() { memset(this,0,sizeof(*this)); }
    1919    const char *  name;
    2020    void *  data;
  • Singular/ipid.cc

    raa2a4e rc4dab4  
    372372  if (h->attribute!=NULL)
    373373  {
    374     //at_KillAll(h,r);
    375374    h->attribute=NULL;
    376375  }
    377   // ring / qring  --------------------------------------------------------
    378   if ((IDTYP(h) == RING_CMD) || (IDTYP(h) == QRING_CMD))
    379   {
    380     // any objects defined for this ring ? -> done by rKill
    381     rKill(h);
    382   }
    383   // package -------------------------------------------------------------
    384   else if (IDTYP(h) == PACKAGE_CMD)
     376  if (IDTYP(h) == PACKAGE_CMD)
    385377  {
    386378    if (strcmp(IDID(h),"Top")==0)
     
    413405    iiCheckPack(currPack);
    414406  }
    415   // poly / vector -------------------------------------------------------
    416   else if ((IDTYP(h) == POLY_CMD) || (IDTYP(h) == VECTOR_CMD))
    417   {
    418     assume(r!=NULL);
    419     p_Delete(&IDPOLY(h),r);
    420   }
    421   // ideal / module/ matrix / map ----------------------------------------
    422   else if ((IDTYP(h) == IDEAL_CMD)
    423            || (IDTYP(h) == MODUL_CMD)
    424            || (IDTYP(h) == MATRIX_CMD)
    425            || (IDTYP(h) == MAP_CMD))
    426   {
    427     assume(r!=NULL);
    428     ideal iid = IDIDEAL(h);
    429     if (IDTYP(h) == MAP_CMD)
    430     {
    431       map im = IDMAP(h);
    432       omFree((ADDRESS)im->preimage);
    433     }
    434     id_Delete(&iid,r);
    435   }
    436   // string -------------------------------------------------------------
    437   else if (IDTYP(h) == STRING_CMD)
    438   {
    439     omFree((ADDRESS)IDSTRING(h));
    440     //IDSTRING(h)=NULL;
    441   }
    442   // proc ---------------------------------------------------------------
    443   else if (IDTYP(h) == PROC_CMD)
    444   {
    445     if (piKill(IDPROC(h))) return;
    446   }
    447   // number -------------------------------------------------------------
    448   else if (IDTYP(h) == NUMBER_CMD)
    449   {
    450     assume(r!=NULL);
    451     n_Delete(&IDNUMBER(h),r);
    452   }
    453   // bigint -------------------------------------------------------------
    454   else if (IDTYP(h) == BIGINT_CMD)
    455   {
    456     nlDelete(&IDNUMBER(h),NULL);
    457   }
    458   // intvec / intmat  ---------------------------------------------------
    459   else if ((IDTYP(h) == INTVEC_CMD)||(IDTYP(h) == INTMAT_CMD))
    460   {
    461     delete IDINTVEC(h);
    462   }
    463   // list  -------------------------------------------------------------
    464   else if (IDTYP(h)==LIST_CMD)
    465   {
    466     IDLIST(h)->Clean(r);
    467     //IDLIST(h)=NULL;
    468   }
    469   // link  -------------------------------------------------------------
    470   else if (IDTYP(h)==LINK_CMD)
    471   {
    472     slKill(IDLINK(h));
    473   }
    474   else if(IDTYP(h)==RESOLUTION_CMD)
    475   {
    476     assume(r!=NULL);
    477     if (IDDATA(h)!=NULL)
    478       syKillComputation((syStrategy)IDDATA(h),r);
    479   }
    480   // blackbox -------------------------------------------------------------
    481   else if (IDTYP(h)>MAX_TOK)
    482   {
    483     blackbox *bb=getBlackboxStuff(IDTYP(h));
    484     if (bb!=NULL) bb->blackbox_destroy(bb,IDDATA(h));
    485     IDDATA(h)=NULL;
    486   }
    487 #ifdef TEST
    488   else if ((IDTYP(h)!= INT_CMD)
    489   &&(IDTYP(h)!=DEF_CMD)
    490   &&(IDTYP(h)!=ALIAS_CMD)
    491   &&(IDTYP(h)!=NONE))
    492     Warn("unknown type to kill: %s(%d)",Tok2Cmdname(IDTYP(h)),IDTYP(h));
    493 #endif
    494 
     407  else if ((IDTYP(h)==RING_CMD)||(IDTYP(h)==QRING_CMD))
     408    rKill(h);
     409  else
     410    s_internalDelete(IDTYP(h),IDDATA(h),r);
    495411  //  general  -------------------------------------------------------------
    496412  // now dechain it and delete idrec
  • Singular/subexpr.cc

    raa2a4e rc4dab4  
    234234
    235235        default:
    236           if (t>MAX_TOK)
    237           {
    238             blackbox * bb=getBlackboxStuff(t);
     236          if (t>MAX_TOK)
     237          {
     238            blackbox * bb=getBlackboxStuff(t);
    239239            PrintNSpaces(spaces);
    240             if (bb!=NULL) { bb->blackbox_Print(bb,d); }
    241             else          { ::Print("Print: blackbox %d(bb=NULL)",t); }
    242           }
    243           else
     240            if (bb!=NULL) { bb->blackbox_Print(bb,d); }
     241            else          { ::Print("Print: blackbox %d(bb=NULL)",t); }
     242          }
     243          else
    244244          ::Print("Print:unknown type %s(%d)", Tok2Cmdname(t),t);
    245245      } /* end switch: (Typ()) */
     
    292292  if (data!=NULL)
    293293  {
    294     switch (rtyp)
    295     {
    296       case INTVEC_CMD:
    297       case INTMAT_CMD:
    298         delete (intvec *)data;
    299         break;
    300       case MAP_CMD:
    301         omFree((ADDRESS)((map)data)->preimage);
    302         ((map)data)->preimage=NULL;
    303         // no break: kill the image as an ideal
    304       case MATRIX_CMD:
    305       case MODUL_CMD:
    306       case IDEAL_CMD:
    307         if ((((long)data) & 3)==0)
    308         {
    309           if(r!=NULL) id_Delete((ideal *)(&data),r);
    310         }
    311         break;
    312       case STRING_CMD:
    313         omFree((ADDRESS)data);
    314         break;
    315       case POLY_CMD:
    316       case VECTOR_CMD:
    317         if (r!=NULL) p_Delete((poly *)(&data),r);
    318         break;
    319       case NUMBER_CMD:
    320         if (r!=NULL) n_Delete((number *)(&data),r);
    321         break;
    322       case BIGINT_CMD:
    323         nlDelete((number *)(&data),r);
    324         break;
    325       case LIST_CMD:
    326         ((lists)data)->Clean(r); // may contain ring-dep data
    327         break;
    328       case QRING_CMD:
    329       case RING_CMD:
    330         rKill((ring)data);
    331         break;
    332       case PROC_CMD:
    333         piKill((procinfov)data);
    334         break;
    335       case LINK_CMD:
    336         slKill((si_link)data);
    337         break;
    338       case COMMAND:
    339       {
    340         command cmd=(command)data;
    341         if (cmd->arg1.rtyp!=0) cmd->arg1.CleanUp();
    342         if (cmd->arg2.rtyp!=0) cmd->arg2.CleanUp();
    343         if (cmd->arg3.rtyp!=0) cmd->arg3.CleanUp();
    344         omFreeBin((ADDRESS)data, sip_command_bin);
    345         break;
    346       }
    347       case RESOLUTION_CMD:
    348         if (r!=NULL) syKillComputation((syStrategy)data,r);
    349         break;
    350       case IDHDL:
    351         attribute=NULL; // is only a pointer to attribute of id
    352         break;
    353       // the following types do not take memory
    354       // or are not copied
    355       case PACKAGE_CMD:
    356       case ANY_TYPE:
    357       case VECHO:
    358       case VPRINTLEVEL:
    359       case VCOLMAX:
    360       case VTIMER:
    361       case VRTIMER:
    362       case VOICE:
    363       case VMAXDEG:
    364       case VMAXMULT:
    365       case TRACE:
    366       case VSHORTOUT:
    367       case VNOETHER:
    368       case VMINPOLY:
    369       case 0:
    370       case INT_CMD:
    371         break;
    372       default:
    373       {
    374         if (rtyp<=MAX_TOK)
    375         ::Print("CleanUp: unknown type %d\n",rtyp);  /* DEBUG */
    376         else if (data!=NULL)
    377         {
    378            blackbox *b=getBlackboxStuff(rtyp);
    379            if (b!=NULL) b->blackbox_destroy(b,data);
    380            data=NULL;
    381         }
    382       }
    383     } /* end switch: (rtyp) */
     294     if (rtyp==IDHDL) attribute=NULL; // is only a pointer to attribute of id
     295     else s_internalDelete(rtyp,data,r);
    384296    //data=NULL; // will be done by Init() at the end
    385297  }
     
    410322      default:
    411323      {
    412         attr t;
    413         while (attribute!=NULL)
    414         {
    415           t=attribute->next;
    416           attribute->kill(currRing);
    417           attribute=t;
    418         }
     324        if (attribute!=NULL) attribute->killAll(r);
    419325      }
    420326    }
     
    508414      {
    509415        blackbox *b=getBlackboxStuff(t);
    510         if (b!=NULL) return b->blackbox_Copy(b,d);
     416        if (b!=NULL) return b->blackbox_Copy(b,d);
    511417        return NULL;
    512418      }
     
    519425}
    520426
    521 
     427void s_internalDelete(const int t,  void *d, const ring r)
     428{
     429  switch (t)
     430  {
     431    case INTVEC_CMD:
     432    case INTMAT_CMD:
     433    {
     434      intvec *v=(intvec*)d;
     435      delete v;
     436      break;
     437    }
     438    case MAP_CMD:
     439    {
     440      map m=(map)d;
     441      omFree((ADDRESS)m->preimage);
     442      m->preimage=NULL;
     443      /* no break: continue as IDEAL*/
     444    }
     445    case MATRIX_CMD:
     446    case IDEAL_CMD:
     447    case MODUL_CMD:
     448    {
     449      ideal i=(ideal)d;
     450      id_Delete(&i,r);
     451      break;
     452    }
     453    case STRING_CMD:
     454      omFree(d);
     455      break;
     456    //case POINTER_CMD:
     457    //  return d;
     458    //case PACKAGE_CMD:
     459    //  return  (void *)paCopy((package) d);
     460    case PROC_CMD:
     461      piKill((procinfo*)d);
     462      break;
     463    case POLY_CMD:
     464    case VECTOR_CMD:
     465    {
     466      poly p=(poly)d;
     467      p_Delete(&p,r);
     468      break;
     469    }
     470    case NUMBER_CMD:
     471    {
     472      number n=(number)d;
     473      n_Delete(&n,r);
     474      break;
     475    }
     476    case BIGINT_CMD:
     477    {
     478      number n=(number)d;
     479      nlDelete(&n,NULL);
     480      break;
     481    }
     482    case LIST_CMD:
     483    {
     484      lists l=(lists)d;
     485      l->Clean(r);
     486      break;
     487    }
     488    case LINK_CMD:
     489    {
     490      si_link l=(si_link)d;
     491      slKill(l);
     492      break;
     493    }
     494    case RING_CMD:
     495    case QRING_CMD:
     496    {
     497      ring R=(ring)d;
     498      #ifdef TEST
     499      if (R==currRing)
     500        PrintS("currRing?\n");
     501      else
     502      #endif
     503      rKill(R);
     504      break;
     505    }
     506    case RESOLUTION_CMD:
     507    {
     508      syStrategy s=(syStrategy)d;
     509      if (s!=NULL) syKillComputation(s,r);
     510      break;
     511    }
     512    case COMMAND:
     513    {
     514     command cmd=(command)d;
     515     if (cmd->arg1.rtyp!=0) cmd->arg1.CleanUp(r);
     516     if (cmd->arg2.rtyp!=0) cmd->arg2.CleanUp(r);
     517     if (cmd->arg3.rtyp!=0) cmd->arg3.CleanUp(r);
     518     omFreeBin((ADDRESS)d, sip_command_bin);
     519     break;
     520    }
     521    case INT_CMD:
     522    case DEF_CMD:
     523    case ALIAS_CMD:
     524    case POINTER_CMD:
     525    case PACKAGE_CMD:
     526    case IDHDL:
     527    case NONE:
     528    case ANY_TYPE:
     529    case VECHO:
     530    case VPRINTLEVEL:
     531    case VCOLMAX:
     532    case VTIMER:
     533    case VRTIMER:
     534    case VOICE:
     535    case VMAXDEG:
     536    case VMAXMULT:
     537    case TRACE:
     538    case VSHORTOUT:
     539    case VNOETHER:
     540    case VMINPOLY:
     541    case LIB_CMD:
     542    case 0: /* type in error case */
     543      break; /* error recovery: do nothing */
     544    //case COMMAND:
     545    //case COMMAND:
     546    default:
     547    {
     548      if (t>MAX_TOK)
     549      {
     550        blackbox *b=getBlackboxStuff(t);
     551        if (b!=NULL) b->blackbox_destroy(b,d);
     552        break;
     553      }
     554      else
     555      Warn("s_internalDelete: cannot delete type %s(%d)",
     556            Tok2Cmdname(t),t);
     557    }
     558  }
     559}
    522560
    523561void * slInternalCopy(leftv source, const int t, void *d, Subexpr e)
     
    823861
    824862        default:
    825           if(t> MAX_TOK)
    826           {
    827             blackbox *bb=getBlackboxStuff(t);
    828             if (bb!=NULL) return bb->blackbox_String(bb,d);
    829           }
     863          if(t> MAX_TOK)
     864          {
     865            blackbox *bb=getBlackboxStuff(t);
     866            if (bb!=NULL) return bb->blackbox_String(bb,d);
     867          }
    830868    } /* end switch: (Typ()) */
    831869  }
  • Singular/subexpr.h

    raa2a4e rc4dab4  
    120120extern omBin libstack_bin;
    121121
     122void s_internalDelete(const int t,  void *d, const ring r);
     123
    122124#endif
Note: See TracChangeset for help on using the changeset viewer.