diff --git a/src/objcftl.c b/src/objcftl.c index 17db851d29..3859747c9f 100644 --- a/src/objcftl.c +++ b/src/objcftl.c @@ -19,12 +19,28 @@ #include #include +#include #include #include #include #include +static ModuleStateOffset CFTLStateOffset = -1; + +struct CFTLModuleState { + Obj WORD_STACK; + Obj WORD_EXPONENT_STACK; + Obj SYLLABLE_STACK; + Obj EXPONENT_STACK; +}; + +extern inline struct CFTLModuleState *CFTLState(void) +{ + return (struct CFTLModuleState *)StateSlotsAtOffset(CFTLStateOffset); +} + + #define IS_INT_ZERO( n ) ((n) == INTOBJ_INT(0)) #define GET_COMMUTE( g ) INT_INTOBJ(ELM_PLIST(commute,(g))) @@ -87,14 +103,14 @@ Obj CollectPolycyc ( Obj ipow = ADDR_OBJ(pcp)[ PC_INVERSEPOWERS ]; Obj exp = ADDR_OBJ(pcp)[ PC_EXPONENTS ]; - Obj wst = ADDR_OBJ(pcp)[ PC_WORD_STACK ]; - Obj west = ADDR_OBJ(pcp)[ PC_WORD_EXPONENT_STACK ]; - Obj sst = ADDR_OBJ(pcp)[ PC_SYLLABLE_STACK ]; - Obj est = ADDR_OBJ(pcp)[ PC_EXPONENT_STACK ]; + Obj wst = CFTLState()->WORD_STACK; + Obj west = CFTLState()->WORD_EXPONENT_STACK; + Obj sst = CFTLState()->SYLLABLE_STACK; + Obj est = CFTLState()->EXPONENT_STACK; Obj conj=0, iconj=0; /*QQ initialize to please compiler */ - Int st, bottom = INT_INTOBJ( ADDR_OBJ(pcp)[ PC_STACK_POINTER ] ); + Int st, bottom = 0; Int g, syl, h, hh; @@ -296,7 +312,6 @@ Obj CollectPolycyc ( } } - ADDR_OBJ(pcp)[ PC_STACK_POINTER ] = INTOBJ_INT( bottom ); return (Obj)0; } @@ -394,6 +409,13 @@ static Int InitLibrary ( return 0; } +static void InitModuleState(ModuleStateOffset offset) +{ + CFTLState()->WORD_STACK = NEW_PLIST( T_PLIST, 4096 ); + CFTLState()->WORD_EXPONENT_STACK = NEW_PLIST( T_PLIST, 4096 ); + CFTLState()->SYLLABLE_STACK = NEW_PLIST( T_PLIST, 4096 ); + CFTLState()->EXPONENT_STACK = NEW_PLIST( T_PLIST, 4096 ); +} /**************************************************************************** ** @@ -411,5 +433,6 @@ static StructInitInfo module = { StructInitInfo * InitInfoPcc ( void ) { + CFTLStateOffset = RegisterModuleState(sizeof(struct CFTLModuleState), InitModuleState, 0); return &module; } diff --git a/src/objcftl.h b/src/objcftl.h index b7dd7c9ca3..e1832f2539 100644 --- a/src/objcftl.h +++ b/src/objcftl.h @@ -27,14 +27,35 @@ #define PC_DEEP_THOUGHT_BOUND 13 #define PC_ORDERS 14 +// TODO: the following stack related positions are not +// used anymore by CollectPolycyc, and will not be used +// anymore in future releases of the polycyclic package. +// We should phase them out for GAP 4.10. #define PC_WORD_STACK 15 #define PC_STACK_SIZE 16 #define PC_WORD_EXPONENT_STACK 17 #define PC_SYLLABLE_STACK 18 #define PC_EXPONENT_STACK 19 #define PC_STACK_POINTER 20 +// TODO: end obsolete + #define PC_DEFAULT_TYPE 21 +/* the following are defined in polycyclic: + +#define PC_PCP_ELEMENTS_FAMILY 22 +#define PC_PCP_ELEMENTS_TYPE 23 + +#define PC_COMMUTATORS 24 +#define PC_INVERSECOMMUTATORS 25 +#define PC_COMMUTATORSINVERSE 26 +#define PC_INVERSECOMMUTATORSINVERSE 27 + +#define PC_NILPOTENT_COMMUTE 28 +#define PC_WEIGHTS 29 +#define PC_ABELIAN_START 30 +*/ + /**************************************************************************** ** *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *