source: git/Singular/subexpr.h @ 08e898

spielwiese
Last change on this file since 08e898 was d389e9, checked in by Hans Schoenemann <hannes@…>, 5 years ago
add syMakeMonom (and tests)
  • Property mode set to 100644
File size: 5.0 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#include "Singular/fevoices.h" /* for sNoName_fe*/
21
22typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MIX, LANG_MAX} language_defs;
23class proc_singular
24{
25public:
26  long   proc_start;       // position where proc is starting
27  long   proc_end;         // position where proc is ending
28  long   def_end;          // position where proc header is ending
29  long   help_start;       // position where help is starting
30  long   help_end;         // position where help is starting
31  long   body_start;       // position where proc-body is starting
32  long   body_end;         // position where proc-body is ending
33  long   example_start;    // position where example is starting
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_VAR BOOLEAN siq;
77
78class sleftv;
79typedef sleftv * leftv;
80
81/// Class used for (list of) interpreter objects
82class sleftv
83{
84  public:
85  /* !! do not change the first 6 entries !! (see ipid.h: idrec) */
86    leftv       next;
87    const char *name;
88    void *      data;
89    attr        attribute;
90    BITSET      flag;
91    int         rtyp;
92                 /* the type of the expression, describes the data field
93                  * (E) markes the type field in iparith
94                  * (S) markes the rtyp in sleftv
95                  * ANY_TYPE:   data is int: real type or 0    (E)
96                  * DEF_CMD:    all types, no change in sleftv (E)
97                  * IDHDL: existing variable         (E)
98                  * IDHDL: variable, data is idhdl   (S)
99                  * COMMAND: data is command         (S)
100                  * INT_CMD:      int constant, data is int  (E,S)
101                  * INTVEC_CMD:   intvec constant, data is intvec * (E,S)
102                  * POLY_CMD:     poly constant, data is poly (E,S)
103                  * ....
104                  */
105    Subexpr e;    /* holds the indices for indexed values */
106    package     req_packhdl;
107    inline void Init() { memset(this,0,sizeof(*this)); }
108    void CleanUp(ring r=currRing);
109
110    /// Called by type_cmd (e.g. "r;") or as default in jPRINT
111    void Print(leftv store=NULL,int spaces=0);
112
113    /// Called for conversion to string (used by string(..), write(..),..)
114    char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
115
116    void Copy(leftv e);
117    attr CopyA();
118    void * CopyD(int t);
119    void * CopyD() { return CopyD(Typ()); }
120    inline const char * Name()
121    {
122      if ((name!=NULL) && (e==NULL)) return name;
123      else return sNoName_fe;
124    }
125    inline const char * Fullname()
126    {
127      if ((name!=NULL) && (e==NULL)) return(this->name);
128      else return sNoName_fe;
129    }
130    int  Typ();
131    int  LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
132    void * Data();
133    leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
134    //leftv LHdl();
135    attr * Attribute();
136    inline leftv Next() { return next; }
137    int listLength();
138    int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
139    BOOLEAN RingDependend();
140};
141
142inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); }
143EXTERN_INST_VAR sleftv sLastPrinted;
144
145void syMake(leftv v,const char * name, package pa = NULL);
146void syMakeMonom(leftv v,const char * name);
147BOOLEAN assumeStdFlag(leftv h);
148
149inline procinfov piCopy(procinfov pi)
150{
151  pi->ref++;
152  return pi;
153}
154BOOLEAN piKill(procinfov l);
155const char *piProcinfo(procinfov pi, const char *request);
156void piShowProcinfo(procinfov pi, char *txt);
157#ifdef HAVE_LIBPARSER
158class libstack;
159typedef libstack *  libstackv;
160
161class libstack
162{
163 public:
164  libstackv next;
165  char      *libname;
166  BOOLEAN   to_be_done;
167  int       cnt;
168  void      push(const char *p, char * libname);
169  libstackv pop(const char *p);
170  inline char *get() { return(libname); }
171};
172#endif /* HAVE_LIBPARSER */
173
174EXTERN_VAR omBin sSubexpr_bin;
175EXTERN_VAR omBin procinfo_bin;
176EXTERN_VAR omBin libstack_bin;
177
178void s_internalDelete(const int t,  void *d, const ring r);
179
180#endif
Note: See TracBrowser for help on using the repository browser.