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 *Subexpr; |
---|
25 | |
---|
26 | extern const char sNoName[]; |
---|
27 | extern BOOLEAN siq; |
---|
28 | extern const char *iiSleftv2name(leftv v); |
---|
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; |
---|
37 | const char *name; |
---|
38 | void * data; |
---|
39 | attr attribute; |
---|
40 | BITSET flag; |
---|
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 */ |
---|
56 | package req_packhdl; |
---|
57 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
58 | void Print(leftv store=NULL,int spaces=0); |
---|
59 | void CleanUp(ring r=currRing); |
---|
60 | char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1); |
---|
61 | void Copy(leftv e); |
---|
62 | attr CopyA(); |
---|
63 | void * CopyD(int t); |
---|
64 | void * CopyD() { return CopyD(Typ()); } |
---|
65 | inline const char * Name() |
---|
66 | { |
---|
67 | if ((name!=NULL) && (e==NULL)) return name; |
---|
68 | else return sNoName; |
---|
69 | } |
---|
70 | inline const char * Fullname() |
---|
71 | { |
---|
72 | if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this)); |
---|
73 | else return sNoName; |
---|
74 | } |
---|
75 | int Typ(); |
---|
76 | int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */ |
---|
77 | void * Data(); |
---|
78 | void SetData(void* value); |
---|
79 | leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */ |
---|
80 | leftv LHdl(); |
---|
81 | attr * Attribute(); |
---|
82 | inline leftv Next() { return next; } |
---|
83 | int listLength(); |
---|
84 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
85 | BOOLEAN RingDependend(); |
---|
86 | }; |
---|
87 | |
---|
88 | inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); } |
---|
89 | extern sleftv sLastPrinted; |
---|
90 | |
---|
91 | void syMake(leftv v,const char * name, idhdl packhdl = NULL); |
---|
92 | BOOLEAN assumeStdFlag(leftv h); |
---|
93 | |
---|
94 | inline procinfov piCopy(procinfov pi) |
---|
95 | { |
---|
96 | pi->ref++; |
---|
97 | return pi; |
---|
98 | } |
---|
99 | BOOLEAN piKill(procinfov l); |
---|
100 | const char *piProcinfo(procinfov pi, const char *request); |
---|
101 | void piShowProcinfo(procinfov pi, char *txt); |
---|
102 | #ifdef HAVE_LIBPARSER |
---|
103 | class libstack; |
---|
104 | typedef libstack * libstackv; |
---|
105 | |
---|
106 | class libstack |
---|
107 | { |
---|
108 | public: |
---|
109 | libstackv next; |
---|
110 | char *libname; |
---|
111 | BOOLEAN to_be_done; |
---|
112 | int cnt; |
---|
113 | void push(char *p, char * libname); |
---|
114 | libstackv pop(char *p); |
---|
115 | inline char *get() { return(libname); } |
---|
116 | }; |
---|
117 | #endif /* HAVE_LIBPARSER */ |
---|
118 | |
---|
119 | #ifndef OM_ALLOC_H |
---|
120 | struct omBin_s; |
---|
121 | #endif |
---|
122 | |
---|
123 | extern omBin_s* sSubexpr_bin; |
---|
124 | extern omBin_s* procinfo_bin; |
---|
125 | extern omBin_s* libstack_bin; |
---|
126 | |
---|
127 | #endif |
---|