[0e1846] | 1 | #ifndef SUBEXPR_H |
---|
| 2 | #define SUBEXPR_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
[6be769] | 6 | /* $Id: subexpr.h,v 1.6 1998-05-09 14:34:32 krueger Exp $ */ |
---|
[0e1846] | 7 | /* |
---|
[6ae4f5] | 8 | * ABSTRACT: handling of leftv |
---|
[0e1846] | 9 | */ |
---|
[f6b5f0] | 10 | |
---|
[0e1846] | 11 | #include <string.h> |
---|
| 12 | #include "structs.h" |
---|
| 13 | |
---|
| 14 | struct _ssubexpr |
---|
| 15 | { |
---|
| 16 | struct _ssubexpr * next; |
---|
| 17 | int start; |
---|
| 18 | }; |
---|
| 19 | |
---|
| 20 | typedef struct _ssubexpr sSubexpr; |
---|
| 21 | typedef sSubexpr * Subexpr; |
---|
| 22 | |
---|
| 23 | extern const char sNoName[]; |
---|
| 24 | extern BOOLEAN siq; |
---|
| 25 | |
---|
| 26 | class sleftv; |
---|
| 27 | typedef sleftv * leftv; |
---|
| 28 | class sleftv |
---|
| 29 | { |
---|
| 30 | public: |
---|
| 31 | /* !! do not change the first 6 entries !! (see ipid.h: idrec) */ |
---|
| 32 | leftv next; |
---|
| 33 | char * name; |
---|
| 34 | void * data; |
---|
| 35 | BITSET flag; |
---|
| 36 | attr attribute; |
---|
| 37 | int rtyp; |
---|
| 38 | /* the type of the expression, describes the data field |
---|
| 39 | * (E) markes the type field in iparith |
---|
| 40 | * (S) markes the rtyp in sleftv |
---|
| 41 | * ANY_TYPE: data is int: real type or 0 (E) |
---|
| 42 | * DEF_CMD: all types, no change in sleftv (E) |
---|
| 43 | * IDHDL: existing variable (E) |
---|
| 44 | * IDHDL: variable, data is idhdl (S) |
---|
| 45 | * COMMAND: data is command (S) |
---|
| 46 | * INT_CMD: int constant, data is int (E,S) |
---|
| 47 | * INTVEC_CMD: intvec constant, data is intvec * (E,S) |
---|
| 48 | * POLY_CMD: poly constant, data is poly (E,S) |
---|
| 49 | * .... |
---|
| 50 | */ |
---|
| 51 | Subexpr e; /* holds the indices for indexed values */ |
---|
| 52 | inline void Init() { memset(this,0,sizeof(*this)); } |
---|
| 53 | void Set(int val); |
---|
| 54 | void Print(leftv store=NULL,int spaces=0); |
---|
| 55 | void CleanUp(); |
---|
| 56 | char * String(void *d=NULL); |
---|
| 57 | void Copy(leftv e); |
---|
| 58 | void * CopyD(); |
---|
| 59 | attr CopyA(); |
---|
| 60 | void * CopyD(int t); |
---|
| 61 | inline const char * Name() |
---|
| 62 | { |
---|
| 63 | if ((name!=NULL) && (e==NULL)) return name; |
---|
| 64 | else return sNoName; |
---|
| 65 | } |
---|
| 66 | int Typ(); |
---|
| 67 | int LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */ |
---|
| 68 | void * Data(); |
---|
| 69 | leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */ |
---|
| 70 | leftv LHdl(); |
---|
| 71 | attr * Attribute(); |
---|
| 72 | inline leftv Next() { return next; } |
---|
| 73 | int listLength(); |
---|
| 74 | int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/ |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | extern sleftv sLastPrinted; |
---|
| 78 | |
---|
| 79 | struct _sssym |
---|
| 80 | { |
---|
| 81 | idhdl h; |
---|
| 82 | Subexpr e; |
---|
| 83 | }; |
---|
| 84 | typedef struct _sssym ssym; |
---|
| 85 | typedef ssym * sym; |
---|
| 86 | |
---|
| 87 | void syMake(leftv v,char * name); |
---|
| 88 | BOOLEAN assumeStdFlag(leftv h); |
---|
| 89 | |
---|
[2ba9a6] | 90 | class proc_singular |
---|
| 91 | { |
---|
| 92 | public: |
---|
| 93 | long proc_start; // position where proc is starting |
---|
[6a51ef] | 94 | long def_end; // position where proc header is ending |
---|
[2ba9a6] | 95 | long help_start; // position where help is starting |
---|
[6be769] | 96 | long help_end; // position where help is starting |
---|
[2ba9a6] | 97 | long body_start; // position where proc-body is starting |
---|
| 98 | long body_end; // position where proc-body is ending |
---|
| 99 | long example_start; // position where example is starting |
---|
| 100 | long proc_end; // position where proc is ending |
---|
| 101 | int proc_lineno; |
---|
| 102 | int body_lineno; |
---|
| 103 | int example_lineno; |
---|
| 104 | char *body; |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | struct proc_object |
---|
| 108 | { |
---|
| 109 | //public: |
---|
| 110 | BOOLEAN (*function)(leftv res, leftv v); |
---|
| 111 | }; |
---|
| 112 | |
---|
| 113 | union uprocinfodata; |
---|
| 114 | |
---|
| 115 | union uprocinfodata |
---|
| 116 | { |
---|
| 117 | public: |
---|
| 118 | proc_singular s; // data of Singular-procedure |
---|
| 119 | struct proc_object o; // pointer to binary-function |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | typedef union uprocinfodata procinfodata; |
---|
| 123 | |
---|
| 124 | typedef enum { LANG_NONE, LANG_SINGULAR, LANG_C } language_defs; |
---|
| 125 | |
---|
| 126 | class procinfo |
---|
| 127 | { |
---|
| 128 | public: |
---|
| 129 | char *libname; |
---|
| 130 | char *procname; |
---|
| 131 | language_defs language; |
---|
| 132 | short ref; |
---|
[6a51ef] | 133 | char is_static; // if set, proc not accessible for user |
---|
[2ba9a6] | 134 | procinfodata data; |
---|
| 135 | }; |
---|
| 136 | |
---|
| 137 | inline procinfov piCopy(procinfov pi) |
---|
| 138 | { |
---|
| 139 | pi->ref++; |
---|
| 140 | return pi; |
---|
| 141 | } |
---|
| 142 | void piKill(procinfov l); |
---|
| 143 | char *piProcinfo(procinfov pi, char *request); |
---|
| 144 | void piShowProcinfo(procinfov pi, char *txt); |
---|
[6a51ef] | 145 | #ifdef HAVE_LIBPARSER |
---|
| 146 | class libstack |
---|
| 147 | { |
---|
| 148 | public: |
---|
| 149 | libstackv next; |
---|
| 150 | char *libname; |
---|
| 151 | BOOLEAN to_be_done; |
---|
| 152 | int cnt; |
---|
| 153 | void push(char *p, char * libname); |
---|
| 154 | libstackv pop(char *p); |
---|
| 155 | inline char *get() { return(libname); } |
---|
| 156 | }; |
---|
| 157 | #endif /* HAVE_LIBPARSER */ |
---|
[0e1846] | 158 | #endif |
---|