source: git/Singular/subexpr.h @ 50cbdc

fieker-DuValspielwiese
Last change on this file since 50cbdc was df5fc1, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: RinDependend git-svn-id: file:///usr/local/Singular/svn/trunk@5218 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.1 KB
Line 
1#ifndef SUBEXPR_H
2#define SUBEXPR_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: subexpr.h,v 1.28 2001-02-09 14:22:56 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
16struct _ssubexpr
17{
18  struct _ssubexpr * next;
19  int start;
20};
21
22typedef struct _ssubexpr sSubexpr;
23typedef sSubexpr * Subexpr;
24
25extern const char sNoName[];
26extern BOOLEAN siq;
27extern char *iiSleftv2name(leftv v);
28
29class sleftv;
30typedef sleftv * leftv;
31class 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    inline void Init() { memset(this,0,sizeof(*this)); }
61    void Set(int val);
62    void Print(leftv store=NULL,int spaces=0);
63    void CleanUp();
64    char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
65    void Copy(leftv e);
66    attr CopyA();
67    void * CopyD(int t);
68    void * CopyD() { return CopyD(Typ()); }
69    inline const char * Name()
70    {
71      if ((name!=NULL) && (e==NULL)) return name;
72      else return sNoName;
73    }
74    inline const char * Fullname()
75    {
76      if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this));
77      else return sNoName;
78    }
79    int  Typ();
80    int  LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
81    void * Data();
82    void SetData(void* value);
83    leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
84    leftv LHdl();
85    attr * Attribute();
86    inline leftv Next() { return next; }
87    int listLength();
88    int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
89    BOOLEAN RingDependend();
90};
91
92inline BOOLEAN RingDependend(int t) { return (BEGIN_RING<t)&&(t<END_RING); }
93extern sleftv sLastPrinted;
94
95struct _sssym
96{
97  idhdl   h;
98  Subexpr e;
99};
100typedef struct _sssym ssym;
101typedef ssym * sym;
102
103void syMake(leftv v,char * name, idhdl packhdl = NULL);
104BOOLEAN assumeStdFlag(leftv h);
105
106class proc_singular
107{
108public:
109  long   proc_start;       // position where proc is starting
110  long   def_end;          // position where proc header is ending
111  long   help_start;       // position where help is starting
112  long   help_end;         // position where help is starting
113  long   body_start;       // position where proc-body is starting
114  long   body_end;         // position where proc-body is ending
115  long   example_start;    // position where example is starting
116  long   proc_end;         // position where proc is ending
117  int    proc_lineno;
118  int    body_lineno;
119  int    example_lineno;
120  char   *body;
121  long help_chksum;
122};
123
124struct proc_object
125{
126//public:
127  BOOLEAN (*function)(leftv res, leftv v);
128};
129
130union uprocinfodata;
131
132union uprocinfodata
133{
134public:
135  proc_singular  s;        // data of Singular-procedure
136  struct proc_object    o; // pointer to binary-function
137};
138
139typedef union uprocinfodata procinfodata;
140
141typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
142// LANG_TOP     : Toplevel package only
143// LANG_SINGULAR:
144// LANG_C       :
145class procinfo
146{
147public:
148  char          *libname;
149  char          *procname;
150  language_defs language;
151  short         ref;
152  char          is_static;        // if set, proc not accessible for user
153  char          trace_flag;
154  procinfodata  data;
155};
156
157inline procinfov piCopy(procinfov pi)
158{
159  pi->ref++;
160  return pi;
161}
162BOOLEAN piKill(procinfov l);
163char *piProcinfo(procinfov pi, char *request);
164void piShowProcinfo(procinfov pi, char *txt);
165#ifdef HAVE_LIBPARSER
166class libstack
167{
168 public:
169  libstackv next;
170  char      *libname;
171  BOOLEAN   to_be_done;
172  int       cnt;
173  void      push(char *p, char * libname);
174  libstackv pop(char *p);
175  inline char *get() { return(libname); }
176};
177#endif /* HAVE_LIBPARSER */
178
179typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX} lib_types;
180lib_types type_of_LIB(char *newlib, char *fullname);
181
182#ifndef OM_ALLOC_H
183struct omBin_s;
184#endif
185
186extern omBin_s* sSubexpr_bin;
187extern omBin_s* sleftv_bin;
188extern omBin_s* procinfo_bin;
189extern omBin_s* libstack_bin;
190
191#endif
Note: See TracBrowser for help on using the repository browser.