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 <kernel/febase.h> |
---|
15 | //#include <kernel/structs.h> |
---|
16 | |
---|
17 | #include <Singular/grammar.h> |
---|
18 | #include <Singular/tok.h> |
---|
19 | #include <Singular/attrib.h> |
---|
20 | |
---|
21 | struct _ssubexpr |
---|
22 | { |
---|
23 | struct _ssubexpr * next; |
---|
24 | int start; |
---|
25 | }; |
---|
26 | |
---|
27 | typedef struct _ssubexpr *Subexpr; |
---|
28 | |
---|
29 | extern const char sNoName[]; |
---|
30 | extern BOOLEAN siq; |
---|
31 | extern const char *iiSleftv2name(leftv v); |
---|
32 | |
---|
33 | class sleftv; |
---|
34 | typedef sleftv * leftv; |
---|
35 | |
---|
36 | /// Class used for (list of) interpreter objects |
---|
37 | class sleftv |
---|
38 | { |
---|
39 | public: |
---|
40 | /* !! do not change the first 6 entries !! (see ipid.h: idrec) */ |
---|
41 | leftv next; |
---|
42 | const char *name; |
---|
43 | void * data; |
---|
44 | attr attribute; |
---|
45 | BITSET flag; |
---|
46 | int rtyp; |
---|
47 | /* the type of the expression, describes the data field |
---|
48 | * (E) markes the type field in iparith |
---|
49 | * (S) markes the rtyp in sleftv |
---|
50 | * ANY_TYPE: data is int: real type or 0 (E) |
---|
51 | * DEF_CMD: all types, no change in sleftv (E) |
---|
52 | * IDHDL: existing variable (E) |
---|
53 | * IDHDL: variable, data is idhdl (S) |
---|
54 | * COMMAND: data is command (S) |
---|
55 | * INT_CMD: int constant, data is int (E,S) |
---|
56 | * INTVEC_CMD: intvec constant, data is intvec * (E,S) |
---|
57 | * POLY_CMD: poly constant, data is poly (E,S) |
---|
58 | * .... |
---|
59 | */ |
---|
60 | Subexpr e; /* holds the indices for indexed values */ |
---|
61 | package req_packhdl; |
---|
62 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
63 | void CleanUp(ring r=currRing); |
---|
64 | |
---|
65 | /// Called by type_cmd (e.g. "r;") or as default in jPRINT |
---|
66 | void Print(leftv store=NULL,int spaces=0); |
---|
67 | |
---|
68 | /// Called for conversion to string (used by string(..), write(..),..) |
---|
69 | char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1); |
---|
70 | |
---|
71 | void Copy(leftv e); |
---|
72 | attr CopyA(); |
---|
73 | void * CopyD(int t); |
---|
74 | void * CopyD() { return CopyD(Typ()); } |
---|
75 | inline const char * Name() |
---|
76 | { |
---|
77 | if ((name!=NULL) && (e==NULL)) return name; |
---|
78 | else return sNoName; |
---|
79 | } |
---|
80 | inline const char * Fullname() |
---|
81 | { |
---|
82 | if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this)); |
---|
83 | else return sNoName; |
---|
84 | } |
---|
85 | int Typ(); |
---|
86 | int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */ |
---|
87 | void * Data(); |
---|
88 | leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */ |
---|
89 | leftv LHdl(); |
---|
90 | attr * Attribute(); |
---|
91 | inline leftv Next() { return next; } |
---|
92 | int listLength(); |
---|
93 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
94 | BOOLEAN RingDependend(); |
---|
95 | }; |
---|
96 | |
---|
97 | inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); } |
---|
98 | extern sleftv sLastPrinted; |
---|
99 | |
---|
100 | void syMake(leftv v,const char * name, idhdl packhdl = NULL); |
---|
101 | BOOLEAN assumeStdFlag(leftv h); |
---|
102 | |
---|
103 | inline procinfov piCopy(procinfov pi) |
---|
104 | { |
---|
105 | pi->ref++; |
---|
106 | return pi; |
---|
107 | } |
---|
108 | BOOLEAN piKill(procinfov l); |
---|
109 | const char *piProcinfo(procinfov pi, const char *request); |
---|
110 | void piShowProcinfo(procinfov pi, char *txt); |
---|
111 | #ifdef HAVE_LIBPARSER |
---|
112 | class libstack; |
---|
113 | typedef libstack * libstackv; |
---|
114 | |
---|
115 | class libstack |
---|
116 | { |
---|
117 | public: |
---|
118 | libstackv next; |
---|
119 | char *libname; |
---|
120 | BOOLEAN to_be_done; |
---|
121 | int cnt; |
---|
122 | void push(char *p, char * libname); |
---|
123 | libstackv pop(char *p); |
---|
124 | inline char *get() { return(libname); } |
---|
125 | }; |
---|
126 | #endif /* HAVE_LIBPARSER */ |
---|
127 | |
---|
128 | extern omBin sSubexpr_bin; |
---|
129 | extern omBin procinfo_bin; |
---|
130 | extern omBin libstack_bin; |
---|
131 | |
---|
132 | void s_internalDelete(const int t, void *d, const ring r); |
---|
133 | |
---|
134 | #endif |
---|