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