[0e1846] | 1 | #ifndef SUBEXPR_H |
---|
| 2 | #define SUBEXPR_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
| 6 | /* |
---|
[6ae4f5] | 7 | * ABSTRACT: handling of leftv |
---|
[0e1846] | 8 | */ |
---|
[f6b5f0] | 9 | |
---|
[0e1846] | 10 | #include <string.h> |
---|
[fb85f97] | 11 | |
---|
| 12 | #include <polys/monomials/ring.h> |
---|
| 13 | |
---|
[72a01e] | 14 | //#include <Singular/ipid.h> |
---|
[fb85f97] | 15 | |
---|
[c12c262] | 16 | #include <kernel/mod2.h> |
---|
[599326] | 17 | #include <Singular/grammar.h> |
---|
| 18 | #include <Singular/tok.h> |
---|
[3ec6bba] | 19 | #include <Singular/attrib.h> |
---|
[0e1846] | 20 | |
---|
[72a01e] | 21 | typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs; |
---|
| 22 | class proc_singular |
---|
| 23 | { |
---|
| 24 | public: |
---|
| 25 | long proc_start; // position where proc is starting |
---|
[469903] | 26 | long proc_end; // position where proc is ending |
---|
[72a01e] | 27 | long def_end; // position where proc header is ending |
---|
| 28 | long help_start; // position where help is starting |
---|
| 29 | long help_end; // position where help is starting |
---|
| 30 | long body_start; // position where proc-body is starting |
---|
| 31 | long body_end; // position where proc-body is ending |
---|
| 32 | long example_start; // position where example is starting |
---|
| 33 | int body_lineno; |
---|
| 34 | int example_lineno; |
---|
| 35 | char *body; |
---|
| 36 | long help_chksum; |
---|
| 37 | }; |
---|
| 38 | struct proc_object |
---|
| 39 | { |
---|
| 40 | //public: |
---|
| 41 | BOOLEAN (*function)(leftv res, leftv v); |
---|
| 42 | }; |
---|
| 43 | |
---|
| 44 | union uprocinfodata |
---|
| 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; |
---|
| 58 | language_defs language; |
---|
| 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 | |
---|
[0e1846] | 67 | struct _ssubexpr |
---|
| 68 | { |
---|
| 69 | struct _ssubexpr * next; |
---|
| 70 | int start; |
---|
| 71 | }; |
---|
| 72 | |
---|
[0e051f] | 73 | typedef struct _ssubexpr *Subexpr; |
---|
[0e1846] | 74 | |
---|
| 75 | extern const char sNoName[]; |
---|
| 76 | extern BOOLEAN siq; |
---|
[85e68dd] | 77 | extern const char *iiSleftv2name(leftv v); |
---|
[0e1846] | 78 | |
---|
| 79 | class sleftv; |
---|
| 80 | typedef sleftv * leftv; |
---|
[fb85f97] | 81 | |
---|
| 82 | /// Class used for (list of) interpreter objects |
---|
[0e1846] | 83 | class sleftv |
---|
| 84 | { |
---|
| 85 | public: |
---|
| 86 | /* !! do not change the first 6 entries !! (see ipid.h: idrec) */ |
---|
| 87 | leftv next; |
---|
[85e68dd] | 88 | const char *name; |
---|
[0e1846] | 89 | void * data; |
---|
| 90 | attr attribute; |
---|
[472f39] | 91 | BITSET flag; |
---|
[0e1846] | 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 */ |
---|
[bd4cb92] | 107 | package req_packhdl; |
---|
[0e1846] | 108 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
[16acb0] | 109 | void CleanUp(ring r=currRing); |
---|
[a9c298] | 110 | |
---|
[fb85f97] | 111 | /// Called by type_cmd (e.g. "r;") or as default in jPRINT |
---|
| 112 | void Print(leftv store=NULL,int spaces=0); |
---|
[a9c298] | 113 | |
---|
[fb85f97] | 114 | /// Called for conversion to string (used by string(..), write(..),..) |
---|
[a79a128] | 115 | char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1); |
---|
[a9c298] | 116 | |
---|
[0e1846] | 117 | void Copy(leftv e); |
---|
[f879c9] | 118 | attr CopyA(); |
---|
[0e1846] | 119 | void * CopyD(int t); |
---|
[2166ad3] | 120 | void * CopyD() { return CopyD(Typ()); } |
---|
[0e1846] | 121 | inline const char * Name() |
---|
| 122 | { |
---|
| 123 | if ((name!=NULL) && (e==NULL)) return name; |
---|
| 124 | else return sNoName; |
---|
| 125 | } |
---|
[c12cf96] | 126 | inline const char * Fullname() |
---|
| 127 | { |
---|
| 128 | if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this)); |
---|
| 129 | else return sNoName; |
---|
| 130 | } |
---|
[0e1846] | 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 */ |
---|
[7ddcb2] | 135 | //leftv LHdl(); |
---|
[0e1846] | 136 | attr * Attribute(); |
---|
| 137 | inline leftv Next() { return next; } |
---|
| 138 | int listLength(); |
---|
| 139 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
[4cbe5d] | 140 | BOOLEAN RingDependend(); |
---|
[0e1846] | 141 | }; |
---|
| 142 | |
---|
[df5fc1] | 143 | inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); } |
---|
[0e1846] | 144 | extern sleftv sLastPrinted; |
---|
| 145 | |
---|
[12148e] | 146 | void syMake(leftv v,const char * name, package pa = NULL); |
---|
[0e1846] | 147 | BOOLEAN assumeStdFlag(leftv h); |
---|
| 148 | |
---|
[2ba9a6] | 149 | inline procinfov piCopy(procinfov pi) |
---|
| 150 | { |
---|
| 151 | pi->ref++; |
---|
| 152 | return pi; |
---|
| 153 | } |
---|
[b2a49b] | 154 | BOOLEAN piKill(procinfov l); |
---|
[85e68dd] | 155 | const char *piProcinfo(procinfov pi, const char *request); |
---|
[2ba9a6] | 156 | void piShowProcinfo(procinfov pi, char *txt); |
---|
[6a51ef] | 157 | #ifdef HAVE_LIBPARSER |
---|
[a48753] | 158 | class libstack; |
---|
| 159 | typedef libstack * libstackv; |
---|
| 160 | |
---|
[6a51ef] | 161 | class libstack |
---|
| 162 | { |
---|
| 163 | public: |
---|
| 164 | libstackv next; |
---|
| 165 | char *libname; |
---|
| 166 | BOOLEAN to_be_done; |
---|
| 167 | int cnt; |
---|
[e2202ee] | 168 | void push(const char *p, char * libname); |
---|
| 169 | libstackv pop(const char *p); |
---|
[6a51ef] | 170 | inline char *get() { return(libname); } |
---|
| 171 | }; |
---|
| 172 | #endif /* HAVE_LIBPARSER */ |
---|
[cd6b45] | 173 | |
---|
[020ef9] | 174 | extern omBin sSubexpr_bin; |
---|
| 175 | extern omBin procinfo_bin; |
---|
| 176 | extern omBin libstack_bin; |
---|
[c232af] | 177 | |
---|
[c4dab4] | 178 | void s_internalDelete(const int t, void *d, const ring r); |
---|
| 179 | |
---|
[0e1846] | 180 | #endif |
---|