source: git/Singular/ipid.h @ 133576

spielwiese
Last change on this file since 133576 was 133576, checked in by Hans Schönemann <hannes@…>, 22 years ago
*hannes: fast_maps, gcc-3 fixes git-svn-id: file:///usr/local/Singular/svn/trunk@5809 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.7 KB
Line 
1#ifndef IPID_H
2#define IPID_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: ipid.h,v 1.33 2002-01-23 13:09:48 Singular Exp $ */
7/*
8* ABSTRACT: identfier handling
9*/
10#include <string.h>
11#include "structs.h"
12#include "subexpr.h"
13
14struct sip_command
15{
16  sleftv arg1; /*arg1 to build_in, proc to proc_call*/
17  sleftv arg2; /*NULL or arg2 to build_in, args to proc_call*/
18  sleftv arg3; /*NULL or arg3*/
19  short argc; /*0,1,2,3 to build_in, -1 otherwise*/
20  short op;   /* build_in or PROC_CMD*/
21};
22
23struct sip_package
24{
25  idhdl         idroot; /* local objects */
26  char          *libname;
27  short         ref;
28  language_defs language;
29  BOOLEAN       loaded;
30  void          *handle;
31};
32
33inline package paCopy(package pack)
34{
35  pack->ref++;
36  return pack;
37}
38
39#ifndef HAVE_NAMESPACES
40inline void paKill(package pack)
41{
42  pack->ref--;
43}
44#endif
45
46union uutypes;
47
48union uutypes
49{
50  int           i;
51  ring          uring;
52  poly          p;
53  number        n;
54  ideal         uideal;
55  map           umap;
56  matrix        umatrix;
57  char *        ustring;
58  intvec *      iv;
59  lists         l;
60  si_link       li;
61  package       pack;
62  procinfo *    pinf;
63};
64
65class idrec
66{
67  public:
68  /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */
69  idhdl      next;
70  char *     id;
71  utypes     data;
72  attr       attribute;
73  BITSET     flag;
74  idtyp      typ;
75
76  short      lev;
77  short      ref;
78
79#define IDNEXT(a)    ((a)->next)
80#define IDTYP(a)     ((a)->typ)
81#define IDFLAG(a)    ((a)->flag)
82#define IDLEV(a)     ((a)->lev)
83#define IDID(a)      ((a)->id)
84#define IDATTR(a)    ((a)->attribute)
85
86#define IDINT(a)    ((a)->data.i)
87#define IDDATA(a)   ((a)->data.ustring)
88#define IDRING(a)   ((a)->data.uring)
89#define IDINTVEC(a) ((a)->data.iv)
90#define IDPOLY(a)   ((a)->data.p)
91#define IDNUMBER(a) ((a)->data.n)
92#define IDIDEAL(a)  (((a)->data).uideal)
93#define IDMATRIX(a) (((a)->data).umatrix)
94#define IDMAP(a)    (((a)->data).umap)
95#define IDSTRING(a) ((a)->data.ustring)
96#define IDLIST(a)   ((a)->data.l)
97#define IDLINK(a)   ((a)->data.li)
98#define IDPACKAGE(a) ((a)->data.pack)
99#define IDPROC(a)   ((a)->data.pinf)
100
101  idrec() { memset(this,0,sizeof(*this)); }
102  idhdl get(const char * s, int lev);
103  idhdl set(char * s, int lev, idtyp t, BOOLEAN init=TRUE);
104  char * String();
105//  ~idrec();
106};
107
108class proclevel {
109  public:
110  proclevel * next;
111  idhdl      currRingHdl;
112  ring       currRing;
113  #ifdef HAVE_NS
114  idhdl      currPackHdl;
115  package    currPack;
116  #endif
117  char      * name;
118  proclevel()  { memset(this,0,sizeof(*this)); }
119  void    push(char *);
120  void    pop();
121};
122extern proclevel *procstack;
123
124#ifdef HAVE_NAMESPACES
125class namerec {
126  public:
127  namehdl    next;
128  namehdl    root;
129  package    pack;
130  char *     name;
131  int        lev;
132  BOOLEAN    isroot;
133#define NSROOT(a) ((a)->pack->idroot)
134#define NSPACK(a) ((a)->pack)
135
136  int        myynest;
137  idhdl      currRingHdl;
138  ring       currRing;
139
140 namerec()  { memset(this,0,sizeof(*this)); }
141  //namehdl    Set(idhdl root);
142  namehdl    pop(BOOLEAN change_nesting=FALSE);
143  namehdl    push(package pack, char *name, int nesting=-1, BOOLEAN init=FALSE);
144  idhdl      get(const char * s, int lev, BOOLEAN root=FALSE);
145};
146
147extern namehdl namespaceroot;
148#define IDROOT (NSROOT(namespaceroot))
149#else /* HAVE_NAMESPACES */
150#ifndef HAVE_NS
151extern idhdl      idroot;
152#define IDROOT idroot
153#endif /* HAVE_NS */
154#endif /* HAVE_NAMESPACES */
155
156#ifdef HAVE_NS
157extern idhdl currPackHdl;
158extern idhdl basePackHdl;
159extern package currPack;
160extern package basePack;
161#define IDROOT (currPack->idroot)
162#endif /* HAVE_NS */
163
164extern idhdl      currRingHdl;
165/*extern ring     currRing;  in structs.h */
166extern ideal      currQuotient;
167
168char *idhdl2id(idhdl pck, idhdl h);
169void  iiname2hdl(const char *name, idhdl *pck, idhdl *id);
170idhdl enterid(char * a, int lev, idtyp t, idhdl* root, BOOLEAN init=TRUE);
171idhdl ggetid(const char *n, BOOLEAN local = FALSE);
172idhdl ggetid(const char *n, BOOLEAN local, idhdl *packhdl);
173void  killid(char * a, idhdl * i);
174void  killhdl(idhdl h);
175void  killhdl2(idhdl h, idhdl * ih, ring r);
176lists ipNameList(idhdl root);
177void  ipMoveId(idhdl h);
178BOOLEAN checkPackage(package pack);
179#ifdef HAVE_NS
180idhdl packFindHdl(package r);
181#endif
182
183#define FLAG_STD   0
184#define FLAG_DRING 1
185#define FLAG_DOPERATOR 2
186#define hasFlag(A,F) Sy_inset((F),(A)->flag)
187#define setFlag(A,F) (A)->flag|=Sy_bit(F)
188#define resetFlag(A,F) (A)->flag&=~Sy_bit(F)
189void ipListFlag(idhdl h);
190
191#ifndef OM_ALLOC_H
192struct omBin_s;
193#endif
194
195extern omBin_s* sip_command_bin;
196extern omBin_s* ip_command_bin;
197extern omBin_s* sip_package_bin;
198extern omBin_s* ip_package_bin;
199extern omBin_s* idrec_bin;
200extern omBin_s* namerec_bin;
201#endif
202
203
Note: See TracBrowser for help on using the repository browser.