subexpr.h
Go to the documentation of this file.
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 <Singular/grammar.h>
17 #include <Singular/tok.h>
18 #include <Singular/attrib.h>
19 
22 {
23 public:
24  long proc_start; // position where proc is starting
25  long def_end; // position where proc header is ending
26  long help_start; // position where help is starting
27  long help_end; // position where help is starting
28  long body_start; // position where proc-body is starting
29  long body_end; // position where proc-body is ending
30  long example_start; // position where example is starting
31  long proc_end; // position where proc is ending
35  char *body;
37 };
39 {
40 //public:
41  BOOLEAN (*function)(leftv res, leftv v);
42 };
43 
45 {
46 public:
47  proc_singular s; // data of Singular-procedure
48  struct proc_object o; // pointer to binary-function
49 };
50 typedef union uprocinfodata procinfodata;
51 
52 class procinfo
53 {
54 public:
55  char *libname;
56  char *procname;
57  package pack;
59  short ref;
60  char is_static; // if set, proc not accessible for user
61  char trace_flag;
62  procinfodata data;
63 };
64 
65 typedef procinfo * procinfov;
66 
67 struct _ssubexpr
68 {
69  struct _ssubexpr * next;
70  int start;
71 };
72 
73 typedef struct _ssubexpr *Subexpr;
74 
75 extern const char sNoName[];
76 extern BOOLEAN siq;
77 extern const char *iiSleftv2name(leftv v);
78 
79 class sleftv;
80 typedef sleftv * leftv;
81 
82 /// Class used for (list of) interpreter objects
83 class sleftv
84 {
85  public:
86  /* !! do not change the first 6 entries !! (see ipid.h: idrec) */
87  leftv next;
88  const char *name;
89  void * data;
92  int rtyp;
93  /* the type of the expression, describes the data field
94  * (E) markes the type field in iparith
95  * (S) markes the rtyp in sleftv
96  * ANY_TYPE: data is int: real type or 0 (E)
97  * DEF_CMD: all types, no change in sleftv (E)
98  * IDHDL: existing variable (E)
99  * IDHDL: variable, data is idhdl (S)
100  * COMMAND: data is command (S)
101  * INT_CMD: int constant, data is int (E,S)
102  * INTVEC_CMD: intvec constant, data is intvec * (E,S)
103  * POLY_CMD: poly constant, data is poly (E,S)
104  * ....
105  */
106  Subexpr e; /* holds the indices for indexed values */
107  package req_packhdl;
108  inline void Init() { memset(this,0,sizeof(*this)); }
109  void CleanUp(ring r=currRing);
110 
111  /// Called by type_cmd (e.g. "r;") or as default in jPRINT
112  void Print(leftv store=NULL,int spaces=0);
113 
114  /// Called for conversion to string (used by string(..), write(..),..)
115  char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
116 
117  void Copy(leftv e);
118  attr CopyA();
119  void * CopyD(int t);
120  void * CopyD() { return CopyD(Typ()); }
121  inline const char * Name()
122  {
123  if ((name!=NULL) && (e==NULL)) return name;
124  else return sNoName;
125  }
126  inline const char * Fullname()
127  {
128  if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this));
129  else return sNoName;
130  }
131  int Typ();
132  int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
133  void * Data();
134  leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
135  //leftv LHdl();
136  attr * Attribute();
137  inline leftv Next() { return next; }
138  int listLength();
139  int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
141 };
142 
143 inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); }
144 extern sleftv sLastPrinted;
145 
146 void syMake(leftv v,const char * name, idhdl packhdl = NULL);
147 BOOLEAN assumeStdFlag(leftv h);
148 
149 inline procinfov piCopy(procinfov pi)
150 {
151  pi->ref++;
152  return pi;
153 }
154 BOOLEAN piKill(procinfov l);
155 const char *piProcinfo(procinfov pi, const char *request);
156 void piShowProcinfo(procinfov pi, char *txt);
157 #ifdef HAVE_LIBPARSER
158 class libstack;
159 typedef libstack * libstackv;
160 
161 class libstack
162 {
163  public:
164  libstackv next;
165  char *libname;
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 
174 extern omBin sSubexpr_bin;
175 extern omBin procinfo_bin;
176 extern omBin libstack_bin;
177 
178 void s_internalDelete(const int t, void *d, const ring r);
179 
180 #endif
proc_singular s
Definition: subexpr.h:47
int cnt
Definition: subexpr.h:167
sleftv * leftv
Definition: subexpr.h:79
sleftv sLastPrinted
Definition: subexpr.cc:55
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int proc_lineno
Definition: subexpr.h:32
omBin_t * omBin
Definition: omStructs.h:12
#define Print
Definition: emacs.cc:83
omBin procinfo_bin
Definition: subexpr.cc:51
char * libname
Definition: subexpr.h:165
Definition: attrib.h:15
Subexpr e
Definition: subexpr.h:106
BITSET flag
Definition: subexpr.h:91
procinfo * procinfov
Definition: subexpr.h:65
libstackv next
Definition: subexpr.h:164
omBin sSubexpr_bin
Definition: subexpr.cc:49
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
long example_start
Definition: subexpr.h:30
void piShowProcinfo(procinfov pi, char *txt)
int body_lineno
Definition: subexpr.h:33
language_defs language
Definition: subexpr.h:58
void syMake(leftv v, const char *name, idhdl packhdl=NULL)
Definition: subexpr.cc:1460
const char * iiSleftv2name(leftv v)
Definition: subexpr.cc:1913
BOOLEAN to_be_done
Definition: subexpr.h:166
BOOLEAN RingDependend(int t)
Definition: subexpr.h:143
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:464
void Init()
Definition: subexpr.h:108
void * CopyD()
Definition: subexpr.h:120
short ref
Definition: subexpr.h:59
const char sNoName[]
Definition: subexpr.cc:56
procinfov piCopy(procinfov pi)
Definition: subexpr.h:149
#define BITSET
Definition: structs.h:17
struct _ssubexpr * next
Definition: subexpr.h:69
const char * Name()
Definition: subexpr.h:121
Definition: idrec.h:34
const char * Fullname()
Definition: subexpr.h:126
void * data
Definition: subexpr.h:89
char * procname
Definition: subexpr.h:56
poly res
Definition: myNF.cc:322
Definition: subexpr.h:20
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
long help_start
Definition: subexpr.h:26
struct proc_object o
Definition: subexpr.h:48
const ring r
Definition: syzextra.cc:208
long def_end
Definition: subexpr.h:25
char * libname
Definition: subexpr.h:55
leftv Next()
Definition: subexpr.h:137
const char * name
Definition: subexpr.h:88
BOOLEAN siq
Definition: subexpr.cc:58
long proc_end
Definition: subexpr.h:31
procinfodata data
Definition: subexpr.h:62
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1434
long help_end
Definition: subexpr.h:27
omBin libstack_bin
Definition: subexpr.cc:52
int dim(ideal I, ring r)
long help_chksum
Definition: subexpr.h:36
leftv next
Definition: subexpr.h:87
char is_static
Definition: subexpr.h:60
language_defs
Definition: subexpr.h:20
const char * piProcinfo(procinfov pi, const char *request)
Definition: ipid.cc:620
#define pi
Definition: libparse.cc:1143
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int example_lineno
Definition: subexpr.h:34
char name(const Variable &v)
Definition: variable.h:95
#define NULL
Definition: omList.c:10
long proc_start
Definition: subexpr.h:24
int start
Definition: subexpr.h:70
int rtyp
Definition: subexpr.h:92
libstack * libstackv
Definition: subexpr.h:158
BOOLEAN piKill(procinfov l)
Definition: ipid.cc:644
attr attribute
Definition: subexpr.h:90
long body_start
Definition: subexpr.h:28
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
char trace_flag
Definition: subexpr.h:61
char * body
Definition: subexpr.h:35
int l
Definition: cfEzgcd.cc:94
ListNode * next
Definition: janet.h:31
long body_end
Definition: subexpr.h:29