My Project
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. More...
 
char * String (void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
 Called for conversion to string (used by string(..), write(..),..) More...
 
void Copy (leftv e)
 
attr CopyA ()
 
void * CopyD (int t)
 
void * CopyD ()
 
const char * Name ()
 
const char * Fullname ()
 
int Typ ()
 
int LTyp ()
 
void * Data ()
 
leftv LData ()
 
attrAttribute ()
 
leftv Next ()
 
int listLength ()
 
int Eval ()
 
BOOLEAN RingDependend ()
 

Data Fields

leftv next
 
const char * name
 
void * data
 
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 1454 of file subexpr.cc.

1455{
1456 if (e==NULL) return &attribute;
1457 if ((rtyp==LIST_CMD)
1458 ||((rtyp==IDHDL)&&(IDTYP((idhdl)data)==LIST_CMD))
1459 || (rtyp>MAX_TOK)
1460 || ((rtyp==IDHDL)&&(IDTYP((idhdl)data)>MAX_TOK)))
1461 {
1462 leftv v=LData();
1463 return &(v->attribute);
1464 }
1465 return NULL;
1466}
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:1468
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:218

◆ CleanUp()

void sleftv::CleanUp ( ring  r = currRing)

Definition at line 348 of file subexpr.cc.

349{
350 if (rtyp!=IDHDL)
351 {
352 if ((name!=NULL) && (name!=sNoName_fe) && (rtyp!=ALIAS_CMD))
353 {
354 //::Print("free %x (%s)\n",name,name);
355 omFree((ADDRESS)name); // may be larger >1000 char (large int)
356 }
357 //name=NULL;
358 //flag=0;
359 if (data!=NULL)
360 {
361 //if (rtyp==IDHDL) attribute=NULL; // is only a pointer to attribute of id
363 //data=NULL; // will be done by Init() at the end
364 }
365 if (attribute!=NULL)
366 {
367 switch (rtyp)
368 {
369 case PACKAGE_CMD:
370 //case IDHDL:
371 case ANY_TYPE:
372 case VECHO:
373 case VPRINTLEVEL:
374 case VCOLMAX:
375 case VTIMER:
376 case VRTIMER:
377 case VOICE:
378 case VMAXDEG:
379 case VMAXMULT:
380 case TRACE:
381 case VSHORTOUT:
382 case VNOETHER:
383 case VMINPOLY:
384 case 0:
385 //attribute=NULL; // will be done by Init() at the end
386 break;
387 default:
388 {
389 attribute->killAll(r);
390 }
391 }
392 }
393 }
394 Subexpr h;
395 while (e!=NULL)
396 {
397 h=e->next;
399 e=h;
400 }
401 //rtyp=NONE; // will be done by Init() at the end
402 if (next!=NULL)
403 {
404 leftv tmp_n;
405 do
406 {
407 tmp_n=next->next;
408 //next->name=NULL;
409 next->next=NULL;
410 next->CleanUp(r);
412 next=tmp_n;
413 } while (next!=NULL);
414 }
415 Init();
416}
void * ADDRESS
Definition: auxiliary.h:119
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:348
const char sNoName_fe[]
Definition: fevoices.cc:55
@ VMAXMULT
Definition: grammar.cc:307
@ VMAXDEG
Definition: grammar.cc:306
@ VMINPOLY
Definition: grammar.cc:309
@ VNOETHER
Definition: grammar.cc:308
STATIC_VAR Poly * h
Definition: janet.cc:971
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
VAR omBin sSubexpr_bin
Definition: subexpr.cc:40
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:514
VAR omBin sleftv_bin
Definition: subexpr.cc:41
@ VCOLMAX
Definition: tok.h:209
@ ALIAS_CMD
Definition: tok.h:34
@ VSHORTOUT
Definition: tok.h:214
@ VPRINTLEVEL
Definition: tok.h:215
@ PACKAGE_CMD
Definition: tok.h:149
@ VECHO
Definition: tok.h:208
@ TRACE
Definition: tok.h:212
@ VTIMER
Definition: tok.h:210
@ VRTIMER
Definition: tok.h:211
@ VOICE
Definition: tok.h:213
#define ANY_TYPE
Definition: tok.h:30

◆ Copy()

void sleftv::Copy ( leftv  e)

Definition at line 685 of file subexpr.cc.

686{
687 Init();
688 rtyp=source->Typ();
689 void *d=source->Data();
690 if(!errorreported)
691 {
692 if (rtyp==BUCKET_CMD)
693 {
695 data=(void*)pCopy(sBucketPeek((sBucket_pt)d));
696 }
697 else
699 if ((source->attribute!=NULL)||(source->e!=NULL))
700 attribute=source->CopyA();
701 flag=source->flag;
702 if (source->next!=NULL)
703 {
705 next->Copy(source->next);
706 }
707 }
708}
void * CopyA()
Definition: subexpr.cc:2100
void Copy(leftv e)
Definition: subexpr.cc:685
BITSET flag
Definition: subexpr.h:90
VAR short errorreported
Definition: feFopen.cc:23
@ BUCKET_CMD
Definition: grammar.cc:283
@ POLY_CMD
Definition: grammar.cc:289
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
poly sBucketPeek(sBucket_pt b)
Definition: sbuckets.cc:455
sleftv * leftv
Definition: structs.h:57
static void * s_internalCopy(const int t, void *d)
Definition: subexpr.cc:430

◆ CopyA()

attr sleftv::CopyA ( )

Definition at line 753 of file subexpr.cc.

754{
755 attr *a=Attribute();
756 if ((a!=NULL) && (*a!=NULL))
757 return (*a)->Copy();
758 return NULL;
759}
Definition: attrib.h:21
attr * Attribute()
Definition: subexpr.cc:1454

◆ CopyD() [1/2]

void * sleftv::CopyD ( )
inline

Definition at line 119 of file subexpr.h.

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

◆ CopyD() [2/2]

void * sleftv::CopyD ( int  t)

Definition at line 710 of file subexpr.cc.

711{
713 {
714 flag&=~Sy_bit(FLAG_OTHER_RING);
715 WerrorS("object from another ring");
716 return NULL;
717 }
718
719 if ((rtyp!=IDHDL)&&(rtyp!=ALIAS_CMD)&&(e==NULL))
720 {
721 if (iiCheckRing(t)) return NULL;
722 void *x = data;
723 if (rtyp==VNOETHER) x = (void *)pCopy((currRing->ppNoether));
724 else if ((rtyp==VMINPOLY) && nCoeff_is_algExt(currRing->cf) && (!nCoeff_is_GF(currRing->cf)))
725 {
726 const ring A = currRing->cf->extRing;
727
728 assume( A != NULL );
729 assume( A->qideal != NULL );
730
731 x=(void *)p_Copy(A->qideal->m[0], A);
732 }
733 data=NULL;
734 return x;
735 }
736 void *d=Data(); // will also do a iiCheckRing
737 if ((!errorreported) && (d!=NULL)) return s_internalCopy(t,d);
738 return NULL;
739}
Variable x
Definition: cfModGcd.cc:4082
void * Data()
Definition: subexpr.cc:1154
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:839
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:910
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define FLAG_OTHER_RING
Definition: ipid.h:110
BOOLEAN iiCheckRing(int i)
Definition: ipshell.cc:1590
#define assume(x)
Definition: mod2.h:387
#define Sy_inset(x, s)
Definition: options.h:32
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 1154 of file subexpr.cc.

1155{
1156 if ((rtyp!=IDHDL) && iiCheckRing(rtyp))
1157 return NULL;
1159 {
1160 flag&=~Sy_bit(FLAG_OTHER_RING);
1161 WerrorS("object from another ring");
1162 return NULL;
1163 }
1164 if (e==NULL)
1165 {
1166 switch (rtyp)
1167 {
1168 case ALIAS_CMD:
1169 {
1170 idhdl h=(idhdl)data;
1171 return ((idhdl)h->data.ustring)->data.ustring;
1172 }
1173 case VECHO: return (void *)(long)si_echo;
1174 case VPRINTLEVEL:return (void *)(long)printlevel;
1175 case VCOLMAX: return (void *)(long)colmax;
1176 case VTIMER: return (void *)(long)getTimer();
1177 case VRTIMER: return (void *)(long)getRTimer();
1178 case VOICE: return (void *)(long)(myynest+1);
1179 case VMAXDEG: return (void *)(long)Kstd1_deg;
1180 case VMAXMULT: return (void *)(long)Kstd1_mu;
1181 case TRACE: return (void *)(long)traceit;
1182 case VSHORTOUT: return (void *)(long)(currRing != NULL ? currRing->ShortOut : 0);
1183 case VMINPOLY:
1184 if ( (currRing != NULL) && nCoeff_is_algExt(currRing->cf) && !nCoeff_is_GF(currRing->cf))
1185 {
1186 /* Q(a), Fp(a), but not GF(q) */
1187 const ring A = currRing->cf->extRing;
1188
1189 assume( A != NULL );
1190 assume( A->qideal != NULL );
1191
1192 return (void *)A->qideal->m[0];
1193 }
1194 else
1195 return (void *)nInit(0);
1196
1197 case VNOETHER: return (void *) (currRing->ppNoether);
1198 case IDHDL:
1199 return IDDATA((idhdl)data);
1200 case COMMAND:
1201 //return NULL;
1202 default:
1203 return data;
1204 }
1205 }
1206 /* e != NULL : */
1207 int t=rtyp;
1208 void *d=data;
1209 if (t==IDHDL)
1210 {
1211 t=((idhdl)data)->typ;
1212 d=IDDATA((idhdl)data);
1213 }
1214 else if (t==ALIAS_CMD)
1215 {
1217 t=IDTYP(h);
1218 d=IDDATA(h);
1219 }
1220 if (iiCheckRing(t))
1221 return NULL;
1222 char *r=NULL;
1223 int index=e->start;
1224 switch (t)
1225 {
1226 case INTVEC_CMD:
1227 {
1228 intvec *iv=(intvec *)d;
1229 if ((index<1)||(index>iv->length()))
1230 {
1231 if (!errorreported)
1232 Werror("wrong range[%d] in intvec %s(%d)",index,this->Name(),iv->length());
1233 }
1234 else
1235 r=(char *)(long)((*iv)[index-1]);
1236 break;
1237 }
1238 case INTMAT_CMD:
1239 {
1240 intvec *iv=(intvec *)d;
1241 if ((index<1)
1242 ||(index>iv->rows())
1243 ||(e->next->start<1)
1244 ||(e->next->start>iv->cols()))
1245 {
1246 if (!errorreported)
1247 Werror("wrong range[%d,%d] in intmat %s(%dx%d)",index,e->next->start,
1248 this->Name(),iv->rows(),iv->cols());
1249 }
1250 else
1251 r=(char *)(long)(IMATELEM((*iv),index,e->next->start));
1252 break;
1253 }
1254 case BIGINTMAT_CMD:
1255 {
1256 bigintmat *m=(bigintmat *)d;
1257 if ((index<1)
1258 ||(index>m->rows())
1259 ||(e->next->start<1)
1260 ||(e->next->start>m->cols()))
1261 {
1262 if (!errorreported)
1263 Werror("wrong range[%d,%d] in bigintmat %s(%dx%d)",index,e->next->start,
1264 this->Name(),m->rows(),m->cols());
1265 }
1266 else
1267 r=(char *)(BIMATELEM((*m),index,e->next->start));
1268 break;
1269 }
1270#ifdef SINGULAR_4_2
1271 case CMATRIX_CMD:
1272 {
1273 bigintmat *m=(bigintmat *)d;
1274 if ((index<1)
1275 ||(index>m->rows())
1276 ||(e->next->start<1)
1277 ||(e->next->start>m->cols()))
1278 {
1279 if (!errorreported)
1280 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",index,e->next->start,
1281 this->Name(),m->rows(),m->cols());
1282 }
1283 else
1284 {
1285 iiNumber2Data[iiCmatrix_index].cf=m->basecoeffs();
1286 iiNumber2Data[iiCmatrix_index].n=BIMATELEM((*m),index,e->next->start);
1287 r=(char*)&iiNumber2Data[iiCmatrix_index];
1288 iiCmatrix_index=(iiCmatrix_index+1) % 4;
1289 }
1290 break;
1291 }
1292#endif
1293 case IDEAL_CMD:
1294 case MODUL_CMD:
1295 case MAP_CMD:
1296 {
1297 ideal I=(ideal)d;
1298 if ((index<1)||(index>IDELEMS(I)))
1299 {
1300 if (!errorreported)
1301 Werror("wrong range[%d] in ideal/module %s(%d)",index,this->Name(),IDELEMS(I));
1302 }
1303 else
1304 r=(char *)I->m[index-1];
1305 break;
1306 }
1307 case SMATRIX_CMD:
1308 {
1309 ideal I=(ideal)d;
1310 int c;
1311 sleftv tmp;
1312 tmp.Init();
1313 tmp.rtyp=POLY_CMD;
1314 if ((index>0)&& (index<=I->rank)
1315 && (e->next!=NULL)
1316 && ((c=e->next->start)>0) &&(c<=IDELEMS(I)))
1317 {
1318 r=(char*)SMATELEM(I,index-1,c-1,currRing);
1319 }
1320 else
1321 {
1322 r=NULL;
1323 }
1324 tmp.data=r;
1325 if ((rtyp==IDHDL)||(rtyp==SMATRIX_CMD))
1326 {
1327 tmp.next=next; next=NULL;
1328 d=NULL;
1329 CleanUp();
1330 memcpy(this,&tmp,sizeof(tmp));
1331 }
1332 // and, remember, r is also the result...
1333 else
1334 {
1335 // ???
1336 // here we still have a memory leak...
1337 // example: list L="123","456";
1338 // L[1][2];
1339 // therefore, it should never happen:
1340 assume(0);
1341 // but if it happens: here is the temporary fix:
1342 // omMarkAsStaticAddr(r);
1343 }
1344 break;
1345 }
1346 case STRING_CMD:
1347 {
1348 // this was a memory leak
1349 // we evalute it, cleanup and replace this leftv by it's evalutated form
1350 // the evalutated form will be build in tmp
1351 sleftv tmp;
1352 tmp.Init();
1353 tmp.rtyp=STRING_CMD;
1354 r=(char *)omAllocBin(size_two_bin);
1355 if ((index>0)&& (index<=(int)strlen((char *)d)))
1356 {
1357 r[0]=*(((char *)d)+index-1);
1358 r[1]='\0';
1359 }
1360 else
1361 {
1362 r[0]='\0';
1363 }
1364 tmp.data=r;
1365 if ((rtyp==IDHDL)||(rtyp==STRING_CMD))
1366 {
1367 tmp.next=next; next=NULL;
1368 //if (rtyp==STRING_CMD) { omFree((ADDRESS)data); }
1369 //data=NULL;
1370 d=NULL;
1371 CleanUp();
1372 memcpy(this,&tmp,sizeof(tmp));
1373 }
1374 // and, remember, r is also the result...
1375 else
1376 {
1377 // ???
1378 // here we still have a memory leak...
1379 // example: list L="123","456";
1380 // L[1][2];
1381 // therefore, it should never happen:
1382 assume(0);
1383 // but if it happens: here is the temporary fix:
1384 // omMarkAsStaticAddr(r);
1385 }
1386 break;
1387 }
1388 case MATRIX_CMD:
1389 {
1390 if ((index<1)
1391 ||(index>MATROWS((matrix)d))
1392 ||(e->next->start<1)
1393 ||(e->next->start>MATCOLS((matrix)d)))
1394 {
1395 if (!errorreported)
1396 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",
1397 index,e->next->start,
1398 this->Name(),
1399 MATROWS((matrix)d),MATCOLS((matrix)d));
1400 }
1401 else
1402 r=(char *)MATELEM((matrix)d,index,e->next->start);
1403 break;
1404 }
1405 default:
1406 {
1407 blackbox *b=NULL;
1408 if (t>MAX_TOK)
1409 {
1411 }
1412 if ((t==LIST_CMD)||((b!=NULL)&&(BB_LIKE_LIST(b))))
1413 {
1414 lists l=(lists)d;
1415 if ((0<index)&&(index<=l->nr+1))
1416 {
1417 if ((e->next!=NULL)
1418 && (l->m[index-1].rtyp==STRING_CMD))
1419 // string[..].Data() modifies sleftv, so let's do it ourself
1420 {
1421 char *dd=(char *)l->m[index-1].data;
1422 int j=e->next->start-1;
1423 r=(char *)omAllocBin(size_two_bin);
1424 if ((j>=0) && (j<(int)strlen(dd)))
1425 {
1426 r[0]=*(dd+j);
1427 r[1]='\0';
1428 }
1429 else
1430 {
1431 r[0]='\0';
1432 }
1433 }
1434 else
1435 {
1436 Subexpr tmp=l->m[index-1].e;
1437 l->m[index-1].e=e->next;
1438 r=(char *)l->m[index-1].Data();
1439 e->next=l->m[index-1].e;
1440 l->m[index-1].e=tmp;
1441 }
1442 }
1443 else //if (!errorreported)
1444 Werror("wrong range[%d] in list %s(%d)",index,this->Name(),l->nr+1);
1445 }
1446 else
1447 Werror("cannot index %s of type %s(%d)",this->Name(),Tok2Cmdname(t),t);
1448 break;
1449 }
1450 }
1451 return r;
1452}
#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:4103
Matrices of numbers.
Definition: bigintmat.h:51
Definition: intvec.h:23
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:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ MAP_CMD
Definition: grammar.cc:285
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
#define IMATELEM(M, I, J)
Definition: intvec.h:85
#define IDDATA(a)
Definition: ipid.h:126
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
EXTERN_VAR int Kstd1_mu
Definition: kstd1.h:49
#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
Definition: mpr_numeric.h:146
#define nInit(i)
Definition: numbers.h:24
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
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)
Definition: simpleideals.h:23
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:185
#define COMMAND
Definition: tok.h:29

◆ Eval()

int sleftv::Eval ( )

Definition at line 1908 of file subexpr.cc.

1909{
1910 BOOLEAN nok=FALSE;
1911 leftv nn=next;
1912 next=NULL;
1913 if(rtyp==IDHDL)
1914 {
1915 int t=Typ();
1916 if (t!=PROC_CMD)
1917 {
1918 void *d=CopyD(t);
1919 data=d;
1920 rtyp=t;
1921 name=NULL;
1922 e=NULL;
1923 }
1924 }
1925 else if (rtyp==COMMAND)
1926 {
1927 command d=(command)data;
1928 if(d->op==PROC_CMD) //assume d->argc==2
1929 {
1930 char *what=(char *)(d->arg1.Data());
1931 idhdl h=ggetid(what);
1932 if((h!=NULL)&&(IDTYP(h)==PROC_CMD))
1933 {
1934 nok=d->arg2.Eval();
1935 if(!nok)
1936 {
1937 nok=iiMake_proc(h,req_packhdl,&d->arg2);
1938 this->CleanUp(currRing);
1939 if (!nok)
1940 {
1941 memcpy(this,&iiRETURNEXPR,sizeof(sleftv));
1943 }
1944 }
1945 }
1946 else nok=TRUE;
1947 }
1948 else if (d->op=='=') //assume d->argc==2
1949 {
1950 if ((d->arg1.rtyp!=IDHDL)&&(d->arg1.rtyp!=DEF_CMD))
1951 {
1952 nok=d->arg1.Eval();
1953 }
1954 if (!nok)
1955 {
1956 const char *n=d->arg1.name;
1957 nok=(n == NULL) || d->arg2.Eval();
1958 if (!nok)
1959 {
1960 int save_typ=d->arg1.rtyp;
1961 omCheckAddr((ADDRESS)n);
1962 if (d->arg1.rtyp!=IDHDL)
1963 syMake(&d->arg1,n);
1964 omCheckAddr((ADDRESS)d->arg1.name);
1965 if (d->arg1.rtyp==IDHDL)
1966 {
1967 n=omStrDup(IDID((idhdl)d->arg1.data));
1968 killhdl((idhdl)d->arg1.data);
1969 d->arg1.Init();
1970 //d->arg1.data=NULL;
1971 d->arg1.name=n;
1972 }
1973 d->arg1.rtyp=DEF_CMD;
1974 sleftv t;
1975 if(save_typ!=PROC_CMD) save_typ=d->arg2.rtyp;
1976 if (::RingDependend(d->arg2.rtyp))
1977 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&currRing->idroot);
1978 else
1979 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&IDROOT);
1980 memcpy(&d->arg1,&t,sizeof(sleftv));
1981 omCheckAddr((ADDRESS)d->arg1.name);
1982 nok=nok||iiAssign(&d->arg1,&d->arg2);
1983 omCheckIf(d->arg1.name != NULL, // OB: ????
1984 omCheckAddr((ADDRESS)d->arg1.name));
1985 if (!nok)
1986 {
1987 d->arg1.Init();
1988 this->CleanUp();
1989 rtyp=NONE;
1990 }
1991 }
1992 }
1993 else nok=TRUE;
1994 }
1995 else
1996 {
1997 sleftv tmp; tmp.Init();
1998 int toktype=iiTokType(d->op);
1999 if ((toktype==CMD_M)
2000 ||( toktype==ROOT_DECL_LIST)
2001 ||( toktype==RING_DECL_LIST))
2002 {
2003 if (d->argc <=3)
2004 {
2005 if (d->argc>=1) nok=d->arg1.Eval();
2006 if ((!nok) && (d->argc>=2))
2007 {
2008 nok=d->arg2.Eval();
2009 d->arg1.next=(leftv)omAllocBin(sleftv_bin);
2010 memcpy(d->arg1.next,&d->arg2,sizeof(sleftv));
2011 d->arg2.Init();
2012 }
2013 if ((!nok) && (d->argc==3))
2014 {
2015 nok=d->arg3.Eval();
2016 d->arg1.next->next=(leftv)omAllocBin(sleftv_bin);
2017 memcpy(d->arg1.next->next,&d->arg3,sizeof(sleftv));
2018 d->arg3.Init();
2019 }
2020 if (d->argc==0)
2021 nok=nok||iiExprArithM(&tmp,NULL,d->op);
2022 else
2023 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2024 }
2025 else
2026 {
2027 nok=d->arg1.Eval();
2028 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2029 }
2030 }
2031 else if (d->argc==1)
2032 {
2033 nok=d->arg1.Eval();
2034 nok=nok||iiExprArith1(&tmp,&d->arg1,d->op);
2035 }
2036 else if(d->argc==2)
2037 {
2038 nok=d->arg1.Eval();
2039 nok=nok||d->arg2.Eval();
2040 nok=nok||iiExprArith2(&tmp,&d->arg1,d->op,&d->arg2);
2041 }
2042 else if(d->argc==3)
2043 {
2044 nok=d->arg1.Eval();
2045 nok=nok||d->arg2.Eval();
2046 nok=nok||d->arg3.Eval();
2047 nok=nok||iiExprArith3(&tmp,d->op,&d->arg1,&d->arg2,&d->arg3);
2048 }
2049 else if(d->argc!=0)
2050 {
2051 nok=d->arg1.Eval();
2052 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2053 }
2054 else // d->argc == 0
2055 {
2056 nok = iiExprArithM(&tmp, NULL, d->op);
2057 }
2058 this->CleanUp();
2059 memcpy(this,&tmp,sizeof(tmp));
2060 }
2061 }
2062 else if (((rtyp==0)||(rtyp==DEF_CMD))
2063 &&(name!=NULL))
2064 {
2065 syMake(this,name);
2066 }
2067#ifdef MDEBUG
2068 switch(Typ())
2069 {
2070 case NUMBER_CMD:
2071#ifdef LDEBUG
2072 nTest((number)Data());
2073#endif
2074 break;
2075 case BIGINT_CMD:
2076#ifdef LDEBUG
2077 n_Test((number)Data(),coeffs_BIGINT);
2078#endif
2079 break;
2080 case POLY_CMD:
2081 pTest((poly)Data());
2082 break;
2083 case IDEAL_CMD:
2084 case MODUL_CMD:
2085 case MATRIX_CMD:
2086 {
2087 ideal id=(ideal)Data();
2088 omCheckAddrSize(id,sizeof(*id));
2089 int i=id->ncols*id->nrows-1;
2090 for(;i>=0;i--) pTest(id->m[i]);
2091 }
2092 break;
2093 }
2094#endif
2095 if (nn!=NULL) nok=nok||nn->Eval();
2096 next=nn;
2097 return nok;
2098}
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:418
int Eval()
Definition: subexpr.cc:1908
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:712
@ RING_DECL_LIST
Definition: grammar.cc:322
@ PROC_CMD
Definition: grammar.cc:280
@ ROOT_DECL_LIST
Definition: grammar.cc:320
@ NUMBER_CMD
Definition: grammar.cc:288
@ CMD_M
Definition: grammar.cc:318
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition: iparith.cc:8881
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:9070
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition: iparith.cc:9371
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition: iparith.cc:9280
int iiTokType(int op)
Definition: iparith.cc:235
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1963
idhdl ggetid(const char *n)
Definition: ipid.cc:572
void killhdl(idhdl h, package proot)
Definition: ipid.cc:407
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:504
INST_VAR sleftv iiRETURNEXPR
Definition: iplib.cc:474
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition: ipshell.cc:1202
#define nTest(a)
Definition: numbers.h:35
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
#define omCheckIf(cond, test)
Definition: omAllocDecl.h:323
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
#define pTest(p)
Definition: polys.h:415
void syMake(leftv v, const char *id, package pa)
Definition: subexpr.cc:1562
@ BIGINT_CMD
Definition: tok.h:38
@ DEF_CMD
Definition: tok.h:58
#define NONE
Definition: tok.h:221

◆ 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 1468 of file subexpr.cc.

1469{
1470 if (e!=NULL)
1471 {
1472 lists l=NULL;
1473 blackbox *b=getBlackboxStuff(rtyp);
1474
1475 if ((rtyp==LIST_CMD)
1476 || ((b!=NULL)&&(BB_LIKE_LIST(b))))
1477 l=(lists)data;
1478 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1479 l=IDLIST((idhdl)data);
1480 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)>MAX_TOK))
1481 {
1483 if (BB_LIKE_LIST(b)) l=IDLIST((idhdl)data);
1484 }
1485 else if (rtyp==ALIAS_CMD)
1486 {
1487 idhdl h=(idhdl)data;
1488 l= (lists)(((idhdl)h->data.ustring)->data.ustring);
1489 }
1490 if (l!=NULL)
1491 {
1492 if ((0>=e->start)||(e->start>l->nr+1))
1493 return NULL;
1494 if (e->next!=NULL)
1495 {
1496 l->m[e->start-1].e=e->next;
1497 leftv r=l->m[e->start-1].LData();
1498 l->m[e->start-1].e=NULL;
1499 return r;
1500 }
1501 return &(l->m[e->start-1]);
1502 }
1503 }
1504 return this;
1505}
#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 1118 of file subexpr.cc.

1119{
1120 lists l=NULL;
1121 int r;
1122 if (rtyp==LIST_CMD)
1123 l=(lists)data;
1124 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1125 l=IDLIST((idhdl)data);
1126 else
1127 return Typ();
1128 //if (l!=NULL)
1129 {
1130 if ((e!=NULL) && (e->next!=NULL))
1131 {
1132 if ((0<e->start)&&(e->start<=l->nr+1))
1133 {
1134 l->m[e->start-1].e=e->next;
1135 r=l->m[e->start-1].LTyp();
1136 l->m[e->start-1].e=NULL;
1137 }
1138 else
1139 {
1140 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1141 r=NONE;
1142 }
1143 return r;
1144 }
1145 return LIST_CMD;
1146 }
1147 return Typ();
1148}

◆ 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 BUCKET_CMD:
114 {
116 if ((e==NULL)
117 && (TEST_V_QRING)
118 &&(currRing->qideal!=NULL))
119 {
120 poly p=pCopy(sBucketPeek(b));
122 PrintNSpaces(spaces);
123 pWrite0(p);
124 pDelete(&p);
125 break;
126 }
127 else
129 }
130 break;
131 case UNKNOWN:
132 case DEF_CMD:
133 PrintNSpaces(spaces);
134 PrintS("`");PrintS(n);PrintS("`");
135 break;
136 case PACKAGE_CMD:
137 PrintNSpaces(spaces);
138 paPrint(n,(package)d);
139 break;
140 case LIB_CMD:
141 case NONE:
142 return;
143 case INTVEC_CMD:
144 case INTMAT_CMD:
145 ((intvec *)d)->show(t,spaces);
146 break;
147 case RING_CMD:
148 {
149 PrintNSpaces(spaces);
150 const ring r = (ring)d;
151 rWrite(r, currRing == r);
152 break;
153 }
154 case MATRIX_CMD:
155 iiWriteMatrix((matrix)d,n,2, currRing, spaces);
156 break;
157 case SMATRIX_CMD:
158 {
160 ipPrint_MA0(m, n);
161 id_Delete((ideal *) &m,currRing);
162 break;
163 }
164 case MODUL_CMD:
165 case IDEAL_CMD:
166 if ((TEST_V_QRING) &&(currRing->qideal!=NULL)
167 &&(!hasFlag(this,FLAG_QRING)))
168 {
169 jjNormalizeQRingId(this);
170 d=Data();
171 }
172 // no break:
173 case MAP_CMD:
174 iiWriteMatrix((matrix)d,n,1, currRing, spaces);
175 break;
176 case POLY_CMD:
177 case VECTOR_CMD:
178 if ((e==NULL)
179 && (TEST_V_QRING)
180 &&(currRing->qideal!=NULL)
181 &&(!hasFlag(this,FLAG_QRING)))
182 {
183 setFlag(this,FLAG_QRING);
184 poly p=(poly)d;
186 if (p!=(poly)d)
187 {
188 d=(void*)p;
189 if ((rtyp==POLY_CMD)||(rtyp==VECTOR_CMD)) data=d;
190 else if (rtyp==IDHDL)
191 {
192 idhdl h=(idhdl)data;
193 IDPOLY(h)=p;
195 }
196 }
197 }
198 PrintNSpaces(spaces);
199 pWrite0((poly)d);
200 break;
201 case RESOLUTION_CMD:
202 {
203 syStrategy tmp=(syStrategy)d;
205 break;
206 }
207 case STRING_CMD:
208 PrintNSpaces(spaces);
209 PrintS((char *)d);
210 break;
211 case INT_CMD:
212 PrintNSpaces(spaces);
213 ::Print("%d",(int)(long)d);
214 break;
215 case PROC_CMD:
216 {
218
219 PrintNSpaces(spaces);
220 PrintS("// libname : ");
221 PrintS(piProcinfo(pi, "libname"));
222 PrintLn();
223
224 PrintNSpaces(spaces);
225 PrintS("// procname : ");
226 PrintS(piProcinfo(pi, "procname"));
227 PrintLn();
228
229 PrintNSpaces(spaces);
230 PrintS("// type : ");
231 PrintS(piProcinfo(pi, "type"));
232 // ::Print("%-*.*s// ref : %s",spaces,spaces," ",
233 // piProcinfo(pi, "ref"));
234 break;
235 }
236 case LINK_CMD:
237 {
238 si_link l=(si_link)d;
239 PrintNSpaces(spaces);
240 ::Print("// type : %s\n", slStatus(l, "type"));
241 PrintNSpaces(spaces);
242 ::Print("// mode : %s\n", slStatus(l, "mode"));
243 PrintNSpaces(spaces);
244 ::Print("// name : %s\n", slStatus(l, "name"));
245 PrintNSpaces(spaces);
246 ::Print("// open : %s\n", slStatus(l, "open"));
247 PrintNSpaces(spaces);
248 ::Print("// read : %s\n", slStatus(l, "read"));
249 PrintNSpaces(spaces);
250 ::Print("// write: %s", slStatus(l, "write"));
251 break;
252 }
253 case BIGINT_CMD:
254 s=String(d);
255 if (s==NULL) return;
256 PrintNSpaces(spaces);
257 PrintS(s);
258 omFree((ADDRESS)s);
259 break;
260 case NUMBER_CMD:
261 {
262 number n=(number)d;
263 nNormalize(n);
264 if ((number)d !=n)
265 {
266 d=n;
267 if (rtyp==IDHDL) IDNUMBER(((idhdl)data))=n;
268 else if(rtyp==NUMBER_CMD) data=(void*)n;
269 }
270 s=String(d);
271 if (s==NULL) return;
272 PrintS(s);
273 omFree((ADDRESS)s);
274 break;
275 }
276 case LIST_CMD:
277 {
278 lists l=(lists)d;
279 if (lSize(l)<0)
280 {
281 PrintNSpaces(spaces);
282 PrintS("empty list\n");
283 }
284 else
285 {
286 int i=0;
287 for (;i<=l->nr;i++)
288 {
289 if (l->m[i].rtyp!=DEF_CMD)
290 {
291 PrintNSpaces(spaces);
292 ::Print("[%d]:\n",i+1);
293 l->m[i].Print(NULL,spaces+3);
294 }
295 }
296 }
297 break;
298 }
299
300 default:
301 if (t>MAX_TOK)
302 {
303 blackbox * bb=getBlackboxStuff(t);
304 PrintNSpaces(spaces);
305 if (bb!=NULL) { bb->blackbox_Print(bb,d); }
306 else { ::Print("Print: blackbox %d(bb=NULL)",t); }
307 }
308 else
309 ::Print("Print:unknown type %s(%d)", Tok2Cmdname(t),t);
310 } /* end switch: (Typ()) */
311 if ((store!=NULL)&&(store!=this))
312 store->CleanUp();
313 }
314 if (next!=NULL)
315 {
316 if (t==COMMAND) PrintLn();
317 else if (t!=LIST_CMD) PrintS(" ");
318 next->Print(NULL,spaces);
319 }
320 else if ((t!=LIST_CMD)&&(t!=SMATRIX_CMD))
321 {
322 PrintLn();
323 }
324#ifdef SIQ
325 if (rtyp!=COMMAND)
326#endif
327 {
328 if ((store!=NULL)
329 && (store!=this))
330 {
331 if((t/*Typ()*/!=LINK_CMD)
332 && (t/*Typ()*/!=PACKAGE_CMD)
333 && (t/*Typ()*/!=DEF_CMD)
334 )
335 {
336 store->rtyp=t/*Typ()*/;
337 store->data=CopyD();
338 if(attribute!=NULL)
339 {
340 store->attribute=CopyA();
341 }
342 store->flag=flag;
343 }
344 }
345 }
346}
int p
Definition: cfModGcd.cc:4078
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:761
attr CopyA()
Definition: subexpr.cc:753
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:327
@ VECTOR_CMD
Definition: grammar.cc:292
@ RESOLUTION_CMD
Definition: grammar.cc:290
@ RING_CMD
Definition: grammar.cc:281
ideal id_Copy(ideal h1, const ring r)
copy an ideal
void jjNormalizeQRingId(leftv I)
Definition: ipassign.cc:2318
VAR idhdl currRingHdl
Definition: ipid.cc:59
const char * piProcinfo(procinfov pi, const char *request)
Definition: ipid.cc:714
#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 ipPrint_MA0(matrix m, const char *name)
Definition: ipprint.cc:57
void paPrint(const char *n, package p)
Definition: ipshell.cc:6327
#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:834
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:132
#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:226
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
procinfo * procinfov
Definition: structs.h:60
ssyStrategy * syStrategy
Definition: syz.h:35
void syPrint(syStrategy syzstr, const char *currRingName)
Definition: syz1.cc:1934
@ 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:222

◆ RingDependend()

BOOLEAN sleftv::RingDependend ( )

Definition at line 418 of file subexpr.cc.

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

◆ 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 761 of file subexpr.cc.

762{
763#ifdef SIQ
764 if (rtyp==COMMAND)
765 {
766 ::Print("##command %d\n",((command)data)->op);
767 if (((command)data)->arg1.rtyp!=0)
768 ((command)data)->arg1.Print(NULL,2);
769 if (((command)data)->arg2.rtyp!=0)
770 ((command)data)->arg2.Print(NULL,2);
771 if (((command)data)->arg3.rtyp==0)
772 ((command)data)->arg3.Print(NULL,2);
773 PrintS("##end\n");
774 return omStrDup("");
775 }
776#endif
777 if (d==NULL) d=Data();
778 if (!errorreported)
779 {
780 char *s;
781 int t=Typ();
782 switch (t /*Typ()*/)
783 {
784 case INT_CMD:
785 if (typed)
786 {
787 s=(char *)omAlloc(MAX_INT_LEN+7);
788 sprintf(s,"int(%d)",(int)(long)d);
789 }
790 else
791 {
792 s=(char *)omAlloc(MAX_INT_LEN+2);
793 sprintf(s,"%d",(int)(long)d);
794 }
795 return s;
796
797 case STRING_CMD:
798 if (d == NULL)
799 {
800 if (typed) return omStrDup("\"\"");
801 return omStrDup("");
802 }
803 if (typed)
804 {
805 s = (char*) omAlloc(strlen((char*) d) + 3);
806 sprintf(s,"\"%s\"", (char*) d);
807 return s;
808 }
809 else
810 {
811 return omStrDup((char*)d);
812 }
813
814 case POLY_CMD:
815 case VECTOR_CMD:
816 if (typed)
817 {
818 char* ps = pString((poly) d);
819 s = (char*) omAlloc(strlen(ps) + 10);
820 sprintf(s,"%s(%s)", (t /*Typ()*/ == POLY_CMD ? "poly" : "vector"), ps);
821 omFree(ps);
822 return s;
823 }
824 else
825 return pString((poly)d);
826
827 case CRING_CMD:
828 return nCoeffString((coeffs)d);
829 #ifdef SINGULAR_4_2
830 case CNUMBER_CMD:
831 return n2String((number2)d,typed);
832 case CMATRIX_CMD:
833 {
834 bigintmat *b=(bigintmat*)d;
835 return b->String();
836 }
837 #endif
838
839 case NUMBER_CMD:
840 StringSetS((char*) (typed ? "number(" : ""));
842 {
843 nfShowMipo(currRing->cf);
844 }
845 else
846 {
847 nWrite((number)d);
848 }
849 StringAppendS((char*) (typed ? ")" : ""));
850 return StringEndS();
851
852 case BIGINT_CMD:
853 {
854 StringSetS((char*) (typed ? "bigint(" : ""));
855 number nl=(number)d;
857 StringAppendS((char*) (typed ? ")" : ""));
858 return StringEndS();
859 }
860 case BUCKET_CMD:
861 return sBucketString((sBucket_pt)d);
862 case MATRIX_CMD:
864 if (typed)
865 {
866 char* ns = (char*) omAlloc(strlen(s) + 40);
867 sprintf(ns, "matrix(ideal(%s),%d,%d)", s,
868 ((ideal) d)->nrows, ((ideal) d)->ncols);
869 omCheckAddr(ns);
870 return ns;
871 }
872 else
873 {
874 return omStrDup(s);
875 }
876
877 case IDEAL_CMD:
878 case MAP_CMD:
879 case MODUL_CMD:
880 case SMATRIX_CMD:
882 if (typed)
883 {
884 char* ns = (char*) omAlloc(strlen(s) + 10);
885 if ((t/*Typ()*/==IDEAL_CMD)||(t==MAP_CMD))
886 sprintf(ns, "ideal(%s)", s);
887 else /*MODUL_CMD, SMATRIX_CMD */
888 sprintf(ns, "module(%s)", s);
889 omFree(s);
890 omCheckAddr(ns);
891 return ns;
892 }
893 return s;
894
895 case INTVEC_CMD:
896 case INTMAT_CMD:
897 {
898 intvec *v=(intvec *)d;
899 s = v->String(dim);
900 if (typed)
901 {
902 char* ns;
903 if (t/*Typ()*/ == INTMAT_CMD)
904 {
905 ns = (char*) omAlloc(strlen(s) + 40);
906 sprintf(ns, "intmat(intvec(%s),%d,%d)", s, v->rows(), v->cols());
907 }
908 else
909 {
910 ns = (char*) omAlloc(strlen(s) + 10);
911 sprintf(ns, "intvec(%s)", s);
912 }
913 omCheckAddr(ns);
914 omFree(s);
915 return ns;
916 }
917 else
918 return s;
919 }
920 case BIGINTMAT_CMD:
921 {
922 bigintmat *bim=(bigintmat*)d;
923 s = bim->String();
924 if (typed)
925 {
926 char* ns = (char*) omAlloc0(strlen(s) + 40);
927 sprintf(ns, "bigintmat(bigintvec(%s),%d,%d)", s, bim->rows(), bim->cols());
928 omCheckAddr(ns);
929 return ns;
930 }
931 else
932 return omStrDup(s);
933 }
934
935 case RING_CMD:
936 s = rString((ring)d);
937
938 if (typed)
939 {
940 char* ns;
941 ring r=(ring)d;
942 if (r->qideal!=NULL)
943 {
944 char* id = iiStringMatrix((matrix) ((ring) d)->qideal, dim,
945 currRing);
946 ns = (char*) omAlloc(strlen(s) + strlen(id) + 20);
947 sprintf(ns, "\"%s\";%sideal(%s)", s,(dim == 2 ? "\n" : " "), id);
948 }
949 else
950 {
951 ns = (char*) omAlloc(strlen(s) + 4);
952 sprintf(ns, "\"%s\"", s);
953 }
954 omFree(s);
955 omCheckAddr(ns);
956 return ns;
957 }
958 return s;
959 case RESOLUTION_CMD:
960 {
962 s = lString(l, typed, dim);
963 l->Clean();
964 return s;
965 }
966
967 case PROC_CMD:
968 {
969 procinfo* pi = (procinfo*) d;
970 if((pi->language == LANG_SINGULAR) && (pi->data.s.body!=NULL))
971 s = (pi->data.s.body);
972 else
973 s = (char *)"";
974 if (typed)
975 {
976 char* ns = (char*) omAlloc(strlen(s) + 4);
977 sprintf(ns, "\"%s\"", s);
978 omCheckAddr(ns);
979 return ns;
980 }
981 return omStrDup(s);
982 }
983
984 case LINK_CMD:
985 s = slString((si_link) d);
986 if (typed)
987 {
988 char* ns = (char*) omAlloc(strlen(s) + 10);
989 sprintf(ns, "link(\"%s\")", s);
991 omCheckAddr(ns);
992 return ns;
993 }
994 return s;
995
996 case LIST_CMD:
997 return lString((lists) d, typed, dim);
998
999 default:
1000 if(t> MAX_TOK)
1001 {
1002 blackbox *bb=getBlackboxStuff(t);
1003 if (bb!=NULL) return bb->blackbox_String(bb,d);
1004 }
1005 } /* end switch: (Typ()) */
1006 }
1007 return omStrDup("");
1008}
int int ncols
Definition: cf_linsys.cc:32
int nrows
Definition: cf_linsys.cc:32
int cols() const
Definition: bigintmat.h:144
int rows() const
Definition: bigintmat.h:145
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:436
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:959
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:591
void nfShowMipo(const coeffs r)
Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d,...
Definition: ffields.cc:551
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3187
char * lString(lists l, BOOLEAN typed, int dim)
Definition: lists.cc:380
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
Definition: matpol.cc:855
const int MAX_INT_LEN
Definition: mylimits.h:13
#define nWrite(n)
Definition: numbers.h:29
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omFreeBinAddr(addr)
Definition: omAllocDecl.h:258
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:673
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:522
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 1011 of file subexpr.cc.

1012{
1013 if (e==NULL)
1014 {
1015 switch (rtyp)
1016 {
1017 case IDHDL:
1018 return IDTYP((idhdl)data);
1019 case ALIAS_CMD:
1020 {
1021 idhdl h=(idhdl)data;
1022 return ((idhdl)h->data.ustring)->typ;
1023 }
1024 case VECHO:
1025 case VPRINTLEVEL:
1026 case VCOLMAX:
1027 case VTIMER:
1028 case VRTIMER:
1029 case VOICE:
1030 case VMAXDEG:
1031 case VMAXMULT:
1032 case TRACE:
1033 case VSHORTOUT:
1034 return INT_CMD;
1035 case VMINPOLY:
1036 data=NULL;
1037 return NUMBER_CMD;
1038 case VNOETHER:
1039 data=NULL;
1040 return POLY_CMD;
1041 //case COMMAND:
1042 // return COMMAND;
1043 default:
1044 return rtyp;
1045 }
1046 }
1047 int r=0;
1048 int t=rtyp;
1049 void *d=data;
1050 if (t==IDHDL) t=IDTYP((idhdl)d);
1051 else if (t==ALIAS_CMD)
1052 { idhdl h=(idhdl)IDDATA((idhdl)data); t=IDTYP(h);d=IDDATA(h); }
1053 switch (t)
1054 {
1055#ifdef SINGULAR_4_2
1056 case CMATRIX_CMD:
1057 {
1058 bigintmat *b=(bigintmat*)d;
1059 if ((currRing!=NULL)&&(currRing->cf==b->basecoeffs()))
1060 return NUMBER_CMD;
1061 else
1062 return CNUMBER_CMD;
1063 }
1064#endif
1065 case INTVEC_CMD:
1066 case INTMAT_CMD:
1067 r=INT_CMD;
1068 break;
1069 case BIGINTMAT_CMD:
1070 r=BIGINT_CMD;
1071 break;
1072 case IDEAL_CMD:
1073 case MATRIX_CMD:
1074 case MAP_CMD:
1075 case SMATRIX_CMD:
1076 r=POLY_CMD;
1077 break;
1078 case MODUL_CMD:
1079 r=VECTOR_CMD;
1080 break;
1081 case STRING_CMD:
1082 r=STRING_CMD;
1083 break;
1084 default:
1085 {
1086 blackbox *b=NULL;
1087 if (t>MAX_TOK)
1088 {
1090 }
1091 if ((t==LIST_CMD)||((b!=NULL)&&BB_LIKE_LIST(b)))
1092 {
1093 lists l;
1094 if (rtyp==IDHDL) l=IDLIST((idhdl)d);
1095 else l=(lists)d;
1096 if ((0<e->start)&&(e->start<=l->nr+1))
1097 {
1098 Subexpr tmp=l->m[e->start-1].e;
1099 l->m[e->start-1].e=e->next;
1100 r=l->m[e->start-1].Typ();
1101 e->next=l->m[e->start-1].e;
1102 l->m[e->start-1].e=tmp;
1103 }
1104 else
1105 {
1106 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1107 r=DEF_CMD;
1108 }
1109 }
1110 else
1111 Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
1112 break;
1113 }
1114 }
1115 return r;
1116}

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: