=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/parse.h,v retrieving revision 1.17 retrieving revision 1.28 diff -u -p -r1.17 -r1.28 --- OpenXM_contrib2/asir2000/parse/parse.h 2003/04/02 09:43:33 1.17 +++ OpenXM_contrib2/asir2000/parse/parse.h 2004/03/03 09:25:30 1.28 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/parse/parse.h,v 1.16 2002/01/28 00:54:44 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/parse/parse.h,v 1.27 2004/02/09 08:23:30 noro Exp $ */ # if defined(VISUAL) #include @@ -68,7 +68,7 @@ typedef enum { I_ANS, I_PVAR, I_ASSPVAR, I_FORMULA, I_LIST, I_STR, I_NEWCOMP, I_CAR, I_CDR, I_CAST, I_COM, I_PROC, I_INDEX, I_EV, I_TIMER, I_GF2NGEN, I_GFPNGEN, I_GFSNGEN, - I_LOP, I_OPT, I_GETOPT, I_POINT, I_QUOTE, I_PAREN, I_MINUS + I_LOP, I_OPT, I_GETOPT, I_POINT, I_QUOTE, I_PAREN, I_MINUS, I_RANGE } fid; /* identifiers for statements */ @@ -96,7 +96,7 @@ typedef enum { A_UNDEF, A_BIN, A_USR, A_PURE, A_PARI } typedef enum { V_IND, V_UC, V_PF, V_SR } vid; -struct oVS { +typedef struct oVS { unsigned int n; unsigned int asize; unsigned int at; @@ -104,19 +104,21 @@ struct oVS { struct oFUNC *usrf; struct oPV *va; NODE opt; -}; +} *VS; -typedef struct oVS *VS; +typedef struct oMODULE { + char *name; + VS pvs; + NODE usrf_list; +} *MODULE; -struct oPV { +typedef struct oPV { char *name; short attr,type; pointer priv; -}; +} *PV; -typedef struct oPV *PV; - -struct oINFILE { +typedef struct oINFILE { char *name; FILE *fp; int ln; @@ -124,24 +126,20 @@ struct oINFILE { char *tname; int encoded; short vol; -}; +} *INFILE; -typedef struct oINFILE *INFILE; - struct oTKWD { char *name; int token; }; -struct oARF { +typedef struct oARF { char *name; void (*fp)(); -}; +} *ARF; -typedef struct oARF *ARF; - -struct oFUNC { - char *name; +typedef struct oFUNC { + char *name,*fullname; int argc; int type; aid id; @@ -150,23 +148,19 @@ struct oFUNC { struct oUSRF *usrf; struct oPF *puref; } f; -}; +} *FUNC; -typedef struct oFUNC *FUNC; - -struct oUSRF { +typedef struct oUSRF { char *fname; - short vol; + MODULE module; int startl,endl; NODE args; VS pvs; char *desc; struct oSNODE *body; -}; +} *USRF; -typedef struct oUSRF *USRF; - -struct oPF { +typedef struct oPF { char *name; int argc; Obj body; @@ -176,61 +170,47 @@ struct oPF { int (*pari)(); double (*libm)(); int (*simplify)(); -}; +} *PF; -typedef struct oPF *PF; - -struct oPFAD { +typedef struct oPFAD { Obj arg; int d; -}; +} *PFAD; -typedef struct oPFAD *PFAD; - -struct oPFINS { +typedef struct oPFINS { struct oPF *pf; struct oPFAD ad[1]; -}; +} *PFINS; -typedef struct oPFINS *PFINS; - #define NEWPF(p) ((p)=(PF)MALLOC(sizeof(struct oPF))) -struct oFNODE { +typedef struct oFNODE { fid id; pointer arg[1]; -}; +} *FNODE; -typedef struct oFNODE *FNODE; - #define NEWFNODE(a,b) \ ((a)=(FNODE)MALLOC(sizeof(struct oFNODE)+sizeof(pointer)*(b-1))) -struct oSNODE { +typedef struct oSNODE { sid id; int ln; pointer arg[1]; -}; +} *SNODE; -typedef struct oSNODE *SNODE; - #define NEWSNODE(a,b) \ ((a)=(SNODE)MALLOC(sizeof(struct oSNODE)+sizeof(pointer)*(b-1)),(a)->ln=asir_infile->ln) -struct oPVI { +typedef struct oPVI { int pv; NODE index; -}; +} *PVI; -typedef struct oPVI *PVI; - -struct oNODE2 { +typedef struct oNODE2 { pointer body1,body2; struct oNODE2 *next; -}; +} *NODE2; -typedef struct oNODE2 *NODE2; - struct ftab { char *name; void (*f)(); @@ -283,16 +263,26 @@ switch ( id ) {\ } #define DEFSIZE 32 -#define MSB (1<<31) +#define PVGLOBAL(i) (((unsigned int)(i))|(1<<30)) +#define PVMGLOBAL(i) (((unsigned int)(i))|(3<<30)) +#define PVATTR(i) (((unsigned int)(i))>>30) +#define PVIND(i) (((unsigned int)(i))&0x3fffffff) #define GETPV(i,p) \ -((int)(i)>=0 ? (int)((p)=CPVS->va[(unsigned int)(i)].priv)\ - : (int)((p)=GPVS->va[(unsigned int)(i)&(~MSB)].priv)) +(PVATTR(i)==0?(int)((p)=CPVS->va[(unsigned int)(i)].priv)\ + :PVATTR(i)==1?(int)((p)=GPVS->va[PVIND(i)].priv)\ + :(int)((p)=MPVS->va[PVIND(i)].priv)) +#define GETPVREF(i,p) \ +(PVATTR(i)==0?(int)((p)=&(CPVS->va[(unsigned int)(i)].priv))\ + :PVATTR(i)==1?(int)((p)=&(GPVS->va[PVIND(i)].priv))\ + :(int)((p)=&(MPVS->va[PVIND(i)].priv))) #define GETPVNAME(i,p) \ -((int)(i)>=0 ? (int)((p)=CPVS->va[(unsigned int)(i)].name)\ - : (int)((p)=GPVS->va[(unsigned int)(i)&(~MSB)].name)) +(PVATTR(i)==0?(int)((p)=CPVS->va[(unsigned int)(i)].name)\ + :PVATTR(i)==1?(int)((p)=GPVS->va[PVIND(i)].name)\ + :(int)((p)=MPVS->va[PVIND(i)].name)) #define ASSPV(i,p) \ -((int)(i)>=0 ? (int)(CPVS->va[(unsigned int)(i)].priv=(pointer)(p))\ - : (int)(GPVS->va[(unsigned int)(i)&(~MSB)].priv=(pointer)(p))) +(PVATTR(i)==0?(int)(CPVS->va[(unsigned int)(i)].priv=(pointer)(p))\ + :PVATTR(i)==1?(int)(GPVS->va[PVIND(i)].priv=(pointer)(p))\ + :(int)(MPVS->va[PVIND(i)].priv=(pointer)(p))) #define NEWNODE2(a) ((a)=(NODE2)MALLOC(sizeof(struct oNODE2))) #define MKNODE2(a,b,c,d) \ @@ -300,12 +290,17 @@ switch ( id ) {\ #define BDY1(a) ((a)->body1) #define BDY2(a) ((a)->body2) -extern VS GPVS,CPVS,EPVS,APVS; +extern VS GPVS,CPVS,EPVS,APVS,MPVS; +extern MODULE CUR_MODULE; +extern NODE MODULE_LIST; +extern char *CUR_FUNC; extern ARF addfs, subfs, mulfs, divfs, remfs, pwrfs; extern INFILE asir_infile; extern NODE usrf,sysf,noargsysf,ubinf,parif,ONENODE; extern int nextbp,nextbplevel; extern int Verbose; +extern int do_quiet; +extern SYMBOL Symbol_grlex, Symbol_glex, Symbol_lex; #if defined(VISUAL_LIB) #include @@ -322,7 +317,7 @@ extern int Verbose; #define fflush w_fflush #endif -#if defined(VISUAL) || (defined(__MACH__) && defined(__ppc__)) +#if defined(__GNUC__) || defined(VISUAL) || (defined(__MACH__) && defined(__ppc__)) || defined(__FreeBSD__) NODE mknode(int,...); FNODE mkfnode(int,fid,...); SNODE mksnode(int,sid,...); @@ -376,8 +371,8 @@ void dp_mod(DP,int,NODE,DP *); void dp_prim_mod(DP,int,DP *); void dp_prim(DP,DP *); void heu_nezgcdnpz(VL,P *,int,P *); -void homogenize_order(struct order_spec *,int,struct order_spec *); -int create_order_spec(Obj,struct order_spec *); +void homogenize_order(struct order_spec *,int,struct order_spec **); +int create_order_spec(VL,Obj,struct order_spec **); int dl_equal(int,DL,DL); void qltozl(Q *,int,Q *); @@ -470,7 +465,8 @@ int get_heapsize(void); int searchpvar(char *); void mkparif(char *,FUNC *); void makevar(char *,P *); -void mkpvs(void); +void mkpvs(char *); +MODULE mkmodule(char *); void stoarg(char *,int *,char **); void yyerror(char *); void closecurrentinput(void); @@ -502,7 +498,7 @@ int gettype(unsigned int); int indextotype(int,int); int loadfile(char *); int loadfiles(NODE); -int makepvar(char *); +unsigned int makepvar(char *); int membertoindex(int,char *); int qcoefp(Obj); int qcoefr(Obj); @@ -550,7 +546,7 @@ void instov(PFINS ,V *); Obj memberofstruct(COMP,char *); void mkpf(char *,Obj ,int ,V *,int (*)(),double (*)(),int (*)(),PF *); void mkpfins(PF ,V *,V *); -void mkuf(char *,char *,NODE,SNODE,int,int,char *); +void mkuf(char *,char *,NODE,SNODE,int,int,char *,MODULE); void newstruct(int,struct oCOMP **); void optobj(Obj *); void println(int, char **, int); @@ -606,12 +602,10 @@ int dp_redble(DP p1,DP p2); void sortbynm(Q *w,int n); int comp_nm(Q *a,Q *b); void qltozl(Q *w,int n,Q *dvr); -void homogenize_order(struct order_spec *old,int n,struct order_spec *new); void dp_rat(DP p,DP *rp); void dp_mod(DP p,int mod,NODE subst,DP *rp); void dp_dehomo(DP p,DP *rp); void dp_homo(DP p,DP *rp); -int create_order_spec(Obj obj,struct order_spec *spec); void dp_nf_tab_mod(DP p,LIST *tab,int mod,DP *rp); void dp_lnf_mod(DP p1,DP p2,NODE g,int mod,DP *r1p,DP *r2p); void dp_lnf_f(DP p1,DP p2,NODE g,DP *r1p,DP *r2p); @@ -775,10 +769,9 @@ void igcd_cofactor(Q a,Q b,Q *gcd,Q *ca,Q *cb); int comp_n(N *a,N *b); int TypeT_NB_check(unsigned int m, unsigned int t); int small_jacobi(int a,int m); -void mkpvs(); void pushpvs(FUNC f); void poppvs(); -int makepvar(char *str); +unsigned int makepvar(char *str); int searchpvar(char *str); int getpvar(VS pvs,char *str,int searchonly); void closecurrentinput(); @@ -799,7 +792,7 @@ void chsgnquote(QUOTE a,QUOTE *c); void objtoquote(Obj a,QUOTE *c); void polytoquote(P a,QUOTE *c); void dptoquote(DP a,QUOTE *c); -void dctoquote(DCP dc,QUOTE v,QUOTE *c); +void dctoquote(DCP dc,QUOTE v,QUOTE *c,int *sgn); void mptoquote(MP m,int n,QUOTE *c); void vartoquote(V v,QUOTE *c); void fnodetotree(FNODE f,LIST *rp); @@ -891,7 +884,7 @@ void gen_searchf(char *name,FUNC *r); void searchf(NODE fn,char *name,FUNC *r); void appenduf(char *name,FUNC *r); void mkparif(char *name,FUNC *r); -void mkuf(char *name,char *fname,NODE args,SNODE body,int startl,int endl,char *desc); +void mkuf(char *name,char *fname,NODE args,SNODE body,int startl,int endl,char *desc,MODULE module); Obj getopt_from_cpvs(char *key); void des_enc(unsigned long *, unsigned char *, unsigned long *); unsigned long round_func(unsigned long , unsigned char *);