1 | #ifndef SUBEXPR_H |
---|
2 | #define SUBEXPR_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: handling of leftv |
---|
9 | */ |
---|
10 | |
---|
11 | #include <string.h> |
---|
12 | #include "grammar.h" |
---|
13 | #include "tok.h" |
---|
14 | #include "structs.h" |
---|
15 | #include "febase.h" |
---|
16 | #include "ring.h" |
---|
17 | |
---|
18 | struct _ssubexpr |
---|
19 | { |
---|
20 | struct _ssubexpr * next; |
---|
21 | int start; |
---|
22 | }; |
---|
23 | |
---|
24 | typedef struct _ssubexpr sSubexpr; |
---|
25 | typedef sSubexpr * Subexpr; |
---|
26 | |
---|
27 | extern const char sNoName[]; |
---|
28 | extern BOOLEAN siq; |
---|
29 | extern const char *iiSleftv2name(leftv v); |
---|
30 | |
---|
31 | class sleftv; |
---|
32 | typedef sleftv * leftv; |
---|
33 | class sleftv |
---|
34 | { |
---|
35 | public: |
---|
36 | /* !! do not change the first 6 entries !! (see ipid.h: idrec) */ |
---|
37 | leftv next; |
---|
38 | const char *name; |
---|
39 | void * data; |
---|
40 | attr attribute; |
---|
41 | BITSET flag; |
---|
42 | int rtyp; |
---|
43 | /* the type of the expression, describes the data field |
---|
44 | * (E) markes the type field in iparith |
---|
45 | * (S) markes the rtyp in sleftv |
---|
46 | * ANY_TYPE: data is int: real type or 0 (E) |
---|
47 | * DEF_CMD: all types, no change in sleftv (E) |
---|
48 | * IDHDL: existing variable (E) |
---|
49 | * IDHDL: variable, data is idhdl (S) |
---|
50 | * COMMAND: data is command (S) |
---|
51 | * INT_CMD: int constant, data is int (E,S) |
---|
52 | * INTVEC_CMD: intvec constant, data is intvec * (E,S) |
---|
53 | * POLY_CMD: poly constant, data is poly (E,S) |
---|
54 | * .... |
---|
55 | */ |
---|
56 | Subexpr e; /* holds the indices for indexed values */ |
---|
57 | package req_packhdl; |
---|
58 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
59 | void Print(leftv store=NULL,int spaces=0); |
---|
60 | void CleanUp(ring r=currRing); |
---|
61 | char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1); |
---|
62 | void Copy(leftv e); |
---|
63 | attr CopyA(); |
---|
64 | void * CopyD(int t); |
---|
65 | void * CopyD() { return CopyD(Typ()); } |
---|
66 | inline const char * Name() |
---|
67 | { |
---|
68 | if ((name!=NULL) && (e==NULL)) return name; |
---|
69 | else return sNoName; |
---|
70 | } |
---|
71 | inline const char * Fullname() |
---|
72 | { |
---|
73 | if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this)); |
---|
74 | else return sNoName; |
---|
75 | } |
---|
76 | int Typ(); |
---|
77 | int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */ |
---|
78 | void * Data(); |
---|
79 | void SetData(void* value); |
---|
80 | leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */ |
---|
81 | leftv LHdl(); |
---|
82 | attr * Attribute(); |
---|
83 | inline leftv Next() { return next; } |
---|
84 | int listLength(); |
---|
85 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
86 | BOOLEAN RingDependend(); |
---|
87 | }; |
---|
88 | |
---|
89 | inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); } |
---|
90 | extern sleftv sLastPrinted; |
---|
91 | |
---|
92 | struct _sssym |
---|
93 | { |
---|
94 | idhdl h; |
---|
95 | Subexpr e; |
---|
96 | }; |
---|
97 | typedef struct _sssym ssym; |
---|
98 | typedef ssym * sym; |
---|
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 | #ifndef OM_ALLOC_H |
---|
129 | struct omBin_s; |
---|
130 | #endif |
---|
131 | |
---|
132 | extern omBin_s* sSubexpr_bin; |
---|
133 | extern omBin_s* procinfo_bin; |
---|
134 | extern omBin_s* libstack_bin; |
---|
135 | |
---|
136 | #endif |
---|