Changeset 06c0b3 in git
- Timestamp:
- May 31, 2012, 3:43:46 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 98d6c34c2a74edb284caaeaec97a1295a4c2a402
- Parents:
- 9aac3e40e249db0a2411b4c4f36cdc9a5d791080
- Location:
- Singular
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/blackbox.h
r9aac3e r06c0b3 60 60 BOOLEAN blackbox_default_OpM(int op,leftv l, leftv r); 61 61 62 /// default procedure to print this blackbox 63 void blackbox_default_Print(blackbox *b,void *d); 64 62 65 /// return the structure to the type given by t 63 66 blackbox* getBlackboxStuff(const int t); -
Singular/ipshell.cc
r9aac3e r06c0b3 113 113 default: return Tok2Cmdname(t); 114 114 } 115 } 116 117 int iiOpsTwoChar(const char *s) 118 { 119 /* not handling: &&, ||, ** */ 120 if (s[1]=='\0') return s[0]; 121 else if (s[2]!='\0') return 0; 122 switch(s[0]) 123 { 124 case '.': if (s[1]=='.') return DOTDOT; 125 else return 0; 126 case ':': if (s[1]==':') return COLONCOLON; 127 else return 0; 128 case '-': if (s[1]=='-') return COLONCOLON; 129 else return 0; 130 case '+': if (s[1]=='+') return PLUSPLUS; 131 else return 0; 132 case '=': if (s[1]=='=') return EQUAL_EQUAL; 133 else return 0; 134 case '<': if (s[1]=='=') return LE; 135 else if (s[1]=='>') return NOTEQUAL; 136 else return 0; 137 case '>': if (s[1]=='=') return GE; 138 else return 0; 139 case '!': if (s[1]=='=') return NOTEQUAL; 140 else return 0; 141 } 142 return 0; 115 143 } 116 144 … … 1736 1764 const coeffs C = r->cf; 1737 1765 assume( C != NULL ); 1738 1766 1739 1767 // sanity check: require currRing==r for rings with polynomial data 1740 if ( (r!=currRing) && ( 1741 1742 || (r->qideal != NULL) 1768 if ( (r!=currRing) && ( 1769 (nCoeff_is_algExt(C) && (C != currRing->cf)) 1770 || (r->qideal != NULL) 1743 1771 #ifdef HAVE_PLURAL 1744 1772 || (rIsPluralRing(r)) … … 2192 2220 TransExtInfo extParam; 2193 2221 extParam.r = extRing; 2194 2222 assume( extRing->qideal == NULL ); 2195 2223 2196 2224 R->cf = nInitChar(n_transExt, &extParam); -
Singular/ipshell.h
r9aac3e r06c0b3 52 52 const char * Tok2Cmdname(int i); 53 53 const char * iiTwoOps(int t); 54 int iiOpsTwoChar(const char *s); 55 54 56 int IsPrime(int i); 55 57 -
Singular/newstruct.cc
r9aac3e r06c0b3 20 20 }; 21 21 22 struct newstruct_proc_s; 23 typedef struct newstruct_proc_a *newstruct_proc; 24 struct newstruct_proc_a 25 { 26 newstruct_proc next; 27 int t; /*tok id */ 28 int args; /* number of args */ 29 procinfov p; 30 }; 31 22 32 struct newstruct_desc_s 23 33 { 24 34 newstruct_member member; 25 35 newstruct_desc parent; 36 newstruct_proc procs; 26 37 int size; // number of mebers +1 27 38 int id; // the type id assigned to this bb … … 96 107 } 97 108 } 109 else if(L->m[n].rtyp==LIST_CMD) 110 { 111 N->m[n].rtyp=L->m[n].rtyp; 112 N->m[n].data=(void *)lCopy((lists)(L->m[n].data)); 113 } 98 114 else if(L->m[n].rtyp>MAX_TOK) 99 115 { … … 102 118 N->m[n].data=(void *)b->blackbox_Copy(b,L->m[n].data); 103 119 } 104 else if(L->m[n].rtyp==LIST_CMD)105 {106 N->m[n].rtyp=L->m[n].rtyp;107 N->m[n].data=(void *)lCopy((lists)(L->m[n].data));108 }109 120 else 110 121 N->m[n].Copy(&L->m[n]); … … 113 124 return N; 114 125 } 115 void * newstruct_Copy(blackbox* b, void *d)126 void * newstruct_Copy(blackbox*, void *d) 116 127 { 117 128 lists n1=(lists)d; … … 121 132 BOOLEAN newstruct_Assign(leftv l, leftv r) 122 133 { 123 blackbox *ll=getBlackboxStuff(l->Typ());124 134 if (r->Typ()>MAX_TOK) 125 135 { … … 169 179 BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2) 170 180 { 171 // interpreter: a1 is newstruct181 // interpreter: a1 or a2 is newstruct 172 182 blackbox *a=getBlackboxStuff(a1->Typ()); 173 newstruct_desc nt =(newstruct_desc)a->data;183 newstruct_desc nt; 174 184 lists al=(lists)a1->Data(); 175 switch(op) 176 { 177 case '.': 178 { 179 if (a2->name!=NULL) 180 { 181 BOOLEAN search_ring=FALSE; 182 newstruct_member nm=nt->member; 183 while ((nm!=NULL)&&(strcmp(nm->name,a2->name)!=0)) nm=nm->next; 184 if ((nm==NULL) && (strncmp(a2->name,"r_",2)==0)) 185 if (a!=NULL) 186 { 187 nt=(newstruct_desc)a->data; 188 switch(op) 189 { 190 case '.': 191 { 192 if (a2->name!=NULL) 185 193 { 186 nm=nt->member; 187 while ((nm!=NULL)&&(strcmp(nm->name,a2->name+2)!=0)) nm=nm->next; 188 if ((nm!=NULL)&&(RingDependend(nm->typ))) 189 search_ring=TRUE; 194 BOOLEAN search_ring=FALSE; 195 newstruct_member nm=nt->member; 196 while ((nm!=NULL)&&(strcmp(nm->name,a2->name)!=0)) nm=nm->next; 197 if ((nm==NULL) && (strncmp(a2->name,"r_",2)==0)) 198 { 199 nm=nt->member; 200 while ((nm!=NULL)&&(strcmp(nm->name,a2->name+2)!=0)) nm=nm->next; 201 if ((nm!=NULL)&&(RingDependend(nm->typ))) 202 search_ring=TRUE; 203 else 204 nm=NULL; 205 } 206 if (nm==NULL) 207 { 208 Werror("member %s nor found", a2->name); 209 return TRUE; 210 } 211 if (search_ring) 212 { 213 ring r; 214 res->rtyp=RING_CMD; 215 res->data=al->m[nm->pos-1].data; 216 r=(ring)res->data; 217 if (r==NULL) { res->data=(void *)currRing; r=currRing; } 218 if (r!=NULL) r->ref++; 219 else Werror("ring of this member is not set and no basering found"); 220 return r==NULL; 221 } 222 else if (RingDependend(nm->typ)) 223 { 224 if (al->m[nm->pos].data==NULL) 225 { 226 // NULL belongs to any ring 227 ring r=(ring)al->m[nm->pos-1].data; 228 if (r!=NULL) 229 { 230 r->ref--; 231 al->m[nm->pos-1].data=NULL; 232 al->m[nm->pos-1].rtyp=DEF_CMD; 233 } 234 } 235 else 236 { 237 //Print("checking ring at pos %d for dat at pos %d\n",nm->pos-1,nm->pos); 238 if ((al->m[nm->pos-1].data!=(void *)currRing) 239 &&(al->m[nm->pos-1].data!=(void*)0L)) 240 { 241 Werror("different ring %lx(data) - %lx(basering)", 242 (long unsigned)(al->m[nm->pos-1].data),(long unsigned)currRing); 243 return TRUE; 244 } 245 } 246 if ((currRing!=NULL)&&(al->m[nm->pos-1].data==NULL)) 247 { 248 // remember the ring, if not already set 249 al->m[nm->pos-1].data=(void *)currRing; 250 al->m[nm->pos-1].rtyp=RING_CMD; 251 currRing->ref++; 252 } 253 } 254 Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin); 255 r->start = nm->pos+1; 256 memcpy(res,a1,sizeof(sleftv)); 257 memset(a1,0,sizeof(sleftv)); 258 if (res->e==NULL) res->e=r; 190 259 else 191 nm=NULL; 260 { 261 Subexpr sh=res->e; 262 while (sh->next != NULL) sh=sh->next; 263 sh->next=r; 264 } 265 return FALSE; 192 266 } 193 if (nm==NULL)267 else 194 268 { 195 Werror ("member %s nor found", a2->name);269 WerrorS("name expected"); 196 270 return TRUE; 197 271 } 198 if (search_ring) 199 { 200 ring r; 201 res->rtyp=RING_CMD; 202 res->data=al->m[nm->pos-1].data; 203 r=(ring)res->data; 204 if (r==NULL) { res->data=(void *)currRing; r=currRing; } 205 if (r!=NULL) r->ref++; 206 else Werror("ring of this member is not set and no basering found"); 207 return r==NULL; 208 } 209 else if (RingDependend(nm->typ)) 210 { 211 if (al->m[nm->pos].data==NULL) 212 { 213 // NULL belongs to any ring 214 ring r=(ring)al->m[nm->pos-1].data; 215 if (r!=NULL) 216 { 217 r->ref--; 218 al->m[nm->pos-1].data=NULL; 219 al->m[nm->pos-1].rtyp=DEF_CMD; 220 } 221 } 222 else 223 { 224 //Print("checking ring at pos %d for dat at pos %d\n",nm->pos-1,nm->pos); 225 if ((al->m[nm->pos-1].data!=(void *)currRing) 226 &&(al->m[nm->pos-1].data!=(void*)0L)) 227 { 228 Werror("different ring %lx(data) - %lx(basering)", 229 (long unsigned)(al->m[nm->pos-1].data),(long unsigned)currRing); 230 return TRUE; 231 } 232 } 233 if ((currRing!=NULL)&&(al->m[nm->pos-1].data==NULL)) 234 { 235 // remember the ring, if not already set 236 al->m[nm->pos-1].data=(void *)currRing; 237 al->m[nm->pos-1].rtyp=RING_CMD; 238 currRing->ref++; 239 } 240 } 241 Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin); 242 r->start = nm->pos+1; 243 memcpy(res,a1,sizeof(sleftv)); 244 memset(a1,0,sizeof(sleftv)); 245 if (res->e==NULL) res->e=r; 246 else 247 { 248 Subexpr sh=res->e; 249 while (sh->next != NULL) sh=sh->next; 250 sh->next=r; 251 } 252 return FALSE; 253 } 254 else 255 { 256 WerrorS("name expected"); 257 return TRUE; 258 } 272 } 273 } 274 } 275 else 276 { 277 a=getBlackboxStuff(a2->Typ()); 278 nt=(newstruct_desc)a->data; 279 al=(lists)a2->Data(); 280 } 281 newstruct_proc p=nt->procs; 282 while((p!=NULL) &&(p->t=op)&&(p->args!=2)) p=p->next; 283 if (p!=NULL) 284 { 285 leftv sl; 286 sleftv tmp; 287 memset(&tmp,0,sizeof(sleftv)); 288 tmp.Copy(a1); 289 tmp.next=(leftv)omAlloc0(sizeof(sleftv)); 290 tmp.next->Copy(a2); 291 idrec hh; 292 memset(&hh,0,sizeof(hh)); 293 hh.id=Tok2Cmdname(p->t); 294 hh.typ=PROC_CMD; 295 hh.data.pinf=p->p; 296 sl=iiMake_proc(&hh,NULL,&tmp); 297 if (sl==NULL) return TRUE; 298 else 299 { 300 res->Copy(sl); 301 return FALSE; 259 302 } 260 303 } … … 267 310 // interpreter: args->1. arg is newstruct 268 311 blackbox *a=getBlackboxStuff(args->Typ()); 312 newstruct_desc nt=(newstruct_desc)a->data; 269 313 switch(op) 270 314 { … … 276 320 } 277 321 default: 278 return blackbox_default_OpM(op,res,args);279 322 break; 280 323 } 281 return TRUE; 324 newstruct_proc p=nt->procs; 325 while((p!=NULL) &&(p->t=op)&&(p->args!=4)) p=p->next; 326 if (p!=NULL) 327 { 328 leftv sl; 329 sleftv tmp; 330 memset(&tmp,0,sizeof(sleftv)); 331 tmp.Copy(args); 332 idrec hh; 333 memset(&hh,0,sizeof(hh)); 334 hh.id=Tok2Cmdname(p->t); 335 hh.typ=PROC_CMD; 336 hh.data.pinf=p->p; 337 sl=iiMake_proc(&hh,NULL,&tmp); 338 if (sl==NULL) return TRUE; 339 else 340 { 341 res->Copy(sl); 342 return FALSE; 343 } 344 } 345 return blackbox_default_OpM(op,res,args); 346 } 347 348 void lClean_newstruct(lists l) 349 { 350 if (l->nr>=0) 351 { 352 int i; 353 ring r=NULL; 354 for(i=l->nr;i>=0;i--) 355 { 356 if ((i>0) && (l->m[i-1].rtyp==RING_CMD)) 357 r=(ring)(l->m[i-1].data); 358 else 359 r=NULL; 360 l->m[i].CleanUp(r); 361 } 362 omFreeSize((ADDRESS)l->m, (l->nr+1)*sizeof(sleftv)); 363 l->nr=-1; 364 } 365 omFreeBin((ADDRESS)l,slists_bin); 282 366 } 283 367 … … 287 371 { 288 372 lists n=(lists)d; 289 n->Clean();373 lClean_newstruct(n); 290 374 } 291 375 } … … 355 439 } 356 440 441 void newstruct_Print(blackbox *b,void *d) 442 { 443 newstruct_desc dd=(newstruct_desc)b->data; 444 newstruct_proc p=dd->procs; 445 while((p!=NULL)&&(p->t!=PRINT_CMD)) 446 p=p->next; 447 if (p!=NULL) 448 { 449 leftv sl; 450 sleftv tmp; 451 memset(&tmp,0,sizeof(tmp)); 452 tmp.rtyp=dd->id; 453 tmp.data=(void*)newstruct_Copy(b,d); 454 idrec hh; 455 memset(&hh,0,sizeof(hh)); 456 hh.id=Tok2Cmdname(p->t); 457 hh.typ=PROC_CMD; 458 hh.data.pinf=p->p; 459 sl=iiMake_proc(&hh,NULL,&tmp); 460 } 461 else 462 blackbox_default_Print(b,d); 463 } 357 464 void newstruct_setup(const char *n, newstruct_desc d ) 358 465 { 359 466 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox)); 360 467 // all undefined entries will be set to default in setBlackboxStuff 361 // the default Print is quite useful e,468 // the default Print is quite useful, 362 469 // all other are simply error messages 363 470 b->blackbox_destroy=newstruct_destroy; 364 471 b->blackbox_String=newstruct_String; 365 //b->blackbox_Print=blackbox_default_Print;472 b->blackbox_Print=newstruct_Print;//blackbox_default_Print; 366 473 b->blackbox_Init=newstruct_Init; 367 474 b->blackbox_Copy=newstruct_Copy; … … 490 597 return scanNewstructFromString(s,res); 491 598 } 599 void newstructShow(newstruct_desc d) 600 { 601 newstruct_member elem; 602 Print("id: %d\n",d->id); 603 elem=d->member; 604 while (elem!=NULL) 605 { 606 Print(">>%s<< at pos %d, type %d\n",elem->name,elem->pos,elem->typ); 607 elem=elem->next; 608 } 609 } 610 611 BOOLEAN newstruct_set_proc(const char *bbname,const char *func, int args,procinfov pr) 612 { 613 int id=0; 614 blackboxIsCmd(bbname,id); 615 blackbox *bb=getBlackboxStuff(id); 616 newstruct_desc desc=(newstruct_desc)bb->data; 617 newstruct_proc p=(newstruct_proc)omAlloc(sizeof(*p)); 618 p->next=desc->procs; desc->procs=p; 619 if(!IsCmd(func,p->t)) 620 { 621 int t=0; 622 if (func[1]=='\0') p->t=func[0]; 623 else if((t=iiOpsTwoChar(func))!=0) 624 { 625 p->t=t; 626 } 627 else 628 { 629 Werror(">>%s<< is not a kernel command",func); 630 return TRUE; 631 } 632 } 633 p->args=args; 634 p->p=pr; pr->ref++; 635 return FALSE; 636 } -
Singular/newstruct.h
r9aac3e r06c0b3 7 7 newstruct_desc newstructFromString(const char *s); 8 8 newstruct_desc newstructChildFromString(const char *p, const char *s); 9 BOOLEAN newstruct_set_proc(const char *name,const char *func,int args, procinfov p); 10 void newstructShow(newstruct_desc d); 9 11 10 12 #endif
Note: See TracChangeset
for help on using the changeset viewer.