My Project
Loading...
Searching...
No Matches
Functions | Variables
attrib.cc File Reference
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "polys/matpol.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "Singular/ipshell.h"
#include "Singular/attrib.h"

Go to the source code of this file.

Functions

static void attr_free (attr h, const ring r=currRing)
 
void * atGet (idhdl root, const char *name, int t, void *defaultReturnValue)
 
void * atGet (leftv root, const char *name, int t)
 
void atSet (idhdl root, char *name, void *data, int typ)
 
void atSet (leftv root, char *name, void *data, int typ)
 
void at_Kill (idhdl root, const char *name, const ring r)
 
void at_KillAll (idhdl root, const ring r)
 
void at_KillAll (leftv root, const ring r)
 
BOOLEAN atATTRIB1 (leftv res, leftv v)
 
BOOLEAN atATTRIB2 (leftv res, leftv v, leftv b)
 
BOOLEAN atATTRIB3 (leftv, leftv v, leftv b, leftv c)
 
BOOLEAN atKILLATTR1 (leftv, leftv a)
 
BOOLEAN atKILLATTR2 (leftv, leftv a, leftv b)
 

Variables

STATIC_VAR omBin sattr_bin = omGetSpecBin(sizeof(sattr))
 

Function Documentation

◆ at_Kill()

void at_Kill ( idhdl  root,
const char *  name,
const ring  r 
)

Definition at line 202 of file attrib.cc.

203{
204 attr temp = root->attribute->get(name);
205 if (temp!=NULL)
206 {
207 attr N = temp->next;
208 attr temp1 = root->attribute;
209 if (temp1==temp)
210 {
211 root->attribute = N;
212 }
213 else
214 {
215 while (temp1->next!=temp) temp1 = temp1->next;
216 temp1->next = N;
217 }
218 temp->kill(r);
219 }
220}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
attr attribute
Definition: idrec.h:41
Definition: attrib.h:21
attr get(const char *s)
Definition: attrib.cc:93
void kill(const ring r)
Definition: attrib.cc:183
attr next
Definition: attrib.h:26
#define NULL
Definition: omList.c:12
int name
New type name for int.
Definition: templateForC.h:21

◆ at_KillAll() [1/2]

void at_KillAll ( idhdl  root,
const ring  r 
)

Definition at line 222 of file attrib.cc.

223{
224 root->attribute->killAll(r);
225 root->attribute = NULL;
226}
void killAll(const ring r)
Definition: attrib.cc:189

◆ at_KillAll() [2/2]

void at_KillAll ( leftv  root,
const ring  r 
)

Definition at line 228 of file attrib.cc.

229{
230 root->attribute->killAll(r);
231 root->attribute = NULL;
232}
attr attribute
Definition: subexpr.h:89

◆ atATTRIB1()

BOOLEAN atATTRIB1 ( leftv  res,
leftv  v 
)

Definition at line 234 of file attrib.cc.

235{
236 attr *aa=(v->Attribute());
237 if (aa==NULL)
238 {
239 WerrorS("this object cannot have attributes");
240 return TRUE;
241 }
242 attr a=*aa;
243 BOOLEAN haveNoAttribute=TRUE;
244 if (v->e==NULL)
245 {
246 if (hasFlag(v,FLAG_STD))
247 {
248 PrintS("attr:isSB, type int\n");
249 haveNoAttribute=FALSE;
250 }
251 if (hasFlag(v,FLAG_QRING))
252 {
253 PrintS("attr:qringNF, type int\n");
254 haveNoAttribute=FALSE;
255 }
256 if (v->Typ()==RING_CMD)
257 {
258 PrintS("attr:cf_class, type int\n");
259 PrintS("attr:global, type int\n");
260 PrintS("attr:maxExp, type int\n");
261 PrintS("attr:ring_cf, type int\n");
262 #ifdef HAVE_SHIFTBBA
263 PrintS("attr:isLetterplaceRing, type int\n");
264 if (rIsLPRing((ring)v->Data()))
265 PrintS("attr:ncgenCount, type int\n");
266 #endif
267
268 haveNoAttribute=FALSE;
269 }
270 }
271 else
272 {
273 leftv at=v->LData();
274 return atATTRIB1(res,at);
275 }
276 if (a!=NULL) a->Print();
277 else if(haveNoAttribute) PrintS("no attributes\n");
278 return FALSE;
279}
BOOLEAN atATTRIB1(leftv res, leftv v)
Definition: attrib.cc:234
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void Print()
Definition: attrib.cc:26
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ RING_CMD
Definition: grammar.cc:281
#define hasFlag(A, F)
Definition: ipid.h:112
#define FLAG_QRING
Definition: ipid.h:108
#define FLAG_STD
Definition: ipid.h:106
void PrintS(const char *s)
Definition: reporter.cc:284
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411

◆ atATTRIB2()

BOOLEAN atATTRIB2 ( leftv  res,
leftv  v,
leftv  b 
)

Definition at line 280 of file attrib.cc.

281{
282 char *name=(char *)b->Data();
283 int t=v->Typ();
284 leftv at=NULL;
285 if (v->e!=NULL)
286 at=v->LData();
287 if (strcmp(name,"isSB")==0)
288 {
289 res->rtyp=INT_CMD;
290 res->data=(void *)(long)hasFlag(v,FLAG_STD);
291 if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_STD)||(hasFlag(at,FLAG_STD)));
292 }
293 else if ((strcmp(name,"rank")==0)&&(/*v->Typ()*/t==MODUL_CMD))
294 {
295 res->rtyp=INT_CMD;
296 res->data=(void *)(((ideal)v->Data())->rank);
297 }
298 else if ((strcmp(name,"global")==0)
299 &&(/*v->Typ()*/t==RING_CMD))
300 {
301 res->rtyp=INT_CMD;
302 res->data=(void *)(((ring)v->Data())->OrdSgn==1);
303 }
304 else if ((strcmp(name,"maxExp")==0)
305 &&(/*v->Typ()*/t==RING_CMD))
306 {
307 res->rtyp=INT_CMD;
308 res->data=(void *)(long)(((ring)v->Data())->bitmask);
309 }
310 else if ((strcmp(name,"ring_cf")==0)
311 &&(/*v->Typ()*/t==RING_CMD))
312 {
313 res->rtyp=INT_CMD;
314 res->data=(void *)(long)(rField_is_Ring((ring)v->Data()));
315 }
316 else if ((strcmp(name,"cf_class")==0)
317 &&(/*v->Typ()*/t==RING_CMD))
318 {
319 res->rtyp=INT_CMD;
320 coeffs cf;
321 if (t==RING_CMD) cf=((ring)v->Data())->cf;
322 else cf=(coeffs)v->Data();
323 res->data=(void *)(long)(cf->type);
324 }
325 else if (strcmp(name,"qringNF")==0)
326 {
327 res->rtyp=INT_CMD;
328 res->data=(void *)(long)hasFlag(v,FLAG_QRING);
329 if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_QRING)||(hasFlag(at,FLAG_QRING)));
330 }
331#ifdef HAVE_SHIFTBBA
332 else if ((strcmp(name,"isLetterplaceRing")==0)
333 &&(/*v->Typ()*/t==RING_CMD))
334 {
335 res->rtyp=INT_CMD;
336 res->data=(void *)(long)(((ring)v->Data())->isLPring);
337 }
338 else if ((strcmp(name,"ncgenCount")==0)
339 &&(/*v->Typ()*/t==RING_CMD))
340 {
341 res->rtyp=INT_CMD;
342 res->data=(void *)(long)(((ring)v->Data())->LPncGenCount);
343 }
344#endif
345 else
346 {
347 attr *aa=v->Attribute();
348 if (aa==NULL)
349 {
350 WerrorS("this object cannot have attributes");
351 return TRUE;
352 }
353 attr a=*aa;
354 a=a->get(name);
355 if (a!=NULL)
356 {
357 res->rtyp=a->atyp;
358 res->data=a->CopyA();
359 }
360 else
361 {
362 res->rtyp=STRING_CMD;
363 res->data=omStrDup("");
364 }
365 }
366 return FALSE;
367}
CanonicalForm cf
Definition: cfModGcd.cc:4083
CanonicalForm b
Definition: cfModGcd.cc:4103
void * CopyA()
Definition: subexpr.cc:2137
int atyp
Definition: attrib.h:27
@ MODUL_CMD
Definition: grammar.cc:287
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define rField_is_Ring(R)
Definition: ring.h:485
@ STRING_CMD
Definition: tok.h:185
@ INT_CMD
Definition: tok.h:96

◆ atATTRIB3()

BOOLEAN atATTRIB3 ( leftv  res,
leftv  v,
leftv  b,
leftv  c 
)

Definition at line 368 of file attrib.cc.

369{
370 idhdl h=(idhdl)v->data;
371 if (v->e!=NULL)
372 {
373 v=v->LData();
374 if (v==NULL) return TRUE;
375 h=NULL;
376 }
377 else if (v->rtyp!=IDHDL) h=NULL;
378 int t=v->Typ();
379
380 char *name=(char *)b->Data();
381 if (strcmp(name,"isSB")==0)
382 {
383 if (c->Typ()!=INT_CMD)
384 {
385 WerrorS("attribute isSB must be int");
386 return TRUE;
387 }
388 if (((long)c->Data())!=0L)
389 {
390 if (h!=NULL) setFlag(h,FLAG_STD);
392 }
393 else
394 {
395 if (h!=NULL) resetFlag(h,FLAG_STD);
397 }
398 }
399 else if (strcmp(name,"qringNF")==0)
400 {
401 if (c->Typ()!=INT_CMD)
402 {
403 WerrorS("attribute qringNF must be int");
404 return TRUE;
405 }
406 if (((long)c->Data())!=0L)
407 {
408 if (h!=NULL) setFlag(h,FLAG_QRING);
410 }
411 else
412 {
413 if (h!=NULL) resetFlag(h,FLAG_QRING);
415 }
416 }
417 else if ((strcmp(name,"rank")==0)&&(/*v->Typ()*/t==MODUL_CMD))
418 {
419 if (c->Typ()!=INT_CMD)
420 {
421 WerrorS("attribute `rank` must be int");
422 return TRUE;
423 }
424 ideal I=(ideal)v->Data();
425 int rk=id_RankFreeModule(I,currRing);
426 I->rank=si_max(rk,(int)((long)c->Data()));
427 }
428 else if (((strcmp(name,"global")==0)
429 || (strcmp(name,"cf_class")==0)
430 || (strcmp(name,"ring_cf")==0)
431 || (strcmp(name,"maxExp")==0))
432 &&(/*v->Typ()*/t==RING_CMD))
433 {
434 Werror("can not set attribute `%s`",name);
435 return TRUE;
436 }
437#ifdef HAVE_SHIFTBBA
438 else if ((strcmp(name,"isLetterplaceRing")==0)
439 &&(/*v->Typ()*/t==RING_CMD))
440 {
441 if (c->Typ()==INT_CMD)
442 ((ring)v->Data())->isLPring=(int)(long)c->Data();
443 else
444 {
445 WerrorS("attribute `isLetterplaceRing` must be int");
446 return TRUE;
447 }
448 }
449 else if ((strcmp(name,"ncgenCount")==0)
450 &&(/*v->Typ()*/t==RING_CMD))
451 {
452 if (c->Typ()==INT_CMD)
453 ((ring)v->Data())->LPncGenCount=(int)(long)c->Data();
454 else
455 {
456 WerrorS("attribute `ncgenCount` must be int");
457 return TRUE;
458 }
459 }
460#endif
461 else
462 {
463 int typ=c->Typ();
464 if (h!=NULL) atSet(h,omStrDup(name),c->CopyD(typ),typ/*c->T(yp()*/);
465 else atSet(v,omStrDup(name),c->CopyD(typ),typ/*c->T(yp()*/);
466 }
467 return FALSE;
468}
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:153
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
Definition: idrec.h:35
void * CopyD(int t)
Definition: subexpr.cc:710
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
#define resetFlag(A, F)
Definition: ipid.h:114
#define setFlag(A, F)
Definition: ipid.h:113
STATIC_VAR Poly * h
Definition: janet.cc:971
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void Werror(const char *fmt,...)
Definition: reporter.cc:189
idrec * idhdl
Definition: ring.h:21
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define IDHDL
Definition: tok.h:31

◆ atGet() [1/2]

void * atGet ( idhdl  root,
const char *  name,
int  t,
void *  defaultReturnValue 
)

Definition at line 132 of file attrib.cc.

133{
134 attr temp = root->attribute->get(name);
135 if ((temp!=NULL) && (temp->atyp==t))
136 return temp->data;
137 else
138 return defaultReturnValue;
139}
void * data
Definition: attrib.h:25

◆ atGet() [2/2]

void * atGet ( leftv  root,
const char *  name,
int  t 
)

Definition at line 141 of file attrib.cc.

142{
143 attr *a=(root->Attribute());
144 if (a!=NULL)
145 {
146 attr temp = (*a)->get(name);
147 if ((temp!=NULL) && (temp->atyp==t))
148 return temp->data;
149 }
150 return NULL;
151}
attr * Attribute()
Definition: subexpr.cc:1462

◆ atKILLATTR1()

BOOLEAN atKILLATTR1 ( leftv  res,
leftv  a 
)

Definition at line 470 of file attrib.cc.

471{
472 idhdl h=NULL;
473 if ((a->rtyp==IDHDL)&&(a->e==NULL))
474 {
475 h=(idhdl)a->data;
477 }
479 if (h->attribute!=NULL)
480 {
481 atKillAll(h);
482 a->attribute=NULL;
483 }
484 else atKillAll(a);
485 return FALSE;
486}
#define atKillAll(H)
Definition: attrib.h:47
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
Subexpr e
Definition: subexpr.h:105

◆ atKILLATTR2()

BOOLEAN atKILLATTR2 ( leftv  res,
leftv  a,
leftv  b 
)

Definition at line 487 of file attrib.cc.

488{
489 if ((a->rtyp!=IDHDL)||(a->e!=NULL))
490 {
491 WerrorS("object must have a name");
492 return TRUE;
493 }
494 char *name=(char *)b->Data();
495 if (strcmp(name,"isSB")==0)
496 {
499 }
500 else if (strcmp(name,"global")==0)
501 {
502 WerrorS("can not set attribut `global`");
503 return TRUE;
504 }
505 else
506 {
507 atKill((idhdl)a->data,name);
508 }
509 return FALSE;
510}
#define atKill(H, A)
Definition: attrib.h:49

◆ atSet() [1/2]

void atSet ( idhdl  root,
char *  name,
void *  data,
int  typ 
)

Definition at line 153 of file attrib.cc.

154{
155 if (root!=NULL)
156 {
157 if ((IDTYP(root)!=RING_CMD)
158 && (!RingDependend(IDTYP(root)))&&(RingDependend(typ)))
159 WerrorS("cannot set ring-dependend objects at this type");
160 else
161 root->attribute=root->attribute->set(name,data,typ);
162 }
163}
attr set(char *s, void *data, int t)
Definition: attrib.cc:70
static int RingDependend(int t)
Definition: gentable.cc:28
#define IDTYP(a)
Definition: ipid.h:119

◆ atSet() [2/2]

void atSet ( leftv  root,
char *  name,
void *  data,
int  typ 
)

Definition at line 165 of file attrib.cc.

166{
167 if (root!=NULL)
168 {
169 attr *a=root->Attribute();
170 int rt=root->Typ();
171 if (a==NULL)
172 WerrorS("cannot set attributes of this object");
173 else if ((rt!=RING_CMD)
174 && (!RingDependend(rt))&&(RingDependend(typ)))
175 WerrorS("cannot set ring-dependend objects at this type");
176 else
177 {
178 *a=(*a)->set(name,data,typ);
179 }
180 }
181}

◆ attr_free()

static void attr_free ( attr  h,
const ring  r = currRing 
)
static

Definition at line 56 of file attrib.cc.

57{
58 if (h->name!=NULL)
59 {
60 omFree(h->name);
61 h->name=NULL;
62 }
63 if (h->data!=NULL) /*avoid assume failure */
64 {
65 s_internalDelete(h->atyp,h->data,r);
66 h->data=NULL;
67 }
68}
#define omFree(addr)
Definition: omAllocDecl.h:261
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:514

Variable Documentation

◆ sattr_bin

STATIC_VAR omBin sattr_bin = omGetSpecBin(sizeof(sattr))

Definition at line 24 of file attrib.cc.