Changeset c227a2f in git
- Timestamp:
- Jun 6, 2011, 4:40:16 PM (13 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- f0910569263b99287146ba84e626f35f43980b56
- Parents:
- e3687463a6a7bf65d26001ae69082c0fdcfeb425
- Location:
- Singular
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/attrib.cc
re368746 rc227a2f 37 37 attr sattr::Copy() 38 38 { 39 omCheckAddrSize(this,sizeof(sattr)); 40 attr n=(attr)omAlloc0Bin(sattr_bin); 41 n->atyp=atyp; 42 if (name!=NULL) n->name=omStrDup(name); 43 n->data=CopyA(); 44 if (next!=NULL) 45 { 46 n->next=next->Copy(); 47 } 48 return n; 39 if (this!=NULL) 40 { 41 omCheckAddrSize(this,sizeof(sattr)); 42 attr n=(attr)omAlloc0Bin(sattr_bin); 43 n->atyp=atyp; 44 if (name!=NULL) n->name=omStrDup(name); 45 n->data=CopyA(); 46 if (next!=NULL) 47 { 48 n->next=next->Copy(); 49 } 50 return n; 51 } 52 else 53 return NULL; 49 54 } 50 55 … … 90 95 while (h!=NULL) 91 96 { 92 if (0 == strcmp(s,h->name)) 93 { 97 if (0 == strcmp(s,h->name)) 98 { 94 99 #ifdef TEST 95 100 //::Print("get attr >>%s<< of type %s\n",h->name, Tok2Cmdname(h->atyp)); … … 114 119 { 115 120 attr temp; 116 if (root->e==NULL) 117 temp = root->attribute->get(name); 118 else 119 temp = (root->LData())->attribute->get(name); 120 if ((temp==NULL) && (root->rtyp==IDHDL)) 121 { 122 idhdl h=(idhdl)root->data; 123 temp=h->attribute->get(name); 124 } 121 attr a=*(root->Attribute()); 122 temp = a->get(name); 125 123 if (temp!=NULL) 126 124 return temp->data; … … 140 138 void * atGet(leftv root,const char * name, int t) 141 139 { 142 attr temp = root->attribute->get(name); 143 if ((temp==NULL) && (root->rtyp==IDHDL)) 144 { 145 idhdl h=(idhdl)root->data; 146 temp=h->attribute->get(name); 147 } 140 attr a=*(root->Attribute()); 141 attr temp = a->get(name); 148 142 if ((temp!=NULL) && (temp->atyp==t)) 149 143 return temp->data; … … 160 154 && (!RingDependend(IDTYP(root)))&&(RingDependend(typ))) 161 155 WerrorS("cannot set ring-dependend objects at this type"); 162 else 156 else 163 157 root->attribute=root->attribute->set(name,data,typ); 164 158 } … … 169 163 if (root!=NULL) 170 164 { 171 if (root->e!=NULL) 172 { 173 Werror("object must have a name for attrib %s",name); 174 } 175 else 176 { 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 183 if (root->rtyp==IDHDL) 184 { 185 idhdl h=(idhdl)root->data; 186 h->attribute=h->attribute->set(name,data,typ); 187 } 188 else 189 { 190 root->attribute=root->attribute->set(name,data,typ); 191 } 165 attr *a=root->Attribute(); 166 int rt=root->Typ(); 167 if ((rt!=RING_CMD) 168 && (rt!=QRING_CMD) 169 && (!RingDependend(rt))&&(RingDependend(typ))) 170 WerrorS("cannot set ring-dependend objects at this type"); 171 else 172 { 173 *a=(*a)->set(name,data,typ); 192 174 } 193 175 } … … 240 222 root->attribute = NULL; 241 223 } 242 243 BOOLEAN atATTRIB1(leftv res,leftv a) 244 { 245 leftv v=a; 224 void at_KillAll(leftv root, const ring r) 225 { 226 root->attribute->killAll(r); 227 root->attribute = NULL; 228 } 229 230 BOOLEAN atATTRIB1(leftv res,leftv v) 231 { 246 232 int t; 247 attr at; 248 if (a->e!=NULL) 249 { 250 v=a->LData(); 251 if (v==NULL) return TRUE; 252 } 253 at=v->attribute; 254 if ((a->rtyp==IDHDL)&&(a->e==NULL)) 255 { 256 at=IDATTR((idhdl)v->data); 257 } 233 attr *aa=(v->Attribute()); 234 if (aa==NULL) 235 { 236 WerrorS("this object cannot have attributes"); 237 return TRUE; 238 } 239 attr a=*aa; 258 240 BOOLEAN haveNoAttribute=TRUE; 259 if (hasFlag(v,FLAG_STD)) 260 { 261 PrintS("attr:isSB, type int\n"); 262 haveNoAttribute=FALSE; 263 } 264 if (hasFlag(v,FLAG_QRING)) 265 { 266 PrintS("attr:qringNF, type int\n"); 267 haveNoAttribute=FALSE; 268 } 269 if (((t=v->Typ())==RING_CMD)||(t==QRING_CMD)) 270 { 271 PrintS("attr:global, type int\n"); 272 haveNoAttribute=FALSE; 273 } 274 if (at!=NULL) at->Print(); 275 else if(haveNoAttribute) PrintS("no attributes\n"); 241 if (v->e==NULL) 242 { 243 if (hasFlag(v,FLAG_STD)) 244 { 245 PrintS("attr:isSB, type int\n"); 246 haveNoAttribute=FALSE; 247 } 248 if (hasFlag(v,FLAG_QRING)) 249 { 250 PrintS("attr:qringNF, type int\n"); 251 haveNoAttribute=FALSE; 252 } 253 if (((t=v->Typ())==RING_CMD)||(t==QRING_CMD)) 254 { 255 PrintS("attr:global, type int\n"); 256 haveNoAttribute=FALSE; 257 } 258 } 259 else 260 { 261 leftv at=v->LData(); 262 return atATTRIB1(res,at); 263 } 264 if (a!=NULL) a->Print(); 265 else if(haveNoAttribute) PrintS("no attributes\n"); 276 266 return FALSE; 277 267 } 278 BOOLEAN atATTRIB2(leftv res,leftv a,leftv b)268 BOOLEAN atATTRIB2(leftv res,leftv v,leftv b) 279 269 { 280 270 char *name=(char *)b->Data(); 281 271 int t; 282 leftv v=a; 283 if (a->e!=NULL) 284 { 285 v=a->LData(); 286 if (v==NULL) return TRUE; 287 } 272 leftv at=NULL; 273 if (v->e!=NULL) 274 at=v->LData(); 288 275 if (strcmp(name,"isSB")==0) 289 276 { 290 277 res->rtyp=INT_CMD; 291 278 res->data=(void *)(long)hasFlag(v,FLAG_STD); 279 if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_STD)||(hasFlag(at,FLAG_STD))); 292 280 } 293 281 else if ((strcmp(name,"rank")==0)&&(v->Typ()==MODUL_CMD)) … … 306 294 res->rtyp=INT_CMD; 307 295 res->data=(void *)(long)hasFlag(v,FLAG_QRING); 296 if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_QRING)||(hasFlag(at,FLAG_QRING))); 308 297 } 309 298 #ifdef HAVE_SHIFTBBA … … 317 306 else 318 307 { 319 attr at; 320 if (v->rtyp==IDHDL) 321 at=IDATTR((idhdl)v->data); 322 else 323 at=v->attribute; 324 at=at->get(name); 325 if (at!=NULL) 326 { 327 res->rtyp=at->atyp; 328 res->data=at->CopyA(); 308 attr *aa=v->Attribute(); 309 if (aa==NULL) 310 { 311 WerrorS("this object cannot have attributes"); 312 return TRUE; 313 } 314 attr a=*aa; 315 a=a->get(name); 316 if (a!=NULL) 317 { 318 res->rtyp=a->atyp; 319 res->data=a->CopyA(); 329 320 } 330 321 else … … 336 327 return FALSE; 337 328 } 338 BOOLEAN atATTRIB3(leftv res,leftv a,leftv b,leftv c)339 { 340 idhdl h=(idhdl) a->data;329 BOOLEAN atATTRIB3(leftv res,leftv v,leftv b,leftv c) 330 { 331 idhdl h=(idhdl)v->data; 341 332 int t; 342 leftv v=a; 343 if (a->e!=NULL) 344 { 345 v=a->LData(); 333 if (v->e!=NULL) 334 { 335 v=v->LData(); 346 336 if (v==NULL) return TRUE; 347 337 h=NULL; 348 338 } 349 if (a->rtyp!=IDHDL) h=NULL; 350 351 attr *at=&(v->attribute); 352 if (h!=NULL) at=&(IDATTR(h)); 339 else if (v->rtyp!=IDHDL) h=NULL; 340 353 341 char *name=(char *)b->Data(); 354 342 if (strcmp(name,"isSB")==0) … … 428 416 BOOLEAN atKILLATTR1(leftv res,leftv a) 429 417 { 418 idhdl h=NULL; 419 if ((a->rtyp==IDHDL)&&(a->e==NULL)) 420 { 421 h=(idhdl)a->data; 422 resetFlag((idhdl)a->data,FLAG_STD); 423 } 424 resetFlag(a,FLAG_STD); 425 if (h->attribute!=NULL) 426 { 427 atKillAll(h); 428 a->attribute=NULL; 429 } 430 else atKillAll(a); 431 return FALSE; 432 } 433 BOOLEAN atKILLATTR2(leftv res,leftv a,leftv b) 434 { 430 435 if ((a->rtyp!=IDHDL)||(a->e!=NULL)) 431 436 { … … 433 438 return TRUE; 434 439 } 435 resetFlag(a,FLAG_STD);436 resetFlag((idhdl)a->data,FLAG_STD);437 if (a->attribute!=NULL)438 {439 atKillAll((idhdl)a->data);440 a->attribute=NULL;441 }442 return FALSE;443 }444 BOOLEAN atKILLATTR2(leftv res,leftv a,leftv b)445 {446 if ((a->rtyp!=IDHDL)||(a->e!=NULL))447 {448 WerrorS("object must have a name");449 return TRUE;450 }451 440 char *name=(char *)b->Data(); 452 441 if (strcmp(name,"isSB")==0) -
Singular/attrib.h
re368746 rc227a2f 39 39 void atSet(leftv root,const char * name,void * data,int typ); 40 40 void at_KillAll(idhdl root,const ring r); 41 void at_KillAll(leftv root,const ring r); 41 42 #define atKillAll(H) at_KillAll(H,currRing) 42 43 void at_Kill(idhdl root,const char * name,const ring r); -
Singular/iparith.cc
re368746 rc227a2f 3036 3036 assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres... 3037 3037 3038 3039 3038 return FALSE; 3040 3039 } … … 3264 3263 else /*IDEAL/MODULE*/ 3265 3264 { 3265 attr *aa=u->Attribute(); 3266 3266 attr a=NULL; 3267 if ( u->attribute!=NULL) a=u->attribute->Copy();3267 if (aa!=NULL) a=(*aa)->Copy(); 3268 3268 jjSTD_1_ID(res,(ideal)u->CopyD(),r,(ideal)v->CopyD(),a); 3269 3269 } -
Singular/ipid.cc
re368746 rc227a2f 372 372 if (h->attribute!=NULL) 373 373 { 374 h->attribute->killAll(r);374 //h->attribute->killAll(r); MEMORY LEAK! 375 375 h->attribute=NULL; 376 376 } -
Singular/ipshell.cc
re368746 rc227a2f 866 866 l->m[0].rtyp=u->Typ(); 867 867 l->m[0].data=u->Data(); 868 l->m[0].attribute=u->attribute; 868 attr *a=u->Attribute(); 869 if (a!=NULL) 870 l->m[0].attribute=*a; 869 871 sleftv tmp2; 870 872 memset(&tmp2,0,sizeof(tmp2)); -
Singular/lists.cc
re368746 rc227a2f 96 96 l->m[pos].data=v->CopyD(); 97 97 l->m[pos].flag=v->flag; 98 if (v->attribute!=NULL) 99 { 100 l->m[pos].attribute=v->attribute->Copy(); 98 attr *a=v->Attribute(); 99 if (a!=NULL) 100 { 101 l->m[pos].attribute=(*a)->Copy(); 101 102 } 102 103 if (ul->m != NULL) … … 167 168 { 168 169 l->m[j]=ul->m[i]; 169 170 memset(&ul->m[i],0,sizeof(ul->m[i])); 170 171 } 171 172 else -
Singular/subexpr.cc
re368746 rc227a2f 324 324 default: 325 325 { 326 if (attribute!=NULL)attribute->killAll(r);326 attribute->killAll(r); 327 327 } 328 328 }
Note: See TracChangeset
for help on using the changeset viewer.