diff --git a/src/RCDEF/rcdef.cpp b/src/RCDEF/rcdef.cpp index da4fab5dd..1c61f4b23 100644 --- a/src/RCDEF/rcdef.cpp +++ b/src/RCDEF/rcdef.cpp @@ -162,7 +162,6 @@ #include "srd.h" #include "xiopak.h" // xffilcomp -// #include "envpak.h" // hello byebye #include "cuevf.h" // EVFHR EVFMH #include "cvpak.h" #include "lookup.h" @@ -2049,7 +2048,13 @@ x { printf( "\nRecord trap!");} // standard type-specific members: Copy() and operator=() fprintf( frc, " %s& Copy( const %s& _d) { Copy( static_cast< const record*>(&_d)); return *this; }\n", rcNam, rcNam); +#if 0 +0 experiment re elimination of duplicate Copy / CopyFrom +0 retain pending finalization of Copy / CopyFrom merge 6-2023 +0 fprintf(frc, " %s& operator=( const %s& _d) = delete;\n", rcNam, rcNam); +#else fprintf( frc, " %s& operator=( const %s& _d) { Copy( static_cast< const record*>(&_d)); return *this; }\n", rcNam, rcNam); +#endif // virtual Copy(): override or not fprintf( frc, " virtual void Copy( const record* pSrc, int options=0)%s;\n", @@ -2230,7 +2235,7 @@ x { printf( "\nRecord trap!");} if (fSrfd) // if doing it and opened ok { - wSrfd4( fSrfd); // write part after per-record stuff, below + // wSrfd4( fSrfd); write part after per-record stuff, below DROPPED 6-2023 fprintf( fSrfd, "\n\n/* end of srfd.cpp */\n" ); fclose(fSrfd); printf(" \n"); @@ -2932,7 +2937,7 @@ LOCAL void wRcTd( FILE *f) // write record and anchor class declara //====================================================================== LOCAL void wSrfd1( FILE *f) -// write "Small record and field descriptor" C source file for compilation and linking into applications +// write "Small record and field descriptor" C++ file for compilation and linking into applications // PART 1 of 4 parts: field types table, and stuff above portion repeated for each record type. @@ -2945,15 +2950,15 @@ LOCAL void wSrfd1( FILE *f) "// srfd.cpp\n" "\n" "/* This is a Record and Field Descriptor Tables source file generated generated by rcdef.exe.\n" - " This file is compiled and linked into an application, such as CN. */\n" ); + " This file is compiled and linked into CSE.*/\n" ); fprintf( f, "\n" "/* DO NOT EDIT: This file is overwritten when rcdef is run.\n" " To change, change rcdef.exe input as desired and re-run rcdef.exe via the appropropriate batch file. */\n\n" "\n" "#include \"cnglob.h\" // includes for DTxxxx symbols\n" "#include \"srd.h\" // defines structures and declares variables. Plus comments. Manually generated file.\n" - "#include // defines base class for record classes in rc____.h files. Manually generated file.\n" - "// also file(s) are included below.\n" + "#include \"ancrec.h\" // defines base class for record classes. Manually generated file.\n" + "// also rccn.h is included below.\n" "\n" "#undef o // in case an .h file defines o\n"// 1-95 ); @@ -2973,9 +2978,8 @@ LOCAL void wSrfd1( FILE *f) for (int i = 0; i < nfdtypes; i++) { // write data type 0 as "0", not "DTSI" or whatever is first, for clearer entry 0 (FDNONE) - char* dtTx = (Fdtab[i].dtype==0 ? const_cast("0") - : strtcat( "DT", dtnames[ dtnmi[ DTBMASK&(Fdtab[i].dtype) ] ], - NULL ) ); + const char* dtTx = (Fdtab[i].dtype==0 ? "0" + : strtcat( "DT", dtnames[ dtnmi[ DTBMASK&(Fdtab[i].dtype) ] ], NULL ) ); /* write line: DTXXXX, LMXXXX, UNXXXX, // number NAME */ fprintf( f, " {%15s, %10s, %13s },\t//%3d %s\n", dtTx, @@ -2990,23 +2994,24 @@ LOCAL void wSrfd1( FILE *f) // Write stuff above "fir" tables for record types - fprintf( f, + fprintf(f, "\n\n/*========== small FIELDS-IN-RECORDS tables for each record type */\n" "\n" - " /* COLUMNS ARE\n" - " .fdTy .evf .ff .off .mName \n" - " (sFdtab (vari- (fld \n" - " index) ation) flgs) (member offset) (member name) field type name\n" - " ------- ------ ----- ----------------- ------------------ --------------- */\n" - "\n" - "/*lint -e619 suppress msg for putting \"text\" in pointer */\n\n"); + "// COLUMNS ARE\n" + "// ff field flags\n" + "// fdTy field type (sFdtab idx)\n" + "// evf variability (evaluation interval)\n" + "// nxsc fn of next field requiring special case copy\n" + "// off member offset\n" + "// mName member name\n" + "// data type (as comment)\n\n"); // wSrfd3, called for each record type, continues the file } // wSrfd1 //====================================================================== LOCAL void wSrfd2( FILE *f) -// write "Small record and field descriptor" C source file for compilation and linking into applications +// write "Small record and field descriptor" c++ source file for compilation and linking into applications // PART 2 of 4 parts: portion repeated at each *file statement @@ -3019,7 +3024,7 @@ LOCAL void wSrfd2( FILE *f) //====================================================================== LOCAL void wSrfd3( FILE *f) -// write "Small record and field descriptor" C source file for compilation and linking into applications +// write "Small record and field descriptor" C++ source file for compilation and linking into applications // PART 3 of 4 parts: portion repeated for each record type: fields-in-record table for current record. @@ -3032,18 +3037,31 @@ LOCAL void wSrfd3( FILE *f) // for file format see comments in srd.h, or in srfd.cpp as output. { + // identify fields that cannot be copied bit-wise + // chain them together for use in e.g. record::Copy + std::vector< int> nxsc(rcdesc->rcdnfds, -1); + int iNxscPrior = 0; + for (int j = 0; j < rcdesc->rcdnfds; j++) + { + int fdi = rcdesc->rcdfdd[j].rcfdnm; // field type + if (strcmp( rcfdnms[fdi], "CHP")==0) + { nxsc[iNxscPrior] = j; + iNxscPrior = j; + } + } + fprintf( f, "struct SFIR sfir%s[] =\t// fields info for RT%s\n" "{\n #define o(m) offsetof(%s,m)\n" - // {dddd, dddd, dddd,ssssssssssssssssssss,sssssssssssssssssss }, - " // .ff .fdTy .evf .off .mName\n", + "// ff fdTy evf nxsc off mName\n", rcNam, rcNam, rcNam ); for (int j = 0; j < rcdesc->rcdnfds; j++) // fields loop { int fdi = rcdesc->rcdfdd[j].rcfdnm; // get field type - fprintf( f, " {%4d, %4d, %4d,%20s,%19s },\t// %s\n", + fprintf( f, " {%4d, %4d, %4d, %4d,%20s,%19s },\t// %s\n", rcdesc->rcdfdd[j].ff, // field flags (attributes) fdi, // field type rcdesc->rcdfdd[j].evf, // field variation + nxsc[ j], // next special copy field strtprintf("o(%s)", fldFullNm2[rcseq][j].c_str()), // full member name, in macro call to make compiler supply offset enquote( fldNm2[ rcseq][j].c_str()), // user member name in quotes (for probes, error messages) rcfdnms[fdi] ); // name of field type, in comment @@ -3051,42 +3069,45 @@ LOCAL void wSrfd3( FILE *f) if (strlen(fldNm2[ rcseq][j].c_str()) > WARNAT) // report overlong ones rcderr( "Warning: member name over %d long: %s", WARNAT, fldNm2[ rcseq][j].c_str()); } - fprintf( f, " { 0, 0, 0, 0, 0 }\t// terminator\n" + fprintf( f, " { 0, 0, 0, 0, 0, 0 }\t// terminator\n" " #undef o\n" "}; // sfir%s\n\n", rcNam ); } // wSrfd3 //====================================================================== -LOCAL void wSrfd4( FILE *f) - -// write "Small record and field descriptor" C source file for compilation and linking into applications - -// PART 4 of 4 parts: stuff after portion repeated for each record type; small record descriptor table. -{ - -// Write small record descriptor table - - fprintf( f, "\n\n/*========== small RECORD DESCRIPTOR table */\n" - "\n" - " // find desired entry by searching for .rt \n" - "\n" - "SRD sRd[] =\n" - "{ // recTy, #fds, fields-in-record pointer\n" - " // .rt .nFlds .fir\n" ); - for (int i = 1; i < nrcnms; i++) // loop records types - // note start at 1 to skip RTNONE - { - RCD* rd = (RCD *)( (char *)Rcdtab + (ULI)Rcdtab[ rctypes[i] & RCTMASK]); - // use offset stored in pointer array - // write line " RTXXXX, nFields, sfirXXXX," - fprintf( f, " {%15s, %3d, sfir%s },\n", - strtcat( "RT", rcnms[i], NULL), - rd->rcdnfds, rcnms[i] ); - } - fprintf( f, " { 0, 0, 0 }\t// terminate table for searching\n" - "}; // sRd[]\n"); - - // caller recs() finishes file and closes. -} // wSrfd4 +#if 0 +0 DROPPED 6-2023 (unused) +0 LOCAL void wSrfd4( FILE *f) +0 +0 // write "Small record and field descriptor" C++ file for compilation and linking into applications +0 +0 // PART 4 of 4 parts: stuff after portion repeated for each record type; small record descriptor table. +0 { +0 +0 // Write small record descriptor table +0 +0 fprintf( f, "\n\n/*========== small RECORD DESCRIPTOR table */\n" +0 "\n" +0 " // find desired entry by searching for .rt \n" +0 "\n" +0 "SRD sRd[] =\n" +0 "{ // recTy, #fds, fields-in-record pointer\n" +0 " // .rt .nFlds .fir\n" ); +0 for (int i = 1; i < nrcnms; i++) // loop records types +0 // note start at 1 to skip RTNONE +0 { +0 RCD* rd = (RCD *)( (char *)Rcdtab + (ULI)Rcdtab[ rctypes[i] & RCTMASK]); +0 // use offset stored in pointer array +0 // write line " RTXXXX, nFields, sfirXXXX," +0 fprintf( f, " {%15s, %3d, sfir%s },\n", +0 strtcat( "RT", rcnms[i], NULL), +0 rd->rcdnfds, rcnms[i] ); +0 } +0 fprintf( f, " { 0, 0, 0 }\t// terminate table for searching\n" +0 "}; // sRd[]\n"); +0 +0 // caller recs() finishes file and closes. +0 } // wSrfd4 +#endif //====================================================================== LOCAL void sumry() // write rcdef summary to screen and file diff --git a/src/ancrec.cpp b/src/ancrec.cpp index 751965a9f..840abf510 100644 --- a/src/ancrec.cpp +++ b/src/ancrec.cpp @@ -60,10 +60,10 @@ record::record(BP _b, TI i, SI noZ/*=0*/) // construct record i of basAnc b, z } // record::record //--------------------------------------------------------------------------------------------------------------------------- void* record::field( int fn) // point to member in record by FIELD # -{ return (void *)((char *)this + b->fir[fn].off); } +{ return (void *)((char *)this + b->fir[fn].fi_off); } //----------------------------------------------------------------------------- const void* record::field( int fn) const -{ return (const void *)((const char *)this + b->fir[fn].off); } +{ return (const void *)((const char *)this + b->fir[fn].fi_off); } //----------------------------------------------------------------------------- void record::RRFldCopy( // record-to-record field copy const record* r, // source record (same type as this) @@ -100,7 +100,7 @@ void record::FldCopy( // field-to-field copy (within record) } // record::FldCopy //----------------------------------------------------------------------------- int record::DType( int fn) const -{ int fdTy = b->fir[ fn].fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table +{ int fdTy = b->fir[ fn].fi_fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table int dt = sFdtab[ fdTy].dtype; // get data type from small Fields info Table return dt; } // record::DType @@ -638,7 +638,7 @@ void CDEC record::chafSelf( // say increment change flag IN SAME RECORD on cha { va_list ap; va_start(ap, chafFn); - chafNV(this->b, ss, b->fir[chafFn].off, ap); + chafNV(this->b, ss, b->fir[chafFn].fi_off, ap); } // record::chafSelf //============================================================================================================================ void CDEC record::chafN( // say increment specified flag during run on change in list of fields in curr record @@ -884,7 +884,7 @@ void * FC basAnc::recFld( TI i, SI fn) // point record i member by FIELD # /* note: this is not in ancrec.h to avoid needing to include srd.h first for sFIRstr; it is not virtual to avoid multiple copies. delete later (3-92) if not used. */ { - return (void *)((char *)&rec(i) + fir[fn].off); // get field offset from basAnc's fields-in-record table + return (void *)((char *)&rec(i) + fir[fn].fi_off); // get field offset from basAnc's fields-in-record table } //--------------------------------------------------------------------------------------------------------------------------- RC FC basAnc::al( // destroy any existing records and allocate space for n (0=default) records @@ -1251,7 +1251,7 @@ const char* basAnc::getChoiTx( // return text of given value for a choice data // add more checks to this code if errors tend to happen... - USI fdTy = fir[fn].fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table + USI fdTy = fir[fn].fi_fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table USI dt = sFdtab[fdTy].dtype; // get data type from small Fields info Table chan &= ~NCNAN; // clear special bits in nchoice value to make checks work diff --git a/src/cueval.cpp b/src/cueval.cpp index ecb568141..880fcc683 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -859,7 +859,7 @@ made things worse TODO (MP) //--- record data loads: load datum of indicated type to 2 or 4 bytes, making private dm copy of strings. // these take rec ptr in stack (from PSRATRN/S), field number inline. // macro gets ptr from stk, adds member offset for inline field number -#define POINT e = (record*)*SPP++; v = (char *)e + e->b->fir[ *IPU++ ].off +#define POINT e = (record*)*SPP++; v = (char *)e + e->b->fir[ *IPU++ ].fi_off #ifdef wanted // not wanted 12-91: there are no UCH or CH values in records. w case PSRATLOD1U: POINT; *--SPU = (USI)*(UCH*)v; break; // 1 unsigned byte w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign @@ -1065,18 +1065,18 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) { record *e = (record *)*SPP++; // get record ptr from eval stack. e->b is its basAnc. SFIR *fir = e->b->fir + *IPU++; // get inline field ptr, point to fields-in-record entry for field - //USI off = fir->off; how to get member offset from fields-in-record table + //USI off = fir->fi_off; how to get member offset from fields-in-record table //USI evf = fir.evf; how to get field variation (evaluation frequency) bits // check for mistimed probe eg to monthly results at end of day (when monthly results contain incomplete data) - if (fir->evf & EVXBEGIVL) // if probed field avail only at end ivl (can probe start-ivl flds anytime) + if (fir->fi_evf & EVXBEGIVL) // if probed field avail only at end ivl (can probe start-ivl flds anytime) { if (!Top.isEndOf) // if not now end of an interval (cnguts.cpp) { *pms = strtprintf( (char *)MH_R0222, // "Internal Error: mistimed probe: %s varies at end of %s\n" // " but access occurred %s" - whatNio( e->b->ancN, e->ss, fir->off), - evfTx( fir->evf, 2), + whatNio( e->b->ancN, e->ss, fir->fi_off), + evfTx( fir->fi_evf, 2), Top.isBegOf ? strtprintf( (char *)MH_R0223, // "at BEGINNING of %s" ivlTx(Top.isBegOf) ) // ivlTx: below @@ -1086,10 +1086,10 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) } IVLCH minIvl = - fir->evf >= EVFSUBHR ? C_IVLCH_S // get ivl corresponding to leftmost evf bit - : fir->evf >= EVFHR ? C_IVLCH_H // (shortest interval at which ok to probe this field) - : fir->evf >= EVFDAY ? C_IVLCH_D - : fir->evf >= EVFMON ? C_IVLCH_M + fir->fi_evf >= EVFSUBHR ? C_IVLCH_S // get ivl corresponding to leftmost evf bit + : fir->fi_evf >= EVFHR ? C_IVLCH_H // (shortest interval at which ok to probe this field) + : fir->fi_evf >= EVFDAY ? C_IVLCH_D + : fir->fi_evf >= EVFMON ? C_IVLCH_M : C_IVLCH_Y; // EVFRUN, EVFFAZ, EVFEOI if (Top.isEndOf > minIvl) // if end of too short an interval (C_IVLCH_ increases for shorter times) @@ -1097,8 +1097,8 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) *pms = strtprintf( (char *)MH_R0225, /* "Mistimed probe: %s\n" " varies at end of %s but accessed at end of %s.\n" " Possibly you combined it in an expression with a faster-varying datum." */ - whatNio( e->b->ancN, e->ss, fir->off), - evfTx( fir->evf, 2), + whatNio( e->b->ancN, e->ss, fir->fi_off), + evfTx( fir->fi_evf, 2), ivlTx(Top.isEndOf) ); return RCBAD; } @@ -1106,19 +1106,19 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) // fetch and check 4-byte quantity #if defined( ND3264) - NANDAT v = *(NANDAT *)((char *)e + fir->off); // fetch 4-byte value from record at offset + NANDAT v = *(NANDAT *)((char *)e + fir->fi_off); // fetch 4-byte value from record at offset if (ISNANDLE(v)) { if (ISUNSET(v)) { *pms = strtprintf( (char *)MH_R0226, // "Internal error: Unset data for %s" - whatNio( e->b->ancN, e->ss, fir->off) ); // describe probed mbr. exman.cpp + whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp return RCBAD; } else if (ISASING(v)) { *pms = strtprintf( (char *)MH_R0232, // "%s probed while being autosized" - whatNio( e->b->ancN, e->ss, fir->off) ); // describe probed mbr. exman.cpp + whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp return RCBAD; } else // other nandles are expression handles @@ -1127,7 +1127,7 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) if (exInfo( h, NULL, NULL, &v)) // get value / if not valid expr # { *pms = strtprintf( (char *)MH_R0227, // "Internal error: bad expression number %d found in %s" - (INT)h, whatNio( e->b->ancN, e->ss, fir->off) ); + (INT)h, whatNio( e->b->ancN, e->ss, fir->fi_off) ); return RCBAD; } if (ISNANDLE(v)) // if expr table contains nan, expr is not eval'd yet. @@ -1147,20 +1147,20 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) } *(NANDAT *)pv = v; #else - void* v = *(void**)((char*)e + fir->off); // fetch 4-byte value from record at offset + void* v = *(void**)((char*)e + fir->fi_off); // fetch 4-byte value from record at offset if (ISNANDLE(v)) { if (ISUNSET(v)) { *pms = strtprintf((char*)MH_R0226, // "Internal error: Unset data for %s" - whatNio(e->b->ancN, e->ss, fir->off)); // describe probed mbr. exman.cpp + whatNio(e->b->ancN, e->ss, fir->fi_off)); // describe probed mbr. exman.cpp return RCBAD; } #if defined( AUTOSIZE) // found "ifdef AUTOSIZING" ?? 4-16-10 else if (ISASING(v)) { *pms = strtprintf((char*)MH_R0232, // "%s probed while being autosized" - whatNio(e->b->ancN, e->ss, fir->off)); // describe probed mbr. exman.cpp + whatNio(e->b->ancN, e->ss, fir->fi_off)); // describe probed mbr. exman.cpp return RCBAD; } #endif @@ -1170,7 +1170,7 @@ LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH) if (exInfo(h, NULL, NULL, &v)) // get value / if not valid expr # { *pms = strtprintf((char*)MH_R0227, // "Internal error: bad expression number %d found in %s" - (INT)h, whatNio(e->b->ancN, e->ss, fir->off)); + (INT)h, whatNio(e->b->ancN, e->ss, fir->fi_off)); return RCBAD; } if (ISNANDLE(v)) // if expr table contains nan, expr is not eval'd yet. @@ -1210,7 +1210,7 @@ LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) record *e = (record *)*SPP++; // get record ptr from eval stack. e->b is its basAnc. USI fn = *IPU++; // get inline field number from instruction stream SFIR *fir = e->b->fir + fn; // get pointer to fields-in-record table for this field - //USI off = fir->off; how to get member offset from fields-in-record table + //USI off = fir->fi_off; how to get member offset from fields-in-record table //USI evf = fir.evf; how to get field variation (evaluation frequency) bits // check 2-byte field -- too small to hold NANDLE, use field status @@ -1220,14 +1220,14 @@ LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) expression (if neither flag on, assume is run field -- bits not set.) */ { *pms = strtprintf( (char *)MH_R0228, // "%s has not been evaluated yet." Also used above. - whatNio( e->b->ancN, e->ss, fir->off) ); // describe probed mbr. exman.cpp + whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp if (pBadH) *pBadH = 0; // don't know handle of uneval'd expr for this variable (could search exTab)? return RCUNSET; // say unset data -- try rearranging exprs } // fetch 2-byte quantity - *pi = *(SI *)((char *)e + fir->off); // fetch 2-byte value from record at offset + *pi = *(SI *)((char *)e + fir->fi_off); // fetch 2-byte value from record at offset return RCOK; } // cuRm2Get #endif diff --git a/src/cul.cpp b/src/cul.cpp index 4a6432827..92d5414de 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -1522,7 +1522,7 @@ x dmfree( DMPP( *p)); // free any prior string value: free ram, NUL *(float *)p = (float)cvExtoIn( *(float *)&c->DFF, // scale value in field's external units to internal, cvpak.cpp - sFdtab[ xSp->b->fir[c->fn].fdTy ].untype ); // field's units + sFdtab[ xSp->b->fir[c->fn].fi_fdTy ].untype ); // field's units // note cvpak units scaling applies only to // NC's, DTFLOAT, [DTDBL], [DTPERCENT], and [DTSSE]. } @@ -1602,7 +1602,7 @@ LOCAL RC FC clearRat( CULT *c) for (cc = (CULT *)c->CULTP2; cc->id; cc++) // loop table records if (cc->cs==DAT) // if table entry is for data { - void *p = (char *)xSp->e + xSp->b->fir[ cc->fn ].off; // datPt() subset: record base + member offset + void *p = (char *)xSp->e + xSp->b->fir[ cc->fn ].fi_off; // datPt() subset: record base + member offset if ( cc->ty==TYSTR // if data is string, || cc->ty==TYFLSTR && ((VALNDT*)p)->ty==TYSTR ) // or float-or-string now set to string, { @@ -1826,7 +1826,7 @@ LOCAL RC FC culRESET() // "unset" a member -- re-default it else *(float *)p = (float)cvExtoIn( // scale value in field's external units to internal, lib\cvpak.cpp *(float *)&c->DFF, // fetch float default as float - sFdtab[ xSp->b->fir[c->fn].fdTy ].untype ); // fld's units + sFdtab[ xSp->b->fir[c->fn].fi_fdTy ].untype ); // fld's units } else if (xSp->sz <= 4) // if <= 4 bytes long, default data is IN .DFPI memcpy( p, &c->DFPI, xSp->sz); // copy data default data to member @@ -2350,7 +2350,7 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0 xStkPt(); // be sure all (basAnc-record-related) ptrs current // fetch field type -- used to specify data type and limit type to exman.cpp - xSp->fdTy = xSp->b->fir[ c->fn ].fdTy; // from tbl whose source code is made by rcdef.exe + xSp->fdTy = xSp->b->fir[ c->fn ].fi_fdTy; // from tbl whose source code is made by rcdef.exe // get array size if specified and check for inconsistent flag combinations if (c->f & ARRAY) @@ -2466,7 +2466,7 @@ x } // data and field status locations xSp->p = // current element location same, til caller increments it - xSp->p0 = (char *)xSp->e + xSp->b->fir[c->fn].off; // element [0] location: record base, + mbr offset, from FIR table + xSp->p0 = (char *)xSp->e + xSp->b->fir[c->fn].fi_off; // element [0] location: record base, + mbr offset, from FIR table xSp->fs = xSp->fs0 + c->fn; // field status byte basic locn is base + field number // for most Fs bits, caller must subscript fs by array elt #. return RCOK; @@ -2649,7 +2649,7 @@ LOCAL RC ganame( char *p; RC rc = xpr( TYID, // TYID: string, implied quotes on unreserved undeclared words - sfirSFI[ SFI_NAME].fdTy, // get field type for an ANAME field so exman.cpp will check string length + sfirSFI[ SFI_NAME].fi_fdTy, // get field type for an ANAME field so exman.cpp will check string length // (we have no defines for fld types: not invariant: data\fields.def // is rearrangable & product dependent) 2-91. Declared in rccn.h. 0, 0, // 0 evfOk, useCl: require constant value @@ -4320,7 +4320,7 @@ LOCAL void FC drefRes() continue; } TI* p = (TI *)((char *)e // field location: where to store reference subscript: record location, - + b->fir[drfp->fn].off); // plus field offset + + b->fir[drfp->fn].fi_off); // plus field offset UCH* fs = (UCH *)e + b->sOff; // field status byte location for field const char* ms=NULL; if (ratLuDefO( drfp->toB, drfp->toName, drfp->defO, diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index 2844ff2a0..96573f243 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -37,7 +37,7 @@ struct PROBEOBJECT // info probe() shares with callees: pass single pointer BP runB; // 0 or run basAnc found with given name, 0'd if member name not found char* what; // name (.what) of basAnc(s) whose records being probed SFIR* inF, * runF; // pointers to "fields-in-record" tables (srfd.cpp) for input and run rats - char* mName; // name of member being probed + const char* mName; // name of member being probed USI inFn, runFn; // input and run basAnc field numbers USI ssTy; // data type of record subscript: TYSTR or TYINT SI ssIsK; // non-0 if record subscript is constant @@ -48,7 +48,7 @@ struct PROBEOBJECT // info probe() shares with callees: pass single pointer /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC FC findMember( PROBEOBJECT *o); LOCAL RC FC tryImInProbe( PROBEOBJECT *o); -LOCAL RC FC lopNty4dt( USI dt, USI *pTy, USI *pSz, PSOP *pLop, char * * pErrSub); +LOCAL RC FC lopNty4dt( USI dt, USI *pTy, USI *pSz, PSOP *pLop, const char** pErrSub); LOCAL void FC disMember( SFIR *f1, SI isIn, SI isRun, SI showAll); @@ -64,7 +64,6 @@ RC FC probe() USI inDt = 0,runDt = 0; PSOP lop; - char *errSub; BP b; SFIR * f; USI fn, minEvf; @@ -150,8 +149,8 @@ RC FC probe() // determine DT___ and TY___ data types, and size of type - if (o.inB) inDt = sFdtab[o.inF->fdTy].dtype; // fetch recdef DT_____ data type for input record member - if (o.runB) runDt = sFdtab[o.runF->fdTy].dtype; // ... run record member + if (o.inB) inDt = sFdtab[o.inF->fi_fdTy].dtype; // fetch recdef DT_____ data type for input record member + if (o.runB) runDt = sFdtab[o.runF->fi_fdTy].dtype; // ... run record member if (o.inB && o.runB && inDt != runDt) // error if inconsistent return perNx( (char *)MH_U0007, //"U0007: Internal error: %s member '%s'\n" @@ -160,6 +159,7 @@ RC FC probe() o.what, o.mName, (INT)inDt, (INT)runDt ); o.dt = o.inB ? inDt : runDt; // get a single data type value + const char* errSub; if (lopNty4dt( o.dt, &o.ty, &o.sz, &lop, &errSub)) // get ty, size, and instruction for dt, below / if bad return perNx( (char *)MH_U0008, // "U0007: %s member '%s' has %s data type (dt) %d" o.what, o.mName, errSub, (INT)o.dt ); @@ -173,20 +173,20 @@ RC FC probe() // EVEOI, b4 initial setup only, or EVFFAZ, also b4 re-setup for run after autosize, 6-95 if (o.inB // if have input record basAnc - && !(o.inF->evf &~EVEOI) // if probed member has no rutime & no EVFFAZ variation - && evfOk & EVEOI ) // if end-of-input time variation ok for expr being evaluated by caller + && !(o.inF->fi_evf &~EVEOI) // if probed member has no rutime & no EVFFAZ variation + && evfOk & EVEOI ) // if end-of-input time variation ok for expr being evaluated by caller { - minEvf = EVEOI; // minimum variability, applicable here if f->evf has no variability + minEvf = EVEOI; // minimum variability, applicable here if f->fi_evf has no variability b = o.inB; f = o.inF; fn = o.inFn; // use input record: set basAnc, SFIR entry, field # for code emit below // note if other operands in expr vary at runtime, cuparse's evf logic will promote expression's evf appropriately. } else if ( o.inB // if have input record basAnc - && !(o.inF->evf &~(EVEOI|EVFFAZ)) // if probed member has no rutime variation + && !(o.inF->fi_evf &~(EVEOI|EVFFAZ)) // if probed member has no rutime variation && evfOk & EVFFAZ ) // if "phasely" variation ok for expr being evaluated by caller { - minEvf = EVFFAZ; // minimum variability, applicable here if f->evf has no variability + minEvf = EVFFAZ; // minimum variability, applicable here if f->fi_evf has no variability b = o.inB; f = o.inF; fn = o.inFn; // use input record: set basAnc, SFIR entry, field # for code emit below @@ -246,8 +246,8 @@ RC FC probe() // ... not needed for EVEOI/EVFFAZ probe, but set where if another operand changes evf to runtime? parSp->ty = o.ty; // data type resulting from this probe parSp->evf |= // with evf of any preceding sub-expr and subscr/name expr above, if any, combine... - f->evf // probed member's evalfreq bits fields-in-record table, and - | minEvf; // min evalFreq, applicable if 0 in f->evf. expr keeps only ruling evf bit. + f->fi_evf // probed member's evalfreq bits fields-in-record table, and + | minEvf; // min evalFreq, applicable if 0 in f->fi_evf. expr keeps only ruling evf bit. prec = PROP; // say have an operand return RCOK; // many other returns above, incl in E macros. caller ERREX's. } // probe @@ -296,7 +296,7 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i { o->inF++; o->inFn++; // try next fir table entry, incr field number - if ( !o->inF->fdTy // if end fir table, not found + if ( !o->inF->fi_fdTy // if end fir table, not found || m && _strnicmp( MNAME(f1), MNAME(o->inF), m) ) /* if preceding m chars of this entry don't match (all entries with same beginning are together) */ { @@ -314,7 +314,7 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i { o->runF++; o->runFn++; // try next fir table entry; //incr field number - if ( !o->runF->fdTy // if end fir table, not found + if ( !o->runF->fi_fdTy // if end fir table, not found || m && _strnicmp( MNAME(f1), MNAME(o->runF), m) ) /* if preceding m chars of this entry don't match (all entries with same beginning are together) */ { @@ -493,7 +493,7 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) return RCCANNOT; /* record not found and evfOk not 0. A non-immediate probe method may work, and expr's msg isn't so bad for other variabilities, so let caller fall thru. */ } - pv = (char *)e + o->inF->off; // point to member + pv = (char *)e + o->inF->fi_off; // point to member v = *(void **)pv; // fetch member as 4-byte quantity // if set to constant value, generate constant for same value @@ -565,11 +565,11 @@ x #define PSRATLODS 112 // rat load string: loads char * from record, duplicate LOCAL RC FC lopNty4dt( // for DT- data type, get TY- type and PSOP to load it from a record of a basAnc USI dt, // recdef world DTxxxx data type - USI *pTy, // NULL or receives ul TYxxxx data type: TYSI, TYFL, or TYSTR. - USI *pSz, // NULL or receives sizeof(ty) - PSOP *pLop, /* NULL or receives pseudo-instruction to load this type from a basAnc record - (instructions supplied here add inline field #'s offset to address on stack, fetch to stack) */ - char * * pErrSub ) /* NULL or receives adjectivial error subtext on error return: + USI* pTy, // NULL or receives ul TYxxxx data type: TYSI, TYFL, or TYSTR. + USI* pSz, // NULL or receives sizeof(ty) + PSOP* pLop, // NULL or receives pseudo - instruction to load this type from a basAnc record + // (instructions supplied here add inline field #'s offset to address on stack, fetch to stack) + const char** pErrSub ) /* NULL or receives adjectivial error subtext on error return: "unexpected", "unrecognized", "un-probe-able", etc */ // if no corresponding TY type, returns errSub text and returns bad. NO ERROR MESSAGE HERE. @@ -791,8 +791,8 @@ void FC showProbeNames(int showAll) runF = runB ? runB->fir : NULL; // .. of the basAnc(s) found above for ( ; ; ) // until break { - if (inF && !inF->fdTy) inF = NULL; // if end of table, set its ptr NULL - if (runF && !runF->fdTy) runF = NULL; // .. + if (inF && !inF->fi_fdTy) inF = NULL; // if end of table, set its ptr NULL + if (runF && !runF->fi_fdTy) runF = NULL; // .. if (!inF && !runF) break; // if end both tables, done // display a member of only table or that matches in both tables @@ -810,8 +810,8 @@ void FC showProbeNames(int showAll) inMax = runMax = 0; // end not yet found in either table for (k = 1; ; k++) // try looking ahead 1,2,... til end or match { - if (!inMax && !(inF+k)->fdTy) inMax = k; // record ends of tables when found - if (!runMax && !(runF+k)->fdTy) runMax = k; // .. + if (!inMax && !(inF+k)->fi_fdTy) inMax = k; // record ends of tables when found + if (!runMax && !(runF+k)->fi_fdTy) runMax = k; // .. if (inMax & runMax) // if end of both tables found { j = inMax; @@ -836,22 +836,21 @@ void FC showProbeNames(int showAll) } breakBreak: // show j input members, k run members - while (j--) if (inF->fdTy) disMember( inF++, 1, 0, showAll); - while (k--) if (runF->fdTy) disMember( runF++, 0, 1, showAll); + while (j--) if (inF->fi_fdTy) disMember( inF++, 1, 0, showAll); + while (k--) if (runF->fi_fdTy) disMember( runF++, 0, 1, showAll); } } } // showProbeNames //========================================================================== LOCAL void FC disMember( SFIR *f1, SI isIn, SI isRun, SI showAll) // display info on one record member, for shoProbeNames { - USI dt, ty; - char *tySubTx="?", *evfSubTx; - - if (f1->ff & FFHIDE && !showAll) // if field flagged to hide (*i on field in cnrecs.def) + if (f1->fi_ff & FFHIDE && !showAll) // if field flagged to hide (*i on field in cnrecs.def) return; // don't display it - dt = sFdtab[f1->fdTy].dtype; // get field's DT- data type from field type's table entry + USI dt = sFdtab[f1->fi_fdTy].dtype; // get field's DT- data type from field type's table entry + USI ty; + const char* tySubTx = "?"; if (lopNty4dt( dt, &ty, NULL, NULL, &tySubTx)==RCOK) // get TY- type or error subText for field's DT- type. above. switch (ty) // if ok get text for DT type (lopNty4dt set it if not RCOK) { @@ -869,16 +868,16 @@ LOCAL void FC disMember( SFIR *f1, SI isIn, SI isRun, SI showAll) // display inf break; // normally hide structures, pointers, errors, etc. } - evfSubTx = !f1->evf ? "constant" // variability subtext - : f1->evf & EVXBEGIVL ? strtprintf( "end of %s", evfTx(f1->evf,2) ) - : evfTx( f1->evf, 0); + const char* evfSubTx = !f1->fi_evf ? "constant" // variability subtext + : f1->fi_evf & EVXBEGIVL ? strtprintf( "end of %s", evfTx(f1->fi_evf,2) ) + : evfTx( f1->fi_evf, 0); printf( " %20s %s %s %-15s %s\n", - MNAME(f1), - isIn ? "I" : " ", - isRun ? "R" : " ", - tySubTx, - evfSubTx ); + MNAME(f1), + isIn ? "I" : " ", + isRun ? "R" : " ", + tySubTx, + evfSubTx ); } // disMember //============================================================================= diff --git a/src/exman.cpp b/src/exman.cpp index d366289fe..02e8826d1 100644 --- a/src/exman.cpp +++ b/src/exman.cpp @@ -619,7 +619,7 @@ void FC extDup( record *nuE, record *e) // duplicate expression table entries f if ( ex->srcB==e->b && ex->srcI==e->ss // if expr in given record && ex->nx >= 0) // if not deleted exTab entry { - USI off = ex->srcB->fir[ex->srcFn].off; + USI off = ex->srcB->fir[ex->srcFn].fi_off; if ( ex->ty==TYSI // if integer (too small for nandle) #if defined( ND3264) || *(NANDAT*)((char *)e + off)==NANDLE(h)) // or field has correct nandle -- insurance @@ -810,7 +810,7 @@ RC FC exWalkRecs() int oi = 0; // init offset table os[] index for (int f = 0; f < b->nFlds; f++) // loop fields in record { - USI dt = sFdtab[ b->fir[f].fdTy ].dtype; // get data type from field info + USI dt = sFdtab[ b->fir[f].fi_fdTy ].dtype; // get data type from field info if ( GetDttab(dt).size==4 // if any 4-byte field (FLOAT, CHP, ... ) (GetDttab: srd.h) || dt==DTVALNDT ) /* or value+data type substruct, which begins with a 4-byte value field (for reportCol 11-91) */ @@ -821,7 +821,7 @@ RC FC exWalkRecs() (char *)MH_E0096); // "exman.cpp:exWalkRecs: os[] overflow" break; } - os[oi++] = b->fir[f].off; // save field's offset + os[oi++] = b->fir[f].fi_off; // save field's offset } } @@ -1228,7 +1228,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre record* e = b->GetAtSafe( ex->srcI); if (e) // insurance check. else errmsg? { - pv = (NANDAT *)((char *)e + b->fir[ex->srcFn].off); // point to member in record by field number + pv = (NANDAT *)((char *)e + b->fir[ex->srcFn].fi_off); // point to member in record by field number if (ex->ty==TYSI) *(SI *)pv = (SI)(LI)v; // store only 16 bits into SI else @@ -1416,8 +1416,8 @@ const char* FC whatNio( USI ancN, TI i, USI off) // error message insert descri // field name const char* mName = nullptr; - for (SFIR *fir = b->fir; fir && fir->fdTy; fir++) // find member name in rat's fields-in-record table - if (fir->off==off) + for (SFIR *fir = b->fir; fir && fir->fi_fdTy; fir++) // find member name in rat's fields-in-record table + if (fir->fi_off==off) mName = MNAME(fir); // srd.h macro points to name text, possibly in special segment if (!mName) mName = strtprintf( (char *)MH_E0109, (INT)off); // if member not found, show offset in msg "member at offset %d" diff --git a/src/exman.h b/src/exman.h index 8f22378cf..07dba7f54 100644 --- a/src/exman.h +++ b/src/exman.h @@ -4,9 +4,6 @@ /* exman.h: decls for expression manager (exman.cpp) */ -// include first: srd.h, for SRD. <==== NO LONGER NEEDED 1-91 edit out unnec includes and many comments *************** - - /*---------- NANDLEs and NANDAT ----------*/ /* a NANDLE is a 32-bit quantity that is not a valid floating point @@ -20,7 +17,7 @@ evaluating and storing expressions during the run. (SI data is extended to 32 bits (TYLLI) where necessary to allow for NANDLEs.) - The bit format of a NANDLE is: 0xFF800000 + n: corrected from FF000000 2-92. + The bit format of a NANDLE is: 0xFF800000 + n: n = 0 to indicate unset; n = expression number 1-16383 to indicate place to store expression. diff --git a/src/srd.h b/src/srd.h index bb7a03aa6..50a135237 100644 --- a/src/srd.h +++ b/src/srd.h @@ -100,19 +100,23 @@ extern SFDTAB sFdtab[]; // array of SFDTAB, indexed by field type # in fields- Accessed pointer in basAnc or (obsolescent) via RT's entry in small record descriptor, below. */ struct SFIR { - UCH ff; // field flags (attributes): define(s) below: FFHIDE, FFBASE. 2 bits used 6-95. - UCH fdTy; // field type: sFdtab index. 7 bits used, almost 8, 6-95, expand using ff bits when need found. - USI evf; // field variation (by program, see cncult.c for input variability) (EVF___ defines, cuevf.h). 9 bits 6-95. - USI off; // member offset in rec. 14 bits needed 6-95. - char* mName; // record struct MEMBER name. for arrays & nested structs, contains composite with .'s and/or [n]'s. + UCH fi_ff; // field flags (attributes): define(s) below: FFHIDE, FFBASE. 2 bits used 6-95. + UCH fi_fdTy; // field type: sFdtab index. 7 bits used, almost 8, 6-95, expand using ff bits when need found. + USI fi_evf; // field variation (by program, see cncult.c for input variability) (EVF___ defines, cuevf.h). 9 bits 6-95. + SI fi_nxsc; // fn of next field requiring special (non-bitwise) code for e.g. copy + // -1 = not special case + // else this field may require special handling and links to next + // supports e.g. general record::Copy(). 6-2023 + USI fi_off; // member offset in rec. 14 bits needed 6-95. + const char* fi_mName; // record struct MEMBER name. for arrays & nested structs, contains composite with .'s and/or [n]'s. }; //--- Historical macro to point to member name in SFIRstr s - #define MNAME(s) ((s)->mName) + #define MNAME(s) ((s)->fi_mName) -/*--- Field Flag bits, for SFIR.ff */ -#define FFHIDE 1 // hide field: omit field from probe info report (CSE -p) -#define FFBASE 2 // field of C++ base class specified via *BASECLASS in records definition file, 7-1-92. +/*--- Field Flag bits, for SFIR.fi_ff */ +inline constexpr UCH FFHIDE{ 1}; // hide field: omit field from probe info report (CSE -p) +inline constexpr UCH FFBASE{ 2}; // field of C++ base class specified via *BASECLASS in records definition file, 7-1-92. /*----- re Record Types @@ -131,16 +135,18 @@ w #define RTBSUB 0x8000 /* Substructure type definition, only for nesting in typedef USI RCT; // record type type #endif - -/*--- Small Record Descriptor Table (srfd.c:sRd) - This table gives information about each record type; it is accessed by searching for the record type. */ -struct SRD // one RT's info in Srd[] -{ RCT rt; // record type plus bits (defined just above) - SI nFlds; // number of fields (excluding start-record overhead) - SFIR * fir; // local ptr to array of info about fields in record: offset, name, type (sFdtab index), etc. -}; -extern SRD sRd[]; /* null-terminated array of SRD, generated by rcdef.exe. - Includes pointers to arrays of SFIR for fields of each record. */ -// note 12-12-91: sRd not referenced -- could be deleted. +#if 0 +0 dropped 6-2023 (unused) +0 /*--- Small Record Descriptor Table (srfd.c:sRd) +0 This table gives information about each record type; it is accessed by searching for the record type. */ +0struct SRD // one RT's info in Srd[] +0{ RCT rt; // record type plus bits (defined just above) +0 SI nFlds; // number of fields (excluding start-record overhead) +0 SFIR * fir; // local ptr to array of info about fields in record: offset, name, type (sFdtab index), etc. +0}; +0extern SRD sRd[]; /* null-terminated array of SRD, generated by rcdef.exe. +0 Includes pointers to arrays of SFIR for fields of each record. */ +0// note 12-12-91: sRd not referenced -- could be deleted. +#endif #endif // ifndef SRD_H at start file // end of srd.h