source: git/Singular/subexpr.h @ 16acb0

spielwiese
Last change on this file since 16acb0 was 16acb0, checked in by Hans Schönemann <hannes@…>, 22 years ago
* hannes: more ring-independence in changing rings, deleting data etc. (see lists::Clean(r), sleftv::CleanUp(r), syKillComputation(r), nap_Delete) git-svn-id: file:///usr/local/Singular/svn/trunk@5708 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.2 KB
Line 
1#ifndef SUBEXPR_H
2#define SUBEXPR_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: subexpr.h,v 1.31 2002-01-10 12:33:24 Singular Exp $ */
7/*
8* ABSTRACT: handling of leftv
9*/
10
11#include <string.h>
12#include "grammar.h"
13#include "tok.h"
14#include "structs.h"
15
16struct _ssubexpr
17{
18  struct _ssubexpr * next;
19  int start;
20};
21
22typedef struct _ssubexpr sSubexpr;
23typedef sSubexpr * Subexpr;
24
25extern const char sNoName[];
26extern BOOLEAN siq;
27extern char *iiSleftv2name(leftv v);
28
29class sleftv;
30typedef sleftv * leftv;
31class sleftv
32{
33  public:
34  /* !! do not change the first 6 entries !! (see ipid.h: idrec) */
35    leftv       next;
36    char *      name;
37    void *      data;
38    attr        attribute;
39    BITSET      flag;
40    int         rtyp;
41                 /* the type of the expression, describes the data field
42                  * (E) markes the type field in iparith
43                  * (S) markes the rtyp in sleftv
44                  * ANY_TYPE:   data is int: real type or 0    (E)
45                  * DEF_CMD:    all types, no change in sleftv (E)
46                  * IDHDL: existing variable         (E)
47                  * IDHDL: variable, data is idhdl   (S)
48                  * COMMAND: data is command         (S)
49                  * INT_CMD:      int constant, data is int  (E,S)
50                  * INTVEC_CMD:   intvec constant, data is intvec * (E,S)
51                  * POLY_CMD:     poly constant, data is poly (E,S)
52                  * ....
53                  */
54    Subexpr e;    /* holds the indices for indexed values */
55#ifdef HAVE_NAMESPACES
56    idhdl       packhdl;
57    idhdl       req_packhdl;
58#define IDSROOT(a) (IDPACKAGE(((sleftv)a).packhdl)->idroot)
59#endif /* HAVE_NAMESPACES */
60#ifdef HAVE_NS
61    package     packhdl;
62    package     req_packhdl;
63#endif /* HAVE_NS */
64    inline void Init() { memset(this,0,sizeof(*this)); }
65    void Set(int val);
66    void Print(leftv store=NULL,int spaces=0);
67    void CleanUp(ring r=currRing);
68    char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
69    void Copy(leftv e);
70    attr CopyA();
71    void * CopyD(int t);
72    void * CopyD() { return CopyD(Typ()); }
73    inline const char * Name()
74    {
75      if ((name!=NULL) && (e==NULL)) return name;
76      else return sNoName;
77    }
78    inline const char * Fullname()
79    {
80      if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this));
81      else return sNoName;
82    }
83    int  Typ();
84    int  LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
85    void * Data();
86    void SetData(void* value);
87    leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
88    leftv LHdl();
89    attr * Attribute();
90    inline leftv Next() { return next; }
91    int listLength();
92    int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
93    BOOLEAN RingDependend();
94};
95
96inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); }
97extern sleftv sLastPrinted;
98
99struct _sssym
100{
101  idhdl   h;
102  Subexpr e;
103};
104typedef struct _sssym ssym;
105typedef ssym * sym;
106
107void syMake(leftv v,char * name, idhdl packhdl = NULL);
108BOOLEAN assumeStdFlag(leftv h);
109
110class proc_singular
111{
112public:
113  long   proc_start;       // position where proc is starting
114  long   def_end;          // position where proc header is ending
115  long   help_start;       // position where help is starting
116  long   help_end;         // position where help is starting
117  long   body_start;       // position where proc-body is starting
118  long   body_end;         // position where proc-body is ending
119  long   example_start;    // position where example is starting
120  long   proc_end;         // position where proc is ending
121  int    proc_lineno;
122  int    body_lineno;
123  int    example_lineno;
124  char   *body;
125  long help_chksum;
126};
127
128struct proc_object
129{
130//public:
131  BOOLEAN (*function)(leftv res, leftv v);
132};
133
134union uprocinfodata;
135
136union uprocinfodata
137{
138public:
139  proc_singular  s;        // data of Singular-procedure
140  struct proc_object    o; // pointer to binary-function
141};
142
143typedef union uprocinfodata procinfodata;
144
145typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
146// LANG_TOP     : Toplevel package only
147// LANG_SINGULAR:
148// LANG_C       :
149class procinfo
150{
151public:
152  char          *libname;
153  char          *procname;
154#ifdef HAVE_NS
155  package       pack;
156#endif
157  language_defs language;
158  short         ref;
159  char          is_static;        // if set, proc not accessible for user
160  char          trace_flag;
161  procinfodata  data;
162};
163
164inline procinfov piCopy(procinfov pi)
165{
166  pi->ref++;
167  return pi;
168}
169BOOLEAN piKill(procinfov l);
170char *piProcinfo(procinfov pi, char *request);
171void piShowProcinfo(procinfov pi, char *txt);
172#ifdef HAVE_LIBPARSER
173class libstack
174{
175 public:
176  libstackv next;
177  char      *libname;
178  BOOLEAN   to_be_done;
179  int       cnt;
180  void      push(char *p, char * libname);
181  libstackv pop(char *p);
182  inline char *get() { return(libname); }
183};
184#endif /* HAVE_LIBPARSER */
185
186typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX} lib_types;
187lib_types type_of_LIB(char *newlib, char *fullname);
188
189#ifndef OM_ALLOC_H
190struct omBin_s;
191#endif
192
193extern omBin_s* sSubexpr_bin;
194extern omBin_s* sleftv_bin;
195extern omBin_s* procinfo_bin;
196extern omBin_s* libstack_bin;
197
198#endif
Note: See TracBrowser for help on using the repository browser.