source: git/Singular/subexpr.h @ fdc537

fieker-DuValspielwiese
Last change on this file since fdc537 was 416465, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* bug-fixes from work with Thomas git-svn-id: file:///usr/local/Singular/svn/trunk@3826 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.8 KB
Line 
1#ifndef SUBEXPR_H
2#define SUBEXPR_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: subexpr.h,v 1.24 1999-11-15 17:20:52 obachman Exp $ */
7/*
8* ABSTRACT: handling of leftv
9*/
10
11#include <string.h>
12#include "structs.h"
13
14#if HAVE_ASO == 1
15#include "subexpr.aso"
16#endif
17
18struct _ssubexpr
19{
20  struct _ssubexpr * next;
21  int start;
22};
23
24typedef struct _ssubexpr sSubexpr;
25typedef sSubexpr * Subexpr;
26
27extern const char sNoName[];
28extern BOOLEAN siq;
29extern char *iiSleftv2name(leftv v);
30
31class sleftv;
32typedef sleftv * leftv;
33class sleftv
34{
35  public:
36  /* !! do not change the first 6 entries !! (see ipid.h: idrec) */
37    leftv       next;
38    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#ifdef HAVE_NAMESPACES
58    idhdl       packhdl;
59    idhdl       req_packhdl;
60#define IDSROOT(a) (IDPACKAGE(((sleftv)a).packhdl)->idroot)
61#endif /* HAVE_NAMESPACES */
62    inline void Init() { memset(this,0,sizeof(*this)); }
63    void Set(int val);
64    void Print(leftv store=NULL,int spaces=0);
65    void CleanUp();
66    char * String(void *d=NULL, BOOLEAN typed = FALSE, int dim = 1);
67    void Copy(leftv e);
68    attr CopyA();
69    void * CopyD(int t);
70    void * CopyD() { return CopyD(Typ()); }
71    inline const char * Name()
72    {
73      if ((name!=NULL) && (e==NULL)) return name;
74      else return sNoName;
75    }
76    inline const char * Fullname()
77    {
78      if ((name!=NULL) && (e==NULL)) return(iiSleftv2name(this));
79      else return sNoName;
80    }
81    int  Typ();
82    int  LTyp(); /* returns LIST_CMD for l[i], otherwise returns Typ() */
83    void * Data();
84    void SetData(void* value);
85    leftv LData(); /* returns &(l[i]) for l[i], otherwise returns this */
86    leftv LHdl();
87    attr * Attribute();
88    inline leftv Next() { return next; }
89    int listLength();
90    int Eval(); /*replace a COMMAND by its result otherwise by CopyD*/
91};
92
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_SINGULAR, LT_ELF, LT_HPUX} lib_types;
180lib_types type_of_LIB(char *newlib, char *fullname);
181#endif
Note: See TracBrowser for help on using the repository browser.