source: git/Singular/subexpr.h @ 48aa42

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