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