1 | #ifndef SUBEXPR_H |
---|
2 | #define SUBEXPR_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: subexpr.h,v 1.30 2001-10-09 16:36:25 Singular Exp $ */ |
---|
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 | |
---|
16 | struct _ssubexpr |
---|
17 | { |
---|
18 | struct _ssubexpr * next; |
---|
19 | int start; |
---|
20 | }; |
---|
21 | |
---|
22 | typedef struct _ssubexpr sSubexpr; |
---|
23 | typedef sSubexpr * Subexpr; |
---|
24 | |
---|
25 | extern const char sNoName[]; |
---|
26 | extern BOOLEAN siq; |
---|
27 | extern char *iiSleftv2name(leftv v); |
---|
28 | |
---|
29 | class sleftv; |
---|
30 | typedef sleftv * leftv; |
---|
31 | class sleftv |
---|
32 | { |
---|
33 | public: |
---|
34 | /* !! do not change the first 6 entries !! (see ipid.h: idrec) */ |
---|
35 | leftv next; |
---|
36 | char * name; |
---|
37 | void * data; |
---|
38 | attr attribute; |
---|
39 | BITSET flag; |
---|
40 | int rtyp; |
---|
41 | /* the type of the expression, describes the data field |
---|
42 | * (E) markes the type field in iparith |
---|
43 | * (S) markes the rtyp in sleftv |
---|
44 | * ANY_TYPE: data is int: real type or 0 (E) |
---|
45 | * DEF_CMD: all types, no change in sleftv (E) |
---|
46 | * IDHDL: existing variable (E) |
---|
47 | * IDHDL: variable, data is idhdl (S) |
---|
48 | * COMMAND: data is command (S) |
---|
49 | * INT_CMD: int constant, data is int (E,S) |
---|
50 | * INTVEC_CMD: intvec constant, data is intvec * (E,S) |
---|
51 | * POLY_CMD: poly constant, data is poly (E,S) |
---|
52 | * .... |
---|
53 | */ |
---|
54 | Subexpr e; /* holds the indices for indexed values */ |
---|
55 | #ifdef HAVE_NAMESPACES |
---|
56 | idhdl packhdl; |
---|
57 | idhdl req_packhdl; |
---|
58 | #define IDSROOT(a) (IDPACKAGE(((sleftv)a).packhdl)->idroot) |
---|
59 | #endif /* HAVE_NAMESPACES */ |
---|
60 | #ifdef HAVE_NS |
---|
61 | package packhdl; |
---|
62 | package req_packhdl; |
---|
63 | #endif /* HAVE_NS */ |
---|
64 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
65 | void Set(int val); |
---|
66 | void Print(leftv store=NULL,int spaces=0); |
---|
67 | void CleanUp(); |
---|
68 | char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1); |
---|
69 | void Copy(leftv e); |
---|
70 | attr CopyA(); |
---|
71 | void * CopyD(int t); |
---|
72 | void * CopyD() { return CopyD(Typ()); } |
---|
73 | inline const char * Name() |
---|
74 | { |
---|
75 | if ((name!=NULL) && (e==NULL)) return name; |
---|
76 | else return sNoName; |
---|
77 | } |
---|
78 | inline const char * Fullname() |
---|
79 | { |
---|
80 | if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this)); |
---|
81 | else return sNoName; |
---|
82 | } |
---|
83 | int Typ(); |
---|
84 | int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */ |
---|
85 | void * Data(); |
---|
86 | void SetData(void* value); |
---|
87 | leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */ |
---|
88 | leftv LHdl(); |
---|
89 | attr * Attribute(); |
---|
90 | inline leftv Next() { return next; } |
---|
91 | int listLength(); |
---|
92 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
93 | BOOLEAN RingDependend(); |
---|
94 | }; |
---|
95 | |
---|
96 | inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); } |
---|
97 | extern sleftv sLastPrinted; |
---|
98 | |
---|
99 | struct _sssym |
---|
100 | { |
---|
101 | idhdl h; |
---|
102 | Subexpr e; |
---|
103 | }; |
---|
104 | typedef struct _sssym ssym; |
---|
105 | typedef ssym * sym; |
---|
106 | |
---|
107 | void syMake(leftv v,char * name, idhdl packhdl = NULL); |
---|
108 | BOOLEAN assumeStdFlag(leftv h); |
---|
109 | |
---|
110 | class proc_singular |
---|
111 | { |
---|
112 | public: |
---|
113 | long proc_start; // position where proc is starting |
---|
114 | long def_end; // position where proc header is ending |
---|
115 | long help_start; // position where help is starting |
---|
116 | long help_end; // position where help is starting |
---|
117 | long body_start; // position where proc-body is starting |
---|
118 | long body_end; // position where proc-body is ending |
---|
119 | long example_start; // position where example is starting |
---|
120 | long proc_end; // position where proc is ending |
---|
121 | int proc_lineno; |
---|
122 | int body_lineno; |
---|
123 | int example_lineno; |
---|
124 | char *body; |
---|
125 | long help_chksum; |
---|
126 | }; |
---|
127 | |
---|
128 | struct proc_object |
---|
129 | { |
---|
130 | //public: |
---|
131 | BOOLEAN (*function)(leftv res, leftv v); |
---|
132 | }; |
---|
133 | |
---|
134 | union uprocinfodata; |
---|
135 | |
---|
136 | union uprocinfodata |
---|
137 | { |
---|
138 | public: |
---|
139 | proc_singular s; // data of Singular-procedure |
---|
140 | struct proc_object o; // pointer to binary-function |
---|
141 | }; |
---|
142 | |
---|
143 | typedef union uprocinfodata procinfodata; |
---|
144 | |
---|
145 | typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs; |
---|
146 | // LANG_TOP : Toplevel package only |
---|
147 | // LANG_SINGULAR: |
---|
148 | // LANG_C : |
---|
149 | class procinfo |
---|
150 | { |
---|
151 | public: |
---|
152 | char *libname; |
---|
153 | char *procname; |
---|
154 | #ifdef HAVE_NS |
---|
155 | package pack; |
---|
156 | #endif |
---|
157 | language_defs language; |
---|
158 | short ref; |
---|
159 | char is_static; // if set, proc not accessible for user |
---|
160 | char trace_flag; |
---|
161 | procinfodata data; |
---|
162 | }; |
---|
163 | |
---|
164 | inline procinfov piCopy(procinfov pi) |
---|
165 | { |
---|
166 | pi->ref++; |
---|
167 | return pi; |
---|
168 | } |
---|
169 | BOOLEAN piKill(procinfov l); |
---|
170 | char *piProcinfo(procinfov pi, char *request); |
---|
171 | void piShowProcinfo(procinfov pi, char *txt); |
---|
172 | #ifdef HAVE_LIBPARSER |
---|
173 | class libstack |
---|
174 | { |
---|
175 | public: |
---|
176 | libstackv next; |
---|
177 | char *libname; |
---|
178 | BOOLEAN to_be_done; |
---|
179 | int cnt; |
---|
180 | void push(char *p, char * libname); |
---|
181 | libstackv pop(char *p); |
---|
182 | inline char *get() { return(libname); } |
---|
183 | }; |
---|
184 | #endif /* HAVE_LIBPARSER */ |
---|
185 | |
---|
186 | typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX} lib_types; |
---|
187 | lib_types type_of_LIB(char *newlib, char *fullname); |
---|
188 | |
---|
189 | #ifndef OM_ALLOC_H |
---|
190 | struct omBin_s; |
---|
191 | #endif |
---|
192 | |
---|
193 | extern omBin_s* sSubexpr_bin; |
---|
194 | extern omBin_s* sleftv_bin; |
---|
195 | extern omBin_s* procinfo_bin; |
---|
196 | extern omBin_s* libstack_bin; |
---|
197 | |
---|
198 | #endif |
---|