My Project
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
sleftv Class Reference

Class used for (list of) interpreter objects. More...

#include <subexpr.h>

Public Member Functions

void Init ()
 
void CleanUp (ring r=currRing)
 
void Print (leftv store=NULL, int spaces=0)
 Called by type_cmd (e.g. "r;") or as default in jPRINT.
 
charString (void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
 Called for conversion to string (used by string(..), write(..),..)
 
void Copy (leftv e)
 
attr CopyA ()
 
voidCopyD (int t)
 
voidCopyD ()
 
const charName ()
 
const charFullname ()
 
int Typ ()
 
int LTyp ()
 
voidData ()
 
leftv LData ()
 
attrAttribute ()
 
leftv Next ()
 
int listLength ()
 
int Eval ()
 
BOOLEAN RingDependend ()
 

Data Fields

leftv next
 
const charname
 
voiddata
 
attr attribute
 
BITSET flag
 
int rtyp
 
Subexpr e
 
package req_packhdl
 

Detailed Description

Class used for (list of) interpreter objects.

Definition at line 82 of file subexpr.h.

Member Function Documentation

◆ Attribute()

attr * sleftv::Attribute ( )

Definition at line 1506 of file subexpr.cc.

1507{
1508 if (e==NULL) return &attribute;
1509 if ((rtyp==LIST_CMD)
1510 ||((rtyp==IDHDL)&&(IDTYP((idhdl)data)==LIST_CMD))
1511 || (rtyp>MAX_TOK)
1512 || ((rtyp==IDHDL)&&(IDTYP((idhdl)data)>MAX_TOK)))
1513 {
1514 leftv v=LData();
1515 return &(v->attribute);
1516 }
1517 return NULL;
1518}
Definition idrec.h:35
Class used for (list of) interpreter objects.
Definition subexpr.h:83
int rtyp
Definition subexpr.h:91
void * data
Definition subexpr.h:88
Subexpr e
Definition subexpr.h:105
leftv LData()
Definition subexpr.cc:1520
attr attribute
Definition subexpr.h:89
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
#define IDTYP(a)
Definition ipid.h:119
#define NULL
Definition omList.c:12
#define IDHDL
Definition tok.h:31
@ LIST_CMD
Definition tok.h:118
@ MAX_TOK
Definition tok.h:220

◆ CleanUp()

void sleftv::CleanUp ( ring  r = currRing)

Definition at line 351 of file subexpr.cc.

352{
353 if (rtyp!=IDHDL)
354 {
355 if ((name!=NULL) && (name!=sNoName_fe) && (rtyp!=ALIAS_CMD))
356 {
357 //::Print("free %x (%s)\n",name,name);
358 omFree((ADDRESS)name); // may be larger >1000 char (large int)
359 }
360 //name=NULL;
361 //flag=0;
362 if (data!=NULL)
363 {
364 //if (rtyp==IDHDL) attribute=NULL; // is only a pointer to attribute of id
366 //data=NULL; // will be done by Init() at the end
367 }
368 if (attribute!=NULL)
369 {
370 switch (rtyp)
371 {
372 case PACKAGE_CMD:
373 //case IDHDL:
374 case ANY_TYPE:
375 case VECHO:
376 case VPRINTLEVEL:
377 case VCOLMAX:
378 case VTIMER:
379 case VRTIMER:
380 case VOICE:
381 case VMAXDEG:
382 case VMAXMULT:
383 case TRACE:
384 case VSHORTOUT:
385 case VNOETHER:
386 case VMINPOLY:
387 case 0:
388 //attribute=NULL; // will be done by Init() at the end
389 break;
390 default:
391 {
392 attribute->killAll(r);
393 }
394 }
395 }
396 }
397 Subexpr h;
398 while (e!=NULL)
399 {
400 h=e->next;
402 e=h;
403 }
404 //rtyp=NONE; // will be done by Init() at the end
405 if (next!=NULL)
406 {
407 leftv tmp_n;
408 do
409 {
410 tmp_n=next->next;
411 //next->name=NULL;
412 next->next=NULL;
413 next->CleanUp(r);
415 next=tmp_n;
416 } while (next!=NULL);
417 }
418 Init();
419}
void killAll(const ring r)
Definition attrib.cc:189
const char * name
Definition subexpr.h:87
void Init()
Definition subexpr.h:107
leftv next
Definition subexpr.h:86
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
const char sNoName_fe[]
Definition fevoices.cc:57
@ VMAXMULT
Definition grammar.cc:308
@ VMAXDEG
Definition grammar.cc:307
@ VMINPOLY
Definition grammar.cc:310
@ VNOETHER
Definition grammar.cc:309
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
STATIC_VAR Poly * h
Definition janet.cc:971
#define omFree(addr)
#define omFreeBin(addr, bin)
void s_internalDelete(const int t, void *d, const ring r)
Definition subexpr.cc:518
EXTERN_VAR omBin sSubexpr_bin
Definition subexpr.h:174
@ VCOLMAX
Definition tok.h:211
@ ALIAS_CMD
Definition tok.h:34
@ VSHORTOUT
Definition tok.h:216
@ VPRINTLEVEL
Definition tok.h:217
@ PACKAGE_CMD
Definition tok.h:150
@ VECHO
Definition tok.h:210
@ TRACE
Definition tok.h:214
@ VTIMER
Definition tok.h:212
@ VRTIMER
Definition tok.h:213
@ VOICE
Definition tok.h:215
#define ANY_TYPE
Definition tok.h:30

◆ Copy()

void sleftv::Copy ( leftv  e)

Definition at line 690 of file subexpr.cc.

691{
692 Init();
693 rtyp=source->Typ();
694 void *d=source->Data();
695 if(!errorreported)
696 {
697 if (rtyp==BUCKET_CMD)
698 {
700 data=(void*)pCopy(sBucketPeek((sBucket_pt)d));
701 }
702 else
704 if ((source->attribute!=NULL)||(source->e!=NULL))
705 attribute=source->CopyA();
706 flag=source->flag;
707 if (source->next!=NULL)
708 {
710 next->Copy(source->next);
711 }
712 }
713}
void Copy(leftv e)
Definition subexpr.cc:690
BITSET flag
Definition subexpr.h:90
VAR short errorreported
Definition feFopen.cc:23
@ BUCKET_CMD
Definition grammar.cc:284
@ POLY_CMD
Definition grammar.cc:290
#define omAllocBin(bin)
#define pCopy(p)
return a copy of the poly
Definition polys.h:185
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
static void * s_internalCopy(const int t, void *d)
Definition subexpr.cc:433
sleftv * leftv
Definition subexpr.h:79

◆ CopyA()

attr sleftv::CopyA ( )

Definition at line 758 of file subexpr.cc.

759{
760 attr *a=Attribute();
761 if ((a!=NULL) && (*a!=NULL))
762 return (*a)->Copy();
763 return NULL;
764}
Definition attrib.h:21
attr * Attribute()
Definition subexpr.cc:1506

◆ CopyD() [1/2]

void * sleftv::CopyD ( )
inline

Definition at line 119 of file subexpr.h.

119{ return CopyD(Typ()); }
int Typ()
Definition subexpr.cc:1049
void * CopyD()
Definition subexpr.h:119

◆ CopyD() [2/2]

void * sleftv::CopyD ( int  t)

Definition at line 715 of file subexpr.cc.

716{
718 {
719 flag&=~Sy_bit(FLAG_OTHER_RING);
720 WerrorS("object from another ring");
721 return NULL;
722 }
723
724 if ((rtyp!=IDHDL)&&(rtyp!=ALIAS_CMD)&&(e==NULL))
725 {
726 if (iiCheckRing(t)) return NULL;
727 void *x = data;
728 if (rtyp==VNOETHER) x = (void *)pCopy((currRing->ppNoether));
729 else if ((rtyp==VMINPOLY) && nCoeff_is_algExt(currRing->cf) && (!nCoeff_is_GF(currRing->cf)))
730 {
731 const ring A = currRing->cf->extRing;
732
733 assume( A != NULL );
734 assume( A->qideal != NULL );
735
736 x=(void *)p_Copy(A->qideal->m[0], A);
737 }
738 data=NULL;
739 return x;
740 }
741 void *d=Data(); // will also do a iiCheckRing
742 if ((!errorreported) && (d!=NULL)) return s_internalCopy(t,d);
743 return NULL;
744}
Variable x
Definition cfModGcd.cc:4090
void * Data()
Definition subexpr.cc:1193
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition coeffs.h:843
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:914
void WerrorS(const char *s)
Definition feFopen.cc:24
#define FLAG_OTHER_RING
Definition ipid.h:110
BOOLEAN iiCheckRing(int i)
Definition ipshell.cc:1587
#define assume(x)
Definition mod2.h:387
#define Sy_inset(x, s)
Definition options.h:33
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:846
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define A
Definition sirandom.c:24

◆ Data()

void * sleftv::Data ( )

Definition at line 1193 of file subexpr.cc.

1194{
1195 if ((rtyp!=IDHDL) && iiCheckRing(rtyp))
1196 return NULL;
1198 {
1199 flag&=~Sy_bit(FLAG_OTHER_RING);
1200 WerrorS("object from another ring");
1201 return NULL;
1202 }
1203 if (e==NULL)
1204 {
1205 switch (rtyp)
1206 {
1207 case ALIAS_CMD:
1208 {
1209 idhdl h=(idhdl)data;
1210 return ((idhdl)h->data.ustring)->data.ustring;
1211 }
1212 case VECHO: return (void *)(long)si_echo;
1213 case VPRINTLEVEL:return (void *)(long)printlevel;
1214 case VCOLMAX: return (void *)(long)colmax;
1215 case VTIMER: return (void *)(long)getTimer();
1216 case VRTIMER: return (void *)(long)getRTimer();
1217 case VOICE: return (void *)(long)(myynest+1);
1218 case VMAXDEG: return (void *)(long)Kstd1_deg;
1219 case VMAXMULT: return (void *)(long)Kstd1_mu;
1220 case TRACE: return (void *)(long)traceit;
1221 case VSHORTOUT: return (void *)(long)(currRing != NULL ? currRing->ShortOut : 0);
1222 case VMINPOLY:
1223 if ( (currRing != NULL) && nCoeff_is_algExt(currRing->cf) && !nCoeff_is_GF(currRing->cf))
1224 {
1225 /* Q(a), Fp(a), but not GF(q) */
1226 const ring A = currRing->cf->extRing;
1227
1228 assume( A != NULL );
1229 assume( A->qideal != NULL );
1230
1231 return (void *)A->qideal->m[0];
1232 }
1233 else
1234 return (void *)nInit(0);
1235
1236 case VNOETHER: return (void *) (currRing->ppNoether);
1237 case IDHDL:
1238 return IDDATA((idhdl)data);
1239 case COMMAND:
1240 //return NULL;
1241 default:
1242 return data;
1243 }
1244 }
1245 /* e != NULL : */
1246 int t=rtyp;
1247 void *d=data;
1248 if (t==IDHDL)
1249 {
1250 t=((idhdl)data)->typ;
1251 d=IDDATA((idhdl)data);
1252 }
1253 else if (t==ALIAS_CMD)
1254 {
1256 t=IDTYP(h);
1257 d=IDDATA(h);
1258 }
1259 if (iiCheckRing(t))
1260 return NULL;
1261 char *r=NULL;
1262 int index=e->start;
1263 switch (t)
1264 {
1265 case INTVEC_CMD:
1266 {
1267 intvec *iv=(intvec *)d;
1268 if ((index<1)||(index>iv->length()))
1269 {
1270 if (!errorreported)
1271 Werror("wrong range[%d] in intvec %s(%d)",index,this->Name(),iv->length());
1272 }
1273 else
1274 r=(char *)(long)((*iv)[index-1]);
1275 break;
1276 }
1277 case INTMAT_CMD:
1278 {
1279 intvec *iv=(intvec *)d;
1280 if ((index<1)
1281 ||(index>iv->rows())
1282 ||(e->next->start<1)
1283 ||(e->next->start>iv->cols()))
1284 {
1285 if (!errorreported)
1286 Werror("wrong range[%d,%d] in intmat %s(%dx%d)",index,e->next->start,
1287 this->Name(),iv->rows(),iv->cols());
1288 }
1289 else
1290 r=(char *)(long)(IMATELEM((*iv),index,e->next->start));
1291 break;
1292 }
1293 case BIGINTVEC_CMD:
1294 {
1295 bigintmat *m=(bigintmat *)d;
1296 if ((index<1)
1297 ||(index>m->cols()))
1298 {
1299 if (!errorreported)
1300 Werror("wrong range[%d] in bigintvec %s(%d)",index,this->Name(),m->cols());
1301 }
1302 else
1303 r=(char *)(BIMATELEM((*m),1,index));
1304 break;
1305 }
1306 case BIGINTMAT_CMD:
1307 {
1308 bigintmat *m=(bigintmat *)d;
1309 if ((index<1)
1310 ||(index>m->rows())
1311 ||(e->next->start<1)
1312 ||(e->next->start>m->cols()))
1313 {
1314 if (!errorreported)
1315 Werror("wrong range[%d,%d] in bigintmat %s(%dx%d)",index,e->next->start,
1316 this->Name(),m->rows(),m->cols());
1317 }
1318 else
1319 r=(char *)(BIMATELEM((*m),index,e->next->start));
1320 break;
1321 }
1322#ifdef SINGULAR_4_2
1323 case CMATRIX_CMD:
1324 {
1325 bigintmat *m=(bigintmat *)d;
1326 if ((index<1)
1327 ||(index>m->rows())
1328 ||(e->next->start<1)
1329 ||(e->next->start>m->cols()))
1330 {
1331 if (!errorreported)
1332 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",index,e->next->start,
1333 this->Name(),m->rows(),m->cols());
1334 }
1335 else
1336 {
1337 iiNumber2Data[iiCmatrix_index].cf=m->basecoeffs();
1338 iiNumber2Data[iiCmatrix_index].n=BIMATELEM((*m),index,e->next->start);
1339 r=(char*)&iiNumber2Data[iiCmatrix_index];
1341 }
1342 break;
1343 }
1344#endif
1345 case IDEAL_CMD:
1346 case MODUL_CMD:
1347 case MAP_CMD:
1348 {
1349 ideal I=(ideal)d;
1350 if ((index<1)||(index>IDELEMS(I)))
1351 {
1352 if (!errorreported)
1353 Werror("wrong range[%d] in ideal/module %s(%d)",index,this->Name(),IDELEMS(I));
1354 }
1355 else
1356 r=(char *)I->m[index-1];
1357 break;
1358 }
1359 case SMATRIX_CMD:
1360 {
1361 ideal I=(ideal)d;
1362 int c;
1363 sleftv tmp;
1364 tmp.Init();
1365 tmp.rtyp=POLY_CMD;
1366 if ((index>0)&& (index<=I->rank)
1367 && (e->next!=NULL)
1368 && ((c=e->next->start)>0) &&(c<=IDELEMS(I)))
1369 {
1370 r=(char*)SMATELEM(I,index-1,c-1,currRing);
1371 }
1372 else
1373 {
1374 r=NULL;
1375 }
1376 tmp.data=r;
1377 if ((rtyp==IDHDL)||(rtyp==SMATRIX_CMD))
1378 {
1379 tmp.next=next; next=NULL;
1380 d=NULL;
1381 CleanUp();
1382 memcpy(this,&tmp,sizeof(tmp));
1383 }
1384 // and, remember, r is also the result...
1385 else
1386 {
1387 // ???
1388 // here we still have a memory leak...
1389 // example: list L="123","456";
1390 // L[1][2];
1391 // therefore, it should never happen:
1392 assume(0);
1393 // but if it happens: here is the temporary fix:
1394 // omMarkAsStaticAddr(r);
1395 }
1396 break;
1397 }
1398 case STRING_CMD:
1399 {
1400 // this was a memory leak
1401 // we evalute it, cleanup and replace this leftv by it's evalutated form
1402 // the evalutated form will be build in tmp
1403 sleftv tmp;
1404 tmp.Init();
1405 tmp.rtyp=STRING_CMD;
1406 r=(char *)omAllocBin(size_two_bin);
1407 if ((index>0)&& (index<=(int)strlen((char *)d)))
1408 {
1409 r[0]=*(((char *)d)+index-1);
1410 r[1]='\0';
1411 }
1412 else
1413 {
1414 r[0]='\0';
1415 }
1416 tmp.data=r;
1417 if ((rtyp==IDHDL)||(rtyp==STRING_CMD))
1418 {
1419 tmp.next=next; next=NULL;
1420 //if (rtyp==STRING_CMD) { omFree((ADDRESS)data); }
1421 //data=NULL;
1422 d=NULL;
1423 CleanUp();
1424 memcpy(this,&tmp,sizeof(tmp));
1425 }
1426 // and, remember, r is also the result...
1427 else
1428 {
1429 // ???
1430 // here we still have a memory leak...
1431 // example: list L="123","456";
1432 // L[1][2];
1433 // therefore, it should never happen:
1434 assume(0);
1435 // but if it happens: here is the temporary fix:
1436 // omMarkAsStaticAddr(r);
1437 }
1438 break;
1439 }
1440 case MATRIX_CMD:
1441 {
1442 if ((index<1)
1443 ||(index>MATROWS((matrix)d))
1444 ||(e->next->start<1)
1445 ||(e->next->start>MATCOLS((matrix)d)))
1446 {
1447 if (!errorreported)
1448 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",
1449 index,e->next->start,
1450 this->Name(),
1451 MATROWS((matrix)d),MATCOLS((matrix)d));
1452 }
1453 else
1454 r=(char *)MATELEM((matrix)d,index,e->next->start);
1455 break;
1456 }
1457 default:
1458 {
1459 blackbox *b=NULL;
1460 if (t>MAX_TOK)
1461 {
1463 }
1464 if ((t==LIST_CMD)||((b!=NULL)&&(BB_LIKE_LIST(b))))
1465 {
1466 lists l=(lists)d;
1467 if ((0<index)&&(index<=l->nr+1))
1468 {
1469 if ((e->next!=NULL)
1470 && (l->m[index-1].rtyp==STRING_CMD))
1471 // string[..].Data() modifies sleftv, so let's do it ourself
1472 {
1473 char *dd=(char *)l->m[index-1].data;
1474 int j=e->next->start-1;
1475 r=(char *)omAllocBin(size_two_bin);
1476 if ((j>=0) && (j<(int)strlen(dd)))
1477 {
1478 r[0]=*(dd+j);
1479 r[1]='\0';
1480 }
1481 else
1482 {
1483 r[0]='\0';
1484 }
1485 }
1486 else
1487 {
1488 Subexpr tmp=l->m[index-1].e;
1489 l->m[index-1].e=e->next;
1490 r=(char *)l->m[index-1].Data();
1491 e->next=l->m[index-1].e;
1492 l->m[index-1].e=tmp;
1493 }
1494 }
1495 else //if (!errorreported)
1496 Werror("wrong range[%d] in list %s(%d)",index,this->Name(),l->nr+1);
1497 }
1498 else
1499 Werror("cannot index %s of type %s(%d)",this->Name(),Tok2Cmdname(t),t);
1500 break;
1501 }
1502 }
1503 return r;
1504}
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
#define BB_LIKE_LIST(B)
Definition blackbox.h:53
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
CanonicalForm b
Definition cfModGcd.cc:4111
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int length() const
Definition intvec.h:94
int cols() const
Definition intvec.h:95
int rows() const
Definition intvec.h:96
const char * Name()
Definition subexpr.h:120
Definition lists.h:24
int nr
Definition lists.h:44
int j
Definition facHensel.cc:110
VAR int printlevel
Definition febase.cc:36
VAR int si_echo
Definition febase.cc:35
VAR int myynest
Definition febase.cc:41
const char * Tok2Cmdname(int tok)
Definition gentable.cc:140
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ MAP_CMD
Definition grammar.cc:286
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ SMATRIX_CMD
Definition grammar.cc:292
@ BIGINTVEC_CMD
Definition grammar.cc:279
#define IMATELEM(M, I, J)
Definition intvec.h:85
#define IDDATA(a)
Definition ipid.h:126
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:50
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:50
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
#define SMATELEM(A, i, j, R)
Definition matpol.h:123
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
slists * lists
#define nInit(i)
Definition numbers.h:24
static int index(p_Length length, p_Ord ord)
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
EXTERN_VAR int colmax
Definition reporter.h:17
idrec * idhdl
Definition ring.h:21
#define IDELEMS(i)
STATIC_VAR omBin size_two_bin
Definition subexpr.cc:44
int getTimer()
Definition timer.cc:95
int getRTimer()
Definition timer.cc:170
@ INTVEC_CMD
Definition tok.h:101
@ CMATRIX_CMD
Definition tok.h:46
@ STRING_CMD
Definition tok.h:187
#define COMMAND
Definition tok.h:29

◆ Eval()

int sleftv::Eval ( )

Definition at line 2001 of file subexpr.cc.

2002{
2004 leftv nn=next;
2005 next=NULL;
2006 if(rtyp==IDHDL)
2007 {
2008 int t=Typ();
2009 if (t!=PROC_CMD)
2010 {
2011 void *d=CopyD(t);
2012 data=d;
2013 rtyp=t;
2014 name=NULL;
2015 e=NULL;
2016 }
2017 }
2018 else if (rtyp==COMMAND)
2019 {
2020 command d=(command)data;
2021 if(d->op==PROC_CMD) //assume d->argc==2
2022 {
2023 char *what=(char *)(d->arg1.Data());
2024 idhdl h=ggetid(what);
2025 if((h!=NULL)&&(IDTYP(h)==PROC_CMD))
2026 {
2027 nok=d->arg2.Eval();
2028 if(!nok)
2029 {
2030 nok=iiMake_proc(h,req_packhdl,&d->arg2);
2031 this->CleanUp(currRing);
2032 if (!nok)
2033 {
2034 memcpy(this,&iiRETURNEXPR,sizeof(sleftv));
2036 }
2037 }
2038 }
2039 else nok=TRUE;
2040 }
2041 else if (d->op=='=') //assume d->argc==2
2042 {
2043 if ((d->arg1.rtyp!=IDHDL)&&(d->arg1.rtyp!=DEF_CMD))
2044 {
2045 nok=d->arg1.Eval();
2046 }
2047 if (!nok)
2048 {
2049 const char *n=d->arg1.name;
2050 nok=(n == NULL) || d->arg2.Eval();
2051 if (!nok)
2052 {
2053 int save_typ=d->arg1.rtyp;
2054 omCheckAddr((ADDRESS)n);
2055 if (d->arg1.rtyp!=IDHDL)
2056 syMake(&d->arg1,n);
2057 omCheckAddr((ADDRESS)d->arg1.name);
2058 if (d->arg1.rtyp==IDHDL)
2059 {
2060 n=omStrDup(IDID((idhdl)d->arg1.data));
2061 killhdl((idhdl)d->arg1.data);
2062 d->arg1.Init();
2063 //d->arg1.data=NULL;
2064 d->arg1.name=n;
2065 }
2066 d->arg1.rtyp=DEF_CMD;
2067 sleftv t;
2068 if(save_typ!=PROC_CMD) save_typ=d->arg2.rtyp;
2069 if (::RingDependend(d->arg2.rtyp))
2070 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&currRing->idroot);
2071 else
2072 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&IDROOT);
2073 memcpy(&d->arg1,&t,sizeof(sleftv));
2074 omCheckAddr((ADDRESS)d->arg1.name);
2075 nok=nok||iiAssign(&d->arg1,&d->arg2);
2076 omCheckIf(d->arg1.name != NULL, // OB: ????
2077 omCheckAddr((ADDRESS)d->arg1.name));
2078 if (!nok)
2079 {
2080 d->arg1.Init();
2081 this->CleanUp();
2082 rtyp=NONE;
2083 }
2084 }
2085 }
2086 else nok=TRUE;
2087 }
2088 else
2089 {
2090 sleftv tmp; tmp.Init();
2091 int toktype=iiTokType(d->op);
2092 if ((toktype==CMD_M)
2093 ||( toktype==ROOT_DECL_LIST)
2094 ||( toktype==RING_DECL_LIST))
2095 {
2096 if (d->argc <=3)
2097 {
2098 if (d->argc>=1) nok=d->arg1.Eval();
2099 if ((!nok) && (d->argc>=2))
2100 {
2101 nok=d->arg2.Eval();
2102 d->arg1.next=(leftv)omAllocBin(sleftv_bin);
2103 memcpy(d->arg1.next,&d->arg2,sizeof(sleftv));
2104 d->arg2.Init();
2105 }
2106 if ((!nok) && (d->argc==3))
2107 {
2108 nok=d->arg3.Eval();
2109 d->arg1.next->next=(leftv)omAllocBin(sleftv_bin);
2110 memcpy(d->arg1.next->next,&d->arg3,sizeof(sleftv));
2111 d->arg3.Init();
2112 }
2113 if (d->argc==0)
2114 nok=nok||iiExprArithM(&tmp,NULL,d->op);
2115 else
2116 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2117 }
2118 else
2119 {
2120 nok=d->arg1.Eval();
2121 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2122 }
2123 }
2124 else if (d->argc==1)
2125 {
2126 nok=d->arg1.Eval();
2127 nok=nok||iiExprArith1(&tmp,&d->arg1,d->op);
2128 }
2129 else if(d->argc==2)
2130 {
2131 nok=d->arg1.Eval();
2132 nok=nok||d->arg2.Eval();
2133 nok=nok||iiExprArith2(&tmp,&d->arg1,d->op,&d->arg2);
2134 }
2135 else if(d->argc==3)
2136 {
2137 nok=d->arg1.Eval();
2138 nok=nok||d->arg2.Eval();
2139 nok=nok||d->arg3.Eval();
2140 nok=nok||iiExprArith3(&tmp,d->op,&d->arg1,&d->arg2,&d->arg3);
2141 }
2142 else if(d->argc!=0)
2143 {
2144 nok=d->arg1.Eval();
2145 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2146 }
2147 else // d->argc == 0
2148 {
2149 nok = iiExprArithM(&tmp, NULL, d->op);
2150 }
2151 this->CleanUp();
2152 memcpy(this,&tmp,sizeof(tmp));
2153 }
2154 }
2155 else if (((rtyp==0)||(rtyp==DEF_CMD))
2156 &&(name!=NULL))
2157 {
2158 syMake(this,name);
2159 }
2160#ifdef MDEBUG
2161 switch(Typ())
2162 {
2163 case NUMBER_CMD:
2164#ifdef LDEBUG
2165 nTest((number)Data());
2166#endif
2167 break;
2168 case BIGINT_CMD:
2169#ifdef LDEBUG
2171#endif
2172 break;
2173 case POLY_CMD:
2174 pTest((poly)Data());
2175 break;
2176 case IDEAL_CMD:
2177 case MODUL_CMD:
2178 case MATRIX_CMD:
2179 {
2180 ideal id=(ideal)Data();
2181 omCheckAddrSize(id,sizeof(*id));
2182 int i=id->ncols*id->nrows-1;
2183 for(;i>=0;i--) pTest(id->m[i]);
2184 }
2185 break;
2186 }
2187#endif
2188 if (nn!=NULL) nok=nok||nn->Eval();
2189 next=nn;
2190 return nok;
2191}
int BOOLEAN
Definition auxiliary.h:87
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
int i
Definition cfEzgcd.cc:132
package req_packhdl
Definition subexpr.h:106
BOOLEAN RingDependend()
Definition subexpr.cc:421
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:716
@ RING_DECL_LIST
Definition grammar.cc:323
@ PROC_CMD
Definition grammar.cc:281
@ ROOT_DECL_LIST
Definition grammar.cc:321
@ NUMBER_CMD
Definition grammar.cc:289
@ CMD_M
Definition grammar.cc:319
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9182
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9371
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9672
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition iparith.cc:9581
int iiTokType(int op)
Definition iparith.cc:233
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2034
idhdl ggetid(const char *n)
Definition ipid.cc:583
void killhdl(idhdl h, package proot)
Definition ipid.cc:416
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
ip_command * command
Definition ipid.h:23
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:512
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:482
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition ipshell.cc:1199
#define nTest(a)
Definition numbers.h:35
#define omStrDup(s)
#define omCheckAddr(addr)
#define omCheckIf(cond, test)
#define omCheckAddrSize(addr, size)
#define pTest(p)
Definition polys.h:414
void syMake(leftv v, const char *name, package pa=NULL)
Definition subexpr.cc:1614
@ BIGINT_CMD
Definition tok.h:38
@ DEF_CMD
Definition tok.h:58
#define NONE
Definition tok.h:223

◆ Fullname()

const char * sleftv::Fullname ( )
inline

Definition at line 125 of file subexpr.h.

126 {
127 if ((name!=NULL) && (e==NULL)) return(this->name);
128 else return sNoName_fe;
129 }

◆ Init()

void sleftv::Init ( )
inline

Definition at line 107 of file subexpr.h.

107{ memset(this,0,sizeof(*this)); }

◆ LData()

leftv sleftv::LData ( )

Definition at line 1520 of file subexpr.cc.

1521{
1522 if (e!=NULL)
1523 {
1524 lists l=NULL;
1526
1527 if ((rtyp==LIST_CMD)
1528 || ((b!=NULL)&&(BB_LIKE_LIST(b))))
1529 l=(lists)data;
1530 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1531 l=IDLIST((idhdl)data);
1532 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)>MAX_TOK))
1533 {
1535 if (BB_LIKE_LIST(b)) l=IDLIST((idhdl)data);
1536 }
1537 else if (rtyp==ALIAS_CMD)
1538 {
1539 idhdl h=(idhdl)data;
1540 l= (lists)(((idhdl)h->data.ustring)->data.ustring);
1541 }
1542 if (l!=NULL)
1543 {
1544 if ((0>=e->start)||(e->start>l->nr+1))
1545 return NULL;
1546 if (e->next!=NULL)
1547 {
1548 l->m[e->start-1].e=e->next;
1549 leftv r=l->m[e->start-1].LData();
1550 l->m[e->start-1].e=NULL;
1551 return r;
1552 }
1553 return &(l->m[e->start-1]);
1554 }
1555 }
1556 return this;
1557}
#define IDLIST(a)
Definition ipid.h:137

◆ listLength()

int sleftv::listLength ( )

Definition at line 51 of file subexpr.cc.

52{
53 int n = 1;
54 leftv sl = next;
55 while (sl!=NULL)
56 {
57 n++;
58 sl=sl->next;
59 }
60 return n;
61}

◆ LTyp()

int sleftv::LTyp ( )

Definition at line 1157 of file subexpr.cc.

1158{
1159 lists l=NULL;
1160 int r;
1161 if (rtyp==LIST_CMD)
1162 l=(lists)data;
1163 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1164 l=IDLIST((idhdl)data);
1165 else
1166 return Typ();
1167 //if (l!=NULL)
1168 {
1169 if ((e!=NULL) && (e->next!=NULL))
1170 {
1171 if ((0<e->start)&&(e->start<=l->nr+1))
1172 {
1173 l->m[e->start-1].e=e->next;
1174 r=l->m[e->start-1].LTyp();
1175 l->m[e->start-1].e=NULL;
1176 }
1177 else
1178 {
1179 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1180 r=NONE;
1181 }
1182 return r;
1183 }
1184 return LIST_CMD;
1185 }
1186 return Typ();
1187}

◆ Name()

const char * sleftv::Name ( )
inline

Definition at line 120 of file subexpr.h.

121 {
122 if ((name!=NULL) && (e==NULL)) return name;
123 else return sNoName_fe;
124 }

◆ Next()

leftv sleftv::Next ( )
inline

Definition at line 136 of file subexpr.h.

136{ return next; }

◆ Print()

void sleftv::Print ( leftv  store = NULL,
int  spaces = 0 
)

Called by type_cmd (e.g. "r;") or as default in jPRINT.

Definition at line 63 of file subexpr.cc.

64{
65 int t=Typ();
66 if (errorreported) return;
67#ifdef SIQ
68 if (rtyp==COMMAND)
69 {
71 char ch[2];
72 ch[0]=c->op;ch[1]='\0';
73 const char *s=ch;
74 if (c->op>127) s=iiTwoOps(c->op);
75 ::Print("##command %d(%s), %d args\n",
76 c->op, s, c->argc);
77 if (c->argc>0)
78 c->arg1.Print(NULL,spaces+2);
79 if(c->argc<4)
80 {
81 if (c->argc>1)
82 c->arg2.Print(NULL,spaces+2);
83 if (c->argc>2)
84 c->arg3.Print(NULL,spaces+2);
85 }
86 PrintS("##end");
87 }
88 else
89#endif
90 {
91 const char *n=Name();
92 char *s;
93 void *d=Data();
94 if (errorreported) return;
95
96 switch (t /*=Typ()*/)
97 {
98 case CRING_CMD:
99 crPrint((coeffs)d);
100 break;
101#ifdef SINGULAR_4_2
102 case CNUMBER_CMD:
103 n2Print((number2)d);
104 break;
105 case CPOLY_CMD:
106 p2Print((poly2)d);
107 break;
108 case CMATRIX_CMD: // like BIGINTMAT
109#endif
110 case BIGINTMAT_CMD:
111 ((bigintmat *)d)->pprint(colmax);
112 break;
113 case BIGINTVEC_CMD:
114 ((bigintmat *)d)->pprint(4096); // allow longer bigintvec
115 break;
116 case BUCKET_CMD:
117 {
119 if ((e==NULL)
120 && (TEST_V_QRING)
121 &&(currRing->qideal!=NULL))
122 {
123 poly p=pCopy(sBucketPeek(b));
126 pWrite0(p);
127 pDelete(&p);
128 break;
129 }
130 else
132 }
133 break;
134 case UNKNOWN:
135 case DEF_CMD:
137 PrintS("`");PrintS(n);PrintS("`");
138 break;
139 case PACKAGE_CMD:
141 paPrint(n,(package)d);
142 break;
143 case LIB_CMD:
144 case NONE:
145 return;
146 case INTVEC_CMD:
147 case INTMAT_CMD:
148 ((intvec *)d)->show(t,spaces);
149 break;
150 case RING_CMD:
151 {
153 const ring r = (ring)d;
154 rWrite(r, currRing == r);
155 break;
156 }
157 case MATRIX_CMD:
159 break;
160 case SMATRIX_CMD:
161 {
163 ipPrint_MA0(m, n);
165 break;
166 }
167 case MODUL_CMD:
168 case IDEAL_CMD:
169 if ((TEST_V_QRING) &&(currRing->qideal!=NULL)
170 &&(!hasFlag(this,FLAG_QRING)))
171 {
172 jjNormalizeQRingId(this);
173 d=Data();
174 }
175 // no break:
176 case MAP_CMD:
178 break;
179 case POLY_CMD:
180 case VECTOR_CMD:
181 if ((e==NULL)
182 && (TEST_V_QRING)
183 &&(currRing->qideal!=NULL)
184 &&(!hasFlag(this,FLAG_QRING)))
185 {
186 setFlag(this,FLAG_QRING);
187 poly p=(poly)d;
189 if (p!=(poly)d)
190 {
191 d=(void*)p;
192 if ((rtyp==POLY_CMD)||(rtyp==VECTOR_CMD)) data=d;
193 else if (rtyp==IDHDL)
194 {
195 idhdl h=(idhdl)data;
196 IDPOLY(h)=p;
198 }
199 }
200 }
202 pWrite0((poly)d);
203 break;
204 case RESOLUTION_CMD:
205 {
208 break;
209 }
210 case STRING_CMD:
212 PrintS((char *)d);
213 break;
214 case INT_CMD:
216 ::Print("%ld",(long)d);
217 break;
218 case PROC_CMD:
219 {
221
223 PrintS("// libname : ");
224 PrintS(piProcinfo(pi, "libname"));
225 PrintLn();
226
228 PrintS("// procname : ");
229 PrintS(piProcinfo(pi, "procname"));
230 PrintLn();
231
233 PrintS("// type : ");
234 PrintS(piProcinfo(pi, "type"));
235 // ::Print("%-*.*s// ref : %s",spaces,spaces," ",
236 // piProcinfo(pi, "ref"));
237 break;
238 }
239 case LINK_CMD:
240 {
241 si_link l=(si_link)d;
243 ::Print("// type : %s\n", slStatus(l, "type"));
245 ::Print("// mode : %s\n", slStatus(l, "mode"));
247 ::Print("// name : %s\n", slStatus(l, "name"));
249 ::Print("// open : %s\n", slStatus(l, "open"));
251 ::Print("// read : %s\n", slStatus(l, "read"));
253 ::Print("// write: %s", slStatus(l, "write"));
254 break;
255 }
256 case BIGINT_CMD:
257 s=String(d);
258 if (s==NULL) return;
260 PrintS(s);
261 omFree((ADDRESS)s);
262 break;
263 case NUMBER_CMD:
264 {
265 number n=(number)d;
266 nNormalize(n);
267 if ((number)d !=n)
268 {
269 d=n;
270 if (rtyp==IDHDL) IDNUMBER(((idhdl)data))=n;
271 else if(rtyp==NUMBER_CMD) data=(void*)n;
272 }
273 s=String(d);
274 if (s==NULL) return;
275 PrintS(s);
276 omFree((ADDRESS)s);
277 break;
278 }
279 case LIST_CMD:
280 {
281 lists l=(lists)d;
282 if (lSize(l)<0)
283 {
285 PrintS("empty list\n");
286 }
287 else
288 {
289 int i=0;
290 for (;i<=l->nr;i++)
291 {
292 if (l->m[i].rtyp!=DEF_CMD)
293 {
295 ::Print("[%d]:\n",i+1);
296 l->m[i].Print(NULL,spaces+3);
297 }
298 }
299 }
300 break;
301 }
302
303 default:
304 if (t>MAX_TOK)
305 {
308 if (bb!=NULL) { bb->blackbox_Print(bb,d); }
309 else { ::Print("Print: blackbox %d(bb=NULL)",t); }
310 }
311 else
312 ::Print("Print:unknown type %s(%d)", Tok2Cmdname(t),t);
313 } /* end switch: (Typ()) */
314 if ((store!=NULL)&&(store!=this))
315 store->CleanUp();
316 }
317 if (next!=NULL)
318 {
319 if (t==COMMAND) PrintLn();
320 else if (t!=LIST_CMD) PrintS(" ");
322 }
323 else if ((t!=LIST_CMD)&&(t!=SMATRIX_CMD))
324 {
325 PrintLn();
326 }
327#ifdef SIQ
328 if (rtyp!=COMMAND)
329#endif
330 {
331 if ((store!=NULL)
332 && (store!=this))
333 {
334 if((t/*Typ()*/!=LINK_CMD)
335 && (t/*Typ()*/!=PACKAGE_CMD)
336 && (t/*Typ()*/!=DEF_CMD)
337 )
338 {
339 store->rtyp=t/*Typ()*/;
340 store->data=CopyD();
341 if(attribute!=NULL)
342 {
343 store->attribute=CopyA();
344 }
345 store->flag=flag;
346 }
347 }
348 }
349}
int p
Definition cfModGcd.cc:4086
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition subexpr.cc:766
attr CopyA()
Definition subexpr.cc:758
void Print(leftv store=NULL, int spaces=0)
Called by type_cmd (e.g. "r;") or as default in jPRINT.
Definition subexpr.cc:63
#define Print
Definition emacs.cc:80
const CanonicalForm int s
Definition facAbsFact.cc:51
const char * iiTwoOps(int t)
Definition gentable.cc:261
@ LIB_CMD
Definition grammar.cc:328
@ VECTOR_CMD
Definition grammar.cc:293
@ RESOLUTION_CMD
Definition grammar.cc:291
@ RING_CMD
Definition grammar.cc:282
void ipPrint_MA0(matrix m, const char *name)
Definition ipprint.cc:57
ideal id_Copy(ideal h1, const ring r)
copy an ideal
void jjNormalizeQRingId(leftv I)
Definition ipassign.cc:2396
VAR idhdl currRingHdl
Definition ipid.cc:59
#define hasFlag(A, F)
Definition ipid.h:112
#define setFlag(A, F)
Definition ipid.h:113
#define IDPOLY(a)
Definition ipid.h:130
#define FLAG_QRING
Definition ipid.h:108
#define IDNUMBER(a)
Definition ipid.h:132
#define jjNormalizeQRingP(p)
Definition ipid.h:103
void paPrint(const char *n, package p)
Definition ipshell.cc:6342
#define pi
Definition libparse.cc:1145
int lSize(lists L)
Definition lists.cc:25
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition matpol.cc:827
The main handler for Singular numbers which are suitable for Singular polynomials.
void crPrint(coeffs c)
Definition number2.cc:25
#define nNormalize(n)
Definition numbers.h:30
#define TEST_V_QRING
Definition options.h:131
#define pDelete(p_ptr)
Definition polys.h:186
void pWrite0(poly p)
Definition polys.h:309
void PrintNSpaces(const int n)
Definition reporter.cc:364
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
void sBucketPrint(sBucket_pt bucket)
Definition sbuckets.cc:466
sBucket * sBucket_pt
Definition sbuckets.h:16
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
matrix id_Module2Matrix(ideal mod, const ring R)
ip_package * package
Definition structs.h:43
const char * piProcinfo(procinfov pi, const char *request)
Definition ipid.cc:725
procinfo * procinfov
Definition subexpr.h:66
ssyStrategy * syStrategy
Definition syz.h:36
void syPrint(syStrategy syzstr, const char *currRingName)
Definition syz1.cc:1935
@ CRING_CMD
Definition tok.h:56
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ CPOLY_CMD
Definition tok.h:48
@ INT_CMD
Definition tok.h:96
#define UNKNOWN
Definition tok.h:224

◆ RingDependend()

BOOLEAN sleftv::RingDependend ( )

Definition at line 421 of file subexpr.cc.

422{
423 int rt=Typ();
424 if(::RingDependend(rt))
425 return TRUE;
426 if (rt==LIST_CMD)
427 return lRingDependend((lists)Data());
428 if (this->next!=NULL)
429 return this->next->RingDependend();
430 return FALSE;
431}
BOOLEAN lRingDependend(lists L)
Definition lists.cc:222

◆ String()

char * sleftv::String ( void d = NULL,
BOOLEAN  typed = FALSE,
int  dim = 1 
)

Called for conversion to string (used by string(..), write(..),..)

Definition at line 766 of file subexpr.cc.

767{
768#ifdef SIQ
769 if (rtyp==COMMAND)
770 {
771 ::Print("##command %d\n",((command)data)->op);
772 if (((command)data)->arg1.rtyp!=0)
773 ((command)data)->arg1.Print(NULL,2);
774 if (((command)data)->arg2.rtyp!=0)
775 ((command)data)->arg2.Print(NULL,2);
776 if (((command)data)->arg3.rtyp==0)
777 ((command)data)->arg3.Print(NULL,2);
778 PrintS("##end\n");
779 return omStrDup("");
780 }
781#endif
782 if (d==NULL) d=Data();
783 if (!errorreported)
784 {
785 char *s;
786 int t=Typ();
787 switch (t /*Typ()*/)
788 {
789 case INT_CMD:
790 if (typed)
791 {
792 #if SIZEOF_LONG==8
793 const size_t len=MAX_INT_LEN+17;
794 #else
795 const size_t len=MAX_INT_LEN+7;
796 #endif
797 s=(char*)omAlloc(len);
798 snprintf(s,len,"int(%ld)",(long)d);
799 }
800 else
801 {
802 #if SIZEOF_LONG==8
803 const size_t len=MAX_INT_LEN+12;
804 #else
805 const size_t len=MAX_INT_LEN+2;
806 #endif
807 s=(char*)omAlloc(len);
808 snprintf(s,len,"%ld",(long)d);
809 }
810 return s;
811
812 case STRING_CMD:
813 if (d == NULL)
814 {
815 if (typed) return omStrDup("\"\"");
816 return omStrDup("");
817 }
818 if (typed)
819 {
820 size_t len=strlen((char*) d) + 3;
821 s = (char*) omAlloc(len);
822 snprintf(s,len,"\"%s\"", (char*) d);
823 return s;
824 }
825 else
826 {
827 return omStrDup((char*)d);
828 }
829
830 case POLY_CMD:
831 case VECTOR_CMD:
832 if (typed)
833 {
834 char* ps = pString((poly) d);
835 size_t len=strlen(ps) + 10;
836 s = (char*) omAlloc(len);
837 snprintf(s,len,"%s(%s)", (t /*Typ()*/ == POLY_CMD ? "poly" : "vector"), ps);
838 omFree(ps);
839 return s;
840 }
841 else
842 return pString((poly)d);
843
844 case CRING_CMD:
845 return nCoeffString((coeffs)d);
846 #ifdef SINGULAR_4_2
847 case CNUMBER_CMD:
848 return n2String((number2)d,typed);
849 case CMATRIX_CMD:
850 {
851 bigintmat *b=(bigintmat*)d;
852 return b->String();
853 }
854 #endif
855
856 case NUMBER_CMD:
857 StringSetS((char*) (typed ? "number(" : ""));
859 {
860 nfShowMipo(currRing->cf);
861 }
862 else
863 {
864 nWrite((number)d);
865 }
866 StringAppendS((char*) (typed ? ")" : ""));
867 return StringEndS();
868
869 case BIGINT_CMD:
870 {
871 StringSetS((char*) (typed ? "bigint(" : ""));
872 number nl=(number)d;
874 StringAppendS((char*) (typed ? ")" : ""));
875 return StringEndS();
876 }
877 case BUCKET_CMD:
878 return sBucketString((sBucket_pt)d);
879 case MATRIX_CMD:
881 if (typed)
882 {
883 size_t len=strlen(s) + 40;
884 char* ns = (char*) omAlloc(len);
885 snprintf(ns,len, "matrix(ideal(%s),%d,%d)", s,
886 ((ideal) d)->nrows, ((ideal) d)->ncols);
888 return ns;
889 }
890 else
891 {
892 return omStrDup(s);
893 }
894
895 case IDEAL_CMD:
896 case MAP_CMD:
897 case MODUL_CMD:
898 case SMATRIX_CMD:
900 if (typed)
901 {
902 size_t len=strlen(s) + 10;
903 char* ns = (char*) omAlloc(len);
904 if ((t/*Typ()*/==IDEAL_CMD)||(t==MAP_CMD))
905 snprintf(ns,len, "ideal(%s)", s);
906 else /*MODUL_CMD, SMATRIX_CMD */
907 snprintf(ns,len, "module(%s)", s);
908 omFree(s);
910 return ns;
911 }
912 return s;
913
914 case INTVEC_CMD:
915 case INTMAT_CMD:
916 {
917 intvec *v=(intvec *)d;
918 s = v->String(dim);
919 if (typed)
920 {
921 char* ns;
922 if (t/*Typ()*/ == INTMAT_CMD)
923 {
924 size_t len=strlen(s) + 40;
925 ns = (char*) omAlloc(len);
926 snprintf(ns,len, "intmat(intvec(%s),%d,%d)", s, v->rows(), v->cols());
927 }
928 else
929 {
930 size_t len=strlen(s) + 10;
931 ns = (char*) omAlloc(len);
932 snprintf(ns,len, "intvec(%s)", s);
933 }
935 omFree(s);
936 return ns;
937 }
938 else
939 return s;
940 }
941 case BIGINTMAT_CMD:
942 {
943 bigintmat *bim=(bigintmat*)d;
944 s = bim->String();
945 if (typed)
946 {
947 size_t len=strlen(s) + 40;
948 char* ns = (char*) omAlloc(len);
949 snprintf(ns,len, "bigintmat(bigintvec(%s),%d,%d)", s, bim->rows(), bim->cols());
950 return ns;
951 }
952 else
953 return omStrDup(s);
954 }
955 case BIGINTVEC_CMD:
956 {
957 bigintmat *bim=(bigintmat*)d;
958 s = bim->String();
959 if (typed)
960 {
961 size_t len=strlen(s) + 40;
962 char* ns = (char*) omAlloc(len);
963 snprintf(ns,len, "bigintvec(%s)", s);
964 return ns;
965 }
966 else
967 return omStrDup(s);
968 }
969
970 case RING_CMD:
971 s = rString((ring)d);
972
973 if (typed)
974 {
975 char* ns;
976 ring r=(ring)d;
977 if (r->qideal!=NULL)
978 {
979 char* id = iiStringMatrix((matrix) ((ring) d)->qideal, dim,
980 currRing);
981 size_t len=strlen(s) + strlen(id) + 20;
982 ns = (char*) omAlloc(len);
983 snprintf(ns,len, "\"%s\";%sideal(%s)", s,(dim == 2 ? "\n" : " "), id);
984 }
985 else
986 {
987 size_t len=strlen(s) + 4;
988 ns = (char*) omAlloc(len);
989 snprintf(ns,len, "\"%s\"", s);
990 }
991 omFree(s);
993 return ns;
994 }
995 return s;
996 case RESOLUTION_CMD:
997 {
999 s = lString(l, typed, dim);
1000 l->Clean();
1001 return s;
1002 }
1003
1004 case PROC_CMD:
1005 {
1006 procinfo* pi = (procinfo*) d;
1007 if((pi->language == LANG_SINGULAR) && (pi->data.s.body!=NULL))
1008 s = (pi->data.s.body);
1009 else
1010 s = (char *)"";
1011 if (typed)
1012 {
1013 size_t len=strlen(s) + 4;
1014 char* ns = (char*) omAlloc(len);
1015 snprintf(ns,len, "\"%s\"", s);
1016 return ns;
1017 }
1018 return omStrDup(s);
1019 }
1020
1021 case LINK_CMD:
1022 s = slString((si_link) d);
1023 if (typed)
1024 {
1025 size_t len=strlen(s) + 10;
1026 char* ns = (char*) omAlloc(len);
1027 snprintf(ns,len, "link(\"%s\")", s);
1029 omCheckAddr(ns);
1030 return ns;
1031 }
1032 return s;
1033
1034 case LIST_CMD:
1035 return lString((lists) d, typed, dim);
1036
1037 default:
1038 if(t> MAX_TOK)
1039 {
1041 if (bb!=NULL) return bb->blackbox_String(bb,d);
1042 }
1043 } /* end switch: (Typ()) */
1044 }
1045 return omStrDup("");
1046}
int int ncols
Definition cf_linsys.cc:32
int nrows
Definition cf_linsys.cc:32
int rows() const
Definition bigintmat.h:145
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition bigintmat.cc:432
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:963
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:595
void nfShowMipo(const coeffs r)
Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d,...
Definition ffields.cc:547
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3191
char * lString(lists l, BOOLEAN typed, int dim)
Definition lists.cc:403
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
Definition matpol.cc:848
const int MAX_INT_LEN
Definition mylimits.h:13
#define nWrite(n)
Definition numbers.h:29
#define omAlloc(size)
#define omFreeBinAddr(addr)
char * pString(poly p)
Definition polys.h:306
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151
char * rString(ring r)
Definition ring.cc:675
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:526
char * sBucketString(sBucket_pt bucket)
Definition sbuckets.cc:461
@ LANG_SINGULAR
Definition subexpr.h:22
int dim(ideal I, ring r)

◆ Typ()

int sleftv::Typ ( )

Definition at line 1049 of file subexpr.cc.

1050{
1051 if (e==NULL)
1052 {
1053 switch (rtyp)
1054 {
1055 case IDHDL:
1056 return IDTYP((idhdl)data);
1057 case ALIAS_CMD:
1058 {
1059 idhdl h=(idhdl)data;
1060 return ((idhdl)h->data.ustring)->typ;
1061 }
1062 case VECHO:
1063 case VPRINTLEVEL:
1064 case VCOLMAX:
1065 case VTIMER:
1066 case VRTIMER:
1067 case VOICE:
1068 case VMAXDEG:
1069 case VMAXMULT:
1070 case TRACE:
1071 case VSHORTOUT:
1072 return INT_CMD;
1073 case VMINPOLY:
1074 data=NULL;
1075 return NUMBER_CMD;
1076 case VNOETHER:
1077 data=NULL;
1078 return POLY_CMD;
1079 //case COMMAND:
1080 // return COMMAND;
1081 default:
1082 return rtyp;
1083 }
1084 }
1085 int r=0;
1086 int t=rtyp;
1087 void *d=data;
1088 if (t==IDHDL) t=IDTYP((idhdl)d);
1089 else if (t==ALIAS_CMD)
1090 { idhdl h=(idhdl)IDDATA((idhdl)data); t=IDTYP(h);d=IDDATA(h); }
1091 switch (t)
1092 {
1093#ifdef SINGULAR_4_2
1094 case CMATRIX_CMD:
1095 {
1096 bigintmat *b=(bigintmat*)d;
1097 if ((currRing!=NULL)&&(currRing->cf==b->basecoeffs()))
1098 return NUMBER_CMD;
1099 else
1100 return CNUMBER_CMD;
1101 }
1102#endif
1103 case INTVEC_CMD:
1104 case INTMAT_CMD:
1105 r=INT_CMD;
1106 break;
1107 case BIGINTVEC_CMD:
1108 case BIGINTMAT_CMD:
1109 r=BIGINT_CMD;
1110 break;
1111 case IDEAL_CMD:
1112 case MATRIX_CMD:
1113 case MAP_CMD:
1114 case SMATRIX_CMD:
1115 r=POLY_CMD;
1116 break;
1117 case MODUL_CMD:
1118 r=VECTOR_CMD;
1119 break;
1120 case STRING_CMD:
1121 r=STRING_CMD;
1122 break;
1123 default:
1124 {
1125 blackbox *b=NULL;
1126 if (t>MAX_TOK)
1127 {
1129 }
1130 if ((t==LIST_CMD)||((b!=NULL)&&BB_LIKE_LIST(b)))
1131 {
1132 lists l;
1133 if (rtyp==IDHDL) l=IDLIST((idhdl)d);
1134 else l=(lists)d;
1135 if ((0<e->start)&&(e->start<=l->nr+1))
1136 {
1137 Subexpr tmp=l->m[e->start-1].e;
1138 l->m[e->start-1].e=e->next;
1139 r=l->m[e->start-1].Typ();
1140 e->next=l->m[e->start-1].e;
1141 l->m[e->start-1].e=tmp;
1142 }
1143 else
1144 {
1145 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1146 r=DEF_CMD;
1147 }
1148 }
1149 else
1150 Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
1151 break;
1152 }
1153 }
1154 return r;
1155}

Field Documentation

◆ attribute

attr sleftv::attribute

Definition at line 89 of file subexpr.h.

◆ data

void* sleftv::data

Definition at line 88 of file subexpr.h.

◆ e

Subexpr sleftv::e

Definition at line 105 of file subexpr.h.

◆ flag

BITSET sleftv::flag

Definition at line 90 of file subexpr.h.

◆ name

const char* sleftv::name

Definition at line 87 of file subexpr.h.

◆ next

leftv sleftv::next

Definition at line 86 of file subexpr.h.

◆ req_packhdl

package sleftv::req_packhdl

Definition at line 106 of file subexpr.h.

◆ rtyp

int sleftv::rtyp

Definition at line 91 of file subexpr.h.


The documentation for this class was generated from the following files: