My Project
Functions | Variables
ipid.cc File Reference
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "coeffs/numbers.h"
#include "coeffs/bigintmat.h"
#include "polys/matpol.h"
#include "polys/monomials/ring.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "kernel/GBEngine/syz.h"
#include "Singular/tok.h"
#include "Singular/ipshell.h"
#include "Singular/fevoices.h"
#include "Singular/lists.h"
#include "Singular/attrib.h"
#include "Singular/links/silink.h"
#include "Singular/ipid.h"
#include "Singular/blackbox.h"
#include "Singular/number2.h"
#include "polys/mod_raw.h"

Go to the source code of this file.

Functions

void paCleanUp (package pack)
 
static long iiS2I (const char *s)
 
void * idrecDataInit (int t)
 
idhdl enterid (const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
 
void killid (const char *id, idhdl *ih)
 
void killhdl (idhdl h, package proot)
 
void killhdl2 (idhdl h, idhdl *ih, ring r)
 
idhdl ggetid (const char *n)
 
void ipListFlag (idhdl h)
 
lists ipNameList (idhdl root)
 
lists ipNameListLev (idhdl root, int lev)
 
static int ipSwapId (idhdl tomove, idhdl &root1, idhdl &root2)
 
void ipMoveId (idhdl tomove)
 
const char * piProcinfo (procinfov pi, const char *request)
 
BOOLEAN piKill (procinfov pi)
 
idhdl packFindHdl (package r)
 
BOOLEAN iiAlias (leftv p)
 

Variables

VAR omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))
 
VAR omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))
 
VAR omBin idrec_bin = omGetSpecBin(sizeof(idrec))
 
VAR coeffs coeffs_BIGINT
 
VAR proclevelprocstack =NULL
 
VAR idhdl currPackHdl = NULL
 
VAR idhdl basePackHdl = NULL
 
VAR package currPack = NULL
 
VAR package basePack = NULL
 
VAR idhdl currRingHdl = NULL
 

Function Documentation

◆ enterid()

idhdl enterid ( const char *  s,
int  lev,
int  t,
idhdl root,
BOOLEAN  init,
BOOLEAN  search 
)

Definition at line 278 of file ipid.cc.

279{
280 if (s==NULL) return NULL;
281 if (root==NULL) return NULL;
282 idhdl h;
283 s=omStrDup(s);
284 // idhdl *save_root=root;
285 if (t==PACKAGE_CMD)
286 {
287 if (root!=&(basePack->idroot))
288 {
289 root=&(basePack->idroot);
290 }
291 }
292 // is it already defined in root ?
293 if ((h=(*root)->get_level(s,lev))!=NULL)
294 {
295 if ((IDTYP(h) == t)||(t==DEF_CMD))
296 {
297 if (IDTYP(h)==PACKAGE_CMD)
298 {
299 if (strcmp(s,"Top")==0)
300 {
301 goto errlabel;
302 }
303 else return h;
304 }
305 else
306 {
307 if (BVERBOSE(V_REDEFINE))
308 {
309 const char *f=VoiceName();
310 if (strcmp(f,"STDIN")==0)
311 Warn("redefining %s (%s)",s,my_yylinebuf);
312 else
313 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
314 }
315 if (s==IDID(h)) IDID(h)=NULL;
316 killhdl2(h,root,currRing);
317 }
318 }
319 else
320 goto errlabel;
321 }
322 // is it already defined in currRing->idroot ?
323 else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
324 {
325 if ((h=currRing->idroot->get_level(s,lev))!=NULL)
326 {
327 if ((IDTYP(h) == t)||(t==DEF_CMD))
328 {
329 if (BVERBOSE(V_REDEFINE))
330 {
331 const char *f=VoiceName();
332 if (strcmp(f,"STDIN")==0)
333 Warn("redefining %s (%s)",s,my_yylinebuf);
334 else
335 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
336 }
337 if (s==IDID(h)) IDID(h)=NULL;
338 killhdl2(h,&currRing->idroot,currRing);
339 }
340 else
341 goto errlabel;
342 }
343 }
344 // is it already defined in idroot ?
345 else if (search && (*root != IDROOT))
346 {
347 if ((h=IDROOT->get_level(s,lev))!=NULL)
348 {
349 if ((IDTYP(h) == t)||(t==DEF_CMD))
350 {
351 if (BVERBOSE(V_REDEFINE))
352 {
353 const char *f=VoiceName();
354 if (strcmp(f,"STDIN")==0)
355 Warn("redefining %s (%s)",s,my_yylinebuf);
356 else
357 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
358 }
359 if (s==IDID(h)) IDID(h)=NULL;
361 }
362 else
363 goto errlabel;
364 }
365 }
366 *root = (*root)->set(s, lev, t, init);
367#ifndef SING_NDEBUG
368 checkall();
369#endif
370 return *root;
371
372 errlabel:
373 //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
374 Werror("identifier `%s` in use",s);
375 //listall();
376 omFree((ADDRESS)s);
377 return NULL;
378}
#define NULL
Definition: auxiliary.h:104
void * ADDRESS
Definition: auxiliary.h:119
f
Definition: cfModGcd.cc:4083
Definition: idrec.h:35
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:236
#define Warn
Definition: emacs.cc:77
const CanonicalForm int s
Definition: facAbsFact.cc:51
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
VAR int yylineno
Definition: febase.cc:40
VAR char my_yylinebuf[80]
Definition: febase.cc:44
const char * VoiceName()
Definition: fevoices.cc:56
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:437
VAR package basePack
Definition: ipid.cc:58
#define IDID(a)
Definition: ipid.h:122
#define IDROOT
Definition: ipid.h:19
#define IDTYP(a)
Definition: ipid.h:119
STATIC_VAR Poly * h
Definition: janet.cc:971
void init()
Definition: lintree.cc:864
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFree(addr)
Definition: omAllocDecl.h:261
#define BVERBOSE(a)
Definition: options.h:34
#define V_REDEFINE
Definition: options.h:44
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
@ PACKAGE_CMD
Definition: tok.h:149
@ DEF_CMD
Definition: tok.h:58

◆ ggetid()

idhdl ggetid ( const char *  n)

Definition at line 571 of file ipid.cc.

572{
573 if (currRing!=NULL)
574 {
575 idhdl h2 = currRing->idroot->get(n,myynest);
576 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
577 idhdl h = IDROOT->get(n,myynest);
578 if (h!=NULL) return h;
579 if (h2!=NULL) return h2;
580 }
581 else
582 {
583 idhdl h = IDROOT->get(n,myynest);
584 if (h!=NULL) return h;
585 }
586 if (basePack!=currPack)
587 return basePack->idroot->get(n,myynest);
588 return NULL;
589}
VAR int myynest
Definition: febase.cc:41
VAR package currPack
Definition: ipid.cc:57
#define IDLEV(a)
Definition: ipid.h:121

◆ idrecDataInit()

void * idrecDataInit ( int  t)

Definition at line 139 of file ipid.cc.

140{
141 switch (t)
142 {
143 //the type with init routines:
144#ifdef SINGULAR_4_2
145 case CNUMBER_CMD:
146 return (void*)n2Init(0,NULL);
147 case CPOLY_CMD:
148 return (void*)p2Init(0,NULL);
149 case CMATRIX_CMD:
150#endif
151 case BIGINTMAT_CMD:
152 return (void *)new bigintmat();
153 case BUCKET_CMD:
154 if (currRing!=NULL)
155 return (void*)sBucketCreate(currRing);
156 else
157 {
158 WerrorS("need basering for polyBucket");
159 return NULL;
160 }
161 case INTVEC_CMD:
162 case INTMAT_CMD:
163 return (void *)new intvec();
164 case NUMBER_CMD:
165 {
166 if (currRing!=NULL) return (void *) nInit(0);
167 else return NULL;
168 }
169 case BIGINT_CMD:
170 return (void *) n_Init(0, coeffs_BIGINT);
171 case IDEAL_CMD:
172 case MODUL_CMD:
173 case MATRIX_CMD:
174 case SMATRIX_CMD:
175 return (void*) idInit(1,1);
176 case MAP_CMD:
177 {
178 map m = (map)idInit(1,1);
179 m->preimage = omStrDup(IDID(currRingHdl));
180 return (void *)m;
181 }
182 case STRING_CMD:
183 return (void *)omAlloc0(1);
184 case LIST_CMD:
185 {
187 l->Init();
188 return (void*)l;
189 }
190 //the types with the standard init: set the struct to zero
191 case LINK_CMD:
192 return (void*) omAlloc0Bin(sip_link_bin);
193 case PACKAGE_CMD:
194 {
195 package pa=(package)omAlloc0Bin(sip_package_bin);
196 pa->language=LANG_NONE;
197 pa->loaded = FALSE;
198 return (void*)pa;
199 }
200 case PROC_CMD:
201 {
203 pi->ref=1;
204 pi->language=LANG_NONE;
205 return (void*)pi;
206 }
207 case RESOLUTION_CMD:
208 return (void *)omAlloc0(sizeof(ssyStrategy));
209 //other types: without alloc. (int,script,poly,def,package,..)
210 case INT_CMD:
211 case DEF_CMD:
212 case POLY_CMD:
213 case VECTOR_CMD:
214 case RING_CMD:
215 case CRING_CMD:
216 case QRING_CMD:
217 return NULL;
218 default:
219 {
220 if (t>MAX_TOK)
221 {
222#ifdef BLACKBOX_DEVEL
223 Print("bb-type %d\n",t);
224#endif
225 blackbox *bb=getBlackboxStuff(t);
226 if (bb!=NULL)
227 return (void *)bb->blackbox_Init(bb);
228 }
229 else
230 Werror("unknown type in idrecDataInit:%d",t);
231 break;
232 }
233 }
234 return (void *)0L;
235}
#define FALSE
Definition: auxiliary.h:96
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:504
Matrices of numbers.
Definition: bigintmat.h:51
Definition: intvec.h:23
Definition: lists.h:24
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:4344
#define Print
Definition: emacs.cc:80
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BUCKET_CMD
Definition: grammar.cc:283
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ MAP_CMD
Definition: grammar.cc:285
@ PROC_CMD
Definition: grammar.cc:280
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
@ VECTOR_CMD
Definition: grammar.cc:292
@ RESOLUTION_CMD
Definition: grammar.cc:290
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
@ RING_CMD
Definition: grammar.cc:281
VAR idhdl currRingHdl
Definition: ipid.cc:59
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define pi
Definition: libparse.cc:1145
VAR omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146
#define nInit(i)
Definition: numbers.h:24
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omAlloc0(size)
Definition: omAllocDecl.h:211
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
procinfo * procinfov
Definition: structs.h:65
VAR omBin procinfo_bin
Definition: subexpr.cc:42
@ LANG_NONE
Definition: subexpr.h:22
@ BIGINT_CMD
Definition: tok.h:38
@ CRING_CMD
Definition: tok.h:56
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ CMATRIX_CMD
Definition: tok.h:46
@ CNUMBER_CMD
Definition: tok.h:47
@ LINK_CMD
Definition: tok.h:117
@ QRING_CMD
Definition: tok.h:158
@ STRING_CMD
Definition: tok.h:185
@ CPOLY_CMD
Definition: tok.h:48
@ INT_CMD
Definition: tok.h:96
@ MAX_TOK
Definition: tok.h:218

◆ iiAlias()

BOOLEAN iiAlias ( leftv  p)

Definition at line 834 of file ipid.cc.

835{
836 if (iiCurrArgs==NULL)
837 {
838 Werror("not enough arguments for proc %s",VoiceName());
839 p->CleanUp();
840 return TRUE;
841 }
843 iiCurrArgs=h->next;
844 h->next=NULL;
845 if (h->rtyp!=IDHDL)
846 {
848 h->CleanUp();
850 return res;
851 }
852 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
853 {
854 WerrorS("type mismatch");
855 return TRUE;
856 }
857 idhdl pp=(idhdl)p->data;
858 switch(pp->typ)
859 {
860 case CRING_CMD:
862 break;
863 case DEF_CMD:
864 case INT_CMD:
865 break;
866 case INTVEC_CMD:
867 case INTMAT_CMD:
868 delete IDINTVEC(pp);
869 break;
870 case NUMBER_CMD:
872 break;
873 case BIGINT_CMD:
875 break;
876 case MAP_CMD:
877 {
878 map im = IDMAP(pp);
879 omFree((ADDRESS)im->preimage);
880 im->preimage=NULL;// and continue
881 }
882 // continue as ideal:
883 case IDEAL_CMD:
884 case MODUL_CMD:
885 case MATRIX_CMD:
887 break;
888 case PROC_CMD:
889 case RESOLUTION_CMD:
890 case STRING_CMD:
892 break;
893 case LIST_CMD:
894 IDLIST(pp)->Clean();
895 break;
896 case LINK_CMD:
898 break;
899 // case ring: cannot happen
900 default:
901 Werror("unknown type %d",p->Typ());
902 return TRUE;
903 }
904 pp->typ=ALIAS_CMD;
905 IDDATA(pp)=(char*)h->data;
906 int eff_typ=h->Typ();
907 if ((RingDependend(eff_typ))
908 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
909 {
910 ipSwapId(pp,IDROOT,currRing->idroot);
911 }
912 h->CleanUp();
914 return FALSE;
915}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
int p
Definition: cfModGcd.cc:4080
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:526
CanonicalForm res
Definition: facAbsFact.cc:60
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1964
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:669
#define IDMAP(a)
Definition: ipid.h:135
#define IDSTRING(a)
Definition: ipid.h:136
EXTERN_VAR omBin sleftv_bin
Definition: ipid.h:145
#define IDDATA(a)
Definition: ipid.h:126
#define IDINTVEC(a)
Definition: ipid.h:128
#define IDLINK(a)
Definition: ipid.h:138
#define IDIDEAL(a)
Definition: ipid.h:133
#define IDNUMBER(a)
Definition: ipid.h:132
#define IDLIST(a)
Definition: ipid.h:137
VAR leftv iiCurrArgs
Definition: ipshell.cc:80
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nDelete(n)
Definition: numbers.h:16
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
idrec * idhdl
Definition: ring.h:21
BOOLEAN RingDependend(int t)
Definition: subexpr.h:142
#define IDHDL
Definition: tok.h:31
@ ALIAS_CMD
Definition: tok.h:34

◆ iiS2I()

static long iiS2I ( const char *  s)
inlinestatic

Definition at line 65 of file ipid.cc.

66{
67 long l;
68 strncpy((char*)&l,s,SIZEOF_LONG);
69 return l;
70}

◆ ipListFlag()

void ipListFlag ( idhdl  h)

Definition at line 609 of file ipid.cc.

610{
611 if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
612#ifdef HAVE_PLURAL
613 if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
614#endif
615}
#define hasFlag(A, F)
Definition: ipid.h:112
#define FLAG_TWOSTD
Definition: ipid.h:107
#define FLAG_STD
Definition: ipid.h:106
void PrintS(const char *s)
Definition: reporter.cc:284

◆ ipMoveId()

void ipMoveId ( idhdl  tomove)

Definition at line 694 of file ipid.cc.

695{
696 if ((currRing!=NULL)&&(tomove!=NULL))
697 {
698 if (RingDependend(IDTYP(tomove))
699 || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
700 {
701 /*move 'tomove' to ring id's*/
702 if (ipSwapId(tomove,IDROOT,currRing->idroot))
703 ipSwapId(tomove,basePack->idroot,currRing->idroot);
704 }
705 else
706 {
707 /*move 'tomove' to global id's*/
708 ipSwapId(tomove,currRing->idroot,IDROOT);
709 }
710 }
711}

◆ ipNameList()

lists ipNameList ( idhdl  root)

Definition at line 617 of file ipid.cc.

618{
619 idhdl h=root;
620 /* compute the length */
621 int l=0;
622 while (h!=NULL) { l++; h=IDNEXT(h); }
623 /* allocate list */
625 L->Init(l);
626 /* copy names */
627 h=root;
628 l=0;
629 while (h!=NULL)
630 {
631 /* list is initialized with 0 => no need to clear anything */
632 L->m[l].rtyp=STRING_CMD;
633 L->m[l].data=omStrDup(IDID(h));
634 l++;
635 h=IDNEXT(h);
636 }
637 return L;
638}
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
sleftv * m
Definition: lists.h:46
INLINE_THIS void Init(int l=0)
#define IDNEXT(a)
Definition: ipid.h:118

◆ ipNameListLev()

lists ipNameListLev ( idhdl  root,
int  lev 
)

Definition at line 640 of file ipid.cc.

641{
642 idhdl h=root;
643 /* compute the length */
644 int l=0;
645 while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
646 /* allocate list */
648 L->Init(l);
649 /* copy names */
650 h=root;
651 l=0;
652 while (h!=NULL)
653 {
654 if (IDLEV(h)==lev)
655 {
656 /* list is initialized with 0 => no need to clear anything */
657 L->m[l].rtyp=STRING_CMD;
658 L->m[l].data=omStrDup(IDID(h));
659 l++;
660 }
661 h=IDNEXT(h);
662 }
663 return L;
664}

◆ ipSwapId()

static int ipSwapId ( idhdl  tomove,
idhdl root1,
idhdl root2 
)
static

Definition at line 669 of file ipid.cc.

670{
671 idhdl h;
672 /* search 'tomove' in root2 : if found -> do nothing */
673 h=root2;
674 while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
675 if (h!=NULL) return FALSE; /*okay */
676 /* search predecessor of h in root1, remove 'tomove' */
677 h=root1;
678 if (tomove==h)
679 {
680 root1=IDNEXT(h);
681 }
682 else
683 {
684 while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
685 if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
686 IDNEXT(h)=IDNEXT(tomove);
687 }
688 /* add to root2 list */
689 IDNEXT(tomove)=root2;
690 root2=tomove;
691 return FALSE;
692}

◆ killhdl()

void killhdl ( idhdl  h,
package  proot 
)

Definition at line 406 of file ipid.cc.

407{
408 int t=IDTYP(h);
409 if (((BEGIN_RING<t) && (t<END_RING))
410 || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
411 killhdl2(h,&currRing->idroot,currRing);
412 else
413 {
414 if(t==PACKAGE_CMD)
415 {
416 killhdl2(h,&(basePack->idroot),NULL);
417 }
418 else
419 {
420 idhdl s=proot->idroot;
421 while ((s!=h) && (s!=NULL)) s=s->next;
422 if (s!=NULL)
423 killhdl2(h,&(proot->idroot),NULL);
424 else if (basePack!=proot)
425 {
426 idhdl s=basePack->idroot;
427 while ((s!=h) && (s!=NULL)) s=s->next;
428 if (s!=NULL)
429 killhdl2(h,&(basePack->idroot),currRing);
430 else
431 killhdl2(h,&(currRing->idroot),currRing);
432 }
433 }
434 }
435}
@ END_RING
Definition: grammar.cc:310
@ BEGIN_RING
Definition: grammar.cc:282

◆ killhdl2()

void killhdl2 ( idhdl  h,
idhdl ih,
ring  r 
)

Definition at line 437 of file ipid.cc.

438{
439 //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
440 idhdl hh;
441
443 && (IDLEV(h)!=myynest)
444 &&(IDLEV(h)==0))
445 {
446 if (((*ih)==basePack->idroot)
447 || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
448 Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
449 }
450 if (h->attribute!=NULL)
451 {
452 if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
453 h->attribute->killAll(IDRING(h));
454 else
455 h->attribute->killAll(r);
456 h->attribute=NULL;
457 }
458 if (IDTYP(h) == PACKAGE_CMD)
459 {
460 if (((IDPACKAGE(h)->language==LANG_C)&&(IDPACKAGE(h)->idroot!=NULL))
461 || (strcmp(IDID(h),"Top")==0))
462 {
463 Warn("cannot kill `%s`",IDID(h));
464 return;
465 }
466 // any objects defined for this package ?
467 if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
468 {
469 if (currPack==IDPACKAGE(h))
470 {
473 }
474 idhdl * hd = &IDRING(h)->idroot;
475 idhdl hdh = IDNEXT(*hd);
476 idhdl temp;
477 while (hdh!=NULL)
478 {
479 temp = IDNEXT(hdh);
480 killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
481 hdh = temp;
482 }
483 killhdl2(*hd,hd,NULL);
484 if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
485 }
489 }
490 else if (IDTYP(h)==RING_CMD)
491 rKill(h);
492 else if (IDDATA(h)!=NULL)
494 // general -------------------------------------------------------------
495 // now dechain it and delete idrec
496 if (IDID(h)!=NULL) // OB: ?????
497 omFree((ADDRESS)IDID(h));
498 IDID(h)=NULL;
499 IDDATA(h)=NULL;
500 if (h == (*ih))
501 {
502 // h is at the beginning of the list
503 *ih = IDNEXT(h) /* ==*ih */;
504 }
505 else if (ih!=NULL)
506 {
507 // h is somethere in the list:
508 hh = *ih;
509 loop
510 {
511 if (hh==NULL)
512 {
513 PrintS(">>?<< not found for kill\n");
514 return;
515 }
516 idhdl hhh = IDNEXT(hh);
517 if (hhh == h)
518 {
519 IDNEXT(hh) = IDNEXT(hhh);
520 break;
521 }
522 hh = hhh;
523 }
524 }
526}
VAR omBin idrec_bin
Definition: ipid.cc:48
VAR idhdl currPackHdl
Definition: ipid.cc:55
idhdl packFindHdl(package r)
Definition: ipid.cc:821
#define IDPACKAGE(a)
Definition: ipid.h:139
void paKill(package pack)
Definition: ipid.h:50
#define IDRING(a)
Definition: ipid.h:127
void iiCheckPack(package &p)
Definition: ipshell.cc:1636
void rKill(ring r)
Definition: ipshell.cc:6255
#define TEST_V_ALLWARN
Definition: options.h:143
#define loop
Definition: structs.h:80
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:514
@ LANG_C
Definition: subexpr.h:22

◆ killid()

void killid ( const char *  id,
idhdl ih 
)

Definition at line 379 of file ipid.cc.

380{
381 if (id!=NULL)
382 {
383 idhdl h = (*ih)->get(id,myynest);
384
385 // id not found in global list, is it defined in current ring ?
386 if (h==NULL)
387 {
388 if ((currRing!=NULL) && (*ih != (currRing->idroot)))
389 {
390 h = currRing->idroot->get(id,myynest);
391 if (h!=NULL)
392 {
393 killhdl2(h,&(currRing->idroot),currRing);
394 return;
395 }
396 }
397 Werror("`%s` is not defined",id);
398 return;
399 }
400 killhdl2(h,ih,currRing);
401 }
402 else
403 WerrorS("kill what ?");
404}

◆ packFindHdl()

idhdl packFindHdl ( package  r)

Definition at line 821 of file ipid.cc.

822{
823 idhdl h=basePack->idroot;
824 while (h!=NULL)
825 {
826 if ((IDTYP(h)==PACKAGE_CMD)
827 && (IDPACKAGE(h)==r))
828 return h;
829 h=IDNEXT(h);
830 }
831 return NULL;
832}

◆ paCleanUp()

void paCleanUp ( package  pack)

Definition at line 775 of file ipid.cc.

776{
777 (pack->ref)--;
778 if (pack->ref < 0)
779 {
780 if( pack->language == LANG_C)
781 {
782 Print("//dlclose(%s)\n",pack->libname);
783#ifdef HAVE_DYNAMIC_LOADING
784 dynl_close (pack->handle);
785#endif /* HAVE_DYNAMIC_LOADING */
786 }
787 omFree((ADDRESS)pack->libname);
788 memset((void *) pack, 0, sizeof(sip_package));
789 pack->language=LANG_NONE;
790 }
791}
int dynl_close(void *handle)
Definition: mod_raw.cc:170

◆ piKill()

BOOLEAN piKill ( procinfov  pi)

Definition at line 737 of file ipid.cc.

738{
739 (pi->ref)--;
740 if (pi->ref == 0)
741 {
742 if (pi->language==LANG_SINGULAR)
743 {
745 while (p!=NULL)
746 {
747 if (p->pi==pi && pi->ref <= 1)
748 {
749 Warn("`%s` in use, can not be killed",pi->procname);
750 return TRUE;
751 }
752 p=p->next;
753 }
754 }
755 if (pi->libname != NULL) // OB: ????
756 omFree((ADDRESS)pi->libname);
757 if (pi->procname != NULL) // OB: ????
758 omFree((ADDRESS)pi->procname);
759
760 if( pi->language == LANG_SINGULAR)
761 {
762 if (pi->data.s.body != NULL) // OB: ????
763 omFree((ADDRESS)pi->data.s.body);
764 }
765 if( pi->language == LANG_C)
766 {
767 }
768 memset((void *) pi, 0, sizeof(procinfo));
769 //pi->language=LANG_NONE;
771 }
772 return FALSE;
773}
Definition: fevoices.h:59
VAR Voice * currentVoice
Definition: fevoices.cc:47
@ LANG_SINGULAR
Definition: subexpr.h:22

◆ piProcinfo()

const char * piProcinfo ( procinfov  pi,
const char *  request 
)

Definition at line 713 of file ipid.cc.

714{
715 if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
716 else if (strcmp(request, "libname") == 0) return pi->libname;
717 else if (strcmp(request, "procname") == 0) return pi->procname;
718 else if (strcmp(request, "type") == 0)
719 {
720 switch (pi->language)
721 {
722 case LANG_SINGULAR: return "singular"; break;
723 case LANG_C: return "object"; break;
724 case LANG_NONE: return "none"; break;
725 default: return "unknown language";
726 }
727 }
728 else if (strcmp(request, "ref") == 0)
729 {
730 char p[8];
731 sprintf(p, "%d", pi->ref);
732 return omStrDup(p); // MEMORY-LEAK
733 }
734 return "??";
735}

Variable Documentation

◆ basePack

VAR package basePack = NULL

Definition at line 58 of file ipid.cc.

◆ basePackHdl

VAR idhdl basePackHdl = NULL

Definition at line 56 of file ipid.cc.

◆ coeffs_BIGINT

VAR coeffs coeffs_BIGINT

Definition at line 50 of file ipid.cc.

◆ currPack

VAR package currPack = NULL

Definition at line 57 of file ipid.cc.

◆ currPackHdl

VAR idhdl currPackHdl = NULL

Definition at line 55 of file ipid.cc.

◆ currRingHdl

VAR idhdl currRingHdl = NULL

Definition at line 59 of file ipid.cc.

◆ idrec_bin

VAR omBin idrec_bin = omGetSpecBin(sizeof(idrec))

Definition at line 48 of file ipid.cc.

◆ procstack

VAR proclevel* procstack =NULL

Definition at line 52 of file ipid.cc.

◆ sip_command_bin

VAR omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))

Definition at line 45 of file ipid.cc.

◆ sip_package_bin

VAR omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))

Definition at line 46 of file ipid.cc.