source: git/Singular/subexpr.h @ a3a6a0

fieker-DuValspielwiese
Last change on this file since a3a6a0 was c12c262, checked in by Hans Schoenemann <hannes@…>, 8 years ago
remove internal type QRING_CMD (except for iiDeclCommand): it is always RING_CMD
  • 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/*
7* ABSTRACT: handling of leftv
8*/
9
10#include <string.h>
11
12#include <polys/monomials/ring.h>
13
14//#include <Singular/ipid.h>
15
16#include <kernel/mod2.h>
17#include <Singular/grammar.h>
18#include <Singular/tok.h>
19#include <Singular/attrib.h>
20
21typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
22class proc_singular
23{
24public:
25  long   proc_start;       // position where proc is starting
26  long   def_end;          // position where proc header is ending
27  long   help_start;       // position where help is starting
28  long   help_end;         // position where help is starting
29  long   body_start;       // position where proc-body is starting
30  long   body_end;         // position where proc-body is ending
31  long   example_start;    // position where example is starting
32  long   proc_end;         // position where proc is ending
33  int    proc_lineno;
34  int    body_lineno;
35  int    example_lineno;
36  char   *body;
37  long help_chksum;
38};
39struct proc_object
40{
41//public:
42  BOOLEAN (*function)(leftv res, leftv v);
43};
44
45union uprocinfodata
46{
47public:
48  proc_singular  s;        // data of Singular-procedure
49  struct proc_object    o; // pointer to binary-function
50};
51typedef union uprocinfodata procinfodata;
52
53class procinfo
54{
55public:
56  char          *libname;
57  char          *procname;
58  package       pack;
59  language_defs language;
60  short         ref;
61  char          is_static;        // if set, proc not accessible for user
62  char          trace_flag;
63  procinfodata  data;
64};
65
66typedef procinfo *         procinfov;
67
68struct _ssubexpr
69{
70  struct _ssubexpr * next;
71  int start;
72};
73
74typedef struct _ssubexpr *Subexpr;
75
76extern const char sNoName[];
77extern BOOLEAN siq;
78extern const char *iiSleftv2name(leftv v);
79
80class sleftv;
81typedef sleftv * leftv;
82
83/// Class used for (list of) interpreter objects
84class sleftv
85{
86  public:
87  /* !! do not change the first 6 entries !! (see ipid.h: idrec) */
88    leftv       next;
89    const char *name;
90    void *      data;
91    attr        attribute;
92    BITSET      flag;
93    int         rtyp;
94                 /* the type of the expression, describes the data field
95                  * (E) markes the type field in iparith
96                  * (S) markes the rtyp in sleftv
97                  * ANY_TYPE:   data is int: real type or 0    (E)
98                  * DEF_CMD:    all types, no change in sleftv (E)
99                  * IDHDL: existing variable         (E)
100                  * IDHDL: variable, data is idhdl   (S)
101                  * COMMAND: data is command         (S)
102                  * INT_CMD:      int constant, data is int  (E,S)
103                  * INTVEC_CMD:   intvec constant, data is intvec * (E,S)
104                  * POLY_CMD:     poly constant, data is poly (E,S)
105                  * ....
106                  */
107    Subexpr e;    /* holds the indices for indexed values */
108    package     req_packhdl;
109    inline void Init() { memset(this,0,sizeof(*this)); }
110    void CleanUp(ring r=currRing);
111
112    /// Called by type_cmd (e.g. "r;") or as default in jPRINT
113    void Print(leftv store=NULL,int spaces=0);
114
115    /// Called for conversion to string (used by string(..), write(..),..)
116    char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
117
118    void Copy(leftv e);
119    attr CopyA();
120    void * CopyD(int t);
121    void * CopyD() { return CopyD(Typ()); }
122    inline const char * Name()
123    {
124      if ((name!=NULL) && (e==NULL)) return name;
125      else return sNoName;
126    }
127    inline const char * Fullname()
128    {
129      if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this));
130      else return sNoName;
131    }
132    int  Typ();
133    int  LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
134    void * Data();
135    leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
136    //leftv LHdl();
137    attr * Attribute();
138    inline leftv Next() { return next; }
139    int listLength();
140    int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
141    BOOLEAN RingDependend();
142};
143
144inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); }
145extern sleftv sLastPrinted;
146
147void syMake(leftv v,const char * name, package pa = NULL);
148BOOLEAN assumeStdFlag(leftv h);
149
150inline procinfov piCopy(procinfov pi)
151{
152  pi->ref++;
153  return pi;
154}
155BOOLEAN piKill(procinfov l);
156const char *piProcinfo(procinfov pi, const char *request);
157void piShowProcinfo(procinfov pi, char *txt);
158#ifdef HAVE_LIBPARSER
159class libstack;
160typedef libstack *  libstackv;
161
162class libstack
163{
164 public:
165  libstackv next;
166  char      *libname;
167  BOOLEAN   to_be_done;
168  int       cnt;
169  void      push(const char *p, char * libname);
170  libstackv pop(const char *p);
171  inline char *get() { return(libname); }
172};
173#endif /* HAVE_LIBPARSER */
174
175extern omBin sSubexpr_bin;
176extern omBin procinfo_bin;
177extern omBin libstack_bin;
178
179void s_internalDelete(const int t,  void *d, const ring r);
180
181#endif
Note: See TracBrowser for help on using the repository browser.