From 27498fc5bfa5848fd09fc48042af915f09b7e255 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Tue, 8 Aug 2023 15:24:43 -0400 Subject: [PATCH 1/9] cndtypes.def cleanup --- src/CNDTYPES.DEF | 49 +++-- src/CNFIELDS.DEF | 3 - src/CNRECS.DEF | 8 +- src/cncult2.cpp | 2 +- src/cueval.h | 2 +- src/cul.cpp | 11 +- src/cuprobe.cpp | 10 +- test/ref/ASHPPKGROOM.REP | 464 +++++++++++++++++++-------------------- 8 files changed, 277 insertions(+), 272 deletions(-) diff --git a/src/CNDTYPES.DEF b/src/CNDTYPES.DEF index 44d714206..5da8fe008 100644 --- a/src/CNDTYPES.DEF +++ b/src/CNDTYPES.DEF @@ -59,28 +59,40 @@ Type Extern Name Name Decl ------- ----- ------------------------- */ -INT XINT "int" -INTP XINTP "int*" -SI XSI "short" -// BOOL -- "short" // added 2-92, deleted 2-94 cuz 32 bits in 32 bit windows. -BOO -- "short" // unambiguous 16-bit Boolean 2-94. -USI XUSI "unsigned short" +// char and variants: always 8 bits +CH -- "char" +UCH -- "unsigned char" + +// SI and variants: always 16 bits +SI -- "int16_t" +USI -- "uint16_t" +BOO -- "int16_t" // unambiguous 16-bit Boolean +TI -- "SI" // (rat) table index (subscript); 0 means unset. + +// INT and variants: always 32 bits +INT -- "int32_t" +UINT -- "uint32_t" + +// LI and variants: same size as pointer (4 on 32 bit / 8 on 64 bit) #if CSE_ARCH == 64 -LI XLI "int64_t" -ULI XULI "uint64_t" +LI -- "int64_t" +ULI -- "uint64_t" #else -LI XLI "long" -ULI XULI "unsigned long" +LI -- "int32_t" +ULI -- "uint32_t" #endif -FLOAT XF "float" -FLOATP -- "float *" -VOIDP -- "void *" + +FLOAT -- "float" +FLOATP -- "float *" +// PERCENT -- "float" // restoring PERCENT restores code in cvpak.cpp +DBL -- "double" + +CULSTR -- "struct CULSTR" // string accessed via 4 byte handle + +VOIDP -- "void *" + DOW -- "short" // day of week, sun=0 in tdpak (1 less than DOWCH) MONTH -- "short" // month, jan=1 in tdpak -CH XCH "char" -CULSTR -- "struct CULSTR" -UCH -- "unsigned char" -TI -- "SI" // (rat) table index (subscript); 0 means unset. ANAME -- "char[64]" // name string for use in RATs: IDATE -- "struct {SI year;SI month;SI mday;SI wday;}" @@ -92,9 +104,6 @@ SHOY -- "unsigned" // subhour of year: (jday*24 + ihr)*4 + subhr // CAUTION: code in tdpak.cpp (at least) assumes IDATETIME is same as an IDATE followed by an ITIME. 9-89. IDATETIME -- "struct {SI year;SI month;SI mday;SI wday;SI hour;SI min;SI sec;}" LDATETIME -- "time_t" -DBL -- "double" -DBLP -- "double*" -// PERCENT -- "float" // restoring PERCENT restores code in cvpak.cpp SGTARGP -- "struct SGTARG *" // pointer to SGTARG for SGRAT.targ MASSLAYERP -- "struct MASSLAYER *" MASSMODELP -- "class MASSMODEL *" diff --git a/src/CNFIELDS.DEF b/src/CNFIELDS.DEF index 59ccdbc35..b8213da4d 100644 --- a/src/CNFIELDS.DEF +++ b/src/CNFIELDS.DEF @@ -33,7 +33,6 @@ TypeName Datatype Limits Units // //========== I. Basic data types + limit variations. Mostly used in CSE. INT INT LMNONE UNNONE -INTP INTP LMNONE UNNONE SI SI LMNONE UNNONE SI_GEZ SI LMGEZ UNNONE SI_GZ SI LMGZ UNNONE @@ -53,8 +52,6 @@ FLOAT_LZ FLOAT LMLZ UNNONE FRAC FLOAT LMFR UNNONE FRAC_GZ FLOAT LMFGZ UNNONE DBL DBL LMNONE UNNONE -FLOATP FLOATP LMNONE UNNONE -DBLP DBLP LMNONE UNNONE //VOIDP VOIDP LMNONE UNNONE unused 5-95 IDATE IDATE LMNONE UNNONE diff --git a/src/CNRECS.DEF b/src/CNRECS.DEF index 5d2d512e4..b7b58a9b0 100644 --- a/src/CNRECS.DEF +++ b/src/CNRECS.DEF @@ -285,7 +285,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on // -1: suppress progress messages ("Input", "Warmup", etc.) via setScreenQuiet() *h LI tp_dbgPrintMask // debug print mask, controls DbPrintf() etc., schedulable via std capabilities *i LI tp_dbgPrintMaskC // debug print mask constant portion (value known during setup) - *declare "LI tp_SetDbMask();" // combine tp_dbgPrintMask and tp_dbgPrintMaskC, call DbSetMask + *declare "int tp_SetDbMask();" // combine tp_dbgPrintMask and tp_dbgPrintMaskC, call DbSetMask *s LI tp_dbgFlag // debug flag value for passing testing info to code; normally no effect //TOP: inputs: autoSizing @@ -1559,8 +1559,8 @@ RECORD SGRAT "solarGain" *RAT *hideall // HIDE 1-92 due to doubts about whether #ifdef SOLAVNEND // undef in cndefns.h (via cnglob.h) 1-18-94: only if computing & using end-ivl as well as ivl avg solar values o BOO sg_isEndIvl // non-0 to use end-interval value (zones) not interval average value (masses) #endif - FLOATP sg_pControl // &0..1.f to multiply gain, or NULL to use 1.0 - // standard time hourly factors + *declare "FLOAT* sg_pControl;" // &0..1.f to multiply gain, or NULL to use 1.0 + // standard time hourly factors // = Btuh to target per unit weather file irrad (Btuh/ft2) *mh *e *array 24 DBL sg_bmXBmF // beam per unit beam *mh *e *array 24 DBL sg_dfXBmF // diffuse per unit beam (e.g. ground reflected) @@ -1879,7 +1879,7 @@ RECORD AUSZ "autoSizing sub" *SUBSTRUCT // AUTOSIZING VARIABLES substructure for //---runtime // set at initialization - *r *e *hide FLOATP az_px // pointer to value being autosized, set at beginning of autosize phase. + *declare "FLOAT* az_px;" // pointer to value being autosized, set at beginning of autosize phase. // CAUTION: storing pointer presumes record won't move during run. // x is ASSUMED to be followed by: // float x_As: receives x as autoSized, or user's x at end autoSize phase if not autoSized diff --git a/src/cncult2.cpp b/src/cncult2.cpp index c2f3179b7..3b589ee2a 100644 --- a/src/cncult2.cpp +++ b/src/cncult2.cpp @@ -477,7 +477,7 @@ RC TOPRAT::tp_FazInit() // start-of-phase init return rc; } // TOPRAT::tp_fazInit //--------------------------------------------------------------------------- -LI TOPRAT::tp_SetDbMask() // evaluate and set current debug print mask +int TOPRAT::tp_SetDbMask() // evaluate and set current debug print mask // WHY: need value available during setup but also with hourly variability // so separate constant and variable parts are used. // returns resulting mask value diff --git a/src/cueval.h b/src/cueval.h index ac993ff12..e1de707a5 100644 --- a/src/cueval.h +++ b/src/cueval.h @@ -226,7 +226,7 @@ PSSTEPPED // simulate "stepped" light control. 1 SI and 2 float args, 1 float re /*--------------------------- PUBLIC VARIABLES ----------------------------*/ -XSI runtrace; // non-0 to display debugging info during execution +extern SI runtrace; // non-0 to display debugging info during execution /*------------------------- FUNCTION DECLARATIONS -------------------------*/ // cueval.c diff --git a/src/cul.cpp b/src/cul.cpp index 5b3452508..3126b3c99 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -2477,7 +2477,7 @@ x } default: return perNx( (char *)MH_S0241, // "cul.cpp:datPt(): Unrecognized CULT.ty %d in entry '%s' at %p" - (INT)ty, (char *)c->id, c ); + ty, (char *)c->id, c ); } if (dt != dtMustBe) // if dt not consistent with ty badTynDt: @@ -2488,10 +2488,11 @@ x } // size consistency check 2-92 - if (GetDttab(dt).size != sz) // get field's data type's size using srd.h fcn 3-1-94 - return perNx( (char *)MH_S0243, /* "Internal error: cul.cpp:datPt(): data size inconsistency: - size of cul type 0x%x is %d, but size of field data type 0x%x is %d" */ - (UI)ty, (INT)sz, (UI)dt, (UI)GetDttab(dt).size ); + const DTTAB& dttab = GetDttab(dt); + if (dttab.size != sz) // get field's data type's size using srd.h fcn 3-1-94 + return perNx( (char *)MH_S0243, // "Internal error: cul.cpp:datPt(): data size inconsistency: + // size of cul type 0x%x is %d, but size of field data type 0x%x is %d" + ty, sz, dt, dttab.size ); // data and field status locations diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index 5a99fd852..4fb43a239 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -643,16 +643,14 @@ w ty = TYSI; // produces ul "integer" type w sz = 2; w break; #else - // DTUCH un-probe-able: no field with this DT 12-91, so not used in records, so don't support. + // DTUCH un-probe-able: no field with this DT 12-91, so not used in records, so don't support. case DTUCH: #endif - //unprobe-able: pointers to basic types (or add a way fetch?) - case DTFLOATP: // unprobable types + // unprobe-able: pointers to basic types (or add a way fetch?) case DTSGTARGP: - case DTDBLP: // rob 1-95 - //unprobe-able types: structures (to probe, make *substructs so they appear as their individual members) + // unprobe-able types: structures (to probe, make *substructs so they appear as their individual members) case DTIDATETIME: case DTIDATE: case DTITIME: @@ -660,7 +658,7 @@ w break; case DTVALNDT: #endif - //unprobe-able types: pointers to unprobe-able types + //unprobe-able types: pointers to unprobe-able types #ifdef DTVOIDP case DTVOIDP: #endif diff --git a/test/ref/ASHPPKGROOM.REP b/test/ref/ASHPPKGROOM.REP index 162157010..d2b6b6a0c 100644 --- a/test/ref/ASHPPKGROOM.REP +++ b/test/ref/ASHPPKGROOM.REP @@ -860,40 +860,40 @@ terminal Parent: zone -------------------- -- --- ----- -- ---- ----- --------------- -------- ---------- -------- -------- * 3 0 12288 0 0 0 0 0 nz 0 tuZone 6 1 5 0 0 12288 zone 0 0 0 0 - tuTLh 6 71 0 0 739 2 0 0 0 0 - tuQMnLh 6 72 0 0 739 2 0 0 0 0 - tuQMxLh 6 73 0 0 739 2 0 0 0 0 - tuPriLh 6 74 0 0 3 1 nz 0 0 0 - tuLhNeedsFlow 6 75 0 0 3 16 nz 0 0 0 - tuhcType 6 76 0 0 3 16 nz 0 0 0 - tuhcCaptRat 6 78 1024 0 3 2 0 0 0 0 + tuTLh 6 68 0 0 739 2 0 0 0 0 + tuQMnLh 6 69 0 0 739 2 0 0 0 0 + tuQMxLh 6 70 0 0 739 2 0 0 0 0 + tuPriLh 6 71 0 0 3 1 nz 0 0 0 + tuLhNeedsFlow 6 72 0 0 3 16 nz 0 0 0 + tuhcType 6 73 0 0 3 16 nz 0 0 0 + tuhcCaptRat 6 75 1024 0 3 2 0 0 0 0 tuhcFxCap 6 3 0 0 3 2 0 1.1 0 0 - tuhcHeatplant 6 102 0 0 1 8192 heatPlant 0 0 0 0 - tuhcMtr 6 83 0 0 1 8192 meter 0 0 0 0 - tuTH 6 107 0 0 739 2 0 0 0 0 - tuTC 6 108 0 0 739 2 0 0 0 0 - tuVfMn 6 109 1024 0 739 2 0 0 0 0 - tuAh 6 112 0 0 1 8192 airHandler 0 0 0 0 - tuVfMxH 6 113 1024 0 739 2 0 0 0 0 - tuVfMxC 6 116 1024 0 739 2 0 0 0 0 - tuVfDs 6 119 0 0 3 2 0 0 0 0 + tuhcHeatplant 6 99 0 0 1 8192 heatPlant 0 0 0 0 + tuhcMtr 6 80 0 0 1 8192 meter 0 0 0 0 + tuTH 6 104 0 0 739 2 0 0 0 0 + tuTC 6 105 0 0 739 2 0 0 0 0 + tuVfMn 6 106 1024 0 739 2 0 0 0 0 + tuAh 6 109 0 0 1 8192 airHandler 0 0 0 0 + tuVfMxH 6 110 1024 0 739 2 0 0 0 0 + tuVfMxC 6 113 1024 0 739 2 0 0 0 0 + tuVfDs 6 116 0 0 3 2 0 0 0 0 tuVfMxHC 6 2 0 0 3 16 nz 0 0 0 tuFxVfHC 6 4 0 0 3 2 0 1.1 0 0 - tuPriH 6 120 0 0 3 1 nz 0 0 0 - tuPriC 6 121 0 0 3 1 nz 0 0 0 - tuSRLeak 6 122 0 0 3 2 0 0.05 0 0 - tuSRLoss 6 123 0 0 3 2 0 0.1 0 0 - tfanSched 6 124 0 0 739 16 nz 0 0 0 - tfanOffLeak 6 125 0 0 3 2 0 0.1 0 0 - tfanType 6 126 0 0 3 16 nz 0 0 0 - tfanVfDs 6 127 0 0 3 2 0 0 0 0 - tfanPress 6 131 0 0 3 2 0 0.3 0 0 - tfanEff 6 132 0 0 3 2 0 0.08 0 0 - tfanMtr 6 144 0 0 1 8192 meter 0 0 0 0 - tfanVfMxF 6 130 4 0 0 2 0 1 0 0 - tfanMotPos 6 137 4 0 0 16 nz 0 0 0 - tfanCurvePy 6 138 128 0 3 2 0 0 nz 0 - tfanMotEff 6 136 4 0 0 2 0 1 0 0 + tuPriH 6 117 0 0 3 1 nz 0 0 0 + tuPriC 6 118 0 0 3 1 nz 0 0 0 + tuSRLeak 6 119 0 0 3 2 0 0.05 0 0 + tuSRLoss 6 120 0 0 3 2 0 0.1 0 0 + tfanSched 6 121 0 0 739 16 nz 0 0 0 + tfanOffLeak 6 122 0 0 3 2 0 0.1 0 0 + tfanType 6 123 0 0 3 16 nz 0 0 0 + tfanVfDs 6 124 0 0 3 2 0 0 0 0 + tfanPress 6 128 0 0 3 2 0 0.3 0 0 + tfanEff 6 129 0 0 3 2 0 0.08 0 0 + tfanMtr 6 141 0 0 1 8192 meter 0 0 0 0 + tfanVfMxF 6 127 4 0 0 2 0 1 0 0 + tfanMotPos 6 134 4 0 0 16 nz 0 0 0 + tfanCurvePy 6 135 128 0 3 2 0 0 nz 0 + tfanMotEff 6 133 4 0 0 2 0 1 0 0 endTerminal 13 0 0 0 0 0 0 0 0 0 @@ -987,7 +987,7 @@ rsys Parent: Top rsFanTy 6 19 0 0 1 16 nz 0 0 0 rsFanMotTy 6 28 0 0 1 16 nz 0 0 0 rsAdjForFanHt 6 50 0 0 1 16 nz 0 0 0 - rsModeCtrl 6 228 0 0 739 16 nz 0 0 0 + rsModeCtrl 6 226 0 0 739 16 nz 0 0 0 rsElecMtr 6 7 16384 0 1 8192 meter 0 0 0 0 rsFuelMtr 6 8 16384 0 1 8192 meter 0 0 0 0 rsLoadMtr 6 9 0 0 1 8192 LOADMETER 0 0 0 0 @@ -1001,77 +1001,77 @@ rsys Parent: Top rsFxCapH 6 75 16384 0 1 2 0 1.4 0 0 rsFxCapAuxH 6 79 16384 0 1 2 0 1 0 0 rsFxCapC 6 77 16384 0 1 2 0 1.2 0 0 - rsAFUE 6 149 0 0 1 2 0 0 0 0 - rsCapH 6 150 1024 0 7 2 0 0 0 0 - rsCapRatCH 6 165 0 0 1 2 0 0.8 0 0 - rsHSPF 6 112 0 0 1 2 0 0 0 0 - rsCap47 6 113 17408 0 7 2 0 0 0 0 - rsCOP47 6 114 16384 0 1 2 0 0 0 0 - rsCap35 6 115 0 0 1 2 0 0 0 0 - rsCOP35 6 116 0 0 1 2 0 0 0 0 - rsCap17 6 117 0 0 1 2 0 0 0 0 - rsCOP17 6 118 0 0 1 2 0 0 0 0 - rsCap05 6 119 0 0 1 2 0 0 0 0 - rsCOP05 6 120 0 0 1 2 0 0 0 0 - rsCapRat1747 6 121 0 0 1 2 0 0 0 0 - rsCapRat9547 6 123 0 0 1 2 0 0 0 0 - rsCapRat0547 6 122 0 0 1 2 0 0 0 0 - rsloadFMin47 6 124 0 0 1 2 0 1 0 0 - rsloadFMin17 6 125 0 0 1 2 0 1 0 0 - rsloadFMin05 6 126 0 0 1 2 0 1 0 0 - rsCOPMin47 6 127 0 0 1 2 0 0 0 0 - rsCOPMin35 6 128 0 0 1 2 0 0 0 0 - rsCOPMin17 6 129 0 0 1 2 0 0 0 0 - rsCOPMin05 6 130 0 0 1 2 0 0 0 0 - rsCdH 6 131 0 0 1 2 0 0 0 0 - rsTypeAuxH 6 140 0 0 1 16 nz 0 0 0 - rsCtrlAuxH 6 141 0 0 1 16 nz 0 0 0 - rsCapAuxH 6 142 17408 0 1 2 0 0 0 0 - rsAFUEAuxH 6 144 0 0 1 2 0 1 0 0 - rsASHPLockOutT 6 147 0 0 739 2 0 -999 0 0 - rsDefrostModel 6 148 16384 0 1 16 nz 0 0 0 - rsCHDHWSYS 6 166 0 0 1 8192 DHWSYS 0 0 0 0 - rsFanPwrH 6 154 0 0 1 2 0 0.365 0 0 - rsSEER 6 173 0 0 1 2 0 0 0 0 - rsEER 6 172 16384 0 1 2 0 0 0 0 - rsCOP95 6 171 0 0 1 2 0 0 0 0 - rsCapC 6 168 17408 0 7 2 0 0 0 0 - rsCap115 6 174 0 0 1 2 0 0 0 0 - rsCOP115 6 175 0 0 1 2 0 0 0 0 - rsCap82 6 177 0 0 1 2 0 0 0 0 - rsCOP82 6 178 0 0 1 2 0 0 0 0 - rsCapRat11595 6 176 0 0 1 2 0 0.9155 0 0 - rsCapRat8295 6 179 0 0 1 2 0 1.06 0 0 - rsloadFMin115 6 180 0 0 1 2 0 1 0 0 - rsloadFMin95 6 181 0 0 1 2 0 1 0 0 - rsloadFMin82 6 182 0 0 1 2 0 1 0 0 - rsCOPMin115 6 183 0 0 1 2 0 0 0 0 - rsCOPMin95 6 184 0 0 1 2 0 0 0 0 - rsCOPMin82 6 185 0 0 1 2 0 0 0 0 - rsFChg 6 198 0 0 1 2 0 1 0 0 - rsCdC 6 191 0 0 1 2 0 0 0 0 - rsVFPerTon 6 186 16384 0 1 2 0 350 0 0 - rsFanPwrC 6 187 0 0 1 2 0 0.365 0 0 - rsSHRtarget 6 197 0 0 1763 2 0 0.7 0 0 + rsAFUE 6 147 0 0 1 2 0 0 0 0 + rsCapH 6 148 1024 0 7 2 0 0 0 0 + rsCapRatCH 6 163 0 0 1 2 0 0.8 0 0 + rsHSPF 6 110 0 0 1 2 0 0 0 0 + rsCap47 6 111 17408 0 7 2 0 0 0 0 + rsCOP47 6 112 16384 0 1 2 0 0 0 0 + rsCap35 6 113 0 0 1 2 0 0 0 0 + rsCOP35 6 114 0 0 1 2 0 0 0 0 + rsCap17 6 115 0 0 1 2 0 0 0 0 + rsCOP17 6 116 0 0 1 2 0 0 0 0 + rsCap05 6 117 0 0 1 2 0 0 0 0 + rsCOP05 6 118 0 0 1 2 0 0 0 0 + rsCapRat1747 6 119 0 0 1 2 0 0 0 0 + rsCapRat9547 6 121 0 0 1 2 0 0 0 0 + rsCapRat0547 6 120 0 0 1 2 0 0 0 0 + rsloadFMin47 6 122 0 0 1 2 0 1 0 0 + rsloadFMin17 6 123 0 0 1 2 0 1 0 0 + rsloadFMin05 6 124 0 0 1 2 0 1 0 0 + rsCOPMin47 6 125 0 0 1 2 0 0 0 0 + rsCOPMin35 6 126 0 0 1 2 0 0 0 0 + rsCOPMin17 6 127 0 0 1 2 0 0 0 0 + rsCOPMin05 6 128 0 0 1 2 0 0 0 0 + rsCdH 6 129 0 0 1 2 0 0 0 0 + rsTypeAuxH 6 138 0 0 1 16 nz 0 0 0 + rsCtrlAuxH 6 139 0 0 1 16 nz 0 0 0 + rsCapAuxH 6 140 17408 0 1 2 0 0 0 0 + rsAFUEAuxH 6 142 0 0 1 2 0 1 0 0 + rsASHPLockOutT 6 145 0 0 739 2 0 -999 0 0 + rsDefrostModel 6 146 16384 0 1 16 nz 0 0 0 + rsCHDHWSYS 6 164 0 0 1 8192 DHWSYS 0 0 0 0 + rsFanPwrH 6 152 0 0 1 2 0 0.365 0 0 + rsSEER 6 171 0 0 1 2 0 0 0 0 + rsEER 6 170 16384 0 1 2 0 0 0 0 + rsCOP95 6 169 0 0 1 2 0 0 0 0 + rsCapC 6 166 17408 0 7 2 0 0 0 0 + rsCap115 6 172 0 0 1 2 0 0 0 0 + rsCOP115 6 173 0 0 1 2 0 0 0 0 + rsCap82 6 175 0 0 1 2 0 0 0 0 + rsCOP82 6 176 0 0 1 2 0 0 0 0 + rsCapRat11595 6 174 0 0 1 2 0 0.9155 0 0 + rsCapRat8295 6 177 0 0 1 2 0 1.06 0 0 + rsloadFMin115 6 178 0 0 1 2 0 1 0 0 + rsloadFMin95 6 179 0 0 1 2 0 1 0 0 + rsloadFMin82 6 180 0 0 1 2 0 1 0 0 + rsCOPMin115 6 181 0 0 1 2 0 0 0 0 + rsCOPMin95 6 182 0 0 1 2 0 0 0 0 + rsCOPMin82 6 183 0 0 1 2 0 0 0 0 + rsFChg 6 196 0 0 1 2 0 1 0 0 + rsCdC 6 189 0 0 1 2 0 0 0 0 + rsVFPerTon 6 184 16384 0 1 2 0 350 0 0 + rsFanPwrC 6 185 0 0 1 2 0 0.365 0 0 + rsSHRtarget 6 195 0 0 1763 2 0 0.7 0 0 rsParElec 6 15 0 0 739 2 0 0 0 0 rsParFuel 6 16 0 0 739 2 0 0 0 0 - rsFEffH 6 223 0 0 1763 2 0 1 0 0 - rsFEffAuxHBackup 6 224 0 0 1763 2 0 1 0 0 - rsFEffAuxHDefrost 6 225 0 0 1763 2 0 1 0 0 - rsFEffC 6 226 0 0 1763 2 0 1 0 0 - rsRhIn 6 192 0 0 739 2 0 0 0 0 - rsTdbOut 6 227 0 0 1763 2 0 0 0 0 + rsFEffH 6 221 0 0 1763 2 0 1 0 0 + rsFEffAuxHBackup 6 222 0 0 1763 2 0 1 0 0 + rsFEffAuxHDefrost 6 223 0 0 1763 2 0 1 0 0 + rsFEffC 6 224 0 0 1763 2 0 1 0 0 + rsRhIn 6 190 0 0 739 2 0 0 0 0 + rsTdbOut 6 225 0 0 1763 2 0 0 0 0 rsDSEH 6 65 0 0 739 2 0 -1 0 0 rsDSEC 6 66 0 0 739 2 0 -1 0 0 rsCapNomH 6 17 0 0 227 2 0 0 0 0 rsCapNomC 6 18 0 0 227 2 0 0 0 0 - rsOAVType 6 213 0 0 1 16 nz 0 0 0 - rsOAVReliefZn 6 214 0 0 1 8192 zone 0 0 0 0 - rsOAVTDbInlet 6 215 0 0 739 2 0 0 0 0 - rsOAVTdiff 6 216 0 0 739 2 0 5 0 0 - rsOAVVfDs 6 217 0 0 1 2 0 0 0 0 - rsOAVVfMinF 6 219 0 0 1 2 0 0.2 0 0 - rsOAVFanPwr 6 218 0 0 1 2 0 0.5 0 0 + rsOAVType 6 211 0 0 1 16 nz 0 0 0 + rsOAVReliefZn 6 212 0 0 1 8192 zone 0 0 0 0 + rsOAVTDbInlet 6 213 0 0 739 2 0 0 0 0 + rsOAVTdiff 6 214 0 0 739 2 0 5 0 0 + rsOAVVfDs 6 215 0 0 1 2 0 0 0 0 + rsOAVVfMinF 6 217 0 0 1 2 0 0.2 0 0 + rsOAVFanPwr 6 216 0 0 1 2 0 0.5 0 0 ductSeg 5 0 0 0 0 0 DuctSeg 0 0 15 0 endRSYS 13 0 0 0 0 0 0 0 0 0 @@ -1559,138 +1559,138 @@ airHandler Parent: Top id cs fn f uc evf ty b dfpi dff p2 ckf -------------------- -- --- ----- -- ---- ----- --------------- -------- ---------- -------- -------- * 3 0 8192 0 0 0 0 0 0 0 - ahSched 6 167 0 0 739 16 nz 0 0 0 + ahSched 6 164 0 0 739 16 nz 0 0 0 ahFxVfFan 6 6 0 0 3 2 0 1.1 0 0 - sfanType 6 168 0 0 3 16 nz 0 0 0 - sfanVfDs 6 169 1032 0 3 2 0 0 0 0 - sfanVfMxF 6 172 0 0 3 2 0 1.3 0 0 - sfanPress 6 173 0 0 3 2 0 3 0 0 - sfanEff 6 174 0 0 3 2 0 0.65 0 0 - sfanShaftBhp 6 175 0 0 3 2 0 0 0 0 - sfanElecPwr 6 176 0 0 1 2 0 0 0 0 - sfanMotEff 6 178 0 0 3 2 0 0.9 0 0 - sfanMotPos 6 179 0 0 3 16 nz 0 0 0 - sfanCurvePy 6 180 128 0 3 2 0 0 nz 0 - sfanMtr 6 186 0 0 1 8192 meter 0 0 0 0 - rfanType 6 199 0 0 3 16 nz 0 0 0 - rfanVfDs 6 200 1024 0 3 2 0 0 0 0 - rfanVfMxF 6 203 0 0 3 2 0 1.3 0 0 - rfanPress 6 204 0 0 3 2 0 0.75 0 0 - rfanEff 6 205 0 0 3 2 0 0.65 0 0 - rfanShaftBhp 6 206 0 0 3 2 0 0 0 0 - rfanElecPwr 6 207 0 0 1 2 0 0 0 0 - rfanMotEff 6 209 0 0 3 2 0 0.9 0 0 - rfanMotPos 6 210 0 0 3 16 nz 0 0 0 - rfanCurvePy 6 211 128 0 3 2 0 0 nz 0 - rfanMtr 6 217 0 0 1 8192 meter 0 0 0 0 - cchCM 6 230 0 0 3 16 nz 0 0 0 - cchPMx 6 231 0 0 3 2 0 0.4 0 0 - cchPMn 6 232 0 0 3 2 0 0.04 0 0 - cchTMx 6 233 0 0 3 2 0 0 0 0 - cchTMn 6 234 0 0 3 2 0 150 0 0 - cchDT 6 235 0 0 3 2 0 20 0 0 - cchTOn 6 236 0 0 3 2 0 72 0 0 - cchTOff 6 237 0 0 3 2 0 72 0 0 - cchMtr 6 238 0 0 1 8192 meter 0 0 0 0 - ahhcType 6 245 0 0 3 16 nz 0 0 0 - ahhcSched 6 246 0 0 739 16 nz 0 0 0 - ahhcCaptRat 6 247 1024 0 739 2 0 0 0 0 + sfanType 6 165 0 0 3 16 nz 0 0 0 + sfanVfDs 6 166 1032 0 3 2 0 0 0 0 + sfanVfMxF 6 169 0 0 3 2 0 1.3 0 0 + sfanPress 6 170 0 0 3 2 0 3 0 0 + sfanEff 6 171 0 0 3 2 0 0.65 0 0 + sfanShaftBhp 6 172 0 0 3 2 0 0 0 0 + sfanElecPwr 6 173 0 0 1 2 0 0 0 0 + sfanMotEff 6 175 0 0 3 2 0 0.9 0 0 + sfanMotPos 6 176 0 0 3 16 nz 0 0 0 + sfanCurvePy 6 177 128 0 3 2 0 0 nz 0 + sfanMtr 6 183 0 0 1 8192 meter 0 0 0 0 + rfanType 6 196 0 0 3 16 nz 0 0 0 + rfanVfDs 6 197 1024 0 3 2 0 0 0 0 + rfanVfMxF 6 200 0 0 3 2 0 1.3 0 0 + rfanPress 6 201 0 0 3 2 0 0.75 0 0 + rfanEff 6 202 0 0 3 2 0 0.65 0 0 + rfanShaftBhp 6 203 0 0 3 2 0 0 0 0 + rfanElecPwr 6 204 0 0 1 2 0 0 0 0 + rfanMotEff 6 206 0 0 3 2 0 0.9 0 0 + rfanMotPos 6 207 0 0 3 16 nz 0 0 0 + rfanCurvePy 6 208 128 0 3 2 0 0 nz 0 + rfanMtr 6 214 0 0 1 8192 meter 0 0 0 0 + cchCM 6 227 0 0 3 16 nz 0 0 0 + cchPMx 6 228 0 0 3 2 0 0.4 0 0 + cchPMn 6 229 0 0 3 2 0 0.04 0 0 + cchTMx 6 230 0 0 3 2 0 0 0 0 + cchTMn 6 231 0 0 3 2 0 150 0 0 + cchDT 6 232 0 0 3 2 0 20 0 0 + cchTOn 6 233 0 0 3 2 0 72 0 0 + cchTOff 6 234 0 0 3 2 0 72 0 0 + cchMtr 6 235 0 0 1 8192 meter 0 0 0 0 + ahhcType 6 242 0 0 3 16 nz 0 0 0 + ahhcSched 6 243 0 0 739 16 nz 0 0 0 + ahhcCaptRat 6 244 1024 0 739 2 0 0 0 0 ahhcFxCap 6 4 0 0 3 2 0 1.1 0 0 - ahhcHeatplant 6 271 0 0 1 8192 heatPlant 0 0 0 0 - ahhcEffR 6 264 0 0 3 2 0 1 0 0 - ahhcEirR 6 251 0 0 739 2 0 1 0 0 - ahhcPyEi 6 265 128 0 3 2 0 0 nz 0 - ahhcStackEffect 6 270 0 0 739 2 0 0 0 0 - ahhcMtr 6 252 0 0 1 8192 meter 0 0 0 0 - ahhcAux 6 253 0 0 739 2 0 0 0 0 - ahhcAuxMtr 6 254 0 0 1 8192 meter 0 0 0 0 - ahpCap17 6 276 0 0 3 2 0 0 0 0 - ahpCapRat1747 6 277 0 0 3 2 0 0.6184 0 0 - ahpCapRat9547 6 278 0 0 1 2 0 0 0 0 - ahpCap35 6 279 0 0 3 2 0 0 0 0 - ahpFd35Df 6 280 0 0 3 2 0 0.85 0 0 - ahpCapIa 6 281 0 0 3 2 0 0.004 0 0 - ahpCapSupH 6 282 0 0 3 2 0 0 0 0 - ahpEffSupH 6 283 0 0 739 2 0 1 0 0 - ahpSupHMtr 6 284 0 0 1 8192 meter 0 0 0 0 - ahpTFrMn 6 285 0 0 3 2 0 17 0 0 - ahpTFrMx 6 286 0 0 3 2 0 47 0 0 - ahpTFrPk 6 287 0 0 3 2 0 42 0 0 - ahpDfrFMn 6 288 0 0 3 2 0 0.0222 0 0 - ahpDfrFMx 6 289 0 0 3 2 0 0.0889 0 0 - ahpDfrCap 6 290 0 0 3 2 0 0 0 0 - ahpTOff 6 291 0 0 3 2 0 5 0 0 - ahpTOn 6 292 0 0 3 2 0 12 0 0 - ahpCOP17 6 293 0 0 3 2 0 0 0 0 - ahpCOP47 6 294 0 0 3 2 0 0 0 0 - ahpInIa 6 295 0 0 3 2 0 0.004 0 0 - ahpCd 6 296 0 0 3 2 0 0.25 0 0 - ahccType 6 314 0 0 3 16 nz 0 0 0 - ahccSched 6 315 0 0 739 16 nz 0 0 0 - ahccCaptRat 6 316 1024 0 3 2 0 0 0 0 - ahccCapsRat 6 333 0 0 3 2 0 0 0 0 - ahccSHRRat 6 336 0 0 3 2 0 0.77 0 0 + ahhcHeatplant 6 268 0 0 1 8192 heatPlant 0 0 0 0 + ahhcEffR 6 261 0 0 3 2 0 1 0 0 + ahhcEirR 6 248 0 0 739 2 0 1 0 0 + ahhcPyEi 6 262 128 0 3 2 0 0 nz 0 + ahhcStackEffect 6 267 0 0 739 2 0 0 0 0 + ahhcMtr 6 249 0 0 1 8192 meter 0 0 0 0 + ahhcAux 6 250 0 0 739 2 0 0 0 0 + ahhcAuxMtr 6 251 0 0 1 8192 meter 0 0 0 0 + ahpCap17 6 273 0 0 3 2 0 0 0 0 + ahpCapRat1747 6 274 0 0 3 2 0 0.6184 0 0 + ahpCapRat9547 6 275 0 0 1 2 0 0 0 0 + ahpCap35 6 276 0 0 3 2 0 0 0 0 + ahpFd35Df 6 277 0 0 3 2 0 0.85 0 0 + ahpCapIa 6 278 0 0 3 2 0 0.004 0 0 + ahpCapSupH 6 279 0 0 3 2 0 0 0 0 + ahpEffSupH 6 280 0 0 739 2 0 1 0 0 + ahpSupHMtr 6 281 0 0 1 8192 meter 0 0 0 0 + ahpTFrMn 6 282 0 0 3 2 0 17 0 0 + ahpTFrMx 6 283 0 0 3 2 0 47 0 0 + ahpTFrPk 6 284 0 0 3 2 0 42 0 0 + ahpDfrFMn 6 285 0 0 3 2 0 0.0222 0 0 + ahpDfrFMx 6 286 0 0 3 2 0 0.0889 0 0 + ahpDfrCap 6 287 0 0 3 2 0 0 0 0 + ahpTOff 6 288 0 0 3 2 0 5 0 0 + ahpTOn 6 289 0 0 3 2 0 12 0 0 + ahpCOP17 6 290 0 0 3 2 0 0 0 0 + ahpCOP47 6 291 0 0 3 2 0 0 0 0 + ahpInIa 6 292 0 0 3 2 0 0.004 0 0 + ahpCd 6 293 0 0 3 2 0 0.25 0 0 + ahccType 6 311 0 0 3 16 nz 0 0 0 + ahccSched 6 312 0 0 739 16 nz 0 0 0 + ahccCaptRat 6 313 1024 0 3 2 0 0 0 0 + ahccCapsRat 6 330 0 0 3 2 0 0 0 0 + ahccSHRRat 6 333 0 0 3 2 0 0.77 0 0 ahccFxCap 6 5 0 0 3 2 0 1.1 0 0 - ahccK1 6 338 0 0 3 2 0 -0.4 0 0 - ahccMinTEvap 6 337 0 0 3 2 0 35 0 0 - ahccDsTDbCnd 6 339 0 0 3 2 0 95 0 0 - ahccDsTDbEn 6 340 0 0 3 2 0 80 0 0 - ahccDsTWbEn 6 341 0 0 3 2 0 67 0 0 - ahccVfR 6 342 0 0 3 2 0 0 0 0 - ahccVfRperTon 6 343 0 0 3 2 0 400 0 0 - ahccEirR 6 320 0 0 739 2 0 1 0 0 - ahccMinUnldPlr 6 344 0 0 3 2 0 1 nz 0 - ahccMinFsldPlr 6 345 0 0 3 2 0 1 nz 0 - pydxCaptT 6 346 128 0 3 2 0 0 nz 0 - pydxCaptF 6 353 128 0 3 2 0 0 nz 0 - pydxCaptFLim 6 358 0 0 3 2 0 1.05 0 0 - pydxEirT 6 359 128 0 3 2 0 0 nz 0 - pydxEirUl 6 366 128 0 3 2 0 0 nz 0 - ahccCoolplant 6 371 0 0 1 8192 coolPlant 0 0 0 0 - ahccGpmDs 6 372 0 0 3 2 0 0 0 0 - ahccNtuoDs 6 373 0 0 3 2 0 2 0 0 - ahccNtuiDs 6 374 0 0 3 2 0 2 0 0 - ahccBypass 6 313 0 0 739 2 0 0 0 0 - ahFanCycles 6 81 0 0 739 16 nz 0 0 0 - ahccMtr 6 321 0 0 1 8192 meter 0 0 0 0 - ahccAux 6 322 0 0 739 2 0 0 0 0 - ahccAuxMtr 6 323 0 0 1 8192 meter 0 0 0 0 - ahTsSp 6 80 0 0 739 18 0 0 0 0 - ahTsMn 6 82 0 0 739 2 0 40 0 0 - ahTsMx 6 83 0 0 739 2 0 250 0 0 - ahTsRaMn 6 84 0 0 739 2 0 0 0 0 - ahTsRaMx 6 85 0 0 739 2 0 0 0 0 + ahccK1 6 335 0 0 3 2 0 -0.4 0 0 + ahccMinTEvap 6 334 0 0 3 2 0 35 0 0 + ahccDsTDbCnd 6 336 0 0 3 2 0 95 0 0 + ahccDsTDbEn 6 337 0 0 3 2 0 80 0 0 + ahccDsTWbEn 6 338 0 0 3 2 0 67 0 0 + ahccVfR 6 339 0 0 3 2 0 0 0 0 + ahccVfRperTon 6 340 0 0 3 2 0 400 0 0 + ahccEirR 6 317 0 0 739 2 0 1 0 0 + ahccMinUnldPlr 6 341 0 0 3 2 0 1 nz 0 + ahccMinFsldPlr 6 342 0 0 3 2 0 1 nz 0 + pydxCaptT 6 343 128 0 3 2 0 0 nz 0 + pydxCaptF 6 350 128 0 3 2 0 0 nz 0 + pydxCaptFLim 6 355 0 0 3 2 0 1.05 0 0 + pydxEirT 6 356 128 0 3 2 0 0 nz 0 + pydxEirUl 6 363 128 0 3 2 0 0 nz 0 + ahccCoolplant 6 368 0 0 1 8192 coolPlant 0 0 0 0 + ahccGpmDs 6 369 0 0 3 2 0 0 0 0 + ahccNtuoDs 6 370 0 0 3 2 0 2 0 0 + ahccNtuiDs 6 371 0 0 3 2 0 2 0 0 + ahccBypass 6 310 0 0 739 2 0 0 0 0 + ahFanCycles 6 78 0 0 739 16 nz 0 0 0 + ahccMtr 6 318 0 0 1 8192 meter 0 0 0 0 + ahccAux 6 319 0 0 739 2 0 0 0 0 + ahccAuxMtr 6 320 0 0 1 8192 meter 0 0 0 0 + ahTsSp 6 77 0 0 739 18 0 0 0 0 + ahTsMn 6 79 0 0 739 2 0 40 0 0 + ahTsMx 6 80 0 0 739 2 0 250 0 0 + ahTsRaMn 6 81 0 0 739 2 0 0 0 0 + ahTsRaMx 6 82 0 0 739 2 0 0 0 0 ahTsDsH 6 2 0 0 739 2 0 0 0 0 ahTsDsC 6 3 0 0 739 2 0 0 0 0 - ahCtu 6 86 0 0 1 8192 terminal 0 0 0 0 - ahWzCzns 6 87 640 0 1 8192 zone nz 0 nz 0 - ahCzCzns 6 103 640 0 1 8192 zone nz 0 nz 0 - oaMnCtrl 6 119 0 0 3 16 nz 0 0 0 - oaMnFrac 6 120 0 0 739 2 0 1 0 0 - oaVfDsMn 6 121 0 0 3 2 0 0 0 0 - oaEcoType 6 122 0 0 3 16 nz 0 0 0 - oaLimT 6 123 0 0 739 18 nz 0 0 0 - oaLimE 6 124 0 0 739 18 0 999 0 0 - oaHXVfDs 6 128 0 0 1 2 0 0 0 0 - oaHXf2 6 129 0 0 1 2 0 0.75 0 0 - oaHXSenEffHDs 6 130 0 0 1 2 0 0 0 0 - oaHXSenEffHf2 6 131 0 0 1 2 0 0 0 0 - oaHXLatEffHDs 6 132 0 0 1 2 0 0 0 0 - oaHXLatEffHf2 6 133 0 0 1 2 0 0 0 0 - oaHXSenEffCDs 6 134 0 0 1 2 0 0 0 0 - oaHXSenEffCf2 6 135 0 0 1 2 0 0 0 0 - oaHXLatEffCDs 6 136 0 0 1 2 0 0 0 0 - oaHXLatEffCf2 6 137 0 0 1 2 0 0 0 0 - oaHXBypass 6 138 0 0 1 16 nz 0 0 0 - oaHXAuxPwr 6 139 0 0 1763 2 0 0 0 0 - oaHXAuxMtr 6 140 0 0 1 8192 meter 0 0 0 0 - oaOaLeak 6 125 0 0 3 2 0 0.05 0 0 - oaRaLeak 6 126 0 0 3 2 0 0.05 0 0 - oaZoneLeak 6 127 0 0 739 2 0 0 0 0 - ahSOLeak 6 163 0 0 3 2 0 0.01 0 0 - ahROLeak 6 164 0 0 3 2 0 0.01 0 0 - ahSOLoss 6 165 0 0 3 2 0 0.02 0 0 - ahROLoss 6 166 0 0 3 2 0 0.02 0 0 + ahCtu 6 83 0 0 1 8192 terminal 0 0 0 0 + ahWzCzns 6 84 640 0 1 8192 zone nz 0 nz 0 + ahCzCzns 6 100 640 0 1 8192 zone nz 0 nz 0 + oaMnCtrl 6 116 0 0 3 16 nz 0 0 0 + oaMnFrac 6 117 0 0 739 2 0 1 0 0 + oaVfDsMn 6 118 0 0 3 2 0 0 0 0 + oaEcoType 6 119 0 0 3 16 nz 0 0 0 + oaLimT 6 120 0 0 739 18 nz 0 0 0 + oaLimE 6 121 0 0 739 18 0 999 0 0 + oaHXVfDs 6 125 0 0 1 2 0 0 0 0 + oaHXf2 6 126 0 0 1 2 0 0.75 0 0 + oaHXSenEffHDs 6 127 0 0 1 2 0 0 0 0 + oaHXSenEffHf2 6 128 0 0 1 2 0 0 0 0 + oaHXLatEffHDs 6 129 0 0 1 2 0 0 0 0 + oaHXLatEffHf2 6 130 0 0 1 2 0 0 0 0 + oaHXSenEffCDs 6 131 0 0 1 2 0 0 0 0 + oaHXSenEffCf2 6 132 0 0 1 2 0 0 0 0 + oaHXLatEffCDs 6 133 0 0 1 2 0 0 0 0 + oaHXLatEffCf2 6 134 0 0 1 2 0 0 0 0 + oaHXBypass 6 135 0 0 1 16 nz 0 0 0 + oaHXAuxPwr 6 136 0 0 1763 2 0 0 0 0 + oaHXAuxMtr 6 137 0 0 1 8192 meter 0 0 0 0 + oaOaLeak 6 122 0 0 3 2 0 0.05 0 0 + oaRaLeak 6 123 0 0 3 2 0 0.05 0 0 + oaZoneLeak 6 124 0 0 739 2 0 0 0 0 + ahSOLeak 6 160 0 0 3 2 0 0.01 0 0 + ahROLeak 6 161 0 0 3 2 0 0.01 0 0 + ahSOLoss 6 162 0 0 3 2 0 0.02 0 0 + ahROLoss 6 163 0 0 3 2 0 0.02 0 0 endAirhandler 13 0 0 0 0 0 0 0 0 0 @@ -1989,7 +1989,7 @@ inverse Parent: Top ivX 6 6 8 0 1771 2 0 0 0 0 ivY 6 7 8 0 1771 2 0 0 0 0 endInverse 13 0 0 0 0 0 0 0 0 0 -! CSE 0.918.0+alt-string-ptrs.3cd2999d.33 for Win32 console +! CSE 0.918.0+64-bit-debug.0047fcfc.66.dirty for Win32 console @@ -3552,18 +3552,18 @@ Input for Run 001: -! CSE 0.918.0+alt-string-ptrs.3cd2999d.33 for Win32 console run(s) done: Wed 12-Jul-23 2:59:57 pm +! CSE 0.918.0+64-bit-debug.0047fcfc.66.dirty for Win32 console run(s) done: Tue 08-Aug-23 3:19:36 pm ! Executable: d:\cse\msvc\cse.exe -! 12-Jul-23 2:54 pm (VS 14.29 2779136 bytes) (HPWH 1.22.0) +! 08-Aug-23 11:32 am (VS 14.29 2775040 bytes) (HPWH 1.22.0) ! Command line: -x! -t1 ashppkgroom ! Input file: D:\cse\test\ashppkgroom.cse ! Report file: D:\CSE\TEST\ASHPPKGROOM.REP ! Timing info -- -! Input: Time = 0.10 Calls = 2 T/C = 0.0480 -! AutoSizing: Time = 0.30 Calls = 1 T/C = 0.2960 -! Simulation: Time = 6.67 Calls = 1 T/C = 6.6670 -! Reports: Time = 0.00 Calls = 1 T/C = 0.0020 -! Total: Time = 7.07 Calls = 1 T/C = 7.0680 +! Input: Time = 0.10 Calls = 2 T/C = 0.0490 +! AutoSizing: Time = 0.30 Calls = 1 T/C = 0.3000 +! Simulation: Time = 6.69 Calls = 1 T/C = 6.6850 +! Reports: Time = 0.00 Calls = 1 T/C = 0.0030 +! Total: Time = 7.09 Calls = 1 T/C = 7.0930 From a74ab381cba16112cdc6c5fa017a8a1ce2205a70 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Mon, 14 Aug 2023 10:28:43 -0400 Subject: [PATCH 2/9] Convert (most) LI/ULI to INT/UINT --- src/CNRECS.DEF | 52 ++++--- src/RCDEF/rcdef.cpp | 6 +- src/ancrec.cpp | 13 +- src/cgresult.cpp | 78 +---------- src/cnah1.cpp | 2 +- src/cnah2.cpp | 8 +- src/cncoil.cpp | 4 +- src/cncult.cpp | 14 +- src/cncult2.cpp | 4 +- src/cncult4.cpp | 6 +- src/cncult5.cpp | 6 +- src/cncult6.cpp | 2 +- src/cnglob.h | 49 +------ src/cnguts.cpp | 52 ++----- src/cnguts.h | 2 +- src/cnloads.cpp | 6 +- src/cnztu.cpp | 2 +- src/cpgbuild.cpp | 14 +- src/cpgbuild.h | 4 +- src/cueval.cpp | 28 ++-- src/cueval.h | 6 +- src/cul.cpp | 36 ++--- src/cuparse.cpp | 100 +++++++------ src/cuprobe.cpp | 6 +- src/cutok.cpp | 4 +- src/cvpak.cpp | 334 +++++++++++++++++++------------------------- src/cvpak.h | 2 +- src/dmpak.cpp | 6 +- src/envpak.cpp | 12 +- src/exman.cpp | 37 ++--- src/exman.h | 2 +- src/impf.cpp | 8 +- src/libstubs.cpp | 4 +- src/messages.cpp | 4 +- src/messages.h | 5 +- src/pgpak.cpp | 47 +++---- src/pgpak.h | 8 +- src/pp.cpp | 8 +- src/rmkerr.cpp | 12 +- src/srd.h | 13 +- src/sytb.cpp | 4 +- src/tdpak.cpp | 9 +- src/tdpak.h | 2 +- src/vrpak.cpp | 74 +++++----- src/vrpak.h | 2 +- src/wfpak.cpp | 24 ++-- src/xiopak.cpp | 30 ++-- src/xiopak.h | 16 +-- src/yacam.cpp | 17 +-- 49 files changed, 492 insertions(+), 692 deletions(-) diff --git a/src/CNRECS.DEF b/src/CNRECS.DEF index c81f07ecf..d53f19961 100644 --- a/src/CNRECS.DEF +++ b/src/CNRECS.DEF @@ -272,7 +272,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on // C_VENTAVAILCH_WHOLEHOUSE: airnet windows / fans // C_VENTAVAILCH_ZONAL: airnet windows / fans (controlled by zone) // C_VENTAVAILCH_RSYSOAV: RSYS outside air vent (central mechanical) - *declare "ULI tp_GetVentAvail() const { return CHN( tp_ventAvail); }" + *declare "INT tp_GetVentAvail() const { return CHN( tp_ventAvail); }" *s *e FLOAT tp_fVent // consensus whole building vent fraction (if not RSYSOAV) // = fraction of full vent flow to use @@ -283,10 +283,10 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on // mostly for debugging. *f SI verbose // screen messages: autosizing: 0 none, 1 some (dflt?), 2-5 more // -1: suppress progress messages ("Input", "Warmup", etc.) via setScreenQuiet() - *h LI tp_dbgPrintMask // debug print mask, controls DbPrintf() etc., schedulable via std capabilities - *i LI tp_dbgPrintMaskC // debug print mask constant portion (value known during setup) + *h INT tp_dbgPrintMask // debug print mask, controls DbPrintf() etc., schedulable via std capabilities + *i INT tp_dbgPrintMaskC // debug print mask constant portion (value known during setup) *declare "int tp_SetDbMask();" // combine tp_dbgPrintMask and tp_dbgPrintMaskC, call DbSetMask - *s LI tp_dbgFlag // debug flag value for passing testing info to code; normally no effect + *s INT tp_dbgFlag // debug flag value for passing testing info to code; normally no effect //TOP: inputs: autoSizing *i FRAC_GZ auszTol // autosizing result tolerance, dfl .005 @@ -707,7 +707,7 @@ RECORD WFILE "weatherFile" *RAT // weather file info, one static instance "Wfile *declare "RC wf_GetDsDayHr( WDHR* pWd, int iHr, int erOp = WRN);" *declare "RC wf_Read( WDHR* pWd, int jDay, int iHr, int erOp = WRN);" *declare "USI* wf_PackedHrRead( int jDay, int iHr, int erOp = WRN);" - *declare "LI wf_PackedHrOffset( int jDay, int iHr, int erOp = WRN);" + *declare "int wf_PackedHrOffset( int jDay, int iHr, int erOp = WRN);" *declare "RC wf_CSWOpen( const char* wfName, int erOp );" *declare "RC wf_CSWRead( WDHR* pwd, int jDay, int iHr, int erOp );" *declare "RC wf_CSWHdrVal( const char* key, const char* val, float& v, RC& rcAll, int erOp=WRN);" @@ -1716,7 +1716,7 @@ RECORD RI "report" *RAT // REPORT (RiB) and EXPORT (XiB) (.what altered) input r *i DOY rpDayBeg // start 1-based Julian day of year, where applicable *i DOY rpDayEnd // end .. *i FLOAT_GZ rpBtuSf // energy (Btu) scale factor - *s *e LI rpCond // condition: if given, rpt lines omitted when FALSE (SI; LI used to hold NAN) (LI currently unprobeable) + *s *e INT rpCond // condition: if given, rpt lines omitted when FALSE (INT used to hold NAN) *i CULSTR rpTitle // title, for UDT, in dm *i SI rpCpl // chars per line, inputtable re UDT's (default -1="as wide as needed") *i RPTHDCH rpHeader // table header or export header yes/no (default yes) @@ -1770,7 +1770,7 @@ RECORD DVRI "dvri" *hideall *RAT // Date-dependent Virtual Report Info -- at run *r DOY rpDayBeg // start 1-based Julian day of year *r DOY rpDayEnd // end .. *r float rpBtuSf // energy (Btu) scale factor - *s LI rpCond // condition: if given, report lines omitted when FALSE (SI; LI used to hold NAN for expression) + *s INT rpCond // condition: if given, report lines omitted when FALSE (INT used to hold NAN for expression) *r SI rpCondGiven // nz if user-given condition: may be reflected in title (when 0, rpCond is TRUE). *r CULSTR rpTitle // title, for UDT, in dm *r SI rpCpl // chars per line, inputtable for UDT's @@ -1812,7 +1812,7 @@ RECORD IMPF "importFile" *RAT // IMPORTFILE input (Impfib) and run (ImpfiB) reco //file *r BOO isOpen // non-0 if file is open and buffer has been allocated successfully *declare "FILE* fh;" // file handle. Initial value, NULL, is not a valid file handle. - *r LI posEndHdr // file pointer after header, for repositioning file after warmup + *r INT posEndHdr // file pointer after header, for repositioning file after warmup //buffer *declare "char* buf;" // file buffer, in heap *r USI bufSz // 0 or allocated size of buffer (actually 1 larger to hold \0) @@ -2262,7 +2262,7 @@ RECORD ZNR "zone" *RAT // zone runtime info RAT. Set mainly from separate ZNI *declare "int zn_AssessVentUtility();" *declare "int zn_OAVAttempt( double tSup);" *declare "int zn_FVentCR();" - *declare "RC zn_CondixCR( ULI ventAvail);" + *declare "RC zn_CondixCR( int ventAvail);" *declare "RC zn_AirRequest( RSYS* rs, int options=0);" *declare "RC zn_AirX( double amfX=0., double _tz=-99.f);" *declare "double zn_HumRat( double amfX, double mwX, double _tz, double* pXLGain=nullptr);" @@ -2716,19 +2716,19 @@ RECORD ZNRES_IVL_SUB "zone interval results sub" *SUBSTRUCT // zone interval res INT n // accumulate call count (to convert sums to averages) // code assumes this is 1st member -//ints. code in cnguts.h and cnguts.cpp:cgaccum assumes SI members are together, start with nHrHeat, end with nHrCeilFan. - // 6-92 there is now no code to set these hourly+ SI members... eventually use or delete; work out sh-->hr accumulation. +// SIs. code in cnguts.h and cnguts.cpp:cgaccum assumes SI members are together, start with nHrHeat, end with nHrCeilFan. +// 6-92 there is now no code to set these hourly+ SI members... eventually use or delete; work out sh-->hr accumulation. SI nHrHeat // # of hours in which any heating occurred; 1st "# of hours" SI nHrCool // ditto cooling SI nHrFanv // ditto fan vent SI nHrNatv // ditto natural vent SI nHrCeilFan // ditto ceiling fan operation; last "# of hours" -//LIs. code in cnguts.h and .cpp assumes LI members together, first is nIter, last is nSubhrLX. - LI nIter // # of iterations - LI nShVentH // # of substeps int this interval when ventilation caused heating +// INTs (32-bit) code in cnguts.h and .cpp assumes INT members together, first is nIter, last is nSubhrLX. + INT nIter // # of iterations + INT nShVentH // # of substeps int this interval when ventilation caused heating // (initial implementation for OAV only, 10-13) - LI nSubhr // subhour counter (convenience) - LI nSubhrLX // # subhours with condensation (excess latent gain) + INT nSubhr // subhour counter (convenience) + INT nSubhrLX // # subhours with condensation (excess latent gain) //floats. code in cnguts.h and cnguts.cpp:cgaccum assumes float members together, including subgroups to average and to sum. //floats to average float tAir // zone air temp; must be 1st float, is first float to average (see cnguts.h) @@ -2797,7 +2797,7 @@ RECORD ZNRES_SUB "zone results sub" *SUBSTRUCT RECORD ZNRES "znRes" *RAT // holds zones and all-zones simulation results (later at subscript # zones + 1) // .name (base class): same as corresponding zone, or sum_of_zones. *declare "ZNR* zr_GetZone() const;" - *declare "LI zr_GetRunTotalLI( int fn) const;" + *declare "int zr_GetRunTotalInt( int fn) const;" *declare "void zr_InitPrior();" *declare "void zr_InitCurr();" @@ -3789,7 +3789,7 @@ x *declare "RC rs_SetDefaultsClg();" *s *e DBL rs_outSenTot // average total sensible heat delivery rate for last subhr, Btuh // = rs_outSen + rs_outFan + rs_outDefrost + rs_outAux -*y *e *array 2 LI rs_calcCount; // # calls to rs_SupplyAirState, re optimizing rs_FindRequiredSpeedF() +*y *e *array 2 INT rs_calcCount; // # calls to rs_SupplyAirState, re optimizing rs_FindRequiredSpeedF() // [ 0] = heating, [1] = cooling *s *e DBL rs_inPrimary // primary input, Btuh (compressor, burner, ) @@ -5723,11 +5723,9 @@ RECORD COOLCOIL "coolCoil sub" *SUBSTRUCT *BASECLASS COIL /* COOLing COIL SUBREC //*s *e FLOAT eir COIL member above: current (dx,elec) energy input ratio: eir = p / q //*s *e POWER qPr COIL member; currently 10-92 not used for coolcoil //*s *e TEMP tsPr plant supply temp at which coil last computed, for compute-flagging coil: COIL member -#if 1 // 10-96 *s *e ENERGY xLGain // condensation heat added to air (const enthalpy) to fix supersaturated wen, this subhr. *s *e ENERGY xLGainYr // .. cumulative over run, for message at end run. - *s *e LI nSubhrsLX // number of subhours in which supersaturated entering air fixed -#endif + *s *e INT nSubhrsLX // number of subhours in which supersaturated entering air fixed //flags for messages at end autoSize (or run, future?) *s *e BOO minTLtd // output limited by minTEvap b4 reaching ahTsMn (DX, 7-95) *s *e BOO cfm2Few // too little flow to permit sizing coil to meet load at min temp (DX, 7-95) @@ -6408,12 +6406,12 @@ RECORD AHRES_IVL_SUB "air handler interval results sub" *SUBSTRUCT // ah result ENERGY pAuxH ENERGY pAuxC // heat and cool aux energy ENERGY pFan // fans input energy HOURS hrsOn // time air handler on: accumulated Top.tp_subhrDur - //long integer members to sum in accumulation. cnguts.h defines assume nSubhr is 1st, nIterFan is last. - LI nSubhr // subhour counter: for convenience / possibly making cluster-dependent - LI nIter1 // iteration counter 1: # times called, including immediate exits - LI nIter2 // iteration counter 2: # times executed - LI nIter4 // iteration counter 4: # inner loops (calls to pute4Fs) - LI nIterFan // # fan adjustment iterations, counting both ups and downs + // int members to sum in accumulation. cnguts.h defines assume nSubhr is 1st, nIterFan is last. + INT nSubhr // subhour counter: for convenience / possibly making cluster-dependent + INT nIter1 // iteration counter 1: # times called, including immediate exits + INT nIter2 // iteration counter 2: # times executed + INT nIter4 // iteration counter 4: # inner loops (calls to pute4Fs) + INT nIterFan // # fan adjustment iterations, counting both ups and downs *END // AHRES_IVL_SUB //============================================================================= diff --git a/src/RCDEF/rcdef.cpp b/src/RCDEF/rcdef.cpp index 9d18321ea..dd6d08649 100644 --- a/src/RCDEF/rcdef.cpp +++ b/src/RCDEF/rcdef.cpp @@ -345,7 +345,7 @@ ULI Dttab[MAXDTH + MAXDTC + 1]; // Snake offset is used here for choice text, stored in sizeof(char *) 2-94 to match appl's struct // re checking that data types don't collide. // array: # of elements -int dttabsz = 0; // [next] slot in Dttab = next data type; is size of table (in LI's) at end. +int dttabsz = 0; // [next] slot in Dttab = next data type; is size of table (in ULI's) at end. // non-sparse data type arrays: subscripts are dtnmi[datatype]. const char* dtnames[MAXDT]; // data type names, set w luadd(dtlut..) static LUTAB dtlut(dtnames, MAXDT); @@ -1204,7 +1204,7 @@ LOCAL void wDttab() // write C++ source data types table dttab.cpp // write size of data types table (to provide same variables as recdef vsrn) fprintf( f, - "\n\n// size of data types table (in LI's)\n" + "\n\n// size of data types table (in ULI's)\n" "\nsize_t Dttmax = %d;\n", dttabsz ); // terminate file, close, update if different @@ -1884,7 +1884,7 @@ LOCAL RC recs( // do records if (nextRcType >= MAXRCS) // prevent exceeding tables { rcderr( "Record handle 0x%x is too big (max 0x%x).", - (UI)nextRcType, (UI)MAXRCS-1 ); + nextRcType, MAXRCS-1 ); goto nexTokRec; // get token and reiterate record loop } rcseq = nextRcType++; diff --git a/src/ancrec.cpp b/src/ancrec.cpp index 5596b866d..c7a7488c6 100644 --- a/src/ancrec.cpp +++ b/src/ancrec.cpp @@ -907,14 +907,9 @@ RC FC basAnc::reAl( TI _n, int erOp/*=ABT*/) // allocate space for n (0=default if (_n < 1) _n = 1 + 1024/eSz; // if # records not specified, use 1k's worth plus 1 TI _nAl = _n+1; // space [0] not used (all 0's for grounding) --> max subscr+1 is n+1 - size_t sz = (ULI)(USI)_nAl * eSz; // size that must be allocated -#if 0 // remove 64k limit, 9-10 -x if (sz >= 0xFFF0) // leave a few bytes for overhead. -x return err( erOp, "Attempt to allocate more than 64K worth of '%s' records", -x (char /*far!*/ *)what ); // returns RCBAD -#endif - desRecs(_nAl, 32767); // insurance: destroy any excess existing records if making block smaller - record* ptrWas = ptr(); // NULL if this is initial allocation + size_t sz = _nAl * eSz; // size that must be allocated + desRecs(_nAl, 32767); // insurance: destroy any excess existing records if making block smaller + record* ptrWas = ptr(); // NULL if this is initial allocation RC rc = dmral( pptr(), sz, erOp|DMZERO); // (re)alloc memory, zero new space, dmpak.cpp if (rc) // if failed ; // leave variables unchanged @@ -974,7 +969,7 @@ RC basAnc::add( // construct record i (0 = next). Allocs if nec. if ( i >= nAl // if (more) record spaces must be allocated (nAl is +1; i,n are not) || !ptr() ) // insurance { - ULI sz = (ULI)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1) + UINT sz = (UINT)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1) TI _n = max( (USI)(sz/eSz), (USI)i); // add 1 + 1K's worth of spaces, or to req'd rec # if more. if (reAl(_n, erOp)) return RCBAD; // (re)alloc rec spaces 1.._n, init nAl, ptr(), space[0], etc. above. diff --git a/src/cgresult.cpp b/src/cgresult.cpp index c239816e6..31fd866fb 100644 --- a/src/cgresult.cpp +++ b/src/cgresult.cpp @@ -699,7 +699,7 @@ void FC vpRxports( // virtual print reports and exports of given frequency for dvrip->rpTitle.CStrIfNotBlank( dvrip->Name())); // title if any, else name continue; // treat as FALSE } - if (!(SI)dvrip->rpCond) // if condition false (value is SI, storage is LI to hold NAN for expr) + if (!dvrip->rpCond) // if condition false { if (reHead) // if header needed, set optn bit to invoke it when not skipped vrChangeOptn( vrh, VR_NEEDHEAD, VR_NEEDHEAD); // .. @@ -1387,82 +1387,6 @@ o && dvrip->rpDayEnd >= Top.tp_endDay ) <--- new year's bug! 2-94 } } } // vpRxFooter - -#ifdef WANTED -w //================================================================= -w void FC cgPrRes( // Print an HSZNRES, for CALRES results file. -w -w SI vrh, // handle of virtual report to which to "print" -w char *heading, /* Heading string */ -w ZNR *zp, // Zone recort pointer, for info used re vpRxRow options added 11-91, probably not used here. -w HSZNRES *pzr ) /* ptr to zone results structure */ -w -w /* Format printed is: -w Line 1: -w Line 2: energy balance values (heat flows and loads)(as for xEB reports) -w Line 3: conditions values (hours of heating, cooling etc)(as for ZST reports) */ -w -w /* NOTE ALSO existence of cgresfil.cpp, containing hst result file functions */ -w -w { -w // heading -w vrPrintf( vrh, "%s\n", heading ); -w -w // EB info -w vpRxRow( // format, print zone data (fcn below) -w vrh, // print destination -w ebColDef, // "energy balance" (aka xEB reports) info columns-to-print table above -w // zp, // zone (used re options; probably unused here) -w pzr, // HSZNRES struct containing data -w 1.f, // no scaling -w 0, // bits: 1 OFF: report, not export -w // following args used IN ORDER at -1 .offsets in ebColDef -w "", "", "" ); // blank row label, shutter fraction and mode. -w -w // ZST-like info -w vpRxRow( -w vrh, // print destination -w stColdef, // "conditions" info (aka ZST report info) columns-to-print table above -w // zp, // zone (used re options; probably unused here) -w pzr, // HSZNRES struct containing data -w 1.f, // no scaling -w 0, // bits: 1 OFF: report, not export. -w // following arg(s) used at -1 .offset(s) in stColdef -w "" ); // blank row label -w } // cgPrRes -w --- related code for former CALRES results files --- -w HSZNRES type: gone (or renamed) (10-93) -w -- deleted from cse.cpp 10-93 (if'd out since 10-91): -w char *resFileName = NULL; -w XFILE *resFileXF = NULL; -w ... -w else if (resFileName==NULL) // else if no results file name yet -w resFileName = arg; // take this arg as results file name -w ... -w // open results output file -w -w if (resFileName != NULL) /* optnl cmd line arg specs results file */ -w { resFileXF = xfopen( /* open file, xiopak.cpp */ -w resFileName, /* name */ -w O_WTUNKA, /* access: text, r/w append, create -w if not found */ -w IGN, /* erOp: errors handled here */ -w FALSE, /* eofs not errors (writing) */ -w NULL ); -w if (resFileXF == NULL) /* if open failed */ -w tiabort( "Unable to open results file '%s'", resFileName); -w } -w ... -w after ok run... -w if ( resFileXF != NULL) -w { cgResWrite( resFileXF); // write run results, hsresfil.cpp -w cgMemRep( "cse cgResWrite"); -w } -w -- deleted from cse.h 10-93. cgresfil.cpp and cgResWrite are GONE, 10-93. -w // cgresfil.cpp -w void FC cgResWrite( XFILE *xfRf); -#endif // WANTED - //========================================================================================================== LOCAL void FC vpEbStRow( // virtual print zone ZEB or ZST row for zone or sum of zones diff --git a/src/cnah1.cpp b/src/cnah1.cpp index afeb858ff..203deae7b 100644 --- a/src/cnah1.cpp +++ b/src/cnah1.cpp @@ -45,7 +45,7 @@ /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI LI dtypes.h cndefns.h +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // AH TU ZNR diff --git a/src/cnah2.cpp b/src/cnah2.cpp index bd203cb67..152da1e2a 100644 --- a/src/cnah2.cpp +++ b/src/cnah2.cpp @@ -5,7 +5,7 @@ // cnah2.cpp -- hvac airHandler simulation routines for CSE -- part 2 /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI LI dtypes.h cndefns.h +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // AH TU ZNR @@ -2520,7 +2520,7 @@ void AH::wzczSp( // determine required supply temp for warmest zone/coolest z #endif rer( PWRN, (char *)MH_R1285, //"Unexpected use 0x%x for terminal [%d] for control zone [%d] for ah [%d]" - (UI)tu->useAr, (INT)tu->ss, (INT)czp->ss, (INT)ss ); + tu->useAr, tu->ss, czp->ss, ss ); continue; /* terminal at min flow: although some other tu usually rules, consider this tu's needed supply temp @@ -3358,7 +3358,7 @@ x || aTs > tz && ahMode & ahHEATBIT ) } else // end of if tu->useAr...else if... rer( PWRN, (char *)MH_R1290, // printf-->rer 10-92 - Name(), (UI)tu->useAr ); // "airHandler %s: Internal error in antRatTs: unexpected tu->useAr 0x%x" + Name(), tu->useAr ); // "airHandler %s: Internal error in antRatTs: unexpected tu->useAr 0x%x" // antRatTs: ALL TU CASES merge here with tz, cz, aCv set to prior or updated values @@ -3587,7 +3587,7 @@ void AH::setFrFanOn( // determine fan on fraction this subhour. Call only if #ifdef DEBUG if (!(uUseAr & (uStH|uStC|uMxH|uMxC))) // devel aid check. uUseAr is set in zRat. rer( PWRN, (char *)MH_R1292, // "AH::setFrFanOn: airHandler '%s': unexpected 'uUseAr' 0x%x" - Name(), (UI)uUseAr ); // after msg fall thru (assumes heating) + Name(), uUseAr ); // after msg fall thru (assumes heating) #endif cMxnx = // flow for frFanOn=1.0 this subhour for this ah/tu is smaller of tu, sfan min( uUseAr & (uStC|uMxC) // test whether ah is on cuz terminal called for cooling or heat diff --git a/src/cncoil.cpp b/src/cncoil.cpp index 44ae027c7..94ec6e317 100644 --- a/src/cncoil.cpp +++ b/src/cncoil.cpp @@ -2446,7 +2446,7 @@ x if (coilUsed==cuHEAT) // if heat coil used, 12-3-92 //case C_COILTYCH_NONE: // if no coil, shd be no q default: - rer( PWRN, (char *)MH_R1338, (UI)ahhc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad heat coil type 0x%x" + rer( PWRN, (char *)MH_R1338, ahhc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad heat coil type 0x%x" } //if (ahhc.q) add /0 protection add if need found ahhc.eir = (ahhc.p + ahhc.pSh + cch.p)/ahhc.q; /* energy input ratio: input/output: @@ -2497,7 +2497,7 @@ x if (coilUsed==cuHEAT) // if heat coil used, 12-3-92 //case C_COILTYCH_NONE: // if no coil, expect no q --> don't get here. default: - rer( PWRN, (char *)MH_R1339, (UI)ahcc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad cool coil type 0x%x" + rer( PWRN, (char *)MH_R1339, ahcc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad cool coil type 0x%x" break; case C_COILTYCH_DX: // DX coil diff --git a/src/cncult.cpp b/src/cncult.cpp index 29d4928e2..d3d6c4a11 100644 --- a/src/cncult.cpp +++ b/src/cncult.cpp @@ -27,7 +27,7 @@ cnculti.h: cncult internal functions shared only amoung cncult,2,3,4,5,6.cpp */ // also in cncult6 cncult3 at least /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI SI LI +#include "cnglob.h" #include #include "ancrec.h" // record: base class for rccn.h classes @@ -918,7 +918,7 @@ static CULT perT[] = CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, prStarCkf), CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, N), CULT( "prZone", DAT, PRI_OWNTI, NO_INP|RDFLIN, 0, 0, TYREF, &ZiB, 0.f, N, N), //TYIREF-->TYREF 10-9-92 -CULT( "prXtype", DAT, PRI_X+XSURF_TY, NO_INP, 0, 0, TYSI, 0, v (LI)CTPERIM, 0.f, N, N), //CTPERIM: cnguts.h. +CULT( "prXtype", DAT, PRI_X+XSURF_TY, NO_INP, 0, 0, TYSI, 0, v CTPERIM, 0.f, N, N), //CTPERIM: cnguts.h. CULT( "prXExCnd", DAT, PRI_X+XSURF_SFEXCND, NO_INP, 0, 0, TYCH, 0, C_EXCNDCH_AMBIENT, N, N), //added 2-95 CULT( "prLen", DAT, PRI_PRLEN, RQD, 0, VEOI, TYFL, 0, 0.f, N, N), CULT( "prF2", DAT, PRI_PRF2, RQD, 0, VEOI, TYFL, 0, 0.f, N, N), @@ -1122,7 +1122,7 @@ CULT( "rpDayBeg", DAT, RI_RPDAYBEG, 0, 0, VEOI, TYDOY, 0 CULT( "rpDayEnd", DAT, RI_RPDAYEND, 0, 0, VEOI, TYDOY, 0, 0, N, N), CULT( "rpBtuSf", DAT, RI_RPBTUSF, 0, 0, VEOI, TYFL, 0, 1.e6f, N, N), // show mBtu. Also in cncult4:addRep(). CULT( "rpCond", DAT, RI_RPCOND, 0, 0, VSUBHRLY|EVPSTIVL, // ok if evaluated at end interval - TYLLI, // SI condition, dflt TRUE, in LI for NAN + TYINT, // SI condition, dflt TRUE, in INT for NAN 0, v 1L, N, N), CULT( "rpTitle", DAT, RI_RPTITLE, 0, 0, VEOI, TYSTR, 0, v 0, N, N), CULT( "rpCpl", DAT, RI_RPCPL, 0, 0, VEOI, TYSI, 0, -1, N, N), @@ -1165,7 +1165,7 @@ CULT( "exDayBeg", DAT, RI_RPDAYBEG, 0, 0, VEOI, TYDOY, CULT( "exDayEnd", DAT, RI_RPDAYEND, 0, 0, VEOI, TYDOY, 0, 0, N, N), CULT( "exBtuSf", DAT, RI_RPBTUSF, 0, 0, VEOI, TYFL, 0, 0, 1e6, N, N), // show mBtu. Also in cncult4:addRep(). CULT( "exCond", DAT, RI_RPCOND, 0, 0, VSUBHRLY|EVPSTIVL, // ok if evaluated post interval - TYLLI, // SI condition, dflt TRUE, in LI for NAN + TYINT, // SI condition, dflt TRUE, in INT for NAN 0, v 1L,0.f, N, N), CULT( "exTitle", DAT, RI_RPTITLE, 0, 0, VEOI, TYSTR, 0, v 0, 0.f, N, N), CULT( "exHeader", DAT, RI_RPHEADER, 0, 0, VEOI, TYCH, 0, C_RPTHDCH_YES, N, N), @@ -2786,9 +2786,9 @@ CULT cnTopCult[] = // Top level table, points to all other tables, used in cal CULT( "radDiffF", DAT, TOPRAT_RADDIFFF, 0, 0, VEOI, TYFL, 0, 1.f, N, N), CULT( "hConvMod", DAT, TOPRAT_HCONVMOD, 0, 0, VEOI, TYCH, 0, C_NOYESCH_YES, N, N), CULT( "verbose", DAT, TOPRAT_VERBOSE, 0, 0, VEOI, TYSI, 0, 1, N, N), - CULT( "dbgPrintMask",DAT, TOPRAT_DBGPRINTMASK,0, 0, VHRLY, TYLLI, 0, 0, N, N), - CULT( "dbgPrintMaskC",DAT, TOPRAT_DBGPRINTMASKC,0, 0, VEOI, TYLLI, 0, 0, N, N), - CULT( "dbgFlag", DAT, TOPRAT_DBGFLAG, 0, 0, VSUBHRLY,TYLLI,0, 0, N, N), + CULT( "dbgPrintMask",DAT, TOPRAT_DBGPRINTMASK,0, 0, VHRLY, TYINT, 0, 0, N, N), + CULT( "dbgPrintMaskC",DAT, TOPRAT_DBGPRINTMASKC,0, 0, VEOI, TYINT, 0, 0, N, N), + CULT( "dbgFlag", DAT, TOPRAT_DBGFLAG, 0, 0, VSUBHRLY,TYINT,0, 0, N, N), CULT( "ventAvail", DAT, TOPRAT_VENTAVAIL, 0, 0, VHRLY, TYCH, 0, nc( C_VENTAVAILVC_WHOLEBLDG), N, N), // TOP autosizing diff --git a/src/cncult2.cpp b/src/cncult2.cpp index 3b589ee2a..15de3fd70 100644 --- a/src/cncult2.cpp +++ b/src/cncult2.cpp @@ -8,7 +8,7 @@ // search NUMS for messages just added 6-95... exman.cpp too. grep NUMS! /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI SI LI. includes cndefns.h, for ZHX_TULHC, +#include "cnglob.h" #include "srd.h" // SFIR, #include "ancrec.h" // record: base class for rccn.h classes @@ -482,7 +482,7 @@ int TOPRAT::tp_SetDbMask() // evaluate and set current debug print mask // so separate constant and variable parts are used. // returns resulting mask value { - LI dbgPrintMask = tp_dbgPrintMaskC; // constant portion (known at EOI) + int dbgPrintMask = tp_dbgPrintMaskC; // constant portion (known at EOI) if (!ISNANDLE( tp_dbgPrintMask)) dbgPrintMask |= tp_dbgPrintMask; // possibly variable portion (ignore if not yet set) DbSetMask( dbgPrintMask); diff --git a/src/cncult4.cpp b/src/cncult4.cpp index 8d5ccf4de..2eae73816 100644 --- a/src/cncult4.cpp +++ b/src/cncult4.cpp @@ -11,7 +11,7 @@ /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI SI LI +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // TOPRATstr ZNRstr SFIstr SDIstr @@ -637,7 +637,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp ownTi = 1; // use first one: is probably Primary renamed with ALTER else // no r/xport files at all rc |= ooer( RI_OWNTI, // issue error once (cul.cpp), no run - (char *)(LI)(isEx ? MH_S0556 : MH_S0557) ); // "No exExportfile given" or "No rpReportfile given" + (char *)(INT)(isEx ? MH_S0556 : MH_S0557) ); // "No exExportfile given" or "No rpReportfile given" } RFI* rfp=NULL; if (ownTi) @@ -1092,7 +1092,7 @@ RC buildUnspoolInfo() // allocate dm block for unspooling specifications in vrUnspool format, set pointer in cnguts.cpp. - LI nbytes = sizeof(VROUTINFO) // bytes per file, without any vrh's except terminating 0 + size_t nbytes = sizeof(VROUTINFO) // bytes per file, without any vrh's except terminating 0 * (RfiB.n + XfiB.n + 1) // number of files. + 1 allows for terminating NULL. + sizeof(int) // bytes per virtual report to unspool * (RiB.n + XiB.n); // # virtual report arguments, including duplicates diff --git a/src/cncult5.cpp b/src/cncult5.cpp index b40525d29..2a215023c 100644 --- a/src/cncult5.cpp +++ b/src/cncult5.cpp @@ -22,7 +22,7 @@ untested and not needed -- disallow when reason found. */ /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI SI LI; includes cndefns.h +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // TOPRATstr PRIBASEstr SFIstr @@ -621,7 +621,7 @@ RC COIL::setup( // check/set up a base class coil subrecord break; // (ahcc, ahhc: omitted coilTy means absent coil) default: - return r->oer( (char *)MH_S0639, (UI)app); // "Internal error: cncult5.cpp:ckCoil: bad coil app 0x%x" + return r->oer( (char *)MH_S0639, app); // "Internal error: cncult5.cpp:ckCoil: bad coil app 0x%x" } // return if coil not present or not allowed @@ -1335,7 +1335,7 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf switch (app) { default: - return r->oer( (char *)MH_S0676, (UI)app); // "Internal error: cncult5.cpp:ckFan: bad fan app 0x%x" + return r->oer( (char *)MH_S0676, app); // "Internal error: cncult5.cpp:ckFan: bad fan app 0x%x" case C_FANAPPCH_TFAN: break; // terminal fan (not implemented 10-92) diff --git a/src/cncult6.cpp b/src/cncult6.cpp index d173df7bd..6427a36b1 100644 --- a/src/cncult6.cpp +++ b/src/cncult6.cpp @@ -7,7 +7,7 @@ /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI SI LI +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // HEATPLANTstr BOILERstr NHPSTAGES HPSTAGESZ diff --git a/src/cnglob.h b/src/cnglob.h index b4fc19659..e3ec579ce 100644 --- a/src/cnglob.h +++ b/src/cnglob.h @@ -26,11 +26,8 @@ /*------------------------- Enhanced declarations --------------------------*/ // following can't be in dtypes.h (without added conditionals) cuz of 16 or 32 bit size -typedef int INT; // signed int 16 or 32 bits as compiled, eg for library fcn args or printf %d. -typedef unsigned int UI; // unsigned 16 or 32 bit int, eg for %x in printf arg list. typedef long long LLI; // signed 64 bit integer typedef unsigned long long ULLI; -//typedef int BOOL; if needed: // 16 or 32 bit Boolean, matches windows.h. /*---------------------- Windows definitions -------------------------------*/ #if CSE_OS == CSE_OS_WINDOWS @@ -338,26 +335,11 @@ template< typename T> T& IvlData( T* ivlData, int ivl) // A NANDLE contains 0xFF80 in the hi word and 0 for unset or ffff for autosizing or expression number 1-16383 in the low word. // CAUTION: highly system dependent. CAUTION: keep distinct from NCHOICEs (below) -// type to hold a NANDLE or a datum (ptr if string) -#if 0 // CSE_ARCH == 64 -#define ND3264 // #define to enable general 32/64 bit code TODO (MP) -typedef ULI NANDAT; // 64 bit - // CAUTION: NANDAT * can pt to only 16 bits (TYSI); check type b4 storing. -template NANDAT AsNANDAT(T v) { return *reinterpret_cast(&v); } -#define ISUNSET(nandat) (AsNANDAT( nandat)==0xff800000L) // test variable for unset data -#define ISASING(nandat) (*reinterpret_cast(&nandat)==0xff80ffffL) // test variable for "to be autosized" 6-95 -#define ISNANDLE(nandat) (((*reinterpret_cast(&nandat)) & 0xffff0000L)==0xff800000L) // test for ref to non-constant expr (or unset) -#define ISNANDLEP(pNandat) ((*(reinterpret_cast(pNandat)) & 0xffff0000L)==0xff800000L) // test for ptr to ref to non-constant expr (or unset) -#define EXN(nandle) ((*reinterpret_cast(&nandle)) & 0xffff) // extract expression # from nandle -#define UNSET (NANDLE(0)) // "unset" value for float/ptr/LI. cast as desired. -#define ASING (NANDLE(0xffff)) // may be stored in values to be determined by autosizing 6-95 -#define NANDLE(h) (static_cast(0xff800000 + h)) // "expr n" ref for float/ptr/LI (or SI in 4 bytes). h = 1..16383. -#elif 1 -// transition aid: 32 bit using AsNANDAT +// type to hold a NANDLE or a datum #define ND3264 // #define to enable general 32/64 bit code TODO (MP) typedef uint32_t NANDAT; // 32 bit unsigned integer -#define NANDLE(h) (static_cast(0xff800000 + h)) // "expr n" ref for float/ptr/LI (or SI in 4 bytes). h = 1..16383. -#define UNSET (NANDLE(0)) // "unset" value for float/ptr/LI. cast as desired. +#define NANDLE(h) (static_cast(0xff800000 + h)) // "expr n" ref for float/int (or SI in 4 bytes). h = 1..16383. +#define UNSET (NANDLE(0)) // "unset" value for float/int. cast as desired. #define ASING (NANDLE(0xffff)) // may be stored in values to be determined by autosizing 6-95 template inline NANDAT AsNANDAT(T& v) { return *reinterpret_cast(&v); } #define ISUNSET( v) (AsNANDAT( v)==UNSET) // true iff v is UNSET @@ -366,29 +348,11 @@ template inline NANDAT AsNANDAT(T& v) { return *reinterpret_cast(pV)) & 0xffff0000L)==0xff800000L) // test for ptr to ref to non-constant expr (or unset) #define EXN(v) (AsNANDAT(v) & 0xffff) // extract expression # from nandle -#else -typedef void * NANDAT; // CAUTION: for fcn args use ptr (NANDAT *) to be sure C does not alter arg bit pattern. - // CAUTION: NANDAT * can pt to only 16 bits (TYSI); check type b4 storing. -template NANDAT AsNANDAT(T v) { return *reinterpret_cast(&v); } -#define ISUNSET(nandat) ((ULI)*(void**)&(nandat)==0xff800000L) // test variable for unset data -#define ISASING(nandat) ((ULI)*(void**)&(nandat)==0xff80ffffL) // test variable for "to be autosized" 6-95 -#define ISNANDLE(nandat) (((ULI)*(void**)&(nandat) & 0xffff0000L)==0xff800000L) // test for ref to non-constant expr (or unset) -#define ISNUM(n) (((ULI)CSE_V(n) & 0x7f800000L) != 0x7f800000L) // true iff float n is a number (not UNSET, NANDLE, NCHOICE or other NAN) -#define ISNANDLEP(pNandat) (((ULI)*(void**)(pNandat) & 0xffff0000L)==0xff800000L) // test for ptr to ref to non-constant expr (or unset) -#define EXN(nandle) ((USI)(ULI)*(void**)&(nandle)) // extract expression # from nandle -#define UNSET ((NANDAT)NANDLE(0)) // "unset" value for float/ptr/LI. cast as desired. -#define ASING ((NANDAT)NANDLE(0xffff)) // may be stored in values to be determined by autosizing 6-95 -#define NANDLE(h) ((NANDAT)(0xff800000L + h)) // "expr n" ref for float/ptr/LI (or SI in 4 bytes). h = 1..16383. - -#endif // macro to access a float that may contain a NAN: don't let compiler treat as floats til numeric content verified. -#if 1 // re 64 bits, 11-2022 -#define CSE_V *(NANDAT *)& // usage: CSE_V x = CSE_V y; if (CSE_V x == CSE_V y) .. where x and y are floats such as CHOICN's. -#else -x #define CSE_V *(void **)& -#endif +// usage: CSE_V x = CSE_V y; if (CSE_V x == CSE_V y) .. where x and y are floats such as CHOICN's. +#define CSE_V *(NANDAT *)& // NCHOICEs are values which can represent one of several choices and which can // be stored in a float and distinguished from all numeric values. 2-92. @@ -426,9 +390,6 @@ x #define CSE_V *(void **)& // macro to generate 32-bit value from 16-bit choice constants, for use where full value needed, as in initialized data // usage: float y = NCHOICE(C_ABCNC_X); #define NCHOICE(nck) ((void *)((ULI)(nck) << 16)) // put in hi word. nck already includes 0x7f80. - - - #endif /*---------------------- return codes / error codes ------------------------*/ diff --git a/src/cnguts.cpp b/src/cnguts.cpp index 5379e558f..184f1c8f2 100644 --- a/src/cnguts.cpp +++ b/src/cnguts.cpp @@ -5,7 +5,7 @@ // cnguts.cpp - Hourly simulation main routine for CSE //------------------------------- INCLUDES ---------------------------------- -#include "cnglob.h" // CSE global defines: USI LI ASSERT dtypes.h cndefns.h +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // WSHADRATstr ZNRstr @@ -1408,23 +1408,23 @@ ZNR* ZNRES::zr_GetZone() const // zone of ZNRES { return ZrB.GetAtSafe( ss); } // ZNRES::zr_GetZone //----------------------------------------------------------------------------- -LI ZNRES::zr_GetRunTotalLI( int fn) const -// return total of ZNRES LI values = cummulative count for run so far +int ZNRES::zr_GetRunTotalInt( int fn) const +// return total of ZNRES INT values = cummulative count for run so far { int dt = DType( ZNRES_CURR + ZNRES_SUB_M + fn); - LI sum = 0; - if (dt != DTLI) + int sum = 0; + if (dt != DTINT) err( PERR, "ZNRES::zr_GetRunTotalLI '%s': bad fn = %d", Name(), fn); else - { sum = *(LI *)field( ZNRES_CURR + ZNRES_SUB_Y + fn ) - + *(LI *)field( ZNRES_CURR + ZNRES_SUB_M + fn ) - + *(LI *)field( ZNRES_CURR + ZNRES_SUB_D + fn ) - + *(LI *)field( ZNRES_CURR + ZNRES_SUB_H + fn ) - + *(LI *)field( ZNRES_CURR + ZNRES_SUB_S + fn ); + { sum = *(INT *)field( ZNRES_CURR + ZNRES_SUB_Y + fn ) + + *(INT *)field( ZNRES_CURR + ZNRES_SUB_M + fn ) + + *(INT *)field( ZNRES_CURR + ZNRES_SUB_D + fn ) + + *(INT *)field( ZNRES_CURR + ZNRES_SUB_H + fn ) + + *(INT *)field( ZNRES_CURR + ZNRES_SUB_S + fn ); } return sum; -} // ZNRES::zr_GetRunTotalLI +} // ZNRES::zr_GetRunTotalInt //----------------------------------------------------------------------------- void ZNRES::zr_InitPrior() // initialize curr mbrs // WHY initialize prior values @@ -1481,8 +1481,8 @@ static SUBMETERSEQ SubMeterSeq; //#define ZRnh1 nHrHeat // 1st "# of hours" in SI members. unused 12-91. //#define ZRnNH ((oRes(nHrCeilFan) - oRes(nHrHeat))/sizeof(SI) + 1) // # of "# of hours": all the SIs. unused 12-91. // LIs -#define ZRl1 nIter // 1st LI member. -#define ZRnL ((oRes(nSubhrLX) - oRes(nIter))/sizeof(LI) + 1) // # LI members +#define ZRl1 nIter // 1st INT member. +#define ZRnL ((oRes(nSubhrLX) - oRes(nIter))/sizeof(INT) + 1) // # INT members // floats: all #define ZRf1 tAir // 1st of avgs & sum float mbrs #define ZRnF ((oRes(litEu) - oRes(tAir))/sizeof(float) + 1) // total # float members to sum. @@ -2047,8 +2047,8 @@ void DUCTSEGRES_IVL_SUB::dsr_SetPrior() const // copy to prior /////////////////////////////////////////////////////////////////////////////// // air handler results /////////////////////////////////////////////////////////////////////////////// -#define ARl1 nSubhr // first li member. summed. -#define ARnL ((oaRes(nIterFan) - oaRes(nSubhr))/sizeof(LI) + 1) // number of li members. +#define ARl1 nSubhr // first INT member. summed. +#define ARnL ((oaRes(nIterFan) - oaRes(nSubhr))/sizeof(INT) + 1) // number of li members. #define ARf1 tDbO // first of all float members, incl avgs and sums #define ARnF ((oaRes(hrsOn) - oaRes(tDbO))/sizeof(float) + 1) // total number of float members #define ARa1 tDbO // first float member to average (temps, flows) @@ -2796,28 +2796,6 @@ LOCAL void FC doIvlReports() // virtual print reports for ending intervals for e vpRxports(C_IVLCH_Y); // do all yearly reports/exports. cgresult.cpp. } // doIvlReports //----------------------------------------------------------------------------------------------------------- -#if 0 // calls & ifdef MEMREP stuff ripped out, 6-95 -* // CAUTION: don't enable in production version cuz "dirty" re multiple calls or DLL, 10-93. -* void FC cgMemRep( // Report current memory use to file "cgmem.rep" -* -* char *s ) // String to print with message -* -* // debugging fnc: several conditional calls in this file, some in cgtest.cpp. -* // CAUTION: not multi-run or DLL safe: does not close file, nor reset info at new entry, 10-93. -*{ -* static XFILE *memF = NULL; -* static ULI dmubeg; // Dmused at start -* static ULI dmuold; // Dmused at last htMemCk -* -* if (memF==NULL) // if first call -* { memF = xfopen( "cgmem.rep", O_WT, WRN, FALSE, NULL); -* dmuold = dmubeg = Dmused; // init memory use variables (AFTER xfopen dmallocs) -* } -* xfprintf( memF, "\n%-20s Dmused = %-6ld Dbeg = %-6ld Dprev = %-+6ld", s, Dmused, Dmused-dmubeg, Dmused-dmuold ); -* dmuold = Dmused; -*} // cgMemRep -#endif -//----------------------------------------------------------------------------------------------------------- void TOPRAT::tp_DoDateDowStuff() // do date, day of week, and holiday stuff for new day // uses .jDay, .isWarmup (set in tp_MainSimI); .tp_begDay (user input); diff --git a/src/cnguts.h b/src/cnguts.h index 017ea924f..b0213ea24 100644 --- a/src/cnguts.h +++ b/src/cnguts.h @@ -60,7 +60,7 @@ inline int IsMSBCZone( int bcty) { return bcty==MSBCZONE || bcty==MSBCTNODE; } #define oRes(m) offsetof( ZNRES_IVL_SUB, m) //----- for AHRES_IVL_SUB: air handler simulation results for 1 interval -// constants for limits for avg and sum loops, cnguts.cpp & cgenbal.cpp. Members are grouped as floats, then LI's. +// constants for limits for avg and sum loops, cnguts.cpp & cgenbal.cpp. Members are grouped as floats, then ints. #define oaRes(m) offsetof( AHRES_IVL_SUB, m) //----- for ZNR.mdSeq[].xi: zone hvac mode sequence ZHX subsript (> 0) or -- diff --git a/src/cnloads.cpp b/src/cnloads.cpp index 18d00ae64..07f3adb31 100644 --- a/src/cnloads.cpp +++ b/src/cnloads.cpp @@ -556,7 +556,7 @@ x } bool bReportVent = Top.jDay == 178 /* && !Top.isWarmup */; #endif - ULI ventAvail = Top.tp_GetVentAvail(); // overall vent availability + INT ventAvail = Top.tp_GetVentAvail(); // overall vent availability Top.tp_fVent = 0.f; // consensus whole building vent fraction (if not RSYSOAV) // = fraction of full vent flow to use @@ -1048,7 +1048,7 @@ int ZNR::zn_FVentCR() // find zone's preferred vent fraction } // ZNR::zn_FVentCR //----------------------------------------------------------------------------- RC ZNR::zn_CondixCR( // zone conditions part 1, convective/radiant model - ULI ventAvail) // vent availability + int ventAvail) // vent availability // C_VENTAVAILVC_WHOLEBLDG, C_VENTAVAILVC_ZONAL // determines tz, tr, zn_qsHvac, zn_qIzSh @@ -3036,7 +3036,7 @@ int RSYS::rs_OAVAttempt() // most further this-step HVAC modelling is skipped if (ZnresB[ zp->ss].curr.S.nShVentH) { const int WARNMAX = 20; - int warnCount = ZnresB[ zp->ss].zr_GetRunTotalLI( ZNRES_IVL_SUB_NSHVENTH); + int warnCount = ZnresB[ zp->ss].zr_GetRunTotalInt( ZNRES_IVL_SUB_NSHVENTH); if (warnCount <= WARNMAX) warn( "Zone '%s', %s: unhelpful vent heating (supply temp = %0.2f)%s", zp->Name(), Top.When( C_IVLCH_S), tSup, diff --git a/src/cnztu.cpp b/src/cnztu.cpp index 866cb2eb9..078104af4 100644 --- a/src/cnztu.cpp +++ b/src/cnztu.cpp @@ -7,7 +7,7 @@ // see cnah.cpp for air handlers, cncoil.cpp for coils. /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // USI LI dtypes.h cndefns.h +#include "cnglob.h" #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // AH TU ZNR diff --git a/src/cpgbuild.cpp b/src/cpgbuild.cpp index a221dbfbc..97bb8d6f9 100644 --- a/src/cpgbuild.cpp +++ b/src/cpgbuild.cpp @@ -66,12 +66,12 @@ LOCAL char * pbPp = NULL; // internal pgpak ptr for use (via pbPpp) when caller LOCAL SI pbROff = 0; // row offset: moves table down. pgbuildr, pbIdxMth, pbIdxL, pbPgIf /*----- other variables shared amoung pgbuildr internal fcns -----*/ -LOCAL PBHEAD * pbHd = NULL; /* curr pgbuildr var arg: spec fcn, or ptr to PBHEAD. - PBHEAD has method, methtab ptr, addl info eg data source, col, hd row, etc. - Set in pgbuildr, used in pbIdxMth, pbTabHd, pbIdxL, pbTabDat, pbFillDat, pbFillEst */ +LOCAL PBHEAD * pbHd = NULL; // curr pgbuildr var arg: spec fcn, or ptr to PBHEAD. + // PBHEAD has method, methtab ptr, addl info eg data source, col, hd row, etc. + // Set in pgbuildr, used in pbIdxMth, pbTabHd, pbIdxL, pbTabDat, pbFillDat, pbFillEst */ /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ -LOCAL void pbLabel( SI pgfmt, SI row, SI col, SI wid, char *label); +LOCAL void pbLabel( SI pgfmt, SI row, SI col, SI wid, const char *label); //========================================================================= void CDEC pgbuildr( @@ -234,8 +234,8 @@ void CDEC pgbuildr( SI col = ((PB_TEXT *)tp)->col; /* more common init */ - char* label = 0; // default no label: for shared case code - char* s = ""; /* no converted data, for PBOMITx cases */ + const char* label = nullptr; // default no label: for shared case code + const char* s = ""; // no converted data, for PBOMITx cases /* METHOD SWITCH */ @@ -376,7 +376,7 @@ void CDEC pgbuildr( } /* pgbuildr */ //========================================================================= -LOCAL void pbLabel( SI pgfmt, SI row, SI col, SI wid, char *label) +LOCAL void pbLabel( SI pgfmt, SI row, SI col, SI wid, const char *label) /* position and write label */ diff --git a/src/cpgbuild.h b/src/cpgbuild.h index 7d27b75e2..62329f796 100644 --- a/src/cpgbuild.h +++ b/src/cpgbuild.h @@ -195,7 +195,7 @@ struct PB_TEXT "rOff" arg is nz, don't use row PGCUR (except in 1st row) but being fixed 2-90: text moved down rOff xtra rows at each PGCUR.] */ - char* text; // Pointer to text, or PBARGP to get a ptr from + const char* text; // Pointer to text, or PBARGP to get a ptr from // pgbuildr arg list, or PBOMITP to display nothing }; @@ -203,7 +203,7 @@ struct PB_TEXT /* NOT USED where expected to use 2-28-90; can remove if never used. */ struct PB_TEXTL /* code assumes same as PB_TEXT + label at end */ { USI pgfmt; SI row; SI col; char* text; - char* label; // label text: PGRJ'd to left of .text text. Include + const char* label; // label text: PGRJ'd to left of .text text. Include // any desired separating spaces in label text. }; diff --git a/src/cueval.cpp b/src/cueval.cpp index 0c67b2414..9dc779f8e 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -57,8 +57,8 @@ union _MTP SI** ppi; USI* pu; float* pf; - LI* pl; - LI** ppl; + INT* pl; + INT** ppl; PSOP* pOp; char* pc; char** ppc; @@ -230,12 +230,8 @@ LOCAL RC FC cuEvalI( RC rc = RCOK; // if error (ms nz), RCBAD will be supplied at exit unless other nz value set. SI idx=0, lo=0, hi=0; // errMsg info, PSDISP_ to PSCHUFAI. - // code assumes LI's, floats, char * are same size - // TODO64 -#if CSE_ARCH == 32 - static_assert(sizeof(LI) == sizeof(float)); -#endif - static_assert(sizeof(LI) == sizeof(char*)); + static_assert(sizeof(INT) == sizeof(float)); // code assumes INTs and FLOATs are same size + static_assert(sizeof(LI) == sizeof(char*)); // code assumes LI and pointers same size static_assert( sizeof(SI)==sizeof(PSOP)); // assumed in (SI *) cast used in PSPKONN case for ( ; ; ) @@ -255,7 +251,7 @@ LOCAL RC FC cuEvalI( // fetch next pseudo-code PSOP op = *IPOP++; printif( runtrace, " ip=0x%x sp=%d op=%d ", - (ULI)evIp, evSp, op); + evIp, evSp, op); void* p = 0; @@ -315,7 +311,7 @@ made things worse TODO (MP) *--SPI = *((SI *)evFp + *IPI++); goto evFck; case PSRLOD4: - *--SPL = *(LI*)((SI *)evFp + *IPI++); + *--SPL = *(INT*)((SI *)evFp + *IPI++); evFck: if (evFp == NULL) // late no-frame check { @@ -346,7 +342,7 @@ made things worse TODO (MP) *((SI *)evFp + *IPI++) = *SPI++; goto evFck; case PSRSTO4: - *(LI *)((SI *)evFp + *IPI++) = *SPL++; + *(INT *)((SI *)evFp + *IPI++) = *SPL++; goto evFck; //--- duplicate stack top @@ -887,7 +883,7 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign break; /*lint +e70 */ // expr not allowed; add UNSET ck if need found. case PSRATLODL: POINT; - *--SPF = (float)*(LI *)v; // long: convert to float. + *--SPF = (float)*(INT *)v; // int: convert to float. break; /*lint +e70 */ // add UNSET ck if need found. case PSRATLODA: POINT; @@ -909,13 +905,13 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign break; #endif case PSRATLOD4: - if ((rc = cuRmGet(&p,&ms,pBadH)) != RCOK) // 4 bytes: float/LI/ULI. 1st fetch/check/fix 4 bytes. + if ((rc = cuRmGet(&p,&ms,pBadH)) != RCOK) // 4 bytes: float/INT/UINT. 1st fetch/check/fix 4 bytes. goto breakbreak; // if unset data or uneval'd expr, ms set. *--SPP = p; // push value fetched break; //--- expression data loads: used when (immediate input) locn already containing expr is probed. 12-91. - case PSEXPLOD4: // 4-byte load (LI, float) + case PSEXPLOD4: // 4-byte load (INT, float) h = *IPU++; // fetch inline expression # (handle) if (exInfo( h, NULL, NULL, reinterpret_cast(&p))) // get expression value / if bad expr # goto badExprH; // issue "bad expr #" msg (h) @@ -930,7 +926,7 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign if (exInfo( h, NULL, NULL, reinterpret_cast(&p))) // get expression value / if bad expr # { badExprH: - ms = strtprintf( (char *)MH_R0220, (UI)h); // "cuEvalI internal error: bad expression number 0x%x" + ms = strtprintf( (char *)MH_R0220, h); // "cuEvalI internal error: bad expression number 0x%x" goto breakbreak; } if (ISNANDLE(p)) // if VALUE of expr is UNSET (other NAN not expected in expr tbl) @@ -1043,7 +1039,7 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign default: ms = strtprintf( (char *)MH_R0221, // "cuEvalI internal error:\n Bad pseudo opcode 0x%x at psip=%p" - (UI)op, IPOP-1 ); + op, IPOP-1 ); case PSEND: // normal terminator printif(runtrace, "\n"); goto breakbreak; diff --git a/src/cueval.h b/src/cueval.h index e1de707a5..4ac43995d 100644 --- a/src/cueval.h +++ b/src/cueval.h @@ -193,14 +193,14 @@ w PSRATLOD1U, // rat load 1 unsigned byte: fetchs UCH, converts to 2 bytes w/o w PSRATLOD1S, // rat load 1 signed byte: fetchs char, converts to 2 bytes, extending sign. #endif PSRATLOD2, // rat load 2 bytes: fetches SI/USI. -PSRATLOD4, // rat load 4 bytes: fetches float/LI/ULI. +PSRATLOD4, // rat load 4 bytes: fetches float/INT/UINT PSRATLODD, // rat load double: converts it float. -PSRATLODL, // rat load long: converts it float. +PSRATLODL, // rat load INT: converts it float. PSRATLODA, // rat load char array (eg ANAME): makes dm copy, leaves ptr in stack PSRATLODS, // rat load string: loads char * from record, duplicates. // expression data access: used when an expr references (probes) an input data location already containing an expression. -PSEXPLOD4, // load 4 byte (li,float) expr value. 2-byte expression number follows inline. +PSEXPLOD4, // load 4 byte (INT,float) expr value. 2-byte expression number follows inline. PSEXPLODS, // load string expr value: make duplicate heap (dm) copy. ditto inline. // import file field loads Followed by -- then source file index, line #. diff --git a/src/cul.cpp b/src/cul.cpp index 3126b3c99..475671aed 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -41,7 +41,7 @@ 1) cast (char *) when used in variable arg list 2) don't compare to NULL (compiler supplies ds): use 0 or !. */ -#include "cnglob.h" // USI SI LI +#include "cnglob.h" /*-------------------------------- OPTIONS --------------------------------*/ @@ -1541,7 +1541,7 @@ x dmfree( DMPP( *p)); // free any prior string value: free ram, NUL *(float *)&c->DFF, // scale value in field's external units to internal, cvpak.cpp 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]. + // NC's, DTFLOAT, [DTDBL], [DTPERCENT], } else if (sz <= 4) // if <= 4 bytes long, default data is IN .DFPI memcpy( p, &c->DFPI, sz); // copy default value to member @@ -2159,6 +2159,7 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc case TYFL: case TYSTR: case TYSI: + case TYINT: /* compile expression: stores value if constant & known now, else saves code & stores "NANDLE" (see exman.h). Does errMsgs, terminator. Also uses: defTyping, xSp->b, xSp->i, xSp->c->fn. */ @@ -2183,7 +2184,7 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc if (xSp->sz==2) *(SI *)xSp->p = specVal; // negative value is not a possible record subscript else // assume a 4-byte field - *(LI *)xSp->p = (LI)specVal; // sign extend to yield NAN for negative codes. 3-92. + *(INT *)xSp->p = (INT)specVal; // sign extend to yield NAN for negative codes. 3-92. // delete any existing table entry for reference from this field, in case ALTER and TYREF drefDelFn( xSp->b, xSp->i, c->fn+xSp->j); // array elts are successive field #'s break; // special rc may be used again at ARRAY loop end @@ -2362,11 +2363,7 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0 other: expected only if [arg is 1 or] CULT is bad: non-fatal error incl bad tables, msg issued, .p NULL, rest of stmt has been skipped. Continue compile. */ { - CULT *c; - SI ty; - USI sz, dt; - - c = xSp->c; // fetch current CULT entry ptr + CULT* c = xSp->c; // fetch current CULT entry ptr xSp->p = NULL; // values to return if error xSp->fs = NULL; // .. xSp->sz = 0; // .. @@ -2396,9 +2393,9 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0 /* reconcile cult .ty and field's dtype, and determine data size. In various cases either ty or dtype may be able to rule the input conversion method for field... 2-91. */ - ty = c->ty; // CULT table entry type - dt = sFdtab[ xSp->fdTy ].dtype; // field's data type - sz = 2; // preset sz to most common value + SI ty = c->ty; // CULT table entry type + USI dt = sFdtab[ xSp->fdTy ].dtype; // field's data type + USI sz = 2; // preset sz to most common value if (dt & DTBCHOICB) // modern (1991) choice field data types { if ( ty != TYCH // cult type must by TYCH @@ -2438,9 +2435,14 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0 else dtMustBe = DTSI; break; + case TYINT: + dtMustBe = DTINT; + sz = 4; + break; + case TYLLI: dtMustBe = DTLI; - sz = 4; + sz = sizeof( LI); break; case TYFL: @@ -2477,12 +2479,12 @@ x } default: return perNx( (char *)MH_S0241, // "cul.cpp:datPt(): Unrecognized CULT.ty %d in entry '%s' at %p" - ty, (char *)c->id, c ); + ty, c->id, c ); } if (dt != dtMustBe) // if dt not consistent with ty badTynDt: - return perNx( (char *)MH_S0242, (UI)ty, (UI)dt, (char *)c->id, c ); - // "cul.cpp:datPt(): Bad ty (0x%x) / dtype (0x%x) combination in entry '%s' at %p" + return perNx( (char *)MH_S0242, ty, dt, c->id, c ); + // "cul.cpp:datPt(): Bad ty (0x%x) / dtype (0x%x) combination in entry '%s' at %p" } xSp->sz = sz; // ok, store size. @@ -2701,7 +2703,7 @@ LOCAL RC ganame( for (int i = 0; i < len; i++) if ( p[i] < ' ') // disallow control chars if (p[i] > 0) // allow 129-255 even if compiler extends sign - return perNx( (char *)MH_S0247, (UI)p[i]); // "Illegal character 0x%x in name" + return perNx( (char *)MH_S0247, p[i]); // "Illegal character 0x%x in name" // if caret not useful, consider adding to errMsg, before the word "name": "what ? what : xSp->c->id". // require non-0 name length if (len==0) @@ -2713,7 +2715,7 @@ LOCAL RC ganame( //=========================================================================== LOCAL RC xpr( // our local expression compiler interface / checker - SI ty, // desired cuparse.cpp type: TYLLI TYFL TYSTR TYSI TYFLSTR or TYCH TYNC (fdTy req'd) + SI ty, // desired cuparse.cpp type: TYLLI TYFL TYSTR TYSI TYINT TYFLSTR or TYCH TYNC (fdTy req'd) // or TYID (returns TYSTR). Also accepts non-cuparse type: TYDOY. USI fdTy, // 0 (FDNONE?) or rec def fld type: dtype (for choices), units (for floats) and limit type are used. USI _evfOK, // permissible eval frequency bits, 0 for constant. diff --git a/src/cuparse.cpp b/src/cuparse.cpp index 6f2e862b6..6c7bab5f0 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -93,9 +93,9 @@ AGENDA items decided to defer, 10-5-90: // apparent bug in konstize() found reading code 2-94. ///Leave unchanged till code tests out bad. -#define FLWANT /* define for changes 2-95 to do intermediate calcs in floating point if wanTy is TYFL, -to elinate user problems with 2/3 = 0 (integer divide) and 2400*300 = 6464 (truncation). - Code out defined when working & satisfactory & accepted in use. */ +#define FLWANT // define for changes 2-95 to do intermediate calcs in floating point if wanTy is TYFL, + // to eliminate user problems with 2/3 = 0 (integer divide) and 2400*300 = 6464 (truncation). + // Code out defined when working & satisfactory & accepted in use. #undef LOKSV // define to restore little-used historical code for assignment to system variables, 2-95 @@ -1158,7 +1158,7 @@ RC FC expTy( SI aN ) // parse/compile expression/statement of given type to current destination, -// including resultant type check and conversions */ +// including resultant type check and conversions // tx: NULL or text of verb/operator, for "after 'xxx'" in error messages // aN: 0 or fcn arg number, for error messages @@ -1166,10 +1166,11 @@ RC FC expTy( // caller must preset: parSp, psp (call iniPile() first). // on return, entry added to parStk describes result. { - ERVARS1 USI cWanTy=wanTy, gotTy; + ERVARS1 + USI cWanTy = wanTy; ERSAVE - printif( trace," expTy(%d,%d) ", (INT)toprec, (INT)wanTy ); + printif( trace," expTy(%d,%d) ", toprec, wanTy ); //---- parse/compile (sub)expression ---- @@ -1177,12 +1178,13 @@ RC FC expTy( wanTy |= TYSTR; EE( expr( toprec, wanTy, tx, aN)) // parse/compile to given precedence. only call to expr 10-90. // EE (cuparsex.h) restores variables and returns on error. - gotTy = parSp->ty; // data type found + USI gotTy = parSp->ty; // data type found switch (gotTy) // check for valid return type { case TYNONE: case TYDONE: // nothing and whole statment (not yet used in CSE) respectively case TYSI: + case TYINT: case TYFL: case TYSTR: case TYCH: // single-bit valid expression return values @@ -1191,7 +1193,7 @@ RC FC expTy( // types valid in calls only: TYID (returns TYSTR). combinations: TYFLSTR TYNUM TYANY and any combo. default: - rc = perNx( (char *)MH_S0012, (UI)gotTy, datyTx(gotTy) ); // "cuparse:expTy: bad return type 0x%x (%s) from expr" + rc = perNx( (char *)MH_S0012, gotTy, datyTx(gotTy) ); // "cuparse:expTy: bad return type 0x%x (%s) from expr" goto er; } @@ -1249,9 +1251,11 @@ RC FC expTy( case TYSI: if (wanTy & TYFL) // includes wanTy==TYNC { - EE( emit(PSFLOAT) ) // convert int to float. konstize below converts constant if constant. - parSp->ty = TYFL; // now have a float + EE(emit(PSFLOAT)) // convert int to float. konstize below converts constant if constant. + parSp->ty = TYFL; // now have a float } + else if (wanTy & TYINT) + parSp->ty = TYINT; break; //case TYFL: // if (wanTy & TYSI) possibly convert to int, or perhaps only if integral. Also do for TYNC after PSNCN @@ -1261,7 +1265,7 @@ RC FC expTy( //---- final check/error message ---- gotTy = parSp->ty; // refetch data type: some cases above change it - if (!(gotTy & wanTy) || (gotTy &~wanTy)) // if still not a desired data type + if (!(gotTy & wanTy) || (gotTy & ~wanTy)) // if still not a desired data type { char *got = ""; if ((gotTy & (TYNC))==TYNC) // TYNC is both TYCH and TYFL bits @@ -1726,11 +1730,12 @@ LOCAL RC FC unOp( // parse arg to unary operator, emit code. ERSAVE NOVALUECHECK; #ifdef FLWANT//at top of file 2-95 - if (argTy != TYNUM) opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. - if ( (wanTy & TYNUM)==TYFL // when compiling a float expression (incl TYNC, TYFLSTR), - && argTy & TYFL ) // for numeric operators (typically argTy==TYNUM, may also be TYANY), - argTy &= ~TYSI; /* float arguments ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- - too much user confusion occurred from C-like integer operations. */ + if (argTy != TYNUM) + opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. + if ( (wanTy & TYNUM)==TYFL // when compiling a float expression (incl TYNC, TYFLSTR), + && argTy & TYFL ) // for numeric operators (typically argTy==TYNUM, may also be TYANY), + argTy &= ~(TYSI|TYINT); // float arguments ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- + // too much user confusion occurred from C-like integer operations. */ EE( expTy( toprec, argTy, tx, 0) ) // get expression. always returns prec >= PROP, right? EE( emit( (parSp->ty==TYFL) ? opFl : opSi ) ) // emit operation code for type EE( combSf() ) // combine 2 parStk frames @@ -1757,14 +1762,13 @@ LOCAL RC FC biOp( // parse 2nd arg to binary operator, emit conversions and op { ERVARS1 ERSAVE -#if 1//2-94 - if (argTy != TYNUM) opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. -#endif + if (argTy != TYNUM) + opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. #ifdef FLWANT//above 2-95 if ( (wanTy & TYNUM)==TYFL // when compiling a float expression (incl TYNC, TYFLSTR), && argTy & TYFL ) // for numeric operators (typically argTy==TYNUM), - argTy &= ~TYSI; /* float arguments ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- - too much user confusion occurred from C-like integer operations. */ + argTy &= ~(TYSI|TYINT); // float arguments ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- + // too much user confusion occurred from C-like integer operations. #endif if (parSp < parStk || (parSp->ty & argTy)==0) // if no preceding value or if preceding value wrong type { @@ -2386,8 +2390,8 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som if (aWanTy & TYFL) // if arg type can be float (expect TYANY or TYNUM) if (f->resTy==TYNUM || f->resTy==TYANY) // if fcn rets arg type (table says returns 'numeric' or 'any type') if ((wanTy & TYNUM)==TYFL) // if compiling a float expression (incl TYNC, TYFLSTR), - aWanTy &= ~TYSI; /* float args ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- - too much user confusion occurred from C-like integer operations. */ + aWanTy &= ~(TYSI|TYINT); // float args ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- + // too much user confusion occurred from C-like integer operations. #endif // parse argument expression (value-expr for choose or select) @@ -2885,8 +2889,8 @@ x rc |= emiDup(); // duplicate stack top break; case TYSTR: // get a char *. >> need to duplicate string storage? - /*lint -e616 case falls in*/ case TYFL: + case TYINT: rc = emit( sto ? PSRSTO4 : PSRLOD4); break; @@ -2999,32 +3003,32 @@ LOCAL RC FC tconv( // generate type conversions to make last n expressions com // returns non-RCOK if error in converting, message issued. { - USI aTy, havTys, wanTy=pWanTy ? *pWanTy : 0; PARSTK *pspe; SI i, diff=0; // merge types into havTys; test if all same (or TYNC/TYCH/TYFL: runtime mixable) - havTys = parSp->ty; - for (i = 1; i < n; i++) // loop n most recent parStk frames except last + USI havTys = parSp->ty; + bool bDiff = false; + for (int i = 1; i < n; i++) // loop n most recent parStk frames except last { - aTy = (parSp-i)->ty; - if (aTy != havTys && (aTy|havTys) != TYNC) // mixes of TYCH, TYFL, TYNC===TYFL|TYCH are not 'different' - diff++; + USI aTy = (parSp-i)->ty; + if (aTy != havTys && (aTy | havTys) != TYNC) // mixes of TYCH, TYFL, TYNC===TYFL|TYCH are not 'different' + bDiff = true; havTys |= aTy; } - if (!diff) // if none are different (or n is 0 or 1) + if (!bDiff) // if none are different (or n is 0 or 1) return RCOK; // return with no processing. SIs, STRs not changed when not mixed with others. // float SIs if have any floats, or choices, or strings (possible choices, else error with TYSI). For TYNUM or TYNC end result. - + USI wanTy = pWanTy ? *pWanTy : 0; if (havTys & (TYFL|TYCH|TYSTR)) { - wanTy &= ~TYSI; // make expTy float any addl SI args for caller + wanTy &= ~(TYSI|TYINT); // make expTy float any addl SI args for caller if (havTys & TYSI) { - for (i = 0; i < n; i++) // loop n most recent parStk frames + for (int i = 0; i < n; i++) // loop n most recent parStk frames { - pspe = parSp - i; - if (pspe->ty==TYSI) // if integer, float it + PARSTK* pspe = parSp - i; + if (pspe->ty==TYSI || pspe->ty == TYINT) // if integer, float it { if (cnvPrevSf( i, PSFLOAT, 0)) // insert conversion op after ith expr back (or just float it if constant) return RCBAD; // error, code buffer full, etc @@ -3032,7 +3036,7 @@ LOCAL RC FC tconv( // generate type conversions to make last n expressions com pspe->ty = TYFL; } } - havTys = (havTys & ~TYSI) | TYFL; // combined type: now have floats, no ints + havTys = (havTys & ~(TYSI|TYINT)) | TYFL; // combined type: now have floats, no ints } } @@ -3043,9 +3047,9 @@ LOCAL RC FC tconv( // generate type conversions to make last n expressions com wanTy &= ~TYSTR; // make expTy convert addl strings to choices (or error) for caller if (choiDt && (havTys & TYSTR)) // if have strings and data type for conversion to choices { - for (i = 0; i < n; i++) // loop n most recent parStk frames + for (int i = 0; i < n; i++) // loop n most recent parStk frames { - pspe = parSp - i; + PARSTK* pspe = parSp - i; if (pspe->ty==TYSTR) // if string, choice it { if (cnvPrevSf( i, PSSCH, choiDt)) // insert ops after ith expr back, or just converts constant in place @@ -3062,8 +3066,10 @@ LOCAL RC FC tconv( // generate type conversions to make last n expressions com get konstize'd b4 fcnAgs adss the jmps which prevent konstize here. */ if ((wanTy & TYNC) != TYNC) { - if ((havTys & TYNUM)) wanTy &= ~(TYSTR|TYCH); // strings/choices cannot be made compatible w numbers w/o TYNC - else if (havTys & (TYSTR|TYCH)) wanTy &= ~TYNUM; // numbers cannot be made compat w strings/choices without TYCN + if ((havTys & TYNUM)) + wanTy &= ~(TYSTR|TYCH); // strings/choices cannot be made compatible w numbers w/o TYNC + else if (havTys & (TYSTR|TYCH)) + wanTy &= ~TYNUM; // numbers cannot be made compat w strings/choices without TYCN // may clear bits already seen (ok: caller about to errMsg incompatibilities). "else" prevents clearing to 0 (insurance). } @@ -3504,6 +3510,9 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express if (sz==4) { op1 = PSKON4; // differences for 4-byte value choicn +#if CSE_ARCH != 32 + ?? // shift looks dubious on 64 bit +#endif op3 = (USI)(v >> 16); xspace--; } @@ -3814,8 +3823,8 @@ RC CDEC emiKon( // emit code to load constant w/o calling here, when const string conv to choice.*/ if (choiDt & DTBCHOICN) goto fourBytes; // determine choice size FROM FILE-GLOBAL choiDt if (choiDt & DTBCHOICB) goto twoBytes; // .. - rc = perNx( (char *)MH_S0077, (UI)choiDt); // "Internal Error in cuparse.cpp:emiKon:\n" ... - goto er; // " no recognized bit in choiDt value 0x%x" + rc = perNx( (char *)MH_S0077, choiDt); // "Internal Error in cuparse.cpp:emiKon:\n" ... + goto er; // " no recognized bit in choiDt value 0x%x" case TYSI: twoBytes: @@ -3970,8 +3979,8 @@ LOCAL RC FC emiPop() // emit additional code to discard any value left on run s case TYSI: EE( emit(PSPOP2) ) goto doesit; + case TYINT: case TYSTR: // >> need to free string storage? - /*lint -e616 case falls in*/ case TYFL: EE( emit(PSPOP4) ) doesit: @@ -4393,6 +4402,7 @@ LOCAL const char* FC datyTx( USI ty) // return text for data type case TYLLI: mh = MH_S0089; break; // "limited-long-integer value" + case TYINT: case TYSI: mh = MH_S0090; break; // "integer value" @@ -4484,7 +4494,7 @@ x // handle EVFDUMMY here if found necessary else if (evf==0) mh = adverb ? MH_S0121 // "never" (Use unexpected) : MH_S0122; // "no" .. } - return msg( NULL, (char *)mh, (UI)evf); // get text from disk, 10-92. + return msg( NULL, (char *)mh, evf); // get text from disk, 10-92. // evf is for %x in bad-value msg to whose handle mh was init. } // evfTx diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index 4fb43a239..622602e5d 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -512,8 +512,8 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) if (exInfo( h, &exEvf, &exTy, NULL)) // get expr's type and variability / if h bad (no msg done)(exman.cpp) { // debug aid msg; shd be ok to continue to other cases - return perNx( (char *)MH_U0023, // "U0023: Internal error: %s '%s' member '%s' \n" - o->what, name, o->mName, (UI)h ); // " contains reference to bad expression # (0x%x)" + return perNx( (char *)MH_U0023, // "U0023: Internal error: %s '%s' member '%s' \n" + o->what, name, o->mName, h ); // " contains reference to bad expression # (0x%x)" } else if (exTy != o->ty) // if expression type does not match member type { @@ -591,7 +591,7 @@ LOCAL RC FC lopNty4dt( // for DT- data type, get TY- type and PSOP to load it f #if defined( DTSGTARG) case DTSGTARG: #endif - lop = PSRATLOD4; // record load 4 bytes: fetches float/[LI/ULI]. + lop = PSRATLOD4; // record load 4 bytes: fetches float ty = TYFL; sz = 4; break; diff --git a/src/cutok.cpp b/src/cutok.cpp index 2642d0797..561cf232a 100644 --- a/src/cutok.cpp +++ b/src/cutok.cpp @@ -240,7 +240,7 @@ int cuTok() // get next cu token, return type RC rc = cvatof( cuToktx, &dval); // convert, cvatoxxx.cpp if (rc) // message error cuEr( // errmsg with line # and file name - 0, msg( NULL, (char *)(LI)rc)); // Tmpstr text for cvatof return code, messages.cpp + 0, msg( NULL, (char *)rc)); // Tmpstr text for cvatof return code, messages.cpp // no error indication returned to caller? cuFlval = (float)dval; // double-->float cuTokty = CUTFLOAT; // say token is a float @@ -325,7 +325,7 @@ int cuTok() // get next cu token, return type // reject random non-whitespace, non-printing characters now if (c < ' ' || c > '~') { - cuEr( 0, (char *)MH_S0151, (UI)c); // "Ignoring illegal char 0x%x" + cuEr( 0, (char *)MH_S0151, c); // "Ignoring illegal char 0x%x" goto reget; } single: // 1-char cases may here or fall in diff --git a/src/cvpak.cpp b/src/cvpak.cpp index 9f824f31e..bf959977d 100644 --- a/src/cvpak.cpp +++ b/src/cvpak.cpp @@ -74,10 +74,10 @@ p p /* for trim trailing 0's. ipv: null + spc */ p static char *gf[4][3] = {"%-*.*g", "%-+*.*g", "%- *.*g", /* left j */ - p "%*.*g", "%+*.*g", "% *.*g", /* rj */ - p "%0*.*g", "%0+*.*g", "%0 *.*g", /* rj 0s */ - p "%*.*g", "%+*.*g", "% *.*g" - }; /* sqz */ +p "%*.*g", "%+*.*g", "% *.*g", /* rj */ +p "%0*.*g", "%0+*.*g", "%0 *.*g", /* rj 0s */ +p "%*.*g", "%+*.*g", "% *.*g" +p }; /* sqz */ p p /* IP lengths. subscript ipv: null, +, space */ p /* dfw 0, feet and inches */ @@ -118,7 +118,7 @@ LOCAL bool FC cvsd( SI mfw, SI dfw); LOCAL bool FC cvdd( SI mfw, SI dfw); LOCAL void FC cvDouble2s(void); LOCAL void FC cvFtIn2s(void); -LOCAL LI FC sepFtInch( double d, SI *inp); +LOCAL int FC sepFtInch( double d, int& inch); // unmaintained test code is at end @@ -221,8 +221,9 @@ p ? wid : wid - 1; // full width, else 1 less else // for other formats ppos = pneg = 1; // init pos and neg precision to 1 - /* Datatype specific internal-->external processing */ - + // Datatype specific internal-->external processing + INT iV{ 0 }; + UINT uiV{ 0 }; switch (dt) { #ifdef FMTPVMASK @@ -232,13 +233,24 @@ p pv=FMTPVSPACE; p Cvnchars = sprintf( str, sif[lj][ipv], wid, *(SI *)data < 0 ? pneg : ppos, *(SI *)data); p break; #else + case DTINT: + iV = *(INT*)data; + goto intOut; + case DTSI: - Cvnchars = sprintf( str, sif[lj], wid, *(SI *)data < 0 ? pneg : ppos, *(SI *)data); + iV = *(SI*)data; + intOut: + Cvnchars = sprintf( str, sif[lj], wid, iV < 0 ? pneg : ppos, iV); break; #endif + case DTUINT: + uiV = *(UINT*)data; + goto uintOut; case DTUSI: - Cvnchars = sprintf( str, usif[lj], wid, ppos, *(USI *)data); + uiV = *(USI*)data; + uintOut: + Cvnchars = sprintf( str, usif[lj], wid, ppos, uiV); break; #ifdef FMTPVMASK @@ -297,18 +309,6 @@ p break; goto valValue; // join float #endif -#ifdef DTSSE // removed from CSE 12-91 rob - /* Special data type for source seasonal efficiency: If value is >= 0., display it as a floating point number. - If negative, display "Hyd", to indicate that system is Hydronic and does not have a defined SSE */ - case DTSSE: - if (*(float *)data < 0.f ) - { - data = "Hyd"; - goto strjust; // Display as string - } - // Fall through to DTFLOAT -#endif - case DTFLOAT: floatCase: // number-choice comes here (from default) if does not contain choice { @@ -403,12 +403,6 @@ x } data = (*(CULSTR*)data).CStr(); goto strjust; // data is pointer to string -#if 0 // untested idea, 1-1-11 -x case DTCSTRING: -x data = (const char *)(CString *)data; -x goto strjust; -#endif - case DTCH: // for char array or string ptr already dereferenced, rob 11-91 case DTANAME: // char[ ] RAT name strjust: @@ -589,49 +583,42 @@ LOCAL void FC cvFtIn2s() // feet-inch length output conversion case for cv // converts 'val' to '*str'; uses other global statics including: fmt, mfw, val, str, lj, lz, ppos, . { - SI biglen = (aval > 178000000.); // true to show feet only: set if > max LI inches, also set below if too wide. - if (!biglen) // if feet not too big to express inches in LI (in sepFtInch): ie normally + bool biglen = (aval > 178000000.); // true to show feet only: set if > max 32-bit int inches, also set below if too wide. + if (!biglen) // if feet not too big to express inches in int (in sepFtInch): ie normally { - SI prcsn; // sprintf 'precision': min # digits for most cases - SI sq = (just==FMTSQ); // squeeze (minimum columns) flag (also 'wid' is 1) - SI fw; // feet or inches-only width - SI inw; // inches subfield width (with feet) - SI indfw; // decimal places for inches - LI ft; // feet of ft-inches value - SI inch; // inches - double dinch; // floating inches where needed - SI justInches; // true to omit feet: 0 < l < 1'0" aval = fabs(val); // absolute val + bool sq = (just==FMTSQ); // squeeze (minimum columns) flag (also 'wid' is 1) + int inch; // inches #ifdef FMTNOQUINCH // define in cvpak.h to restore feature, 11-91 x SI quinch = !(fmt & FMTNOQUINCH); // 1 for " after inches x ft = sepFtInch( val, &inch); // separate/fix feet, inches x justInches = (quinch && ft == 0L && inch != 0); x // true to omit feet; never happens if quinch is off -- prevents ambiguous single numbers. #else // 11-91 quinch coded out as 1 - ft = sepFtInch( val, &inch); // separate/fix feet, inches - justInches = (ft == 0L && inch != 0); // true to omit feet + int ft = sepFtInch( val, inch); // separate/fix feet, inches + bool justInches = (ft == 0 && inch != 0); // true to omit feet #endif // digits after decimal point in INCHES - indfw = fmt & FMTDFWMASK; // init decimal places for inches (same value as former 'dfw') + int indfw = fmt & FMTDFWMASK; // init decimal places for inches (same value as former 'dfw') if (fmt & FMTRTZ) // with truncating trailing 0's optn, { // dfw is total sig digs, not digits after . // Reduce indfw to digits to print AFTER DECIMAL in INCHES. - SI ndig = 0; + int ndig = 0; while (indfw > 0 && Pten[ndig++] <= aval) // while value < power of 10 indfw--; // reduce for each feet digit // (need no Pten size cks here due to 178000000 ck above) ndig = 0; - dinch = (float)abs(inch); + double dinch = abs(double(inch)); while (indfw > 0 && Pten[ndig++] <= dinch ) // while inches < pwr of 10 indfw--; // reduce for each inches digit b4 . } // printf width/space needed for inches if with feet - inw = justInches ? 0 // for inches-only fw is used, else + int inw = justInches ? 0 // for inches-only fw is used, else : 2 // 2 for integral inches (space b4 0-9; exact inw needed for rj) .. - sq // but only 1 col if squeezing (no space b4 squeezed 0-9; inw < actual ok when sq on) + (indfw!=0) // 1 for . if needed @@ -639,7 +626,7 @@ x // true to omit feet; never happens if quinch is off -- prevents ambiguous // printf width for feet (or inches if no feet) - fw = lj ? 1 // 1 to left-justify, else + int fw = lj ? 1 // 1 to left-justify, else : wid - inw // wid less inch space and - (!justInches) // less ' space and #ifdef FMTNOQUINCH @@ -649,13 +636,14 @@ x - quinch; // less " space #endif if (fw < 1) // Prevent fw < 0: else trails blanks to fw = 1; // .. -fw cols. NB wid=1 for FMTSQ (10-88). - prcsn = lz ? fw-wsign : 1; // min # digits most cases + int prcsn = lz ? fw-wsign : 1; // min # digits most cases // format feet-inches if (indfw) // if non-0 # dec places for inches { // show with decimal inches + double dinch = 0.; if (justInches) // if showing inches only { dinch = val*12.; // compute float inches @@ -767,7 +755,7 @@ x } // if feet-inch value too big, show feet only - if (biglen) // if value too big for LI inches at entry, OR feet-inches format exceeded field width + if (biglen) // if value too big for int inches at entry, OR feet-inches format exceeded field width { cvin2sBuf( str, (char *)&val, // recursive call to do feet only DTDBL, @@ -1110,6 +1098,49 @@ LOCAL SI FC cvttz( char *_str, SI trailChar, SI minWid) *pend = (char)0; // truncate return (SI)strlen(_str); // new length. another return above. } // cvttz +//---------------------------------------------------------------------- +template< typename T> static RC LimitCheck(T v, int limit) +{ + RC rc = RCOK; + switch (limit) + { + case LMLEZ: + if (v > 0) rc = MH_V0022; + break; + case LMLZ: + if (v >= 0) rc = MH_V0026; + break; + case LMNZ: + if (v == 0) rc = MH_V0025; + break; + case LMGZ: + if (v <= 0) rc = MH_V0024; + break; + case LMGEZ: + if (v < 0) rc = MH_V0023; + break; + case LMG1: + if (v <= T(1)) rc = MH_V0028; + break; + case LMGE1: + if (v < T(1)) rc = MH_V0027; + break; + case LMFR: + if (v < 0 || v > T(1)) rc = MH_V0031; + break; + case LMFGZ: + if (v <= 0 || v > T(1)) rc = MH_V0032; + break; + case LMDOY: + if (v < T(1) || v > T(365)) rc = MH_V0034; + break; + + default: + err(PWRN, "LimitCheck: missing case for limit %d", limit); + } + return rc; + +} // LimitCheck //====================================================================== RC FC cvLmCk( // Check input data for being within limits for data and limit type @@ -1121,132 +1152,55 @@ RC FC cvLmCk( // Check input data for being within limits for data and limit t { RC rc = RCOK; - if (limit != LMNONE) + if (limit == LMNONE) + return rc; + + switch (dt) { - switch (dt) - { + { int iV; + + case DTDOY: + iV = *(DOY*)p; + goto iVCheck; case DTSI: - switch (limit) - { - case LMGZ: - if (*(SI *)p <= 0) rc = MH_V0024; - break; - case LMGEZ: - if (*(SI *)p < 0) rc = MH_V0023; - break; - case LMG1: - if (*(SI *)p <= 1) rc = MH_V0028; - break; - case LMGE1: - if (*(SI *)p < 1) rc = MH_V0027; - break; - case LMLEZ: - if (*(SI *)p > 0) rc = MH_V0022; - break; - case LMLZ: - if (*(SI *)p >= 0) rc = MH_V0026; - break; - case LMNZ: - if (*(SI *)p == 0) rc = MH_V0025; - break; - case LMDOY: - if (*(SI *)p < 1 || *(SI *)p > 365) rc = MH_V0034; - break; - default: - break; - } + iV = *(SI*)p; + goto iVCheck; + case DTINT: + iV = *(INT*)p; + iVCheck: + rc = LimitCheck(iV, limit); break; + } + + { UINT uiV; + case DTUSI: - switch (limit) - { - case LMGZ: - if (*(USI *)p == 0) rc = MH_V0024; - break; - case LMDOY: - if (*(USI *)p < 1 || *(USI *)p > 365) rc = MH_V0034; - break; - case LMNZ: - if (*(USI *)p == 0) rc = MH_V0025; - break; - default: - break; - } - break; - case DTLI: - switch (limit) - { - case LMGZ: - if (*(LI *)p <= 0) rc = MH_V0024; - break; - case LMGEZ: - if (*(LI *)p < 0) rc = MH_V0023; - break; - case LMG1: - if (*(LI *)p <= 1) rc = MH_V0028; - break; - case LMGE1: - if (*(LI *)p < 1) rc = MH_V0027; - break; - case LMLEZ: - if (*(LI *)p > 0) rc = MH_V0022; - break; - case LMLZ: - if (*(LI *)p >= 0) rc = MH_V0026; - break; - case LMNZ: - if (*(LI *)p == 0) rc = MH_V0025; - break; - default: - break; - } + uiV = *(USI*)p; + goto uiVCheck; + case DTUINT: + uiV = *(UINT*)p; + uiVCheck: + rc = LimitCheck(uiV, limit); break; + } + + { double dV; + case DTFLOAT: -#ifdef DTPERCENT - case DTPERCENT: -#endif - switch (limit) - { - case LMGZ: - if (*(float *)p <= 0.f) rc = MH_V0024; - break; - case LMGEZ: - if (*(float *)p < 0.f) rc = MH_V0023; - break; - case LMG1: - if (*(float *)p <= 1.f) rc = MH_V0028; - break; - case LMGE1: - if (*(float *)p < 1.f) rc = MH_V0027; - break; - case LMLEZ: - if (*(float *)p > 0.f) rc = MH_V0022; - break; - case LMLZ: - if (*(float *)p >= 0.f) rc = MH_V0026; - break; - case LMNZ: - if (*(float *)p == 0.f) rc = MH_V0025; - break; - case LMFGZ: - if (*(float *)p <= 0.f || *(float *)p > 1.f) rc = MH_V0032; - break; -#ifdef DTPERCENT - case LMFR: - if (*(float *)p < 0.f || *(float *)p > 1.f) rc = (dt==DTPERCENT) ? MH_V0033 : MH_V0031; - break; -#else - case LMFR: - if (*(float *)p < 0.f || *(float *)p > 1.f) rc = MH_V0031; - break; -#endif - default: - break; - } - break; - default: + dV = *(FLOAT*)p; + goto dvCheck; + case DTDBL: + dV = *(DBL*)p; + dvCheck: + rc = LimitCheck(dV, limit); break; } + + // case DTLI: // DTLI not supported as input data + default: + err(PWRN, "cvLmCk: unsupported DT=%d", dt); } + return rc; } // cvLmCk //====================================================================== @@ -1272,7 +1226,7 @@ double FC cvIntoEx( // Convert value from internal units to external double f, // value to be converted int units ) // unit type -// call only for DTFLOAT, DTDBL, DTPERCENT, or DTSSE value +// call only for DTFLOAT, DTDBL, (DTPERCENT), // returns converted value { if (units != UNNONE) // if it has units @@ -1311,23 +1265,20 @@ double FC cvstdangle( // Normalize an angle into 0 to 2*PI range // made local and renamed from cvftinch, 2-91: //============================================================================ -LOCAL LI FC sepFtInch( // Break up length into feet and inches +LOCAL int FC sepFtInch( // Break up length into feet and inches double d, // Length to be broken up (float or double feet) - SI *inp ) // Location for returning inches. fcn value is LI feet. + int& inch ) // return: inches -/* Returns integral feet as fcn value, plus integral inches via *inp. - If d < 0, feet are returned negative; inches are returned positive unless feet are 0. - Since d is converted to LI inches, the largest distance which can be converted is around 178,956,970 ft - (about 33,893 miles; I know you're disappointed). */ +// Returns integral feet as fcn value, plus integral inches via *inp. +// If d < 0, feet are returned negative; inches are returned positive unless feet are 0. +// Since d is converted to int inches, the largest distance which can be converted is around 178,956,970 ft +// (about 33,893 miles; I know you're disappointed). { - LI totin, ft; - SI nd; - - nd = d < 0.0 ? -12 : 12; - totin = (LI)( d*(double)nd + 0.5 ); // total inches, pos, rounded - ft = totin/nd; // feet, signed - *inp = (SI)((ft==0 && d < 0.) ? -totin : totin%12); // inches + int nd = d < 0.0 ? -12 : 12; + int totin = (int)( d*(double)nd + 0.5 ); // total inches, pos, rounded + int ft = totin/nd; // feet, signed + inch = (ft==0 && d < 0.) ? -totin : totin%12; // inches return ft; } // sepFtInch @@ -1362,7 +1313,7 @@ const char* getChoiTxI( // text for choice of choice data type chan &= ~NCNAN; // remove them for check. But leave improper bits to evoke error msg. if (chan <= 0 || chan > GetDttab(dt).nchoices) // check that choice is in range 1 to # choices for dt. GetDttab: srd.h. { - err( PWRN, (char *)MH_V0036, (INT)chan, (UI)dt ); // display program error err msg + err( PWRN, (char *)MH_V0036, chan, dt ); // display program error err msg // "cvpak:getChoiTx(): choice %d out of range for dt 0x%x" return "bad choice"; } @@ -1383,7 +1334,7 @@ const char* getChoiTxI( // text for choice of choice data type *pTyX = tyX; return chtx; } - err( PWRN, (char *)MH_V0037, (UI)dt ); // program (internal) err msg + err( PWRN, (char *)MH_V0037, dt ); // program (internal) err msg // "cvpak:getChoiTx(): given data type 0x%x not a choice type" return "bad dt"; } // getChoiTxI @@ -1479,7 +1430,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for return RCBAD; // bad value for data type return } if (pms) - *pms = strtprintf( (char *)MH_V0038, (UI)dt ); // "cvpak:cvS2Choi(): given data type 0x%x not a choice type" + *pms = strtprintf( (char *)MH_V0038, dt ); // "cvpak:cvS2Choi(): given data type 0x%x not a choice type" return RCBAD; // bad data type. 2+ other returns above } // cvS2Choi @@ -1795,7 +1746,7 @@ unused, 2-2022 RC FC cvatol( /* convert string to (signed) long integer */ char *s, /* string */ - LI *pn, /* receives value */ + INT* pn, /* receives value */ SI hexoct) /* 0 accept decimal only, nz also accept 0x for hex and 0o for octal */ @@ -1808,14 +1759,11 @@ RC FC cvatol( /* convert string to (signed) long integer */ /* returns RCOK if ok, else other value */ { - LI n, newn; - SI sign, digSeen, digVal, base; - char c; - n = 0L; - digSeen = 0; - base = 10; - sign = 1; + int n = 0; + int digSeen = 0; + int base = 10; + int sign = 1; while (isspaceW( *s)) /* pass leading whiteSpace */ s++; @@ -1830,11 +1778,11 @@ RC FC cvatol( /* convert string to (signed) long integer */ while (1) /* loop to process digits */ { - c = tolower(*s); /* fetch next character */ + char c = tolower(*s); /* fetch next character */ if (!(isxdigit(c))) /* nondigit ends number */ break; s++; /* NOW advance pointer */ - digVal = (c<='9') ? c-'0' : c-'a'+10; /* convert digit to binary */ + int digVal = (c<='9') ? c-'0' : c-'a'+10; /* convert digit to binary */ if (!digSeen && digVal==0) /* if 0 first digit */ { c = tolower(*s); @@ -1855,7 +1803,7 @@ RC FC cvatol( /* convert string to (signed) long integer */ { if (digVal >= base) // check e.g. for 8 or 9 in octal # return MH_V0010; // "Invalid number"; digit too big for base - newn = n * (LI)base + (LI)digVal; /* accumulate value */ + int newn = n * base + digVal; /* accumulate value */ if (newn < n) /* klutzy overflow check */ return MH_V0012; // "Value must be between -2147483639 and // 2147483639" @@ -1869,7 +1817,7 @@ RC FC cvatol( /* convert string to (signed) long integer */ s++; if (*s) // check for terminating null return MH_V0010; // "Invalid number": trailing garbage - *pn = n * (LI)sign; /* return value to caller */ + *pn = n * sign; /* return value to caller */ return RCOK; /* good return */ } /* cvatol */ diff --git a/src/cvpak.h b/src/cvpak.h index d7e0f4871..a9b0e9ad8 100644 --- a/src/cvpak.h +++ b/src/cvpak.h @@ -82,7 +82,7 @@ RC FC cvS2Choi( const char *s, USI dt, void *pv, USI *pSz, const char** pms); RC FC cvatof( const char *_str, double *vp, bool percent=false ); #if 0 -x RC FC cvatol(char* s, LI* pn, SI hexoct); // convert string to long integer +x RC FC cvatol(char* s, INT* pn, SI hexoct); // convert string to long integer x RC FC cvatof2( char *s1, char *s2, double *vp, SI percent ); #endif diff --git a/src/dmpak.cpp b/src/dmpak.cpp index dd753fc40..ae2f76f89 100644 --- a/src/dmpak.cpp +++ b/src/dmpak.cpp @@ -20,7 +20,7 @@ const USI dmBlkOvhd = sizeof( USI) + sizeof( size_t); // total overhead static inline void* dmAppP( void* q) { return (char *)q + dmBlkOvhd; } static inline void* dmMallocP( void* p) { return (char *)p - dmBlkOvhd; } static inline USI& dmRefCount( void* p) { return *(USI *)dmMallocP( p); } -static inline ULI& dmSize( void* p) { return *(((ULI*)p)-1); } +static inline UINT& dmSize( void* p) { return *(((UINT*)p)-1); } // Statistics available to tune memory mgmt // TODO: not maintained in MSVC @@ -39,7 +39,7 @@ static DMP mgMalloc( // malloc with statistics DMP q = malloc( blkSz); // adjust size for overhead if (q != NULL) // if succeeded { p = dmAppP( q); // app pointer (after overhead) - dmSize(p) = ULI(blkSz); + dmSize(p) = UINT(blkSz); dmRefCount( p) = 1; DmCount++; // statistics: # blocks in use Dmused += blkSz; // .. # bytes in use @@ -71,7 +71,7 @@ static DMP dmralloc( // Reallocate heap space using realloc() DMP qNu = realloc( qOld, nuSz + dmBlkOvhd); if (qNu) { pNu = dmAppP( qNu); - dmSize(pNu) = ULI(nuSz + dmBlkOvhd); + dmSize(pNu) = UINT(nuSz + dmBlkOvhd); Dmused += dmSize( pNu) - oldsz; // statistics if (Dmused > DmMax) DmMax = Dmused; diff --git a/src/envpak.cpp b/src/envpak.cpp index 98c9452aa..0d3268aad 100644 --- a/src/envpak.cpp +++ b/src/envpak.cpp @@ -27,16 +27,6 @@ #include // _NSGetExecutablePath #endif -/*-------------------------------- DEFINES --------------------------------*/ -// (none now) - -/*--------------------------------- TYPES ---------------------------------*/ -/* Types used here, defined elsewhere, include: -* system time (as LI seconds since 0:0:0 Jan 1 1970 under MSDOS): -* typedef long time_t msc library's time.h type for time() return -* typedef long LDATETIME our type for same thing. dtypes.def/dtypes.h -* (dtypes.h is #included in cnglob.h) */ - /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL void CDEC enkiint(INT); // no NEAR -- passed to another function @@ -208,7 +198,7 @@ void FC ensystd( // Return the system date and time as IDATETIME //===================================================================== LDATETIME FC ensysldt() // Return system date and time as LDATETIME { - return (LDATETIME)time(NULL); // LI seconds since 1/1/1970 (msc library) + return (LDATETIME)time(NULL); // seconds since 1/1/1970 (msc library) } // ensysldt /* *************** Keyboard Interrupt Handling Routines ************ */ diff --git a/src/exman.cpp b/src/exman.cpp index 9462d693b..d27567ecf 100644 --- a/src/exman.cpp +++ b/src/exman.cpp @@ -9,7 +9,7 @@ /*------------------------------- INCLUDES --------------------------------*/ -#include "cnglob.h" // ULI SI +#include "cnglob.h" #include "msghans.h" // MH_V0035, MH_E0090 @@ -66,7 +66,7 @@ depends on IEEE floating point format (hi word FF00 is Not-A-Number); depends on IBM memory allocation (segment FF00 will not occur in data pointers as ROM is there); - depends on user caution to limit SI data stored in LI to 16 bits + depends on user caution to limit SI data stored NANDLE to 16 bits to insure data not looking like a NANDLE. */ /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ @@ -446,7 +446,7 @@ void EXTAB::ext_StoreValue() const // store current expression value into record if (pVal) // in case pRat errored { if (ext_ty == TYSI) // "can't" get here 10-90 - *(SI*)pVal = (SI)(LI)ext_v; // SI's have only 16 bits + *(SI*)pVal = (SI)(INT)ext_v; // SI's have only 16 bits else if (ext_ty == TYSTR) CopyCULSTR(pVal, &ext_v); @@ -646,7 +646,7 @@ RC FC exPile( // compile an expression from current input // DON'T MATTER for non-field calls: not used if evfOk 0 or expr constant. */ // >>> OR should we save ermTx, to show cult not fir member names? // review what callers pass for ermTx. 2-91 <<<< - NANDAT *pDest, // rcvs constant value (LI, float, char *, or SI), or nandle for non-constant expr + NANDAT *pDest, // rcvs constant value (SI, INT, FLOAT, CULSTR), or nandle for non-constant expr // (which is saved for access by the nandle) (not allowed for TYSI). USI *pGotTy, // NULL or receives actual data type gotten (useful with wanTy = TYFLSTR). USI *pGotEvf ) // NULL or receives actual eval frequency (variation) of expression compiled @@ -671,17 +671,17 @@ RC FC exPile( // compile an expression from current input if (wanTy==TYSI || wanTy==TYCH && choiDt & DTBCHOICB) // 16-bit ints and choicb choices cannot hold NANDLEs { - perlc( (char *)MH_E0090, (UI)_evfOk ); // devel aid. perlc: issue parse errMsg w line # & caret, cuparse.cpp + perlc( (char *)MH_E0090, _evfOk ); // devel aid. perlc: issue parse errMsg w line # & caret, cuparse.cpp // "exman.cpp:exPile: Internal error: bad table entry: \n" // " bad evfOk 0x%x for 16-bit quantity" _evfOk &= (EVEOI|EVFFAZ); // fix & continue } if (wanTy & TYCH && !(choiDt & (DTBCHOICB|DTBCHOICN))) - return perlc( (char *)MH_E0091, (UI)wanTy, (UI)choiDt); /* "exman.cpp:exPile: Internal error: \n" + return perlc( (char *)MH_E0091, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" " called with TYCH wanTy 0x%x but non-choice choiDt 0x%x" */ if ((wanTy & (TYCH|TYFL))==(TYCH|TYFL)) if (!(choiDt & DTBCHOICN)) - return perlc( (char *)MH_E0092, (UI)wanTy, (UI)choiDt); /* "exman.cpp:exPile: Internal error: \n" + return perlc( (char *)MH_E0092, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" " called with TYNC wanTy 0x%x but 2-byte choiDt 0x%x" */ /* compile expression from current input file to pseudocode OR constant value */ @@ -707,7 +707,7 @@ RC FC exPile( // compile an expression from current input if (gotTy == TYSI // return the constant value in destination. SI has 16 bit storage only || gotTy == TYCH && choiDt & DTBCHOICB) // choice types with this bit on are 16 bits only { - *(SI*)pDest = (SI)(LI)v; // return lo 16 bits of value + *(SI*)pDest = (SI)(INT)v; // return lo 16 bits of value if (ISNCHOICE(v)) // redundantly check for not a 4-byte choice value (cnglob.h macro) perlc((char*)MH_E0093); // "exman.cpp:exPile: Internal error:\n" // " 4-byte choice value returned by exOrk for 2-byte type". devel aid @@ -806,7 +806,7 @@ RC FC uniLimCt( // check limits & apply units, with errMsg suitable for compile _ermTx ? _ermTx : "", // in case _ermTx is NULL (unexpected/fix call if found) txVal( ty, p), // text for the bad value (below) msg( NULL, // text for MH (in rc) to Tmpstr (messages.cpp) SHD BE OK TO pass han to perNx now 3-92. - (char *)(LI)rc)); // MH in low byte of char * + (char *)rc)); // MH in low byte of char * } // uniLimCt //=========================================================================== LOCAL RC FC uniLim( @@ -1350,7 +1350,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre txVal( ex->ext_ty, pv), // convert value to text (local) whatEx(h), // what this expr orginally set (local) msg( NULL, // text for MH to Tmpstr, messages.cpp SHD BE OK TO PASS han to rer now, 3-92. - (char *)(LI)rc) ); // cast rc to char * + (const char *)(INT)rc) ); // cast rc to char * // test for change, condition value by type, store new value in exTab. ex->ext_v is old value, *pv is new value. @@ -1387,7 +1387,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre case TYSI: // (10-90: insurance: SI's can't get here as exPile accepts only constant values for user SI type) // but if can happen, 0 pad the SI for exTab.v. case TYLLI: // SI data in LI storage - v = (NANDAT)*(USI*)pv; // 0 pad SI to LI + v = (NANDAT)*(USI*)pv; // 0 pad SI to NANDAT goto chtst; default: @@ -1417,11 +1417,11 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre { pv = (NANDAT *)((char *)e + b->fir[ex->ext_srcFn].fi_off); // point to member in record by field number if (ex->ext_ty==TYSI) - *(SI *)pv = (SI)(LI)ex->ext_v; // store only 16 bits into SI + *(SI *)pv = (SI)(INT)ex->ext_v; // store only 16 bits into SI else if (ex->ext_ty == TYSTR) CopyCULSTR(pv, &ex->ext_v); else - *pv = ex->ext_v; // TYFL, TYLLI, + *pv = ex->ext_v; // TYFL, TYINT, *((UCH *)e + b->sOff + ex->ext_srcFn) |= FsVAL; // field status bit: say value now stored in this member: // is no longer nandle; caller can test/use its value. } @@ -1448,7 +1448,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre if (pVal) // in case pRat errored { if (ex->ext_ty==TYSI) // "can't" get here 10-90 - *(SI *)pVal = (SI)(LI)v; // SI's have only 16 bits + *(SI *)pVal = (SI)(INT)v; // SI's have only 16 bits else if (ex->ext_ty==TYSTR) { @@ -1518,7 +1518,7 @@ RC FC exInfo( // return info on expression # *pTy = ex->ext_ty; if (pv) if (ex->ext_ty==TYSI) - *(SI *)pv = (SI)(LI)ex->ext_v; + *(SI *)pv = (SI)(INT)ex->ext_v; else *pv = ex->ext_v; // caller cueval.cpp cupIncRef's pointer if string, 7-92. return RCOK; @@ -1542,7 +1542,10 @@ LOCAL const char* FC txVal( // case TYDOY: type is TYSI here, 2-91 case TYLLI: case TYSI: - return strtprintf( "%d", (INT)*(SI *)p); + return strtprintf( "%d", *(SI *)p); + + case TYINT: + return strtprintf("%d", *(INT*)p); case TYFL: return strtprintf( "%g", *(float *)p); @@ -1552,7 +1555,7 @@ LOCAL const char* FC txVal( default: err( PWRN, // display intrnl err msg - (char *)MH_E0107, (UI)ty ); // "exman.cpp:txVal: unexpected 'ty' 0x%x" + (char *)MH_E0107, ty ); // "exman.cpp:txVal: unexpected 'ty' 0x%x" return "?"; } } // txVal diff --git a/src/exman.h b/src/exman.h index fce21ca5c..70f273b28 100644 --- a/src/exman.h +++ b/src/exman.h @@ -25,7 +25,7 @@ depends on IEEE floating point format (hi word FF80 is Not-A-Number); depends on IBM memory allocation (segment FF80 should not occur in data pointers as ROM is there); - depends on user caution to limit SI data stored in LI to 16 bits + depends on user caution to limit SI data stored in 32-bit int to 16 bits to insure data not looking like a NANDLE. must be kept distinct from NCHOICEs (cnglob.h): 7F8x hi word. */ diff --git a/src/impf.cpp b/src/impf.cpp index ec585d147..df238bc08 100644 --- a/src/impf.cpp +++ b/src/impf.cpp @@ -607,15 +607,15 @@ RC FC impfStart() // import files stuff done at start run } // save file postition after header to seek back to after warmup. - LI temPos = ftell(impf->fh); // get file position - if (temPos < 0L) // -1L if error + int temPos = int( ftell(impf->fh)); // get file position + if (temPos < 0) // -1 if error { rc = err( PWRN, // general error message (rmkerr.cpp), count error (errCount++), return RCBAD. (char *)MH_R1902, // "Tell error (%ld) on import file %s. No run." impf->im_fileName.CStr() ); continue; } - USI unused = impf->bufN - impf->bufI2; // number of unscanned bytes remaining in buffer - impf->posEndHdr = temPos - (LI)(ULI)unused; // store position at start of data + int unused = impf->bufN - impf->bufI2; // number of unscanned bytes remaining in buffer + impf->posEndHdr = temPos - unused; // store position at start of data impf->lineNoEndHdr = impf->lineNo; // store corresponding line number for error messages } return rc; diff --git a/src/libstubs.cpp b/src/libstubs.cpp index 9341c01e7..93ea89bf2 100644 --- a/src/libstubs.cpp +++ b/src/libstubs.cpp @@ -48,9 +48,9 @@ int CheckAbort() { return 0; } //----------------------------------------------------------------------------- -int vrIsEmpty(int) +bool vrIsEmpty(int) { - return 1; // return TRUE + return true; // return "not empty" } //----------------------------------------------------------------------------- short vrStr(int, const char*) diff --git a/src/messages.cpp b/src/messages.cpp index 273f2bce8..4b539a39e 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -45,7 +45,7 @@ extern SI msgTblCount; // number of messages in msgTbl[] LOCAL SI msgIsinit = 0; // non-0 after message world initialized this session /*----------------------- LOCAL FUNCTION DECLARATIONS ----------------------*/ LOCAL void FC msgSort( void); -LOCAL char * FC msgFind( int erOp, MH mh); +LOCAL const char * FC msgFind( int erOp, MH mh); LOCAL INT CDEC msgCompare( const void *m1, const void *m2); // for qsort, not FC NEAR LOCAL RC FC msgCheck( int erOp, const char *pMsg); @@ -271,7 +271,7 @@ LOCAL void FC msgSort() // sort msgTbl[] by message handle } // msgSort //============================================================================== -LOCAL char * FC msgFind( // find/read from disk full text for a message handle +LOCAL const char * FC msgFind( // find/read from disk full text for a message handle int erOp, // error reporting control, typically PWRN MH mh ) // message handle of message being sought diff --git a/src/messages.h b/src/messages.h index 4d8e7ca37..e5de4de4d 100644 --- a/src/messages.h +++ b/src/messages.h @@ -20,9 +20,8 @@ const int MSG_MAXLEN = 2000; // PROBABLE safe dimension for msg buffers, for use //---- entry in msgTbl[] ---- struct MSGTBL -{ MH msgHan; // message handle: int 0 - 16384 as defined in msghans.h - char* msg; // pointer to message text associated with msgHan - // OR (use cast), in msgTbl read from disk text file, ULI file offset of text in message in file. +{ MH msgHan; // message handle: int 0 - 16384 as defined in msghans.h + const char* msg; // pointer to message text associated with msgHan }; /*--------------------------- PUBLIC VARIABLES ----------------------------*/ diff --git a/src/pgpak.cpp b/src/pgpak.cpp index b9933042d..fdc7ff67b 100644 --- a/src/pgpak.cpp +++ b/src/pgpak.cpp @@ -37,11 +37,11 @@ with arbitrary cursor moves and overwrites, then displayed/printed after fully p /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC FC pgralloce( char * *, SI, SI); LOCAL void FC pgsetup( char *, SI, SI); -LOCAL RC FC pgcleare( char * *, int erOp); +LOCAL RC FC pgcleare( char **, int erOp); LOCAL void FC pgerase( char **, SI); LOCAL SI FC pgGenrRc( SI, SI); -LOCAL USI pgcByto( char **ps, USI *pnMax, char *cods, SI bsF); // no FC: has check_stack -LOCAL USI FC pgcStrWid( char *s, USI nMax, SI bsF); +LOCAL USI pgcByto( const char **ps, USI *pnMax, const char* cods, SI bsF); // no FC: has check_stack +LOCAL USI FC pgcStrWid( const char *s, USI nMax, SI bsF); #if 0 // no calls in CSE, 11-91. use pgalloce. x //======================================================================== @@ -283,8 +283,8 @@ void FC pgw( // Write to a page in memory, no error return/options. */ SI row, SI col, /* 1-based row and column for first (normally), last (if right-justified) or center character. Each may be [PGMID for middle, PGEDGE for bottom / right, or] PGCUR+-n for current +- n. */ - char *s ) /* string to be written, or "" to just set curr row/col, or NULL to do NOTHING. - String is clipped at edges of page except see PGGROW. */ + const char *s ) // string to be written, or "" to just set curr row/col, or NULL to do NOTHING. + // String is clipped at edges of page except see PGGROW. { pgwe( ppp, fmt, row, col, s, ABT); @@ -299,7 +299,7 @@ RC FC pgwe( // Write to a page in memory, inner routine // position: PGRJ right justify; PGCNTR center; SI row, SI col, // 1-based row and column for first (normally), last (if right-justified) or center character. // Each may be PGCUR+-n for current +- n - char *s, // string to be written, or "" to just set curr row/col, or NULL to do NOTHING. + const char *s, // string to be written, or "" to just set curr row/col, or NULL to do NOTHING. // String is clipped at edges of page except see PGGROW. int erOp ) // error action, and option bit: // PGOPSTAY: restore "cursor" row-col afterward, @@ -494,7 +494,7 @@ void FC pgwrep( // Repeat write to a page in memory: used to draw lines, etc. SI col, /* col position for first char of string. Upper left corner is 1,1. Any portion of string which is outside page area is ignored except the page can grow at the bottom if PGGROW is included in fmt */ - char *s, // string write: will be repeated as required to achieve length len. + const char *s, // string write: will be repeated as required to achieve length len. SI len ) // Length of string to be written (max 132, not checked). { char stemp[134]; @@ -535,17 +535,16 @@ RC FC pgfille( // Copy text to a page in memory, handling word wrapping, with */ SI row, SI col, /* 1-based row and column for first character. Each may be PGCUR+-n for current +- n [or PGMID for middle, PGEDGE for bottom / right] */ - char *s, // Null terminated string to be written + const char *s, // Null terminated string to be written int erOp ) // WRN, ABT, etc to use if must enlarge page /* returns RCOK if ok, other value if error, e.g. out of memory, if not ABT. Note that original page must still be freed after error, and indeed may have been reallocated and *ppp updated. */ { - char *pp, *sw, *ew; SI colstart, wl, nbyHan; - pp = *ppp; // fetch page pointer + char* pp = *ppp; // fetch page pointer // leading newline options if (fmt & PGNLIF && PP->clw != 0) // newline if not at left { @@ -581,10 +580,10 @@ RC FC pgfille( // Copy text to a page in memory, handling word wrapping, with } // find start and end of word - sw = s; // init start word + const char* sw = s; // init start word while (isspaceW(*sw)) // pass white space (whitespace is sw++; // output with word unless we wrap) - ew = sw; // init end word + const char* ew = sw; // init end word while (!(isspaceW(*ew)) // pass word body: non-whitespace, && *ew // non-null characters, && !(*ew=='\\' && *(ew+1)=='n') ) // not \n @@ -660,7 +659,7 @@ RC FC pgfille( // Copy text to a page in memory, handling word wrapping, with } // pgfille //========================================================================= -LOCAL USI pgcByto( char **ps, USI *pnMax, char *cods, SI bsF) +LOCAL USI pgcByto( const char **ps, USI *pnMax, const char *cods, SI bsF) // bytes to next \ code in given list, plus \\ special treatment if bsF @@ -668,13 +667,13 @@ LOCAL USI pgcByto( char **ps, USI *pnMax, char *cods, SI bsF) // \x where x is in "cods", or non-leading \\: terminate // other \'s considered part of text -- \ and following char display { - char c, *s, *s0; - USI nMax, l, n; + char c; + USI n; - s = *ps; - nMax = *pnMax; // fetch args - s0 = s; // string start - l = (USI)strlen(s); // string length + const char* s = *ps; + USI nMax = *pnMax; // fetch args + const char* s0 = s; // string start + int l = strlenInt(s); // string length if (nMax > l) // give large nMax to use entire strlen nMax = l; // limit nMax to string length @@ -709,17 +708,17 @@ LOCAL USI pgcByto( char **ps, USI *pnMax, char *cods, SI bsF) // two other returns above } // pgcByto //========================================================================= -LOCAL USI FC pgcStrWid( char *s, USI nMax, SI bsF) +LOCAL USI FC pgcStrWid( const char *s, USI nMax, SI bsF) // string width: strlen less enhancement \ codes, stopping at nMax or at \n // if bsF, \\ is taken as 1 column { - char c, *s0; - USI l, n, wid; + char c; + USI n, wid; - s0 = s; // save start of string - l = (USI)strlen(s); // string length + const char* s0 = s; // save start of string + int l = strlenInt(s); // string length if (nMax > l) // give large nMax to use entire strlen nMax = l; // limit nMax to string length wid = nMax; // width is length if no \ codes diff --git a/src/pgpak.h b/src/pgpak.h index f9cbc391b..3c518c772 100644 --- a/src/pgpak.h +++ b/src/pgpak.h @@ -115,10 +115,10 @@ const int PGOPSTAY = EROP7; // restore "cursor" row-col after writing: so caller extern RC FC pgalloce( SI, SI, char * *, int erOp); extern void FC pgfree( char * *); extern void FC pgDelrows( char **ppp, SI row, SI nrows); -extern void FC pgw( char **, USI, SI, SI, char *); -extern RC FC pgwe( char **, USI, SI, SI, char *, int erOp); -extern void FC pgwrep( char **, USI, SI, SI, char *, SI); -extern RC FC pgfille( char * *, USI, SI, SI, char *, int erOp); +extern void FC pgw( char **, USI, SI, SI, const char *); +extern RC FC pgwe( char **, USI, SI, SI, const char *, int erOp); +extern void FC pgwrep( char **, USI, SI, SI, const char *, SI); +extern RC FC pgfille( char * *, USI, SI, SI, const char *, int erOp); extern SI FC pgnrows( char *,USI); extern SI FC pgcrow( char *); extern void FC pgputrc( char *, SI, SI, SI, SI *, SI *); diff --git a/src/pp.cpp b/src/pp.cpp index 8ac417d8f..fa738df1e 100644 --- a/src/pp.cpp +++ b/src/pp.cpp @@ -2390,10 +2390,9 @@ SI FC ppTok() // digit first: decode as integer - SI base; + int base; if (isdigitW(c)) { - LI tem; // set up re 0x, 0o prefixes if (c=='0' && c2=='x') // 0x: hex { @@ -2409,9 +2408,10 @@ SI FC ppTok() base = 10; // digits syntax and integer value loop + int tem; do { - tem = (LI)ppSival * (LI)base + (LI)(c-'0'); // SI value + tem = ppSival * base + (c-'0'); // value ppSival = (SI)(USI)tem; c = ppCDc(); // next token char if (!isalnumW(c)) // if not digit, or letter for hex @@ -2495,7 +2495,7 @@ SI FC ppTok() // reject random non-whitespace, non-printing characters now if (c < ' ' || c > '~') { - ppErr( (char *)MH_P0071, (UI)c); // "Ignoring illegal char 0x%x" + ppErr( (char *)MH_P0071, c); // "Ignoring illegal char 0x%x" goto reget; } // single: // 1-char cases may here or fall in diff --git a/src/rmkerr.cpp b/src/rmkerr.cpp index ed47d7956..5ff3c42de 100644 --- a/src/rmkerr.cpp +++ b/src/rmkerr.cpp @@ -227,13 +227,13 @@ RC errFileOpen( // close existing error message file, if any. recursion CAUTION: called from errI. if (errFile != NULL) { - LI len = -2L; - if (fseek( errFile, 0L, SEEK_END)==0) // position pointer to end, 0 if ok + int len = -2; + if (fseek( errFile, 0, SEEK_END)==0) // position pointer to end, 0 if ok len = ftell( errFile); // read file pointer, -1L if bad fclose( errFile); if (!IsBlank( erfName)) // if have saved name -- insurance { - if (len==0L) // if file is empty (no errors) + if (len==0) // if file is empty (no errors) std::remove(erfName); // erase file -- don't garbage up directory #ifdef OUTPNAMS //may be defined in cnglob.h. 10-93. else // file not erased, @@ -1093,13 +1093,13 @@ RC DbFileOpen( // close existing error message file, if any. recursion CAUTION: called from errI. if (dbgFile != NULL) { - LI len = -2L; - if (fseek( dbgFile, 0L, SEEK_END)==0) // position pointer to end, 0 if ok + long len = -2l; + if (fseek( dbgFile, 0l, SEEK_END)==0) // position pointer to end, 0 if ok len = ftell( dbgFile); // read file pointer, -1L if bad fclose( dbgFile); if (!IsBlank( dbFName)) // if have saved name -- insurance { - if (len==0L) // if file is empty + if (len==0l) // if file is empty unlink( dbFName); // erase file -- don't garbage up directory #ifdef OUTPNAMS //may be defined in cnglob.h. 10-93. else // file not erased, diff --git a/src/srd.h b/src/srd.h index 48f597e70..66d8c96c8 100644 --- a/src/srd.h +++ b/src/srd.h @@ -28,13 +28,13 @@ // data type table globals - but access using GetDttab(), below extern ULI Dttab[]; // dttab.cpp, generated by rcdef.exe -extern size_t Dttmax; // size (in LI's) of Dttab +extern size_t Dttmax; // size (in ULI's) of Dttab // structure for accessing data type table entry -// (Dttab may be constructed by rcdef.exe as array of LI, with subscript dt & DTBMASK, +// (Dttab may be constructed by rcdef.exe as array of ULI, with subscript dt & DTBMASK, // size in loword, # choices in hiword, char * choice text ptrs following.) struct DTTAB -{ // next two correspond to LOWORD and HIWORD, respectively, of LI Dttab[masked dt] +{ // next two correspond to LOWORD and HIWORD, respectively, of ULI Dttab[masked dt] SI size; // storage size of choice data type (2) SI nchoices; // # choices (incl hidden choices) <-- 0 (HIWORD) in non-choice type, cd use as choice type indicator. // next member corresponds to Dttab[dt+1...] @@ -52,14 +52,15 @@ inline const char* GetChoiceText( USI dt, USI chan) { return GetDttab(dt).choicb //-- expr() data types -- each type is different bit so can represent groups of types and test with 'and'. Data type USI. #define TYSI 0x01 // 16-bit integer (or BOOlean) #define TYFL 0x02 // float -#define TYNUM (TYSI|TYFL) // "any numeric data type" (test by and'ing) #define TYSTR 0x04 // string #define TYFLSTR (TYFL|TYSTR) // number (as float) or string, known at compile time. for CSE reportCol.colVal. #define TYID 0x08 // id: string; quotes implied around non-reserved identifier (for record names) at outer level #define TYCH 0x10 // choice (DTxxx must also be given): string or id, conv to 16/32 bit choicb/choicn value #define TYNC (TYFL|TYCH) // number (float) or specified 32 bit choicn choice, not necess known til runtime. // TYDOY day of year: def in cul.h; given to cuparse.cpp as TYSI, 2-91. -// 0x20-0x80 reserved for expansion of above +#define TYINT 0x20 // 32-integer +// 0x40-0x80 reserved for expansion of above +#define TYNUM (TYSI|TYINT|TYFL) // "any numeric data type" (test by and'ing) #define TYANY 0x1f // any value ok: 'or' of all of above // TYLLI 0x100 not used in cuparse: exman.cpp changes to TYSI. #define TYNONE 0x200 // no value (start of (sub)expression) @@ -68,7 +69,7 @@ inline const char* GetChoiceText( USI dt, USI chan) { return GetDttab(dt).choicb //-- exman.cpp:exPile data types -- #define TYLLI 0x100 // limited long integer: 16 bit value in 32 bit storage to support nan-flagging -//TYSI CAUTION cannot hold nan-flags, use TYLLI (with LI storage!) +//TYSI CAUTION cannot hold nan-flags, use TYLLI (with 32 bit storage!) // everywhere exman's runtime expressions are to be supported //TYSTR TYID TYFL TYCH TYNC as above // not used in exman.cpp: TYNUM, TYANY, TYNONE, ? TYDONE. diff --git a/src/sytb.cpp b/src/sytb.cpp index 98507ca0c..acf89506c 100644 --- a/src/sytb.cpp +++ b/src/sytb.cpp @@ -111,7 +111,7 @@ RC FC syAdd( SYTBH *st, SI tokTy, BOO casi, STBK* stbk, int op) return err( PWRN, (char *)MH_P0080); // display internal error msg "Sytb.cpp: bad call to syAdd" // returns RCBAD if (tokTy & ~TOKTYMASK) - return err( PWRN, (char *)MH_P0081, (UI)tokTy); // "Sytb.cpp: syAdd: tokTy 0x%x has disallowed hi bits" + return err( PWRN, (char *)MH_P0081, tokTy); // "Sytb.cpp: syAdd: tokTy 0x%x has disallowed hi bits" // enlarge allocation if nec (does initial alloc if st->p is NULL) if (st->n >= st->nAl) @@ -204,7 +204,7 @@ RC FC syDel( SYTBH *st, SI tokTy, BOO casi, [[maybe_unused]] BOO nearId, char *i // always issue message for this? err( PWRN, // display internal error msg (char *)MH_P0084, // "sytb.cpp:syDel(): bad call: token type / casi / nearId is 0x%x not 0x%x" - (UI)p->iTokTy, (UI)iTokTy ); + p->iTokTy, iTokTy ); return RCBAD; } diff --git a/src/tdpak.cpp b/src/tdpak.cpp index bec3839f4..56f51699c 100644 --- a/src/tdpak.cpp +++ b/src/tdpak.cpp @@ -18,7 +18,7 @@ // IDATE: struct {SI year; SI month; SI mday; SI wday; } // ITIME: struct {SI hour; SI min; SI sec; } // IDATETIME: struct {SI year; SI month; SI mday; SI wday; SI hour; SI min; SI sec; } -// LDATETIME: LI seconds from 1/1/70 +// LDATETIME: int seconds from 1/1/70 // 1-based: .month, .mday; // 0-based: .wday, .hour, .min, .sec.; typedef SI DOW. @@ -158,10 +158,10 @@ int tddMonLen( // length of month int iMon) // month (1 - 12) { return TdInfo.mlen[ iMon]; } //----------------------------------------------------------------------- -const char* tdldts( // Convert LI date/time to string +const char* tdldts( // Convert int date/time to string LDATETIME ldt, // Date/time to be converted (seconds from 1/1/70 (MSDOS)). - // Note: use envpak.cpp:ensysldt(), or msc library time(), to get current time in this format. + // Note: use envpak.cpp:ensysldt(), or msc library time(), to get current time in this format. char *s ) // NULL to use Tmpstr[], or buffer to receive string. // Returns s for convenience @@ -174,14 +174,13 @@ const char* tdldts( // Convert LI date/time to string return tddtis( &idt, s); // convert IDATETIME to string, this file } // tdldts //======================================================================= -void tdldti( // Convert LI date/time to integer year/month/day/hour/minute/second format +void tdldti( // Convert date/time to integer year/month/day/hour/minute/second format LDATETIME ldt, // Date/time to be converted (seconds from 1/1/70(MSDOS)). // Note: use envpak.cpp:ensysldt(), or msc library time(), to get current time in this format. IDATETIME *idt ) // Pointer to integer format date/time structure { struct tm *ptr; // msc time.h structure -// On PC, LDATETIME format is C Runtime LI format -- use library routine to convert ptr = localtime( &ldt); // msc library. adjust date/time for time zone and daylight, break up. idt->year = ptr->tm_year; // copy to members in our structure idt->month = ptr->tm_mon + 1; diff --git a/src/tdpak.h b/src/tdpak.h index 713cafade..62dec3f63 100644 --- a/src/tdpak.h +++ b/src/tdpak.h @@ -19,7 +19,7 @@ // IDATE: struct {SI year; SI month; SI mday; SI wday; } // ITIME: struct {SI hour; SI min; SI sec; } // IDATETIME: struct {SI year; SI month; SI mday; SI wday; SI hour; SI min; SI sec; } -// LDATETIME: LI seconds from 1/1/70 +// LDATETIME: seconds from 1/1/70 // 1-based: .month, .mday; // 0-based: .wday, .hour, .min, .sec.; typedef SI DOW. diff --git a/src/vrpak.cpp b/src/vrpak.cpp index 726176a9a..3892d1306 100644 --- a/src/vrpak.cpp +++ b/src/vrpak.cpp @@ -60,7 +60,7 @@ struct VRI int col; int row; // line #: on current page during spooling; on last page when spooling done. int row1; // # rows on first page if pageN > 1 - ULI o1, o2; // start and end offsets in spool file of vr's data, both -1L if no data in vr + UINT o1, o2; // start and end offsets in spool file of vr's data, both -1 if no data in vr }; //--------------------------------------------------------------------------- // once-only info on virtual reports and spool file: static, shared amoung vr files & fcns. @@ -71,19 +71,19 @@ struct SPL bool isOpen; // true iff spool file is open (possibly redundant) const char* splFName; // spool file name (is separate copy needed??) XFILE *splxf; // spool file - ULI spO; // spool file offset: curr ptr while writing, eof offset while reading. - ULI spWo; // offset to which written - any bytes after spWo not on disk yet. + UINT spO; // spool file offset: curr ptr while writing, eof offset while reading. + UINT spWo; // offset to which written - any bytes after spWo not on disk yet. RC vrRc; // nz iff previous error that must terminate vr scheme, such as i/o error on spool file. // Nops further calls. DO NOT SET on local errors that admit of continuation. // re virtual reports in spool file int sp_nVrh; // max used handle (vr subscript+1). handle 0 not used. - int sp_vrNal; // allocated size of vr + int sp_vrNal; // allocated size of vr VRI* sp_vr; // pointer to active VRI table in dm // re unspooling VROUTINFO* // unused report file (vrUnspool) argument info: voInfo; // ... points to NULL or VROUTINFO (vrpak.h) for next output file // each variable-length, 0-terminated VROUTINFO is followed by another or NULL. - ULI runO1, runO2; // min and max+1 spool file offsets of vr's in current run + UINT runO1, runO2; // min and max+1 spool file offsets of vr's in current run int uN; // number of uns[] entries in use int nFo; // number of open output files int maxFo; // nFo after which dos open error occurred: assume out of handles, do not exceed again. @@ -91,14 +91,14 @@ struct SPL char* p1; // start of data in buffer. code assumes always same as buf1. char* p; // read ptr / during write, points to start of item (for dropping) char* p2; // end of data+1 / write ptr - ULI bufO1, bufO2; // file offset of p1, p2 + UINT bufO1, bufO2; // file offset of p1, p2 // re spool file buffer (in dm) - static const ULI BUFSZ; // nominal size - ULI bufSz; // working size (BUFSZ-1) + static const UINT BUFSZ; // nominal size + UINT bufSz; // working size (BUFSZ-1) char* buf1; // start char* buf2; // end+1 }; // struct SPL -const ULI SPL::BUFSZ = 0xf000; // spool file buffer size +const UINT SPL::BUFSZ = 0xf000; // spool file buffer size // tested OK at 0x2800, 8-15 static SPL spl = { 0 }; // info about spool file, etc; points to VRI vr[] in dm. @@ -113,7 +113,7 @@ static RC vrErrIV( const char* file, const char* fcn, const char* mOrH, va_list static RC vrBufAl(); static RC vrBufLoad(); static RC vrBufMore(); -static RC dropFront( ULI drop); +static RC dropFront( UINT drop); //--------------------------------------------------------------------------------------------------------------------------- @@ -258,7 +258,7 @@ RC vrOpen( // open virtual report and return handle vr->pageN = 1; // 1-based for external display //vr->row1 = vr->row = vr->col = 0; // 0'd by memset above vr->spooling++; // say virtual report is open to receive text into spool - vr->o1 = vr->o2 = ULI(-1); // say no data in this vr yet + vr->o1 = vr->o2 = UINT(-1); // say no data in this vr yet *pVrh = vrh; // return handle @@ -314,14 +314,14 @@ RC vrIsFormatted( int vrh) // test if formatting is on for virtual report return ((vr->optn & VR_FMT) != 0); // TRUE if formatting option (vrpak.h) on } // vrIsFormatted //--------------------------------------------------------------------------------------------------------------------------- -int vrIsEmpty( int vrh) // test if any output yet in virtual report +bool vrIsEmpty( int vrh) // true iff no output yet in virtual report // used e.g. to write heading first time { VRI *vr; - if (vrCkHan( vrh, &vr)) // if bad handle or prior error (vrRc) - return 0; // return as though non-empty - return (vr->o2 <= vr->o1); // TRUE if end <= beginning + if (vrCkHan( vrh, &vr)) // if bad handle or prior error (vrRc) + return false; // return as though non-empty + return vr->o2 <= vr->o1; // TRUE iff end <= beginning } // vrIsEmpty //============================================================================= @@ -433,7 +433,7 @@ RC vrStrF( // output string to virtual report with format info option; inner f if (!*s) // if string length 0 return RCOK; // don't bother to write it if (incl) // not if text not going into buffer - if (int( vr->o1) < 0) // first time (preset to -1L) + if (vr->o1 == UINT( -1)) // first time (preset to -1) vr->o1 = spl.spO; // save spool offset of start of vr's data // write start-of-text stuff into spool @@ -541,7 +541,7 @@ LOCAL RC vrPut( // transmit n bytes to virtual report -- writes to vr spool fil if (spl.bufO2 != spl.spO) // if end of buffer is not write point { ASSERT( spl.spO==spl.spWo); // then end file must have been written to disk - dropFront( ULI( spl.p2 - spl.p1)); // write or discard entire buffer contents, update p,p1,p2, bufO1,2. vrpak3. + dropFront( spl.p2 - spl.p1); // write or discard entire buffer contents, update p,p1,p2, bufO1,2. vrpak3. spl.bufO1 = spl.bufO2 = spl.spO; // set offsets of empty buffer to those of file eof ASSERT( n < spl.buf2 - spl.p2); } @@ -651,7 +651,7 @@ struct UNS int optn; // option bit(s): VR_FMT (vrpak.h) on if page formatting on for this file int* vrhs; // ptr to 0-terminated list of handles (in a caller's arg or arg list) int vrh; // current/next handle - ULI o1, o2; // start and end+1 file offsets of vr's data in spool file, copied from spl.vr[vrh] + UINT o1, o2; // start and end+1 file offsets of vr's data in spool file, copied from spl.vr[vrh] int fStat; // out file status: -2: ready for next out file (start or prior closed); // -1: set up, ready to open; 0: ok, unspooling vr's; // > 0: ready to close and set to -2: 1: completed ok, 2: error (suppress final page formatting). @@ -691,7 +691,7 @@ LOCAL int vruNuHan( UNS* u); LOCAL int vruNuf( UNS* u); LOCAL int vruOpen( UNS* u); LOCAL RC unsRun( UNS* onlyU); -LOCAL int vrEvent( UNS* onlyU, ULI *pNxEv); +LOCAL int vrEvent( UNS* onlyU, UINT* pNxEv); LOCAL RC endVrCase( UNS* u); LOCAL int getWholeText( UNS* onlyU); LOCAL RC vruOut( UNS* u, char* s); @@ -1227,7 +1227,7 @@ LOCAL RC unsRun( // guts of pass over spool file. UNS* u0, * u, * un; SpoolTy ty; int vrh, txLen = 0; - ULI nxEv; + UINT nxEv; // onlyU must disable anything that could alter buffer or pointers, including reading more text. @@ -1270,7 +1270,7 @@ x (INT)onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName // read spool item - ty = (SpoolTy)(ULI)*(UCH *)spl.p++; // type of next item in buffer; avoid sign extension + ty = (SpoolTy)(UINT)*(UCH *)spl.p++; // type of next item in buffer; avoid sign extension vrh = *(int *)spl.p; spl.p += sizeof(int); // vr handle follows all ty's other than eof if (ty==vrBody || ty==vrFormat) // if text item (body or format) @@ -1327,14 +1327,14 @@ x (INT)onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName LOCAL int vrEvent( // process unsRun "event" if any and determine file offset of next event UNS* onlyU, // non-0 if caller unsRun is doing nested one-vr look-back catch-up call - ULI *pNxEv ) /* receives spool file offset of next "event" requiring attention here: - next offset at which a vr opens or closes. */ + UINT* pNxEv ) // receives spool file offset of next "event" requiring attention here: + // next offset at which a vr opens or closes. // returns non-0 to terminate run (no open vr's, or serious error) { UNS* u; - ULI bufOp = spl.bufO1 + (ULI)(spl.p - spl.p1); - ULI nxEv; + UINT bufOp = spl.bufO1 + (UINT)(spl.p - spl.p1); + UINT nxEv; // open & close vr's / count open vrs @@ -1433,7 +1433,7 @@ LOCAL RC endVrCase( UNS* u) // called from unsRun after end of vr u advanced to pSave = spl.p; p2Save = spl.p2; // save unspool buffer pointers spl.p2 = spl.p; - spl.p = spl.p1 + (ULI)(u->o1 - spl.bufO1); // set to process from start vr to curr posn only + spl.p = spl.p1 + (UINT)(u->o1 - spl.bufO1); // set to process from start vr to curr posn only u->did = 0; unsRun(u); // re-scan text to curr pos doing this one u only // nb 'onlyU' disables any buffer read or move. @@ -1468,7 +1468,7 @@ LOCAL int getWholeText( UNS* onlyU ) // read entire text into buffer, return it txLen = (spl.p2 - spl.p) - 1; // termination problem. truncate & continue. break; } - if ( ULI(spl.p2 - spl.p) > spl.bufSz - 1024) // min buf size - 1024 would be better -- uniformity + if ( UINT(spl.p2 - spl.p) > spl.bufSz - 1024) // min buf size - 1024 would be better -- uniformity { vrErr( "getWholeText", (char *)MH_R1222); // "text too long for spool file buffer" txLen = (spl.p2 - spl.p) - 1; // truncate @@ -1712,8 +1712,8 @@ LOCAL int addUsedFile( // add report/export file name to list tested by isUsedV /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL int bufCase(); LOCAL RC bufLoad( int cs); -LOCAL RC bufWrite( const char* p, ULI n); -LOCAL RC bufRead( ULI off, char* buf, ULI n, ULI *pnRead ); +LOCAL RC bufWrite( const char* p, UINT n); +LOCAL RC bufRead( UINT off, char* buf, UINT n, UINT *pnRead ); //----------------------------------------------------------------------------------------------------------------------------- RC vrBufAl() // allocate vr spool file buffer @@ -1771,13 +1771,13 @@ RC vrBufMore() // append additional data from spool file to unspool buffer if (nAv >= 2048) // ... but at least 2048 bytes n = nAv; // limit read to what will fit buffer -- defer copy-back. else // space is < n and < 2048 - dropFront( ULI( spl.p - spl.p1)); // discard data at start of buf to make room for read. + dropFront( UINT( spl.p - spl.p1)); // discard data at start of buf to make room for read. // Discard all text up to p to be at an item boundary. if (n > spl.buf2 - spl.p2) // again check space in buffer n = spl.buf2 - spl.p2; // must be small buffer, reduce read to fit // read - ULI nRead; + UINT nRead; if (bufRead( spl.bufO2, spl.p2, n, &nRead)) { // on i/o error reading spool, set buffer emtpy. bufRead has set vrRc. caller should terminate run. spl.p = spl.p1 = spl.p2 = spl.buf1; @@ -1808,7 +1808,7 @@ LOCAL int bufCase() // buffer load case-determiner { if (spl.bufO1 - spl.runO1 + 4096 > spl.bufSz) // more than buf len (less 4k) b4 text in buf return 0; // forget buf contents - if (LI(spl.bufO1 - spl.runO2) > min(LI(bufN),4096)) // if no overlap & if gap > # bytes in buf or 4K + if (int(spl.bufO1 - spl.runO2) > min(bufN,4096)) // if no overlap & if gap > # bytes in buf or 4K return 0; // forget buf contents // overlaps, or gap is small so read its text too in order to preserve rest of buffer contents return 1; // say read text from o1 to bufO1 in front of present text @@ -1823,7 +1823,7 @@ LOCAL int bufCase() // buffer load case-determiner // desired text starts after text in buffer if (spl.runO2 - spl.bufO1 > spl.bufSz) // if desired & present text won't all fit in buffer return 0; // forget buffer contents - if (spl.runO1 - spl.bufO2 > ULI( min( bufN, 4096))) // if gap is not small + if (spl.runO1 - spl.bufO2 > UINT( min( bufN, 4096))) // if gap is not small return 0; // forget buffer contents (rathar than reading text in gap) return 4; // read the gap (bufO2..o1) and some of desired text } // bufCase @@ -1844,7 +1844,7 @@ LOCAL RC bufLoad( int cs) // vr buffer loader inner function { // assumption: buf1 = p1 always. int N; - ULI n, nRead; + UINT n, nRead; switch (cs) { case0: @@ -1930,7 +1930,7 @@ LOCAL RC bufLoad( int cs) // vr buffer loader inner function return spl.vrRc; // set by bufRead/bufWrite on error } // bufLoad //----------------------------------------------------------------------------------------------------------------------------- -RC dropFront( ULI drop) // discard bytes from front of unspool buffer, set p to front of buffer +RC dropFront( UINT drop) // discard bytes from front of unspool buffer, set p to front of buffer { // write any unwritten bytes in data to be dropped if (spl.spWo < spl.bufO1 + drop) // if some of bytes to be dropped not on disk yet @@ -1953,7 +1953,7 @@ RC dropFront( ULI drop) // discard bytes from front of unspool buffer, set p to //----------------------------------------------------------------------------------------------------------------------------- LOCAL RC bufWrite( // write n bytes from p to file offset spl.spWo, update spWo const char* p, - ULI n) + UINT n) { if (spl.vrRc) // if already a fatal-to-unspool call error return spl.vrRc; // just return bad @@ -1969,7 +1969,7 @@ LOCAL RC bufWrite( // write n bytes from p to file offset spl.spWo, update spWo return spl.vrRc; } // bufWrite //----------------------------------------------------------------------------------------------------------------------------- -LOCAL RC bufRead( ULI off, char* buf, ULI n, ULI* pnRead ) // read into unspool buffer +LOCAL RC bufRead( UINT off, char* buf, UINT n, UINT* pnRead ) // read into unspool buffer // on error, sets spl.vrRc and returns RCBAD. { diff --git a/src/vrpak.h b/src/vrpak.h index 61b419ae3..4b6004ea1 100644 --- a/src/vrpak.h +++ b/src/vrpak.h @@ -63,7 +63,7 @@ RC FC vrClose( int vrh); int FC vrGetOptn( int vrh); RC FC vrChangeOptn( int vrh, int mask, int optn); RC FC vrIsFormatted( int vrh); -int FC vrIsEmpty( int vrh); +bool vrIsEmpty( int vrh); RC FC vrSetPage( int vrh, int pageN); int FC vrGetPage( int vrh); int FC vrGetLine( int vrh); diff --git a/src/wfpak.cpp b/src/wfpak.cpp index ab7ff4601..e41fe2e42 100644 --- a/src/wfpak.cpp +++ b/src/wfpak.cpp @@ -2219,7 +2219,7 @@ USI* WFILE::wf_PackedHrRead( // access an hour's packed data // returns pointer to hour's data, or NULL if error { // determine file offset of desired hour's data - LI hrOffset = wf_PackedHrOffset( jDay, iHr, erOp); + int hrOffset = wf_PackedHrOffset( jDay, iHr, erOp); if (!hrOffset) return NULL; @@ -2230,50 +2230,50 @@ USI* WFILE::wf_PackedHrRead( // access an hour's packed data erOp ); } // WFILE::wf_PackedHrRead //--------------------------------------------------------------------------- -LI WFILE::wf_PackedHrOffset( // determine file offset of an hour's packed data +int WFILE::wf_PackedHrOffset( // determine file offset of an hour's packed data int jDay, // Julian date 1-365 (or 366 if leap year), or month 1-12 with WF_DSNDAY option int iHr, // hour 0-23 int erOp /*=WRN*/ ) // msg control: WRN, IGN, etc (notcne.h/cnglob.h) // option bit(s) (wfpak.h): WF_DSNDAY: read hour from design day for month 1-12 in "jDay" argument. -// returns offset of hour's data, or 0L if error +// returns offset of hour's data, or 0 if error { - LI hrOffset; + int hrOffset; if (erOp & WF_DSNDAY) // if design day rather than regular simulation data { if (wFileFormat==BSGS || wFileFormat==BSGSdemo) { err( erOp, (char *)MH_R0107); // "Design Days not supported in BSGS (aka TMP or PC) weather files" - return 0L; + return 0; } // assume ET1 or later format if (jDay < 1 || jDay > 12) { err( erOp, (char *)MH_R0108, (int) jDay); /* "Program error in use of function wfPackedhrRead\n\n" " Invalid Month (%d) in \"jDay\" argument: not in range 1 to 12." */ - return 0L; + return 0; } if (firstDdm > lastDdm || lastDdm < 1) { err( erOp, (char *)MH_R0109, yac->pathName() ); // "Weather file \"%s\" contains no design days" - return 0L; + return 0; } if (jDay < firstDdm || jDay > lastDdm) { err( erOp, (char *)MH_R0110, jDay, // "Weather file contains no design day for month %d\n\n" yac->pathName(), // " (Weather file \"%s\" contains design day data only for months %d to %d)" - (int)firstDdm, - (int)lastDdm ); - return 0L; + firstDdm, + lastDdm ); + return 0; } // design days are AFTER the regular days hrOffset = hdrBytes // pass header - + hourBytes*( 24L *( jdl - jd1 + 1 // pass all regular hourly data + + hourBytes*( 24 *( jdl - jd1 + 1 // pass all regular hourly data + jDay - firstDdm ) // pass preceding months' design days + iHr ); // pass preceding hours this day (iHr 0-based) } else // not design day request -- normally - hrOffset = hdrBytes + ((jDay - jd1)*24L + iHr)*hourBytes; // offset of regular hourly data + hrOffset = hdrBytes + ((jDay - jd1)*24 + iHr)*hourBytes; // offset of regular hourly data return hrOffset; } // wfPackedOffset //============================================================================= diff --git a/src/xiopak.cpp b/src/xiopak.cpp index 9f968182d..d30fdde11 100644 --- a/src/xiopak.cpp +++ b/src/xiopak.cpp @@ -101,7 +101,7 @@ SEC FC xfrename( // Rename a file { sec = errno; err( erOp, // display message per erOp, rmkerr.cpp - (char *)(LI)MH_I0021, // "I0021: Unable to rename file '%s' to '%s':\n %s" + (char *)MH_I0021, // "I0021: Unable to rename file '%s' to '%s':\n %s" f1, f2, // filenames for message msgSec(sec)); // sec text for message (messages.cpp) } @@ -386,17 +386,17 @@ SEC FC xfwrite( // Write to a file //====================================================================== SEC FC xftell( // Return current file position with proper accounting of buffered characters - XFILE *xf, // Pointer to extended IO packet for file - LI *fpos) // Pointer to LI to receive current file position + XFILE* xf, // Pointer to extended IO packet for file + long* fpos) // Pointer to receive current file position -/* attempts ftell() call w/o regard to prior errors so should return pos even - on eofd file. */ +// attempts ftell() call w/o regard to prior errors so should return pos even +// on eofd file. /* Returns: SECOK if result is good. else other sec w/ *fpos = -1 (DOES NOT SET xf->xflsterr) */ { SEC sec; - LI pos = ftell(xf->han); /* get position at c library level */ + int pos = ftell(xf->han); /* get position at c library level */ if (pos == -1L) sec = xioerr(xf); /* report error, DON'T set xflsterr */ else @@ -411,7 +411,7 @@ SEC FC xftell( // Return current file position with proper accounting of buffe SEC FC xfseek( // Reposition file pointer XFILE *xf, /* Pointer to extended IO packet for file */ - LI disp, /* Byte displacement */ + long disp, /* Byte displacement */ int mode ) /* Mode (these are C library constants in stdio.h) -- SEEK_SET: disp is offset from beg of file SEEK_CUR: disp is offset from current position @@ -451,8 +451,8 @@ SEC FC xfseek( // Reposition file pointer //====================================================================== SEC FC xfsize( // Return the current size of a file - XFILE *xf, // Pointer to extended IO packet for file. Must be open. - uintmax_t *psize) // Current size of file + XFILE* xf, // Pointer to extended IO packet for file. Must be open. + uintmax_t* psize) // Current size of file // Returns SECOK if no errors; else other sec (DOES NOT set xf->xflsterr) { @@ -490,7 +490,7 @@ uintmax_t FC dskDrvFreeSpace() // returns total disk free space in bytes on cur //====================================================================== SEC FC xlsterr( // Retrieve and clear lsterr value for specified open file - XFILE *xf) // Pointer to extended IO packet for file + XFILE* xf) // Pointer to extended IO packet for file /* Returns SECOK if no errors have occurred on file xf, or errno of last error. *** lsterr value is reset to SECOK. *** */ @@ -505,7 +505,7 @@ SEC FC xlsterr( // Retrieve and clear lsterr value for specified open file } // xlsterr //====================================================================== void FC xeract( // Reset error and eof action codes for file xf - XFILE *xf, // Pointer to extended IO packet for file + XFILE* xf, // Pointer to extended IO packet for file int erOp, // New error action code for file: IGN, WRN, ABT, PWRN, PABT, etc (cnglobl.h) SI eoferr) // If TRUE, treat EOFs as errors @@ -800,7 +800,7 @@ RC FC xfcopy( // Copy a file if (xfs==NULL) { rc = MH_I0022; // "I0022: file '%s' does not exist" - mOrH = (char *)(LI)rc; + mOrH = (char *)rc; erArg = fns; } else @@ -812,7 +812,7 @@ RC FC xfcopy( // Copy a file strchr(accd, 'w')) // Check for a create file mode on ? MH_I0023 // "I0023: Unable to create file '%s'" : MH_I0024; // "I0024: File '%s' does not exist, cannot copy onto it" - mOrH = (char *)(LI)rc; + mOrH = (char *)rc; erArg = fnd; } else @@ -822,7 +822,7 @@ RC FC xfcopy( // Copy a file if (availspace < reqspace + 2048) { rc = MH_I0025; // "I0025: not enough disk space to copy file '%s'" - mOrH = (char *)(LI)rc; + mOrH = (char *)rc; erArg = fns; } else @@ -901,7 +901,7 @@ RC FC xfcopy2( // copy bytes from one file to another (inner xfcopy loop) if (rc && pMsg) // if err and caller wants msg *pMsg = msg( NULL, // retrieve msg w/ args in Tmpstr, messages.cpp - (char *)(LI)rc, // MH for err + (char *)rc, // MH for err fName, // arg: name of file w/ error msgSec(sec)); // arg: sec text, messages.cpp diff --git a/src/xiopak.h b/src/xiopak.h index 3e656e94e..f9c156548 100644 --- a/src/xiopak.h +++ b/src/xiopak.h @@ -97,14 +97,14 @@ const char * FC xgetdir( void); SEC FC xchdir( const char*, int erOp=WRN); RC FC xfGetPath( const char * *, int erOp=WRN); XFILE* xfopen( const char* fname, const char* access, int erOp=WRN, bool eoferr=false, SEC *psec=NULL); -SEC FC xfclose( XFILE **xfp, SEC *pCumSec=NULL); -SEC FC xfread( XFILE *, char *, USI); -SEC CDEC xfprintf( XFILE *, const char *, ... ); -SEC FC xfwrite( XFILE *, const char *, size_t); -SEC FC xftell( XFILE *, LI *); -SEC FC xfseek( XFILE *, LI, int mode); -SEC FC xfsize( XFILE *, LI*); -SEC FC xlsterr( XFILE *); +SEC FC xfclose( XFILE** xfp, SEC *pCumSec=NULL); +SEC FC xfread( XFILE* xf, char *, USI); +SEC CDEC xfprintf( XFILE* xf, const char *, ... ); +SEC FC xfwrite( XFILE* xf, const char* buf, size_t nbytes); +SEC FC xftell( XFILE* xf, long* fPos); +SEC FC xfseek( XFILE* xf, long disp, int mode); +SEC FC xfsize( XFILE* xf, uintmax_t* psize); +SEC FC xlsterr( XFILE* xf); RC FC xfcopy( const char *, const char *, const char*, SI); RC FC xfcopy2( XFILE *xfs, XFILE *xfd, int op, const char** pMsg); diff --git a/src/yacam.cpp b/src/yacam.cpp index a41ca9ec0..6a4249e91 100644 --- a/src/yacam.cpp +++ b/src/yacam.cpp @@ -757,13 +757,12 @@ int YACAM::scanLine( // scan file for line match } // YACAM::scanLine //--------------------------------------------------------------------------- // "control string" chars for YACAM::getLineCSV. Each letter uses a pointer from variable arg list -// I L F: short integer, long integer, float. +// I L F: 16-bit integer, 32-bit integer, float. // C: read quoted string to char[] array. Array size follows pointer in var arg list. // D: date, month and day, no year, leap year flag from caller // X: skip (data discarded, no pointer advance) // 1-99: repeat count for following char, using same pointer: for arrays or adjacent members of same type. //---------------------------------------------------------------------------- -#pragma optimize( "", off) // re bad va_arg code, 9-2010 RC YACAM::getLineCSV( // read, decode, and store data per control string int erOp, // error message control: IGN, WRN, etc per comments above; // and option bit(s) @@ -856,7 +855,7 @@ RC YACAM::getLineCSV( // read, decode, and store data per control string case 'C': // string to *p if (strlen( tok) >= size) // if too long, issue message, truncate, continue { errFlLn( "Overlong string will be truncated to %d characters (from %d):\n '%s'.", - (int)size-1, (int)strlen(tok), tok ); + (int)size-1, strlenInt(tok), tok ); tok[ size-1] = '\0'; // truncate; } strcpy( (char *)p, tok); // cannot overrun @@ -894,16 +893,16 @@ x else // has digit size = sizeof(float); } else // I or L: 16 or 32 bit integer - { LI v = strtol( tok, &pNext, 0); // convert to long. radix 0 --> respond to 0, 0x. + { long v = strtol( tok, &pNext, 0); // convert to long. radix 0 --> respond to 0, 0x. if (cc=='I') { if (v < -32768L || v > 32767L) rc = errFlLn( (char *)MH_I0115, tok); // cnd'l msg including "Integer too large: \"%s\"." - *(short *)p = (short)v; - size = sizeof(short); + *(SI*)p = SI(v); + size = sizeof(SI); } else // 'L' - { *(long *)p = v; - size = sizeof(long); + { *(INT *)p = INT( v); + size = sizeof(INT); } } // final syntax check: check for all input used @@ -929,8 +928,6 @@ x else // has digit return rc; } // YACAM::getLineCSV -//--------------------- -#pragma optimize( "", on) //----------------------------------------------------------------------------- RC YACAM::checkExpected( // check match to expected item const char* found, From a6ce06b3df57ce92b82ad602160413e113012592 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Mon, 14 Aug 2023 13:38:54 -0400 Subject: [PATCH 3/9] Debug WIP --- src/cncult.cpp | 4 ++-- src/cul.cpp | 3 +++ src/cuparse.cpp | 17 ++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/cncult.cpp b/src/cncult.cpp index d3d6c4a11..732b2a778 100644 --- a/src/cncult.cpp +++ b/src/cncult.cpp @@ -1122,7 +1122,7 @@ CULT( "rpDayBeg", DAT, RI_RPDAYBEG, 0, 0, VEOI, TYDOY, 0 CULT( "rpDayEnd", DAT, RI_RPDAYEND, 0, 0, VEOI, TYDOY, 0, 0, N, N), CULT( "rpBtuSf", DAT, RI_RPBTUSF, 0, 0, VEOI, TYFL, 0, 1.e6f, N, N), // show mBtu. Also in cncult4:addRep(). CULT( "rpCond", DAT, RI_RPCOND, 0, 0, VSUBHRLY|EVPSTIVL, // ok if evaluated at end interval - TYINT, // SI condition, dflt TRUE, in INT for NAN + TYINT, // condition, dflt TRUE, in INT for NAN 0, v 1L, N, N), CULT( "rpTitle", DAT, RI_RPTITLE, 0, 0, VEOI, TYSTR, 0, v 0, N, N), CULT( "rpCpl", DAT, RI_RPCPL, 0, 0, VEOI, TYSI, 0, -1, N, N), @@ -1165,7 +1165,7 @@ CULT( "exDayBeg", DAT, RI_RPDAYBEG, 0, 0, VEOI, TYDOY, CULT( "exDayEnd", DAT, RI_RPDAYEND, 0, 0, VEOI, TYDOY, 0, 0, N, N), CULT( "exBtuSf", DAT, RI_RPBTUSF, 0, 0, VEOI, TYFL, 0, 0, 1e6, N, N), // show mBtu. Also in cncult4:addRep(). CULT( "exCond", DAT, RI_RPCOND, 0, 0, VSUBHRLY|EVPSTIVL, // ok if evaluated post interval - TYINT, // SI condition, dflt TRUE, in INT for NAN + TYINT, // condition, dflt TRUE, in INT for NAN 0, v 1L,0.f, N, N), CULT( "exTitle", DAT, RI_RPTITLE, 0, 0, VEOI, TYSTR, 0, v 0, 0.f, N, N), CULT( "exHeader", DAT, RI_RPHEADER, 0, 0, VEOI, TYCH, 0, C_RPTHDCH_YES, N, N), diff --git a/src/cul.cpp b/src/cul.cpp index 475671aed..959733388 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -513,6 +513,7 @@ x trace = 1; } // compile + trace = 1; if (cs != 3) // unless just closing file. cases 0 and 4 have returned above. rv = culComp(); // compile, for cases 1 and 2. returns 1,2,3,4. just below. else @@ -2063,6 +2064,8 @@ LOCAL RC culDAT() // do cul DAT case per xSp other: non-fatal error, message issued, rest of input statement has been skipped, continue compilation. */ { + trace = 1; + // get '=' next if (tkIf(CUTEQ)==0) // if not = next return perNx( (char *)MH_S0231); // "'=' expected" diff --git a/src/cuparse.cpp b/src/cuparse.cpp index 6c7bab5f0..47e0453b3 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -1254,8 +1254,11 @@ RC FC expTy( EE(emit(PSFLOAT)) // convert int to float. konstize below converts constant if constant. parSp->ty = TYFL; // now have a float } +#if 0 +may need to add SI -> INT conversion? ?TYINT? else if (wanTy & TYINT) parSp->ty = TYINT; +#endif break; //case TYFL: // if (wanTy & TYSI) possibly convert to int, or perhaps only if integral. Also do for TYNC after PSNCN @@ -1814,7 +1817,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? // on arrival here, has been parsed and '?' seen. { - ERVARS1 SI isK, v; USI aWanTy, ty1, ty2; + ERVARS1 SI isK, v; ERSAVE // re condition (expression before ?, already parsed) @@ -1832,9 +1835,9 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? // then-expr. Any type value ok. NB prec of ':' is prec of '?' - 1. #ifdef FLWANT - aWanTy = (wanTy & (TYID|TYCH|TYSI)) | (TYANY & ~(TYID|TYCH|TYSI)); // messy type bits feed thru to then-expr and else-expr + USI aWanTy = (wanTy & (TYID|TYCH|TYSI|TYINT)) | (TYANY & ~(TYID|TYCH|TYSI|TYINT)); // messy type bits feed thru to then-expr and else-expr #else -* aWanTy = (wanTy & (TYID|TYCH)) | (TYANY & ~(TYID|TYCH)); // messy type bits feed thru to then-expr and else-expr +* USI aWanTy = (wanTy & (TYID|TYCH)) | (TYANY & ~(TYID|TYCH)); // messy type bits feed thru to then-expr and else-expr #endif EE( expTy( prec-1, aWanTy, ttTx, 0)) // get value, new parStk frame. EXPECT( CUTCLN, ":") // error if colon not next @@ -1854,8 +1857,8 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? EE( tconv(2, &aWanTy) ) /* emit code to convert 2 values to same type, if possible. May convert either stack frame; knows about unfilled jmps at end (0xffff)*/ // type compatibility check/message is here for context-specific message format - ty1 = (parSp-1)->ty; - ty2 = parSp->ty; + USI ty1 = (parSp-1)->ty; + USI ty2 = parSp->ty; if (ty1 != ty2 && (ty1|ty2) != TYNC) // types must be same or combined type must be TYNC -- only 2-bit type allowed { rc = perNx( (char *)MH_S0033, // "Incompatible expressions before and after ':' -- \n cannot combine '%s' and '%s'" @@ -3892,8 +3895,8 @@ LOCAL RC FC emiLod( USI ty, void *p) // emit code to load datum of type ty from case TYSI: EE( emit(PSLOD2) ) break; - case TYSTR: // get a char *. >> need to duplicate string storage? - /*lint -e616 case falls in*/ + case TYSTR: // get a CULSTR. >> need to duplicate string storage? + case TYINT: case TYFL: EE( emit(PSLOD4) ) break; From f3a21b6b123004f4b0e0d5e4e179ea915a1f1653 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Tue, 15 Aug 2023 16:02:12 -0400 Subject: [PATCH 4/9] TYINT expression support; all tests pass --- src/cueval.cpp | 6 ++ src/cueval.h | 1 + src/cul.cpp | 3 +- src/cuparse.cpp | 228 +++++++++++++++++++++------------------ src/cuparsex.h | 6 +- src/cuprobe.cpp | 10 +- test/actest1bL.cse | 2 - test/ref/ACTEST1BL.REP | 22 ++-- test/ref/ASHPPKGROOM.REP | 24 ++--- 9 files changed, 163 insertions(+), 139 deletions(-) diff --git a/src/cueval.cpp b/src/cueval.cpp index 9dc779f8e..5f52324a7 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -368,6 +368,12 @@ made things worse TODO (MP) *SPF = (float)siTem; break; + case PSINT: + siTem = *SPI; + SPC += sizeof(SI) - sizeof(INT); + *SPL = INT(siTem); + break; + case PSIBOO: *SPI = (*SPI != 0); break; // make any non-0 a 1 diff --git a/src/cueval.h b/src/cueval.h index 4ac43995d..6dfd88e7f 100644 --- a/src/cueval.h +++ b/src/cueval.h @@ -66,6 +66,7 @@ PSPOP4, // discard 4 bytes (float or string pointer) (ditto) // conversions PSFIX, // float to SI PSFLOAT, // SI to float +PSINT, // SI to INT PSIBOO, // SI to "boolean": make any non-0 a 1 PSSCH, // string to choicb or choicn. char * on stack, DTxxx (Dttab[]/dtypes.h) data type follows. PSNCN, // number-choice to number, ie error if contains choice diff --git a/src/cul.cpp b/src/cul.cpp index 959733388..2ec85bbaf 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -513,7 +513,7 @@ x trace = 1; } // compile - trace = 1; + // trace = 1; if (cs != 3) // unless just closing file. cases 0 and 4 have returned above. rv = culComp(); // compile, for cases 1 and 2. returns 1,2,3,4. just below. else @@ -2064,7 +2064,6 @@ LOCAL RC culDAT() // do cul DAT case per xSp other: non-fatal error, message issued, rest of input statement has been skipped, continue compilation. */ { - trace = 1; // get '=' next if (tkIf(CUTEQ)==0) // if not = next diff --git a/src/cuparse.cpp b/src/cuparse.cpp index 47e0453b3..de61a7b3d 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -24,8 +24,8 @@ // possible probe that errors if NC is not numeric (combine probe & convert for specific err msg) // possible probe codes to get numeric or choice values or issue specific error messages; use in cnvPrevSf. // fcnArgs MA type-matching switch probably unneeded -- default does it all now? -// insurance: isKE should identify constants for TYNC, and return type TYCH or TYFL -// ---> konstize can change parSp->ty, or isKE/konstize ty return path so caller changes. review calls. +// insurance: isKonExp should identify constants for TYNC, and return type TYCH or TYFL +// ---> konstize can change parSp->ty, or isKonExp/konstize ty return path so caller changes. review calls. // nb TYCH intended to accept DTCHOICN's even without TYFL. @@ -667,7 +667,7 @@ LOCAL RC FC fcnImport( SFST *f); LOCAL RC FC fcnReg( SFST *f, USI wanTy); #endif LOCAL RC FC fcnChoose( SFST *f, USI wanTy); -LOCAL RC FC fcnArgs( SFST *f, SI nA0, USI wanTy, USI optn, USI *pa1Ty, SI *pnA, SI *pDefa, SI *pisK, SI *pv); +LOCAL RC FC fcnArgs( SFST *f, SI nA0, USI wanTy, USI optn, USI *pa1Ty, SI *pnA, SI *pDefa, SI *pisKon, SI *pv); #if defined(LOKFCN) || defined(LOCSV) LOCAL RC FC emiFcn( SFST *f, SI onLeft, USI a1Ty); #else @@ -682,11 +682,11 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy); LOCAL RC FC uFcn( UFST *stb ); LOCAL SI FC dumVar( SI toprec, USI wanTy, RC *prc); LOCAL RC FC var( UVST *v, USI wanTy); -LOCAL RC FC expSi( SI toprec, SI *pisK, SI *pv, char *tx, SI aN); -LOCAL RC FC convSi( SI *pisK, SI *pv, SI b4, char *tx, SI aN); +LOCAL RC FC expSi( SI toprec, SI *pisKon, SI *pv, char *tx, SI aN); +LOCAL RC FC convSi( SI* pisKon, SI *pv, SI b4, char *tx, SI aN); LOCAL RC FC tconv( SI n, USI *pWanTy); LOCAL RC FC utconvN( SI n, char *tx, SI aN); -LOCAL SI FC isKE( void **ppv); +LOCAL SI FC isKonExp( void **ppv); LOCAL USI FC cleanEvf( USI evf, USI _evfOk); LOCAL RC FC cnvPrevSf( SI n, PSOP op1, PSOP op2); LOCAL RC FC movPsLastN( SI nFrames, SI nPsc); @@ -989,7 +989,7 @@ RC FC exOrk( // compile expression from current input file, return constant valu const char *ermTxPar, // NULL or text describing preceding verb etc for err msgs USI *pGotTy, // NULL or receives data type found (useful eg when TYFLSTR requested) USI *pEvf, // receives cleaned evaluation frequency bits - SI *pisK, // receives non-0 if expression is constant + SI *pisKon, // receives non-0 if expression is constant void *pvPar, // if constant, rcvs value, <= 4 bytes (ptr if TYSTR), else not changed -- caller may pre-store nandle. // RECEIVES 4 BYTES even for SI or 2-byte choice value (caller truncates). PSOP **pip ) // rcvs ptr to code in dm (if not constant) else NULL @@ -1018,7 +1018,6 @@ RC FC exOrk( // compile expression from current input file, return constant valu // compile expression USI gotTy{ wanTy }; // init vars in case expTy returns error USI gotEvf{ 0 }; - SI isK{ 0 }; Eer( expTy( toprec, wanTy, ermTx, 0) ) // compile expr of type 'wanTy'. Parse to token of precedence <= 'toprec'. // Ungets terminating token. Below. Errors go to 'er:' (expTy issues msgs). gotTy = parSp->ty; // type found @@ -1028,13 +1027,14 @@ RC FC exOrk( // compile expression from current input file, return constant valu // determine if constant void* pv; - Eer( konstize( &isK, &pv, 0 ) ) // evals if evaluable and un-eval'd. Rets flag and ptr (ptr to ptr for TYSTR). below. + SI isKon{ 0 }; + Eer( konstize( &isKon, &pv, 0 ) ) // evals if evaluable and un-eval'd. Rets flag and ptr (ptr to ptr for TYSTR). below. USI codeSize; Eer( finPile( &codeSize) ) // now terminate compilation / get size // for constant, return value and no code - ULI v = 0; - if (isK) // if konstize found (or made) a constant value + ULI v = 0; // TODO64 -- ULI? + if (isKon) // if konstize found (or made) a constant value { // fetch from konstize's storage, condition value if (gotTy == TYSTR) // pv points to ptr to text @@ -1059,7 +1059,7 @@ RC FC exOrk( // compile expression from current input file, return constant valu } // not constant: store and return pseudo-code - else // isK==0 + else // isKon==0 { Eer( dmal( DMPP( ip), codeSize, WRN) ) // alloc dm space, dmpak.cpp memcpy( ip, ps, codeSize); // put pseudocode in the space @@ -1077,9 +1077,9 @@ RC FC exOrk( // compile expression from current input file, return constant valu if (rc != RCOK) { er: // Eer macro comes here on non-RCOK fcn return - isK = 1; // say is constant (ret *pisK) + isKon = 1; // say is constant (ret *pisKon) if (gotTy==TYSTR) // gotTy init to wanTy above - v = (ULI)""; // for string return null string + v = (ULI)""; // for string return null string TODO64 -- ULI? else v = 0L; // for float or int return zero // ip = NULL preset above. gotEvf=0 init. @@ -1090,13 +1090,13 @@ RC FC exOrk( // compile expression from current input file, return constant valu *pGotTy = gotTy; // return actual type gotten; useful eg if TYFLSTR requested. if (pEvf) // evaluation frequency bits return *pEvf = gotEvf; // 0, or parSp->evf cleaned above - if (pisK) - *pisK = isK; // non-0 if already-evaluated constant + if (pisKon) + *pisKon = isKon; // non-0 if already-evaluated constant if (pip) *pip = ip; // NULL or pointer to pseudo-code - if (isK) // *pvPar left unchanged if non-constant + if (isKon) // *pvPar left unchanged if non-constant if (pvPar) - *(ULI*)pvPar = v; // value + *(ULI*)pvPar = v; // value -- TODO64 ULI? return rc; #undef Eer @@ -1152,17 +1152,14 @@ RC FC finPile( USI *pCodeSize) //========================================================================== RC FC expTy( SI toprec, - USI wanTy, // desired type. see exOrk() above for list of externally originated types. - // addl internally originated type combinations incl at least TYNUM and TYANY&~TYSI - const char* tx, - SI aN ) + USI wanTy, // desired type. see exOrk() above for list of externally originated types. + // addl internally originated type combinations incl at least TYNUM and TYANY&~TYSI + const char* tx, // NULL or text of verb / operator, for "after 'xxx'" in error messages + SI aN ) // 0 or fcn arg number, for error messages // parse/compile expression/statement of given type to current destination, // including resultant type check and conversions -// tx: NULL or text of verb/operator, for "after 'xxx'" in error messages -// aN: 0 or fcn arg number, for error messages - // caller must preset: parSp, psp (call iniPile() first). // on return, entry added to parStk describes result. { @@ -1249,16 +1246,16 @@ RC FC expTy( //break; case TYSI: - if (wanTy & TYFL) // includes wanTy==TYNC + if (wanTy & TYINT) // test for TYINT before TYFL { - EE(emit(PSFLOAT)) // convert int to float. konstize below converts constant if constant. - parSp->ty = TYFL; // now have a float + EE(emit(PSINT)) // convert SI to INT. konstize below converts constant if constant. + parSp->ty = TYINT; + } + else if (wanTy & TYFL) // includes wanTy==TYNC + { + EE(emit(PSFLOAT)) // convert SI to float. konstize below converts constant if constant. + parSp->ty = TYFL; // now have a float } -#if 0 -may need to add SI -> INT conversion? ?TYINT? - else if (wanTy & TYINT) - parSp->ty = TYINT; -#endif break; //case TYFL: // if (wanTy & TYSI) possibly convert to int, or perhaps only if integral. Also do for TYNC after PSNCN @@ -1343,8 +1340,7 @@ LOCAL RC expr( // parse/compile inner recursive fcn switch (opp->cs) { - OPTBL *svOpp; - SI isK1, isK2, v1, v2; + OPTBL* svOpp; // every case must update as needed: parSp->ty, evf, did; and prec = operand if not always covered. @@ -1378,22 +1374,25 @@ LOCAL RC expr( // parse/compile inner recursive fcn do not eval 2nd arg (branch around it) if first is conclusive; eliminate unneeded code when args are constant. */ case CSLEO: - EE( convSi( &isK1, &v1, 1, ttTx, 0) ) // check/konstize value b4 & convert to int - EE( emit(opp->v1) ) // PSJZP for &&, PSJNZP for || - EE( emit(0xffff) ) // offset (displacment) space + { + SI isK1, isK2, v1, v2; + OPTBL* svOpp; + EE(convSi(&isK1, &v1, 1, ttTx, 0)) // check/konstize value b4 & convert to int + EE(emit(opp->v1)) // PSJZP for &&, PSJNZP for || + EE(emit(0xffff)) // offset (displacment) space svOpp = opp; // save thru expTy - EE( expSi( prec, &isK2, &v2, ttTx, 0) ) // value after: get int expr, konstize + EE(expSi(prec, &isK2, &v2, ttTx, 0)) // value after: get int expr, konstize if (isK1) // if 1st expr was constant { /* get rid of non-significant argument: * if arg 1 is && || * 0 drop arg 2 drop arg 1 * nz drop arg 1 drop arg 2 */ - EE( dropSfs( /* delete parStk frame(s)+code */ + EE(dropSfs( /* delete parStk frame(s)+code */ (v1 != 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2), */ /* 1: drop top-1 frame (arg 1) */ - 1 ) ) // drop 1 frame - EE( dropJmpIf() ) // delete arg 1 trailJmp + 1)) // drop 1 frame + EE(dropJmpIf()) // delete arg 1 trailJmp } else if (isK2) // if 2nd expr contant { @@ -1401,20 +1400,21 @@ LOCAL RC expr( // parse/compile inner recursive fcn * if arg 2 is && || * 0 drop arg 1 drop arg 2 * nz drop arg 2 drop arg 1 */ - EE( dropSfs( /* delete parStk frame(s)+code */ - (v2==0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2) */ + EE(dropSfs( /* delete parStk frame(s)+code */ + (v2 == 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2) */ /* 1: drop top-1 frame (arg 1) */ - 1 ) ) // drop 1 frame - EE( dropJmpIf() ) // delete arg 1 trailJmp + 1)) // drop 1 frame + EE(dropJmpIf()) // delete arg 1 trailJmp } else // neither arg constant, keep both { - EE( fillJmp(1) ) // set offset of jmp (end PREV parStk frame) to jmp here - EE( combSf() ) // combine code after & b4 + EE(fillJmp(1)) // set offset of jmp (end PREV parStk frame) to jmp here + EE(combSf()) // combine code after & b4 } - EE( emit(PSIBOO) ) // make any nz a 1 - EE( konstize( NULL, NULL, 0) ) // constize to combine PSIBOO - break; + EE(emit(PSIBOO)) // make any nz a 1 + EE(konstize(NULL, NULL, 0)) // constize to combine PSIBOO + } + break; // grouping operators: (, [ @@ -1817,12 +1817,12 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? // on arrival here, has been parsed and '?' seen. { - ERVARS1 SI isK, v; + ERVARS1 SI isKon, v; ERSAVE // re condition (expression before ?, already parsed) - EE( convSi( &isK, &v, 1, ttTx, 0) ) // check/konstize preceding value & convert it to int - if (!isK) // if condition not constant + EE( convSi( &isKon, &v, 1, ttTx, 0) ) // check/konstize preceding value & convert it to int + if (!isKon) // if condition not constant { // after condition, branch if false to else-expr EE( emit(PSPJZ) ) // emit branch-if-zero (false) op code @@ -1841,7 +1841,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? #endif EE( expTy( prec-1, aWanTy, ttTx, 0)) // get value, new parStk frame. EXPECT( CUTCLN, ":") // error if colon not next - if (!isK) + if (!isKon) { // after then-expr, unconditional branch around else expr EE( emit(PSJMP) ) // append unconditional branch to then-expr @@ -1849,7 +1849,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? } // now set offset of branch after condition: come here, to do else-expr - if (!isK) // if condition done at runtime + if (!isKon) // if condition done at runtime EE( fillJmp(1) ) // sets offset of branch at end PREVIOUS parStk frame to current psp value // else-expression, conversions to make exprs same type, check @@ -1865,7 +1865,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? datyTx(ty1), datyTx(ty2) ); goto er; // in ERREX macro } - if (isK) // if condition constant (value in 'v') + if (isKon) // if condition constant (value in 'v') { // DELETE dead code that never needs to be executed with constant condition EE( dropSfs( 2, 1) ) // delete condition expression @@ -1966,12 +1966,12 @@ LOCAL RC FC fcnImport( SFST *f) // first argument: name of ImportFile object. // cuparse seems to have no intended support for contants, but expTy then konstize should work. 2-94. CSE_E( expTy( PRCOM, TYID, (char *)f->id, 1) ) // get TYID (similar to TYSTR) expr for 1st argument. makes parStk frame. - SI isK; // receives TRUE if konstize detects or makes constant + SI isKon; // receives TRUE if konstize detects or makes constant void *pv; // receives pointer to const value (ptr to ptr for TYSTR) // (search EMIKONFIX re correcting apparent bug in ptr ptr return 2-94) - CSE_E( konstize( &isK, &pv, 0) ) /* test expression just compiled: detect constant value; + CSE_E( konstize( &isKon, &pv, 0) ) /* test expression just compiled: detect constant value; else evaluate now to make constant value if possible. */ - if (!isK) // if not contant (and could not be make constant) + if (!isKon) // if not contant (and could not be make constant) return perNx( (char *)MH_S0123, /* "S0123: %s argument %d must be constant,\n" " but given value varies %s" */ (char *)f->id, // cast near ptr to far @@ -1990,8 +1990,8 @@ LOCAL RC FC fcnImport( SFST *f) CSE_E( expTy( PRCOM, TYSI|TYID, (char *)f->id, 2) ) // get integer, identifier (returns TYSTR) or string expr for 2nd argument #endif BOO byName = parSp->ty==TYSTR; // TYSI is by field number. Others should not return. - CSE_E( konstize( &isK, &pv, 0) ) // detect or make constant value if possible - if (!isK) // if not constant + CSE_E( konstize( &isKon, &pv, 0) ) // detect or make constant value if possible + if (!isKon) // if not constant return perNx( (char *)MH_S0123, /* "S0123: %s argument %d must be constant,\n" " but given value varies %s" */ (char *)f->id, // cast near ptr to far @@ -2165,7 +2165,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- // wanTy: TYID and TYCH bits feed thru when parsing value expressions. { - USI aTy, optn; SI nA0=0, haveIx=0, isK=0, v, nA, defa, nAnDef, base, i; RC rc; + USI aTy, optn; SI nA0=0, haveIx=0, isKon=0, v, nA, defa, nAnDef, base, i; RC rc; if (tokeNot(CUTLPR)) // pass '(' after fcn name return perNx( (char *)MH_S0038, (char *)f->id ); // "'(' missing after built-in function name '%s'". cast f->id to far. @@ -2184,7 +2184,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- parSp->ty = TYSI; // (probably unnec to set) parSp->evf |= EVFHR; // hour changes hourly: don't constize haveIx = 1; // have index expr in parStk - //isK = 0; // not a constant index + //isKon = 0; // not a constant index } else if (f->f & F2) // select(): no index argument { @@ -2193,9 +2193,9 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- } else // choose(), choose1(): integer index expression { - CSE_E( expSi( PRCOM, &isK, &v, f->id, 1) ) // get int expr and konstize + CSE_E( expSi( PRCOM, &isKon, &v, f->id, 1) ) // get int expr and konstize #ifndef RUNT - if (isK) // if index constant + if (isKon) // if index constant optn &= ~16; /* don't default the default in fcnArgs: our msg below is better than PSCHUFAI done out of context by konstize below. 10-90, 2-91.*/ #endif @@ -2213,7 +2213,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- wanTy, /* messy parsing bits may feed thru to value expressions */ optn, /* options set above */ &aTy, &nA, &defa, /* return info. defa 0,1,2. */ - &isK, &v ) ) // only set for select (optn 8) + &isKon, &v ) ) // only set for select (optn 8) nAnDef = nA - (defa != 0); // compute # args less default // error message for left side use if (tokeIf(CUTEQ)) // "=" after ")" (else unget) ? @@ -2226,7 +2226,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- else if (nAnDef > 24) // > 24 args gets warning pWarnlc( (char *)MH_S0042); // "hourval() arguments in excess of 24 will be ignored" - if (isK) // if constant index (1) or select all cond false (-1) + if (isKon) // if constant index (1) or select all cond false (-1) { // Delete all code but the one value expr selected by the constant index @@ -2281,7 +2281,7 @@ o v = nAnDef; // use default (nA-1) // constantize and combine with preceding code - CSE_E( konstize( NULL, NULL, 0) ) // eval now if possible. usually redundant due to isK stuff above. + CSE_E( konstize( NULL, NULL, 0) ) // eval now if possible. usually redundant due to isKon stuff above. CSE_E( combSf() ) // combine with preceding stack frame // notes: @@ -2305,13 +2305,13 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som USI *paTy, // rcvs type of arg 1 (or all args if MA), for use re arg-dependent code emission and/or result type SI *pnA, // rcvs # args (or pairs) parsed here. excl nA0, incl default SI *pDefa, // rcvs 1 if "default" preceded last arg, 2 if dflt dflt gen'd (runtime errmsg), else 0 - SI *pisK, SI *pv ) /* set for select (optn 8 only) a la choose index: - *pisK = nz if known which val-expr will be used; + SI *pisKon, SI *pv ) /* set for select (optn 8 only) a la choose index: + *pisKon = nz if known which val-expr will be used; *pv = 0-based index (arg #) of that expr (nA if all false: default or error, 2-91) */ { //ERVARS //<--- believe unnec here becuase caller fcn() does. 10-90 - SI aN=0, uAN=0, nSF=0, defdef=0, selC=0, isK=-1, v=0; - SI tisK=0, tv=0; // isK and v for current select() condExpr + SI aN=0, uAN=0, nSF=0, defdef=0, selC=0, isKon=-1, v=0; + SI tisK=0, tv=0; // isKon and v for current select() condExpr USI aTy=TYNONE, aWanTy=0, defa=0; RC rc; @@ -2356,15 +2356,15 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som selC++; // say have select cond-expr -- complete arg pair after val-expr. } // return info on constant conditions in choose-index format - if (isK < 0) // if active val-expr not yet determined (ie all false constants to here) + if (isKon < 0) // if active val-expr not yet determined (ie all false constants to here) { if (tisK==0) // if this cond-expr not constant - isK = 0; // cannot know active val-expr til run + isKon = 0; // cannot know active val-expr til run else if (tv==0) // if constant 0 ; // no change, keep looking else // const non-0, preceded by const 0s if here { - isK = 1; // say DO know which val-expr will be used + isKon = 1; // say DO know which val-expr will be used v = aN-1; // 0-based index of that val-expr, for caller } } @@ -2416,7 +2416,7 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som && !defa // if no default given by user && f->op2 // if table has def def code #ifndef RUNT // remove to use konstize's msg not fcnChoose's - && !(optn & 8 && isK < 0) /* not if all select condExprs + && !(optn & 8 && isKon < 0) /* not if all select condExprs const 0: fcnChoose does better ermMsg */ #endif ); @@ -2599,11 +2599,11 @@ x break; *pDefa = defa; // 2 if default default generated, else 0 if (optn & 8) // ret info on const cond's for select() { - if (pisK) - *pisK = isK; // 0 unknown, 1 known, -1 all cond 0: default/error + if (pisKon) + *pisKon = isKon; // 0 unknown, 1 known, -1 all cond 0: default/error if (pv) - *pv = isK >= 0 // < 0 all cond 0, 0 non-const cond, - ? v // isK > 0: 0-based idx of expr with true cond + *pv = isKon >= 0 // < 0 all cond 0, 0 non-const cond, + ? v // isKon > 0: 0-based idx of expr with true cond : aN; // all false: out of range to tell fcnChoose to use default, error if !defa } return RCOK; @@ -2939,11 +2939,13 @@ LOCAL RC FC var([[maybe_unused]] UVST *f, [[maybe_unused]] USI wanTy) // parse LOCAL RC FC expSi( // get an integer expression for a condition. accepts & fixes floats, konstizes, returns info. SI toprec, // precedence to which to parse -- eg PRCOM - // *pisK and *pv receive info for code optimization by elminating conditional code when condition is constant. - SI *pisK, // NULL or receives non-0 if is constant - SI *pv, // NULL or receives value if constant + SI *pisKon, // NULL or receives non-0 if is constant + SI *pv, // NULL or receives value if constant char *tx, // text of preceding operator or fcn name, for errMsgs SI aN ) // 0 or fcn argument number, for errMsgs + +// *pisKon and *pv receive info for code optimization by elminating conditional code when condition is constant. + { RC rc; @@ -2951,19 +2953,22 @@ LOCAL RC FC expSi( // get an integer expression for a condition. accepts & fix CSE_E( expTy( toprec, TYNUM, tx, aN) ) // convert it to int if float (error if string), test if constant - return convSi( pisK, pv, 0, tx, aN); + return convSi( pisKon, pv, 0, tx, aN); } // expSi //========================================================================== LOCAL RC FC convSi( // convert last expr to int, else issue error. konstizes. - // *pisK and *pv receive info for code optimization by elminating conditional code when condition is constant - SI *pisK, // NULL or receives non-0 if is constant + SI* pisKon, // NULL or receives non-0 if is constant SI *pvPar, // NULL or receives value if constant SI b4, // for errMsgs: 1 if expr b4 ; 0 expr after; moot if aN. char *tx, // text of preceding operator or fcn name, for errMsgs SI aN ) // 0 or fcn argument number, for errMsgs + +// *pisKon and *pv receive info for code optimization by eliminating conditional code when condition is constant + + { - RC rc; SI isK; void *pv; + RC rc = RCOK; switch (parSp->ty) { @@ -2978,13 +2983,16 @@ LOCAL RC FC convSi( // convert last expr to int, else issue error. konstizes. default: return perNx( (char *)MH_S0060, b4 ? before(tx,aN) : after(tx,aN) ); // "Integer value required%s" } - rc = konstize( &isK, &pv, 0); // if expression can be evaluated now and replaced with constant, do so + + SI isKon; + void* pv; + rc = konstize( &isKon, &pv, 0); // if expression can be evaluated now and replaced with constant, do so if (rc==RCOK) // if ok, return optimization info { - if (pisK) + if (pisKon) { - *pisK = isK; // non-0 if value constant - if (isK) // if constant (else pv unInit --> protect violation) + *pisKon = isKon; // non-0 if value constant + if (isKon) // if constant (else pv unInit --> protect violation) if (pvPar) // if value return pointer given *pvPar = *(SI *)pv; // return constant value to caller } @@ -3141,7 +3149,7 @@ LOCAL RC FC utconvN( // do "usual type conversions" to match last n NUMERIC ex //========================================================================== RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now and replace with a constant load - SI *pisK, // NULL or receives non-0 if is constant + SI* pisKon, // NULL or receives non-0 if is constant void **ppv, // NULL or, if constant, receives ptr to value (ptr to ptr for TYSTR). Volatile: next konstize will overwrite. SI inDm ) // for TYSTR: 0: put text inline in code; // application of cases 1/2 not yet clear 10-10-90 no non-0 inDm values yet tested @@ -3154,19 +3162,19 @@ RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now an void* p = NULL; char *q=NULL; const char* ms; - SI isK = 0; + SI isKon = 0; PSOP jmp; ERSAVE - switch (isKE(&p)) // test for top parStk frame being constant (next) + switch (isKonExp(&p)) // test for top parStk frame being constant (next) { default: //case 0: // not constant or not a value or has side effect. printif( kztrace, " n0 "); - break; // isK is 0. + break; // isKon is 0. case 1: // just a constant (no reduction possible) - isK++; // NB isKE sets p in this case (only). + isKon++; // NB isKonExp sets p in this case (only). printif( kztrace, " n1 "); break; @@ -3182,7 +3190,7 @@ RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now an // if need found: don't do if it has a trailing jump (or terminate, evaluate, move/restore). { printif( kztrace, " y%d ", parSp->ty); - isK++; // say is constant + isKon++; // say is constant // get value rc = cuEvalR( parSp->psp1, &p, &ms, NULL); // Evaluates, & rets ptr to value (ptr to ptr to TYSTR). cueval.cpp. @@ -3247,9 +3255,9 @@ RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now an } // switch // return info if pointers given - if (pisK) - *pisK = isK; - if (isK) + if (pisKon) + *pisKon = isKon; + if (isKon) if (ppv) *ppv = p; @@ -3259,7 +3267,7 @@ RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now an } // konstize //========================================================================== -LOCAL SI FC isKE( // test if *parSp is a constant expression +LOCAL SI FC isKonExp( // test if *parSp is a constant expression void **ppv ) // NULL or rcvs ptr to value in return 1 case ONLY (rcvs char * for TYSTR; CAUTION 1) VOLATILE 2) into code) @@ -3268,7 +3276,7 @@ LOCAL SI FC isKE( // test if *parSp is a constant expression 2: constant expression, but not last subexpression emitted 3: constant expression that can be evaluated now and replaced in place with a constant */ { - USI sz, szkon; PSOP kop; static char *p; + static char *p; // TODO64 -- yikes, return value in static? See return 1 case // test if has side effect -- if so, better do at run time if (parSp->did) // if contains assignment, fcn w side effect, etc @@ -3279,6 +3287,8 @@ LOCAL SI FC isKE( // test if *parSp is a constant expression return 0; // some element in expr not constant // cases by type + PSOP kop; + USI szkon{ 0 }; switch (parSp->ty) { /* case TYANY: TYNUM: TYNONE: TYDONE: */ @@ -3289,6 +3299,11 @@ LOCAL SI FC isKE( // test if *parSp is a constant expression kop = PSKON2; // op code szkon = sizeof(PSOP) + sizeof(SI); // space needed break; + + case TYINT: + kop = PSKON4; + szkon = sizeof(PSOP) + sizeof(INT); // space needed + break; case TYSTR: #if defined( USE_PSPKONN) @@ -3321,7 +3336,7 @@ LOCAL SI FC isKE( // test if *parSp is a constant expression } /*lint +e616 */ // test if already just a constant - sz = (USI)((char *)parSp->psp2 - (char *)parSp->psp1); + USI sz = (USI)((char *)parSp->psp2 - (char *)parSp->psp1); if (sz==szkon) // if right size incl args { if (*parSp->psp1==kop) // if op code already constant-load @@ -3354,7 +3369,7 @@ LOCAL SI FC isKE( // test if *parSp is a constant expression // this subexpression ok to evaluate now and replace in place with constant return 3; -} // isKE +} // isKonExp //========================================================================== LOCAL USI FC maxEvf( USI evf) @@ -3514,7 +3529,7 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express { op1 = PSKON4; // differences for 4-byte value choicn #if CSE_ARCH != 32 - ?? // shift looks dubious on 64 bit + TODO64 // shift looks dubious on 64 bit #endif op3 = (USI)(v >> 16); xspace--; @@ -3869,6 +3884,7 @@ RC CDEC emiKon( // emit code to load constant // else if inDm==1, use given p and fall thru [[fallthrough]]; case TYFL: + case TYINT: fourBytes: EE( emit(PSKON4) ) EE( emit4( (void**)p) ) diff --git a/src/cuparsex.h b/src/cuparsex.h index 952e86ebc..f8cf17525 100644 --- a/src/cuparsex.h +++ b/src/cuparsex.h @@ -66,9 +66,9 @@ extern SI maxErrors; // used in cul.cpp /*------------------------- FUNCTION DECLARATIONS -------------------------*/ // some cuparse.cpp fcns used in [cumain.cpp or] cuprobe.cpp -RC FC konstize( SI *pisK, void **ppv, SI inDm); -RC FC newSf( void); -RC FC combSf( void); +RC FC konstize( SI* isKon, void **ppv, SI inDm); +RC FC newSf(); +RC FC combSf(); RC FC dropSfs( SI k, SI n); RC CDEC emiKon( USI ty, void *p, SI inDm, char **pp); RC FC emit( PSOP op); diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index 622602e5d..fb1e5aa66 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -116,7 +116,7 @@ RC FC probe() static SI iZero = 0; CSE_E( newSf()) // use separate stack frame to be like expression case CSE_E( emiKon( TYSI, &iZero, 0, NULL ) ) // emit code for a 0 contant - o.pSsV = parSp->psp1 + 1; // where the constant 0 value is, as from curparse.cpp:isKE via cuparse:konstize. + o.pSsV = parSp->psp1 + 1; // where the constant 0 value is, as from curparse.cpp:isKonExp via cuparse:konstize. o.ssIsK = 1; // say subscript is constant, as from konstize as called in [expr] case above. parSp->ty = TYSI; // have integer value unToke(); // unget the . and fall thru @@ -584,6 +584,12 @@ LOCAL RC FC lopNty4dt( // for DT- data type, get TY- type and PSOP to load it f sz = 2; break; + case DTINT: + lop = PSRATLOD4; // basAnc record load 2 bytes: fetches SI/USI. + ty = TYINT; + sz = 4; + break; + case DTFLOAT: // float types #if defined( DTPERCENT) case DTPERCENT: @@ -603,7 +609,7 @@ LOCAL RC FC lopNty4dt( // for DT- data type, get TY- type and PSOP to load it f break; case DTLDATETIME: // show dateTime as number (?) - case DTLI: + case DTLI: // TODO64 probably don't want DTLI here case DTULI: lop = PSRATLODL; // record load long: converts it float, potentially loosing some precision. ty = TYFL; diff --git a/test/actest1bL.cse b/test/actest1bL.cse index 116715014..8e6234629 100644 --- a/test/actest1bL.cse +++ b/test/actest1bL.cse @@ -628,8 +628,6 @@ Report rpType=UDT rpFreq=SUBHOUR rpDayBeg=CoolDay rpDayEnd=CoolDay rpCPL=121 Report rpType=ZEB rpFreq=hour rpZone=SDuctZone rpDayBeg= Heatday rpDayEnd=Heatday Report rpType=ZEB rpFreq=hour rpZone=RDuctZone rpDayBeg= Heatday rpDayEnd=Heatday -/CSEBtuSF - //Zone Data Dump reports Report rpType=ZDD rpZone=Single Report rpType=ZDD rpZone= SDuctZone diff --git a/test/ref/ACTEST1BL.REP b/test/ref/ACTEST1BL.REP index 5b5d975f5..c84bce3cf 100644 --- a/test/ref/ACTEST1BL.REP +++ b/test/ref/ACTEST1BL.REP @@ -4454,7 +4454,7 @@ IzXfer RDuctZone-DLkO Zn1: RDuctZone Zn2: -- UAconst: 0 NVctrl: AirNetD ! Log for Run 001: Simple Default, no latent ################ -! CSE 0.904.0+termah.94de11f5.87.dirty for Win32 console Tue 26-Apr-22 3:15:50 pm +! CSE 0.918.0+64-bit-debug.a6ce06b3.81.dirty for Win32 console Tue 15-Aug-23 3:12:38 pm ================ @@ -57735,7 +57735,7 @@ Single CZ: anMCp/T[ 0]=21.42/1132.7 anMCp/T[ 1]=0.00/0.0 ventUt=0 Nair=8386216.40 Dair=107014.39 Nrad=205594.83 Drad=2437.89 CX=1173.65 airX=12.820 TH=70.00 TD=74.00 TC=78.00 tSP=78.00 md=2 amfReq=9084 amfSup=8267 tSup=56.03 ta=78.00 tr=82.27 qIzSh=-538 fvent=0.000 pz0=-0.0052 qsHvac=-44111 -! CSE 0.904.0+termah.94de11f5.87.dirty for Win32 console +! CSE 0.918.0+64-bit-debug.a6ce06b3.81.dirty for Win32 console @@ -58371,8 +58371,6 @@ Input for Run 001: Report rpType=ZEB rpFreq=hour rpZone=SDuctZone rpDayBeg= Heatday rpDayEnd=Heatday Report rpType=ZEB rpFreq=hour rpZone=RDuctZone rpDayBeg= Heatday rpDayEnd=Heatday - /CSEBtuSF - //Zone Data Dump reports Report rpType=ZDD rpZone=Single Report rpType=ZDD rpZone= SDuctZone @@ -58438,18 +58436,18 @@ Input for Run 001: -! CSE 0.904.0+termah.94de11f5.87.dirty for Win32 console run(s) done: Tue 26-Apr-22 3:15:53 pm +! CSE 0.918.0+64-bit-debug.a6ce06b3.81.dirty for Win32 console run(s) done: Tue 15-Aug-23 3:12:40 pm ! Executable: d:\cse\msvc\cse.exe -! 26-Apr-22 2:49 pm (VS 14.29 2999296 bytes) (HPWH 1.18.1) +! 15-Aug-23 2:42 pm (VS 14.29 2776576 bytes) (HPWH 1.22.0) ! Command line: -x! -t1 actest1bl ! Input file: D:\cse\test\actest1bl.cse -! Report file: D:\cse\test\actest1bl.rep +! Report file: D:\CSE\TEST\ACTEST1BL.REP ! Timing info -- -! Input: Time = 0.06 Calls = 1 T/C = 0.0600 -! AutoSizing: Time = 0.00 Calls = 0 T/C = 0.0000 -! Simulation: Time = 2.58 Calls = 1 T/C = 2.5780 -! Reports: Time = 0.07 Calls = 1 T/C = 0.0660 -! Total: Time = 2.71 Calls = 1 T/C = 2.7060 +! Input: Time = 0.06 Calls = 1 T/C = 0.0640 +! AutoSizing: Time = 0.00 Calls = 0 T/C = 0.0000 +! Simulation: Time = 2.74 Calls = 1 T/C = 2.7380 +! Reports: Time = 0.07 Calls = 1 T/C = 0.0680 +! Total: Time = 2.87 Calls = 1 T/C = 2.8730 diff --git a/test/ref/ASHPPKGROOM.REP b/test/ref/ASHPPKGROOM.REP index 472785091..87bfb0fdd 100644 --- a/test/ref/ASHPPKGROOM.REP +++ b/test/ref/ASHPPKGROOM.REP @@ -509,9 +509,9 @@ Top radDiffF 6 60 0 0 1 2 0 1 0 0 hConvMod 6 63 0 0 1 16 nz 0 0 0 verbose 6 64 0 0 1 1 nz 0 0 0 - dbgPrintMask 6 65 0 0 739 256 0 0 0 0 - dbgPrintMaskC 6 66 16384 0 1 256 0 0 0 0 - dbgFlag 6 67 0 0 1763 256 0 0 0 0 + dbgPrintMask 6 65 0 0 739 32 0 0 0 0 + dbgPrintMaskC 6 66 16384 0 1 32 0 0 0 0 + dbgFlag 6 67 0 0 1763 32 0 0 0 0 ventAvail 6 61 0 0 739 16 nz 0 0 0 auszTol 6 68 0 0 1 2 0 0.005 0 0 heatDsTDbO 6 69 16384 0 739 2 0 0 0 0 @@ -1748,7 +1748,7 @@ report Parent: Top rpDayBeg 6 11 16384 0 1 28672 0 0 0 0 rpDayEnd 6 12 16384 0 1 28672 0 0 0 0 rpBtuSf 6 13 0 0 1 2 0 1e+06 0 0 - rpCond 6 14 0 0 1771 256 nz 0 0 0 + rpCond 6 14 0 0 1771 32 nz 0 0 0 rpTitle 6 15 0 0 1 4 0 0 0 0 rpCpl 6 16 16384 0 1 1 nz 0 0 0 rpHeader 6 17 16384 0 1 16 nz 0 0 0 @@ -1774,7 +1774,7 @@ export Parent: Top exDayBeg 6 11 0 0 1 28672 0 0 0 0 exDayEnd 6 12 0 0 1 28672 0 0 0 0 exBtuSf 6 13 0 0 1 2 0 1e+06 0 0 - exCond 6 14 0 0 1771 256 nz 0 0 0 + exCond 6 14 0 0 1771 32 nz 0 0 0 exTitle 6 15 0 0 1 4 0 0 0 0 exHeader 6 17 0 0 1 16 nz 0 0 0 exFooter 6 18 0 0 1 16 nz 0 0 0 @@ -1989,7 +1989,7 @@ inverse Parent: Top ivX 6 6 8 0 1771 2 0 0 0 0 ivY 6 7 8 0 1771 2 0 0 0 0 endInverse 13 0 0 0 0 0 0 0 0 0 -! CSE 0.918.0+64-bit-debug.0047fcfc.66.dirty for Win32 console +! CSE 0.918.0+64-bit-debug.a6ce06b3.81.dirty for Win32 console @@ -3552,18 +3552,18 @@ Input for Run 001: -! CSE 0.918.0+64-bit-debug.0047fcfc.66.dirty for Win32 console run(s) done: Tue 08-Aug-23 3:19:36 pm +! CSE 0.918.0+64-bit-debug.a6ce06b3.81.dirty for Win32 console run(s) done: Tue 15-Aug-23 3:26:47 pm ! Executable: d:\cse\msvc\cse.exe -! 08-Aug-23 11:32 am (VS 14.29 2775040 bytes) (HPWH 1.22.0) +! 15-Aug-23 2:42 pm (VS 14.29 2776576 bytes) (HPWH 1.22.0) ! Command line: -x! -t1 ashppkgroom ! Input file: D:\cse\test\ashppkgroom.cse ! Report file: D:\CSE\TEST\ASHPPKGROOM.REP ! Timing info -- -! Input: Time = 0.10 Calls = 2 T/C = 0.0490 +! Input: Time = 0.10 Calls = 2 T/C = 0.0495 ! AutoSizing: Time = 0.30 Calls = 1 T/C = 0.3000 -! Simulation: Time = 6.69 Calls = 1 T/C = 6.6850 -! Reports: Time = 0.00 Calls = 1 T/C = 0.0030 -! Total: Time = 7.09 Calls = 1 T/C = 7.0930 +! Simulation: Time = 6.75 Calls = 1 T/C = 6.7490 +! Reports: Time = 0.00 Calls = 1 T/C = 0.0020 +! Total: Time = 7.16 Calls = 1 T/C = 7.1590 From bf62aaa473cefa1102f193c89a7dce4980605159 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Mon, 21 Aug 2023 11:21:09 -0400 Subject: [PATCH 5/9] Bug fixes; some tests run --- src/cgdebug.cpp | 21 ++++++++++------- src/cncult.cpp | 2 +- src/cncult4.cpp | 4 ++-- src/cpgbuild.h | 17 ++++++------- src/cueval.cpp | 56 +++++++++++++++++++++++++++++-------------- src/cueval.h | 11 +++++---- src/cuparse.cpp | 63 ++++++++++++++++++++++++++++++++++++------------- src/exman.cpp | 6 ++--- src/vrpak.cpp | 2 +- 9 files changed, 121 insertions(+), 61 deletions(-) diff --git a/src/cgdebug.cpp b/src/cgdebug.cpp index 42e27969d..01fc5b441 100644 --- a/src/cgdebug.cpp +++ b/src/cgdebug.cpp @@ -250,9 +250,6 @@ static PB_DATOFFL izxct[] = { { PBMETHEND }}; static PBHEAD izxch = { PBDATOFFL, izxct, 0, 0, 0 }; - MSRAT *mse; - IZXRAT *ize; - SI did; char *pp=NULL; RC rc=RCOK; @@ -282,29 +279,36 @@ o pgbuildr( &pp, &rc, 0, 0, 0, NULL, &cfh, zp, PBDONE ); // XSURFs: Walls, windows, perimeter, mass exterior walls // CAUTION special args for some tables may be hard-coded into cgCmpDump by 'ty'. +#if 1 cgCmpDump( vrh, zi, 0, CTEXTWALL, &cmph1); +#endif +#if 1 cgCmpDump( vrh, zi, 0, CTMXWALL, &cmph1); +#endif +#if 1 cgCmpDump( vrh, zi, 0, CTINTWALL, &cmph1i); // !! 2-95 cgCmpDump( vrh, 0, zi, CTINTWALL, &cmph1io); // duplicate display of walls with "outside" in this zone cgCmpDump( vrh, zi, 0, CTWINDOW, &cmph2); cgCmpDump( vrh, zi, 0, CTPERIM, &cmph3); // Mass: dump those masses whose inside is adjacent to the current zone. - did = 0; + bool did = false; + MSRAT* mse; RLUP( MsR, mse) { if (IsMSBCZone( mse->inside.bc_ty) && mse->inside.bc_zi==zi) // if mass inside is adjacent to zone zi { cgMassDump( mse); - did++; + did = true; } } if (did) // if printed any vrStr(vrh, "\r\n" ); // blank line after all 12-89 // Interzone transfers; scan all, print those whose zone 1 is equal to current zone. Thus each IZXfer prints once. - did = 0; + did = false; pgbuildr( &pp, &rc, 20, 120, 0, NULL, PBSPECEND ); // 78-->120 2-95 // pre-alloc PAGE. Unlikely to be more than a full page of them, so print all on 1 PAGE to page 1st not between. + IZXRAT* ize; RLUP( IzxR, ize) // for izxfer 1 to .n (cnglob.h macro) { if (ize->iz_zi1 == zi) @@ -319,11 +323,12 @@ o pgbuildr( &pp, &rc, 0, 0, 0, NULL, &cfh, zp, PBDONE ); name2, // 2 ize->getChoiTx( IZXRAT_NVCNTRL, 1),// 3 PBSPECEND ); - did++; + did = true;; } } if (did) // if any izxfers pgbuildr( &pp, &rc, 0, 0, 0, NULL, PBDONE); // print PAGE +#endif pgfree( &pp); // free page, NULL pp, pgpak.cpp } // cgzndump @@ -434,7 +439,7 @@ static PBHEAD ashwatH = { PBDATOFFL, ashwatT, 0, 0, 0 }; } // display record and subsidiary records pgbuildr( &pp, &rc, 30, 127, 0, NULL, pbh, xs, // alloc PAGE, dump. - argp, PBSPECEND ); + argp, (void *)PBSPECEND ); if (xs->x.xs_IsASHWAT()) pgbuildr( &pp, &rc, 0, 0, 0, NULL, &ashwatH, xs->x.xs_pFENAW[ 0], PBSPECEND ); diff --git a/src/cncult.cpp b/src/cncult.cpp index 732b2a778..b96987843 100644 --- a/src/cncult.cpp +++ b/src/cncult.cpp @@ -918,7 +918,7 @@ static CULT perT[] = CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, prStarCkf), CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, N), CULT( "prZone", DAT, PRI_OWNTI, NO_INP|RDFLIN, 0, 0, TYREF, &ZiB, 0.f, N, N), //TYIREF-->TYREF 10-9-92 -CULT( "prXtype", DAT, PRI_X+XSURF_TY, NO_INP, 0, 0, TYSI, 0, v CTPERIM, 0.f, N, N), //CTPERIM: cnguts.h. +CULT( "prXtype", DAT, PRI_X+XSURF_TY, NO_INP, 0, 0, TYSI, 0, CTPERIM, N, N), //CTPERIM: cnguts.h. CULT( "prXExCnd", DAT, PRI_X+XSURF_SFEXCND, NO_INP, 0, 0, TYCH, 0, C_EXCNDCH_AMBIENT, N, N), //added 2-95 CULT( "prLen", DAT, PRI_PRLEN, RQD, 0, VEOI, TYFL, 0, 0.f, N, N), CULT( "prF2", DAT, PRI_PRF2, RQD, 0, VEOI, TYFL, 0, 0.f, N, N), diff --git a/src/cncult4.cpp b/src/cncult4.cpp index 2eae73816..e6213e002 100644 --- a/src/cncult4.cpp +++ b/src/cncult4.cpp @@ -624,7 +624,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp default: if (!errCount()) // if other error has occurred, suppress msg: may be consequential - rc = oer( (char *)MH_S0555, exrp, rpTy); // "cncult:topRp: Internal error: Bad %sType %d" + rc = oer( (const char *)MH_S0555, exrp, rpTy); // "cncult:topRp: Internal error: Bad %sType %d" } // default/check file reference. Defaulted to rp/exfile in which nested, else default here to "Primary" (supplied by TopStarPrf) @@ -637,7 +637,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp ownTi = 1; // use first one: is probably Primary renamed with ALTER else // no r/xport files at all rc |= ooer( RI_OWNTI, // issue error once (cul.cpp), no run - (char *)(INT)(isEx ? MH_S0556 : MH_S0557) ); // "No exExportfile given" or "No rpReportfile given" + (const char *)LI(isEx ? MH_S0556 : MH_S0557) ); // "No exExportfile given" or "No rpReportfile given" } RFI* rfp=NULL; if (ownTi) diff --git a/src/cpgbuild.h b/src/cpgbuild.h index 62329f796..896855acc 100644 --- a/src/cpgbuild.h +++ b/src/cpgbuild.h @@ -18,14 +18,15 @@ NULL (ignored), or or a "special function" word: */ -/* pgbuildr SPECIAL FUNCTIONS used in vbl arg list to terminate, print, etc:*/ -#define PBSPECOUT 1L /* "Output" page: call fcn per prFunc arg */ -#define PBSPECFR 2L /* Free pgpak page */ -#define PBSPECEND 4L /* Terminator for pgbuildr() arg list */ -#define PBSPECMAX 128L /* Any value below this is taken as special */ - -#define PBDONE ((PBHEAD *)(PBSPECOUT | PBSPECFR | PBSPECEND)) - /* Handy combo value to end pgbuildr() arg list */ +// pgbuildr SPECIAL FUNCTIONS used in vbl arg list to terminate, print, etc: +// LI: same size as pointer +constexpr LI PBSPECOUT = 1; // "Output" page: call fcn per prFunc arg +constexpr LI PBSPECFR = 2; // Free pgpak page +constexpr LI PBSPECEND = 4; // Terminator for pgbuildr() arg list +constexpr LI PBSPECMAX = 128; // Any value below this is taken as special + +constexpr LI PBDONE = PBSPECOUT | PBSPECFR | PBSPECEND; + // Handy combo value to end pgbuildr() arg list /*-------------------------- Defines for PBHEAD ---------------------------*/ diff --git a/src/cueval.cpp b/src/cueval.cpp index 5f52324a7..61016650c 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -145,13 +145,13 @@ w} /* cuEvalF */ //=========================================================================== RC FC cuEvalR( // evaluate pseudocode & return ptr to value - void *ip, // ptr to code to evaluate + void* ip, // ptr to code to evaluate - void **ppv, // receives ptr to value (ptr to ptr to TYSTR). + void** ppv, // receives ptr to value. // Caller must know value type/size. // Value must be moved before next call to any eval fcn. - // For TYSTR, value may be ptr to text INLINE IN CODE. */ - const char **pmsg, // NULL or receives ptr to un-issued Tmpstr error msg. + // For TYSTR, value may be ptr to text INLINE IN CODE. + const char** pmsg, // NULL or receives ptr to un-issued Tmpstr error msg. // CAUTION: msg is in transitory temp string storage: use or strsave promptly. USI *pBadH ) // NULL or receives 0 or expr # of uneval'd expr when RCUNSET is returned. @@ -168,13 +168,14 @@ RC FC cuEvalR( // evaluate pseudocode & return ptr to value rc = cuEval( ip, pmsg, pBadH); // evaluate to *evStk if (ppv != NULL) // return pointer to value in eval stack *ppv = evSp; +#if 0 // TODO64 if (rc==RCOK) // if ok, check size of value: devel aid { // remove if other sizes become possible SI sz = (SI)((char *)evStkBase - (char *)evSp); if (sz != 2 && sz != 4) { - const char* ms = strtprintf( (char *)MH_R0202, (INT)sz); // "cuEvalR internal error: \n value %d bytes: neither 2 nor 4" + const char* ms = strtprintf( (char *)MH_R0202, sz); // "cuEvalR internal error: \n value %d bytes: neither 2 nor 4" if (pmsg) *pmsg = ms; // return TRANSITORY message pointer else @@ -182,6 +183,7 @@ RC FC cuEvalR( // evaluate pseudocode & return ptr to value return RCBAD; } } +#endif return rc; } // cuEvalR // make public if need found: @@ -281,7 +283,7 @@ made things worse TODO (MP) int line; #endif - //--- constants inline in code. Move 4 bytes as long not float to avoid 8087 exceptions. + //--- constants inline in code. Move 4 bytes as long not float to avoid 8087 exceptions. case PSKON2: *--SPI = *IPI++; break; // 2 bytes @@ -356,24 +358,42 @@ made things worse TODO (MP) break; // 4 bytes. CAUTION string ptrs now need cupIncRef, 7-92 //--- conversions - case PSFIX: - siTem = (SI)*SPF; - SPC += sizeof(float) - sizeof(SI); - *SPI = siTem; + case PSFIX2: // float to SI + { SI siTem = SI(*SPF); + SPC += sizeof(float) - sizeof(SI); + *SPI = siTem; + } break; - case PSFLOAT: - siTem = *SPI; - SPC += sizeof(SI) - sizeof(float); - *SPF = (float)siTem; + case PSFIX4: // float to INT + *SPL = INT(*SPF); // assume same sizeof() + break; + + case PSFLOAT2: // SI to float + { SI siTem = *SPI; + SPC += sizeof(SI) - sizeof(float); + *SPF = FLOAT(siTem); + } break; - case PSINT: - siTem = *SPI; - SPC += sizeof(SI) - sizeof(INT); - *SPL = INT(siTem); + case PSFLOAT4: // INT to float + *SPF = FLOAT(*SPL); // assume same sizeof() break; + case PSSIINT: // SI to INT + { SI tSI = *SPI; + SPC += sizeof(SI) - sizeof(INT); + *SPL = INT(tSI); + } + break; + + case PSINTSI: // INT to SI + { INT tINT = *SPL; + SPC += sizeof(INT) - sizeof(SI); + *SPI = SI( tINT); + } + break; + case PSIBOO: *SPI = (*SPI != 0); break; // make any non-0 a 1 diff --git a/src/cueval.h b/src/cueval.h index 6dfd88e7f..10a06e00b 100644 --- a/src/cueval.h +++ b/src/cueval.h @@ -35,7 +35,7 @@ PSPKONN, // load pointer to inline literal such as "text". // followed by ~#words (excl self) and the literal. #endif -// load values from memory locations, address in next 4 pseudo-code bytes +// load values from memory locations, address in next 4 or 8 (sizeof(void *)) pseudo-code bytes PSLOD2, // 2 bytes PSLOD4, // 4 bytes @@ -64,9 +64,12 @@ PSPOP2, // discard 2 bytes (SI) (expr as statement) PSPOP4, // discard 4 bytes (float or string pointer) (ditto) // conversions -PSFIX, // float to SI -PSFLOAT, // SI to float -PSINT, // SI to INT +PSFIX2, // float to SI +PSFIX4, // float to INT +PSFLOAT2, // SI to float +PSFLOAT4, // INT to float +PSSIINT, // SI to INT +PSINTSI, // INT to SI PSIBOO, // SI to "boolean": make any non-0 a 1 PSSCH, // string to choicb or choicn. char * on stack, DTxxx (Dttab[]/dtypes.h) data type follows. PSNCN, // number-choice to number, ie error if contains choice diff --git a/src/cuparse.cpp b/src/cuparse.cpp index de61a7b3d..8fa43d18d 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -337,8 +337,8 @@ struct SFST : public STBK // symbol table for each function static SFST itSfs[] = { //--id-- -----f----- evf -cs-- resTy #args--argTy's-- ---codes--- - SFST( "fix", ROK, 0, FCREG, TYSI, 1, TYNUM, 0, 0, 0, PSFIX), - SFST( "toFloat", ROK, 0, FCREG, TYFL, 1, TYNUM, 0, 0, PSFLOAT, 0), + SFST( "fix", ROK, 0, FCREG, TYSI, 1, TYNUM, 0, 0, 0, PSFIX2), + SFST( "toFloat", ROK, 0, FCREG, TYFL, 1, TYNUM, 0, 0, PSFLOAT2, 0), SFST( "brkt", ROK|MA, 0, FCREG, TYNUM, 3, TYNUM, 0, 0, PSIBRKT,PSFBRKT), SFST( "min", ROK|MA|VA|VC, 0, FCREG, TYNUM, 1, TYNUM, 0, 0, PSIMIN, PSFMIN), SFST( "max", ROK|MA|VA|VC, 0, FCREG, TYNUM, 1, TYNUM, 0, 0, PSIMAX, PSFMAX), @@ -701,6 +701,7 @@ LOCAL RC FC emiSto( SI dup1st, void *p); LOCAL RC FC emiDup( void); LOCAL RC FC emiPop( void); LOCAL RC FC emit4( void **p); +LOCAL RC FC emitPtr( void** p); #if defined( USE_PSPKONN) LOCAL RC FC emitStr(const char* s, int sLen); #endif @@ -1096,7 +1097,7 @@ RC FC exOrk( // compile expression from current input file, return constant valu *pip = ip; // NULL or pointer to pseudo-code if (isKon) // *pvPar left unchanged if non-constant if (pvPar) - *(ULI*)pvPar = v; // value -- TODO64 ULI? + *(NANDAT*)pvPar = v; // TODO64: was ULI*, NANDAT* seems right return rc; #undef Eer @@ -1248,12 +1249,25 @@ RC FC expTy( case TYSI: if (wanTy & TYINT) // test for TYINT before TYFL { - EE(emit(PSINT)) // convert SI to INT. konstize below converts constant if constant. - parSp->ty = TYINT; + EE(emit(PSSIINT)) // convert SI to INT. konstize below converts constant if constant. + parSp->ty = TYINT; } else if (wanTy & TYFL) // includes wanTy==TYNC { - EE(emit(PSFLOAT)) // convert SI to float. konstize below converts constant if constant. + EE(emit(PSFLOAT2)) // convert SI to float. konstize below converts constant if constant. + parSp->ty = TYFL; + } + break; + + case TYINT: + if (wanTy & TYSI) // test for TYSI before TYFL + { + EE(emit(PSINTSI)) // convert INT to SI. konstize below converts constant if constant. + parSp->ty = TYINT; + } + else if (wanTy & TYFL) // includes wanTy==TYNC + { + EE(emit(PSFLOAT4)) // convert INT to float. konstize below converts constant if constant. parSp->ty = TYFL; // now have a float } break; @@ -1777,7 +1791,7 @@ LOCAL RC FC biOp( // parse 2nd arg to binary operator, emit conversions and op { if (parSp >= parStk && parSp->ty==TYSI && argTy==TYFL) // if have int and want float { - EE( cnvPrevSf( 0, PSFLOAT, 0)) // float it. eg ' (ft-inches). + EE( cnvPrevSf( 0, PSFLOAT2, 0)) // float it. eg ' (ft-inches). parSp->ty = TYFL; // konstize may use ty. } else if (parSp >= parStk && parSp->ty==TYNC && argTy==TYFL) // if have number-choice and want float @@ -2808,7 +2822,7 @@ LOCAL RC FC uFcn( UFST *stb ) // compile call to user function // emit call code CSE_E( emit2( PSCALA) ); // absolute call - CSE_E( emit4( (void **)&stb->ip) ); // address to call + CSE_E( emitPtr( (void **)&stb->ip) ); // address to call // fcn body removes arguments from stack, leaves return value (PSRETA) prec = PROP; // operand last (necess if 0 args) @@ -2973,7 +2987,7 @@ LOCAL RC FC convSi( // convert last expr to int, else issue error. konstizes. switch (parSp->ty) { case TYFL: - CSE_E( emit( PSFIX) ) // float: convert (rif error) + CSE_E( emit( PSFIX2) ) // float: convert (rif error) parSp->ty = TYSI; // type is now integer break; // consistency issue: some contexts (expTy) may not fix floats where int needed @@ -3041,7 +3055,7 @@ LOCAL RC FC tconv( // generate type conversions to make last n expressions com PARSTK* pspe = parSp - i; if (pspe->ty==TYSI || pspe->ty == TYINT) // if integer, float it { - if (cnvPrevSf( i, PSFLOAT, 0)) // insert conversion op after ith expr back (or just float it if constant) + if (cnvPrevSf( i, PSFLOAT2, 0)) // insert conversion op after ith expr back (or just float it if constant) return RCBAD; // error, code buffer full, etc // can't konstize here: eg select a select arg cond-value pair is not a value, might jmp yonder. pspe->ty = TYFL; @@ -3133,7 +3147,7 @@ LOCAL RC FC utconvN( // do "usual type conversions" to match last n NUMERIC ex pspe = parSp - i; if (pspe->ty==TYSI) { - EE( cnvPrevSf( i, PSFLOAT, 0) ) // insert conversion op after ith expr back (or just float it if constant) + EE( cnvPrevSf( i, PSFLOAT2, 0) ) // insert conversion op after ith expr back (or just float it if constant) pspe->ty = TYFL; } } @@ -3529,7 +3543,7 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express { op1 = PSKON4; // differences for 4-byte value choicn #if CSE_ARCH != 32 - TODO64 // shift looks dubious on 64 bit + printf("\nFix cnvPrevSf shift"); // TODO64 shift looks dubious on 64 bit #endif op3 = (USI)(v >> 16); xspace--; @@ -3568,7 +3582,7 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express // if just floated an integer constant, replace with float const // (coding ASSUMES sizeof( SI const + PSFLOAT) = sizeof(float const) - if ( op1==PSFLOAT // *pspe: just stored + if ( op1==PSFLOAT2 // *pspe: just stored && *(pspe-3)==PSKON2 // 2-byte const op used for int consts && pspe-3==parSpe->psp1 ) // 2 codes + op only (be sure PSKON2 not tail of something else) { @@ -3921,7 +3935,7 @@ LOCAL RC FC emiLod( USI ty, void *p) // emit code to load datum of type ty from goto er; // "Bug in cuparse.cpp:emiLod switch" } /*lint +e616 */ - EE( emit4( &p) ) // address of variable follows op code + EE( emitPtr( &p) ) // address of variable follows op code return RCOK; ERREX(emiLod) @@ -4047,14 +4061,31 @@ RC FC emit2( SI i) // emit a 2-byte quantity return RCOK; } // emit2 //========================================================================== -LOCAL RC FC emit4( void **p) // emit 4-byte quantity POINTED TO by p: float or pointer +LOCAL RC FC emit4( void **p) // emit 4-byte quantity POINTED TO by p: FLOAT or INT // keeps code terminated (without pointing past terminator) // maintains current stack frame .psp2 { if (p) // NULL means no emit, just terminate { *(void **)psp = *p; - IncP( DMPP( psp), sizeof( void *)); + IncP( DMPP( psp), sizeof( float)); + } + *psp = PSEND; // terminate, don't point past: insurance + parSp->psp2 = psp; // update current parse stack frame end-of-pseudoCode pointer + if (psp >= pspMax) // if buffer overfull (no data lost yet here) + return emiBufFull(); // enlarge it (future) or issue message + return RCOK; +} // emit4 +//========================================================================== +LOCAL RC FC emitPtr(void** p) // emit 4-byte quantity POINTED TO by p: float or pointer + +// keeps code terminated (without pointing past terminator) +// maintains current stack frame .psp2 +{ + if (p) // NULL means no emit, just terminate + { + *(void**)psp = *p; + IncP(DMPP(psp), sizeof(void*)); } *psp = PSEND; // terminate, don't point past: insurance parSp->psp2 = psp; // update current parse stack frame end-of-pseudoCode pointer diff --git a/src/exman.cpp b/src/exman.cpp index d27567ecf..aa64edfb4 100644 --- a/src/exman.cpp +++ b/src/exman.cpp @@ -695,7 +695,7 @@ RC FC exPile( // compile an expression from current input &gotTy, /* rcvs actual data type found 11-91 */ &gotEvf, /* rcvs evaluation frequency bits */ &isKon, /* receives is-constant flag */ - &v, /* iff const, rcvs constant value (4 bytes even for SI; dm ptr for TYSTR) */ + &v, /* iff const, rcvs constant value (4 bytes even for SI; dm ptr for TYSTR) */ &ip ) ) // rcvs NULL if constant, or ptr to pseudo-code in dm // leaves tokTy set; comma ; ) ] terminators gobbled. @@ -771,7 +771,7 @@ RC FC exPile( // compile an expression from current input EXTDUMPIF( "exPile new end"); } -#if 0 && defined( _DEBUG) +#if 1 && defined( _DEBUG) extValidate( "exPile"); #endif @@ -1350,7 +1350,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre txVal( ex->ext_ty, pv), // convert value to text (local) whatEx(h), // what this expr orginally set (local) msg( NULL, // text for MH to Tmpstr, messages.cpp SHD BE OK TO PASS han to rer now, 3-92. - (const char *)(INT)rc) ); // cast rc to char * + (const char *)(LI)rc) ); // test for change, condition value by type, store new value in exTab. ex->ext_v is old value, *pv is new value. diff --git a/src/vrpak.cpp b/src/vrpak.cpp index 3892d1306..1027105f1 100644 --- a/src/vrpak.cpp +++ b/src/vrpak.cpp @@ -1985,7 +1985,7 @@ LOCAL RC bufRead( UINT off, char* buf, UINT n, UINT* pnRead ) // read into unsp } // read sec = xfread( spl.splxf, buf, n); // read, lib\xiopak.cpp - *pnRead = spl.splxf->nxfer; // return # bytes read + *pnRead = UINT( spl.splxf->nxfer); // return # bytes read if (sec != SECOK) // if error or eof (not an error to us) { xlsterr( spl.splxf); // clear error/eof indication -- else further calls may nop From fc242d1cf980e023816d4d3d0579489848e05685 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Thu, 24 Aug 2023 11:11:33 -0400 Subject: [PATCH 6/9] Expression eval bug fix --- src/cueval.cpp | 62 ++++++++++++++++++++++++------------------------- src/cuparse.cpp | 9 ------- src/strpak.cpp | 2 +- 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/src/cueval.cpp b/src/cueval.cpp index 61016650c..e4c31774a 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -9,14 +9,11 @@ #include "cnglob.h" // CSE global definitions. ASSERT. /*-------------------------------- OPTIONS --------------------------------*/ -#define PROBE // define for features to support CSE record data probes. Undefine for portable linkability. #define IMPORT // define for features to support CSE Import() function; Undefine for portable linkability. 2-94. -#ifdef PROBE #include "srd.h" // SFIR #include "ancrec.h" // record: base class for rccn.h classes #include "rccn.h" // Top.isEndOf -#endif #include "msghans.h" // MH_R0201 #include "messages.h" // msgIsHan @@ -28,13 +25,11 @@ #endif #include "cueval.h" // PS defines, RCUNSET; decls for fcns in this file -#ifdef PROBE #include "cul.h" // FsSET FsVAL #include "cuparse.h" // evfTx must follow cueval.h, for PSOP #include "cnguts.h" // Top #include "cuevf.h" #include "exman.h" // whatEx whatNio exInfo -#endif #include "xiopak.h" @@ -94,11 +89,9 @@ SI runtrace = 0; // settable as sys var $runtrace (cuparse.cpp) /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC FC cuEval( void *ip, const char** pmsg, USI *pBadH); LOCAL RC FC cuEvalI( const char** pmsg, USI *pBadH); -#ifdef PROBE // features that depend especially on being linked in CSE environmemt -LOCAL RC FC cuRmGet( void **pv, const char** pms, USI *pBadH); +LOCAL RC FC cuRmGet( NANDAT& vRet, const char** pms, USI *pBadH); LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH); LOCAL const char * FC ivlTx( IVLCH ivl); -#endif /*lint -e124 "Pointer to void not allowed" when comparing void ptrs */ /*lint -e52 "Expected an lvalue" on every "((SI*)evSp)--" etc */ @@ -252,7 +245,7 @@ LOCAL RC FC cuEvalI( // fetch next pseudo-code PSOP op = *IPOP++; - printif( runtrace, " ip=0x%x sp=%d op=%d ", + printif( runtrace, "\n ip=%p sp=%p op=%d ", evIp, evSp, op); void* p = 0; @@ -267,6 +260,7 @@ LOCAL RC FC cuEvalI( USI h; void* tIp; void* tSp; + NANDAT vND; #if 0 #if 0 && defined( ND3264) made things worse TODO (MP) @@ -306,6 +300,7 @@ made things worse TODO (MP) break; // 2 bytes case PSLOD4: *--SPL = *(*IPPL++); + printif(runtrace, " %f", *SPF); break; // 4 bytes //--- load 2, 4 bytes from stack frame (fcn args 12-90). signed offset in words is in next word. @@ -402,8 +397,10 @@ made things worse TODO (MP) if (cvS2Choi((char*)*SPP++, *IPU++, (void *)&v, &h, &ms) == RCBAD) // cvpak.cpp goto breakbreak; // if error (ms set) ms = NULL; // insurance, drop possible info msg - if (h == 4) *--SPP = v; // if a 4-byte choice type (choicn), return 4 bytes - else *--SPI = *(SI*)&v; // assume 2 bytes: choicb + if (h == 4) + *--SPP = v; // if a 4-byte choice type (choicn), return 4 bytes + else + *--SPI = *(SI*)&v; // assume 2 bytes: choicb break; case PSNCN: // number-choice to number 'conversion' @@ -847,8 +844,6 @@ made things worse TODO (MP) printf( "%s", *SPCC++); break; -#ifdef PROBE // probe-related features that depend especially on being linked in CSE environmemt - //--- record data access operations, 12-91. move up at reorder? case PSRATRN: // point record by number: ancN inline, rec number on stack, leaves record address on stack b = basAnc::anc4n( *IPU++, PABT); // get inline anchor number, point basAnc (ancpak.cpp) @@ -919,21 +914,31 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign *--SPP = AsCULSTR(v).Strsave(); #endif break; // char[], eg ANAME: put in dm. NAN not expected. + case PSRATLODS: // CULSTR: 4 byte value -#if 0 // cuRmGet now handles CULSTR - if ((rc = cuRmGet(&p,&ms,pBadH)) != RCOK) // char *. 1st fetch/check/fix 4 bytes. + if ((rc = cuRmGet(vND,&ms,pBadH)) != RCOK) // char *. 1st fetch/check/fix 4 bytes. goto breakbreak; // if unset data or uneval'd expr, ms set. +#if 0 if (p) cupIncRef( DMPP( p)); // ++ ref count of ptr if not into code (below) else p = strsave(""); // supply dm "" for NULL pointer - *--SPP = p; // stack pointer - break; #endif + { const char* s = AsCULSTR(&vND).CStr(); + *--SPP = (void*)s; // stack pointer + } + break; + case PSRATLOD4: +#if 1 + if ((rc = cuRmGet( vND, &ms, pBadH)) != RCOK) // 4 bytes: float/INT/UINT. 1st fetch/check/fix 4 bytes. + goto breakbreak; // if unset data or uneval'd expr, ms set. + *--SPL = vND; // push value fetched +#else if ((rc = cuRmGet(&p,&ms,pBadH)) != RCOK) // 4 bytes: float/INT/UINT. 1st fetch/check/fix 4 bytes. goto breakbreak; // if unset data or uneval'd expr, ms set. - *--SPP = p; // push value fetched + *--SPP = p; // push value fetched +#endif break; //--- expression data loads: used when (immediate input) locn already containing expr is probed. 12-91. @@ -968,7 +973,6 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign *--SPP = p ? p : strsave(""); // stack pointer, supplying dm "" for NULL ptr dmIncRef( DMPP( p)); // ++ ref count of copied ptr, nop if NULL break; -#endif // PROBE #ifdef IMPORT // Import-file related features that depend on being linked in CSE environment @@ -1088,16 +1092,13 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign return rc; // RCOK if ok } // cuEvalI -#ifdef PROBE // features that depend especially on being linked in CSE environmemt //============================================================================ // is it time to put cuEvalI ms and pBadH in file-globals? -LOCAL RC FC cuRmGet( - void **pv, // point to value - const char** pms, +LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset check and expr fix. + NANDAT& vRet, // value returned (non-NAN if success) + const char** pms, // returned: unissued error message if any USI *pBadH) -// access 4-byte record member, for cuEvalI, with unset check and expr fix. - // pops record pointer from eval stack (evSp); fetches inline field number from instruction stream (evIp). // Expression reference (expected if input record probed) is replaced with current 4-byte value from expression table if set. @@ -1110,6 +1111,8 @@ LOCAL RC FC cuRmGet( 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 evf = fir.evf; how to get field variation (evaluation frequency) bits + *pms = nullptr; + vRet = 0; // check for mistimed probe eg to monthly results at end of day (when monthly results contain incomplete data) @@ -1189,6 +1192,8 @@ LOCAL RC FC cuRmGet( } } #if 1 + vRet = v; +#elif 0 if (fir->fi_GetDT() == DTCULSTR) *(const char**)pv = AsCULSTR(&v); else @@ -1250,9 +1255,7 @@ LOCAL RC FC cuRmGet( #endif return RCOK; } // cuRmGet -#endif // PROBE -#ifdef PROBE // features that depend especially on being linked in CSE environmemt //============================================================================ // is it time to put cuEvalI ms and pBadH in file-globals? LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) @@ -1288,9 +1291,7 @@ LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) *pi = *(SI *)((char *)e + fir->fi_off); // fetch 2-byte value from record at offset return RCOK; } // cuRm2Get -#endif -#ifdef PROBE // features that depend especially on being linked in CSE environmemt //============================================================================ LOCAL const char* FC ivlTx( IVLCH ivl) // text for interval. general use function? { @@ -1307,10 +1308,9 @@ LOCAL const char* FC ivlTx( IVLCH ivl) // text for interval. general use functi case C_IVLCH_S: return "subhour"; default: - return strtprintf( (char *)MH_R0229, (INT)ivl); // "Bad IVLCH value %d" + return strtprintf( (char *)MH_R0229, ivl); // "Bad IVLCH value %d" } } // ivlTx -#endif //============================================================================ static inline bool IsDM( DMP p) // return nz iff string block "looks like" it is on heap diff --git a/src/cuparse.cpp b/src/cuparse.cpp index 8fa43d18d..97a49fffe 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -82,9 +82,6 @@ AGENDA items decided to defer, 10-5-90: /*-------------------------------- OPTIONS --------------------------------*/ -#define PROBE // define to include code for CSE data structures "probe" feature. -// undefine for portable linkability (without cuprobe.cpp), as to use in another project. - #define IMPORT // define to include code for Import() function to access CSE import files. // undefine for portable linkability (without cncult4.cpp), eg to use in another project. @@ -183,11 +180,7 @@ OPTBL opTbl[] = PRASS, CSU, 0, 0, "=", // CUTEQ 19 = assignment 25, CSCMP, PSIGT, PSFGT, ">", // CUTGT 20 > 13, CSCUT, 0, 0, "?", // CUTQM 21 ? -#ifdef PROBE PROP, CSCUT, 0, 0, "@", // CUTAT 22 @ probe -#else - perr, CSU, 0, 0, "@", // CUTAT 22 @ -#endif // single chars [ .. ` have tok type ascii - '[' + 23 PROP, CSGRP, CUTRB, ']', "[", // CUTLB 23 [ grouping perr, CSU, 0, 0, "\\", // CUTBS 24 \ */ @@ -1539,12 +1532,10 @@ LOCAL RC expr( // parse/compile inner recursive fcn EE( var( (UVST*)stbk, wanTy) ) // do it break; -#ifdef PROBE case CUTAT: // @ []. NOVALUECHECK; EE( probe()); // cuprobe.cpp break; -#endif case CUTID: // identifier not yet in symbol table NOVALUECHECK; // added 2-92: always missing ?? diff --git a/src/strpak.cpp b/src/strpak.cpp index a797513ac..cfca289f0 100644 --- a/src/strpak.cpp +++ b/src/strpak.cpp @@ -119,7 +119,7 @@ char* CULSTR::CStrModifiable() const // pointer to string { return IsNANDLE() ? nullptr : us_GetCULSTREL().usl_str; -} // CULSTR::CStr() +} // CULSTR::CStrModifiable() //----------------------------------------------------------------------------- bool CULSTR::IsNANDLE() const { From 915fda6961689585015a1ee89cad46379867a7d9 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Mon, 28 Aug 2023 15:39:52 -0400 Subject: [PATCH 7/9] Initial 64-bit ctest scheme --- test/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 72e13301d..6a36dacb8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,13 @@ add_subdirectory(wcmp) add_subdirectory(error_handling) + +if ("${CSE_BUILD_ARCHITECTURE}" STREQUAL "64") + set( refdir "ref64") +else() + set( refdir "ref") +endif() + macro(make_cse_test case) get_filename_component(test_name ${case} NAME_WE) set(test_comment "! ") @@ -13,7 +20,7 @@ macro(make_cse_test case) ) add_test(NAME ${test_name}.Regression - COMMAND $ "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.rep" "${CMAKE_CURRENT_SOURCE_DIR}/ref/${test_name}.rep" "!" + COMMAND $ "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.rep" "${CMAKE_CURRENT_SOURCE_DIR}/${refdir}/${test_name}.rep" "!" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties(${test_name}.Regression PROPERTIES DEPENDS ${test_name}.Run) From 2706ab4e00c96a68a341747a02a382f8fd63de8d Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Tue, 3 Oct 2023 12:30:42 -0400 Subject: [PATCH 8/9] Corrections/fixes re PR comments --- src/CNRECS.DEF | 4 +- src/ancrec.cpp | 8 ++-- src/ancrec.h | 2 +- src/cgdebug.cpp | 7 +--- src/cncult3.cpp | 5 --- src/cnglob.h | 20 --------- src/cnguts.cpp | 8 ++-- src/cnloads.cpp | 2 +- src/cnztu.cpp | 8 ++-- src/cse.cpp | 20 ++++----- src/cueval.cpp | 108 +++++------------------------------------------- src/cueval.h | 2 + src/cuparse.cpp | 67 ++++++++++++++++-------------- src/cuparse.h | 2 +- src/cuprobe.cpp | 7 +++- src/cvpak.cpp | 55 ++---------------------- src/cvpak.h | 1 - src/exman.cpp | 41 +++++++++--------- src/msgtbl.cpp | 2 +- src/strpak.cpp | 19 +++++---- 20 files changed, 116 insertions(+), 272 deletions(-) diff --git a/src/CNRECS.DEF b/src/CNRECS.DEF index 4d4e4f5e6..fc38c0d8b 100644 --- a/src/CNRECS.DEF +++ b/src/CNRECS.DEF @@ -272,7 +272,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on // C_VENTAVAILCH_WHOLEHOUSE: airnet windows / fans // C_VENTAVAILCH_ZONAL: airnet windows / fans (controlled by zone) // C_VENTAVAILCH_RSYSOAV: RSYS outside air vent (central mechanical) - *declare "INT tp_GetVentAvail() const { return CHN( tp_ventAvail); }" + *declare "int tp_GetVentAvail() const { return CHN( tp_ventAvail); }" *s *e FLOAT tp_fVent // consensus whole building vent fraction (if not RSYSOAV) // = fraction of full vent flow to use @@ -2798,7 +2798,7 @@ RECORD ZNRES_SUB "zone results sub" *SUBSTRUCT RECORD ZNRES "znRes" *RAT // holds zones and all-zones simulation results (later at subscript # zones + 1) // .name (base class): same as corresponding zone, or sum_of_zones. *declare "ZNR* zr_GetZone() const;" - *declare "int zr_GetRunTotalInt( int fn) const;" + *declare "int zr_GetAllIntervalTotal( int fn) const;" *declare "void zr_InitPrior();" *declare "void zr_InitCurr();" diff --git a/src/ancrec.cpp b/src/ancrec.cpp index 617000c6d..d7f20c89f 100644 --- a/src/ancrec.cpp +++ b/src/ancrec.cpp @@ -714,7 +714,7 @@ RC record::notGzEr(int fn) // issue error message for field not greater than 0. //----------------------------------------------------------------------------- RC record::AtMost( // check for interacting input int setMax, // max # of fields that can be set in this group - int fn1, ...) // list of field #, 0 terminated, REMEMBER THE 0 + int fn, ...) // list of field #, 0 terminated, REMEMBER THE 0 // returns RCOK iff # set args with group <= setMax // else RCBAD (msg issued) @@ -724,17 +724,17 @@ RC record::AtMost( // check for interacting input std::vector< const char*> fnIdList; va_list ap; - va_start(ap, setMax); + va_start(ap, fn); int setCount = 0; // # of IsSet() fields int fnCount; // # of fields for (fnCount = 0; ; ++fnCount) { - int fn = va_arg(ap, int); if (!fn) break; if (IsSet(fn)) ++setCount; fnIdList.push_back(mbrIdTx(fn)); + fn = va_arg(ap, int); } if (setCount > setMax) @@ -1094,7 +1094,7 @@ BP FC basAnc::anc4n( USI an, int erOp/*=ABT*/) // access anc for anchor number { if (an < 1 || an > Nanc || !ancs || ancs[an]==0) { - err( erOp, (char *)MH_X0053, (INT)an); // "anc4n: bad or unassigned record anchor number %d" + err( erOp, (char *)MH_X0053, an); // "anc4n: bad or unassigned record anchor number %d" return 0; } return ancs[an]; diff --git a/src/ancrec.h b/src/ancrec.h index 32f8f7fff..b35ae4cb3 100644 --- a/src/ancrec.h +++ b/src/ancrec.h @@ -275,7 +275,7 @@ class record // base class for records void CDEC chafSelf( SI chafFn, ...); void CDEC chafN( BP _b, TI i, USI off, ...); void chafNV( BP _b, TI i, USI off, va_list ap); - RC AtMost(int setMax, int fn1, ...); + RC AtMost(int setMax, int fn, ...); RC CheckArray(int fn, int nSetExpected); RC limitCheck( int fn, double vMin, double vMax, diff --git a/src/cgdebug.cpp b/src/cgdebug.cpp index 01fc5b441..e9035e081 100644 --- a/src/cgdebug.cpp +++ b/src/cgdebug.cpp @@ -279,13 +279,8 @@ o pgbuildr( &pp, &rc, 0, 0, 0, NULL, &cfh, zp, PBDONE ); // XSURFs: Walls, windows, perimeter, mass exterior walls // CAUTION special args for some tables may be hard-coded into cgCmpDump by 'ty'. -#if 1 cgCmpDump( vrh, zi, 0, CTEXTWALL, &cmph1); -#endif -#if 1 cgCmpDump( vrh, zi, 0, CTMXWALL, &cmph1); -#endif -#if 1 cgCmpDump( vrh, zi, 0, CTINTWALL, &cmph1i); // !! 2-95 cgCmpDump( vrh, 0, zi, CTINTWALL, &cmph1io); // duplicate display of walls with "outside" in this zone cgCmpDump( vrh, zi, 0, CTWINDOW, &cmph2); @@ -328,7 +323,7 @@ o pgbuildr( &pp, &rc, 0, 0, 0, NULL, &cfh, zp, PBDONE ); } if (did) // if any izxfers pgbuildr( &pp, &rc, 0, 0, 0, NULL, PBDONE); // print PAGE -#endif + pgfree( &pp); // free page, NULL pp, pgpak.cpp } // cgzndump diff --git a/src/cncult3.cpp b/src/cncult3.cpp index c804dfefd..45a6d0a55 100644 --- a/src/cncult3.cpp +++ b/src/cncult3.cpp @@ -916,12 +916,7 @@ RC FC topSg() // SGDIST processing at RUN // solar gain: finally, add sgdist from window's XSURF to spec'd mass or quick surface side -#if defined( ND3264) cnuSgDist( &gz->x, targTy, targTi, AsNANDAT( sg->d.sd_FSO), AsNANDAT( sg->d.sd_FSC)); -#else - cnuSgDist(&gz->x, targTy, targTi, CSE_V sg->d.sd_FSO, CSE_V sg->d.sd_FSC); -#endif - // note: explicitly distributed solar gain is subtracted from that automatically distributed to zone's // air and surfaces at run time, in cgsolar.cpp (can't do here as .sd_FSO/C may contain live exprs). 2-95. diff --git a/src/cnglob.h b/src/cnglob.h index e3ec579ce..625508bd0 100644 --- a/src/cnglob.h +++ b/src/cnglob.h @@ -336,7 +336,6 @@ template< typename T> T& IvlData( T* ivlData, int ivl) // CAUTION: highly system dependent. CAUTION: keep distinct from NCHOICEs (below) // type to hold a NANDLE or a datum -#define ND3264 // #define to enable general 32/64 bit code TODO (MP) typedef uint32_t NANDAT; // 32 bit unsigned integer #define NANDLE(h) (static_cast(0xff800000 + h)) // "expr n" ref for float/int (or SI in 4 bytes). h = 1..16383. #define UNSET (NANDLE(0)) // "unset" value for float/int. cast as desired. @@ -362,14 +361,9 @@ template inline NANDAT AsNANDAT(T& v) { return *reinterpret_cast> 16)) more portable fetch-only alternative #define CHN(n) (*((uint16_t*)&(n)+1)) // access hi word, lvalue use ok. 80x86 DEPENDENT. PCMS<--grep target. -// #define CHN(n) (*((USI *)&(n)+1)) // access hi word, lvalue use ok. 80x86 DEPENDENT. PCMS<--grep target. - #define NCNAN 0x7f80 // bits that make nchoice a nan; is combined with choice index 1-7f to form stored value // macro to test if n has an NCHOICE value: @@ -378,20 +372,6 @@ template inline NANDAT AsNANDAT(T& v) { return *reinterpret_cast(nck) << 16)) // put in hi word. nck must include 0x7f80. -#else -// macro to fetch/store into variable n's hi word. Use w 16-bit flag/choice # dtypes.h C_DTYPE_XXXX constants gen'd by rcdef. -// usage: float y; CHN(y) = C_ABCNC_X; if (CHN(y)==C_ABCNC_X) ... -// #define CHN(n) ((USI)((ULI)(*(void **)&(n)) >> 16)) more portable fetch-only alternative -#define CHN(n) (*((USI *)&(n)+1)) // access hi word, lvalue use ok. 80x86 DEPENDENT. PCMS<--grep target. - -#define NCNAN 0x7f80 // bits that make nchoice a nan; is combined with choice index 1-7f to form stored value -// macro to test if n has an NCHOICE value: -#define ISNCHOICE(n) (((ULI)CSE_V(n) & 0xff800000L)==0x7f800000L) -// macro to generate 32-bit value from 16-bit choice constants, for use where full value needed, as in initialized data -// usage: float y = NCHOICE(C_ABCNC_X); -#define NCHOICE(nck) ((void *)((ULI)(nck) << 16)) // put in hi word. nck already includes 0x7f80. -#endif - /*---------------------- return codes / error codes ------------------------*/ // RC Return Codes: integers returned by fcns to indicate call outcome diff --git a/src/cnguts.cpp b/src/cnguts.cpp index 184f1c8f2..311324595 100644 --- a/src/cnguts.cpp +++ b/src/cnguts.cpp @@ -1408,13 +1408,13 @@ ZNR* ZNRES::zr_GetZone() const // zone of ZNRES { return ZrB.GetAtSafe( ss); } // ZNRES::zr_GetZone //----------------------------------------------------------------------------- -int ZNRES::zr_GetRunTotalInt( int fn) const -// return total of ZNRES INT values = cummulative count for run so far +int ZNRES::zr_GetAllIntervalTotal( int fn) const +// return total of ZNRES INT values = cumulative count for run so far { int dt = DType( ZNRES_CURR + ZNRES_SUB_M + fn); int sum = 0; if (dt != DTINT) - err( PERR, "ZNRES::zr_GetRunTotalLI '%s': bad fn = %d", + err( PERR, "ZNRES::zr_GetRunTotalInt '%s': bad fn = %d", Name(), fn); else { sum = *(INT *)field( ZNRES_CURR + ZNRES_SUB_Y + fn ) @@ -1424,7 +1424,7 @@ int ZNRES::zr_GetRunTotalInt( int fn) const + *(INT *)field( ZNRES_CURR + ZNRES_SUB_S + fn ); } return sum; -} // ZNRES::zr_GetRunTotalInt +} // ZNRES::zr_GetAllIntervalTotal //----------------------------------------------------------------------------- void ZNRES::zr_InitPrior() // initialize curr mbrs // WHY initialize prior values diff --git a/src/cnloads.cpp b/src/cnloads.cpp index ba14f317e..57c8cc201 100644 --- a/src/cnloads.cpp +++ b/src/cnloads.cpp @@ -3036,7 +3036,7 @@ int RSYS::rs_OAVAttempt() // most further this-step HVAC modelling is skipped if (ZnresB[ zp->ss].curr.S.nShVentH) { const int WARNMAX = 20; - int warnCount = ZnresB[ zp->ss].zr_GetRunTotalInt( ZNRES_IVL_SUB_NSHVENTH); + int warnCount = ZnresB[ zp->ss].zr_GetAllIntervalTotal( ZNRES_IVL_SUB_NSHVENTH); if (warnCount <= WARNMAX) warn( "Zone '%s', %s: unhelpful vent heating (supply temp = %0.2f)%s", zp->Name(), Top.When( C_IVLCH_S), tSup, diff --git a/src/cnztu.cpp b/src/cnztu.cpp index 078104af4..2cfa79399 100644 --- a/src/cnztu.cpp +++ b/src/cnztu.cpp @@ -191,7 +191,7 @@ RC FC hvacIterSubhr() // terminate loop after too many iterations if (++Top.iter >= MAXITER) // rer: display runtime message with date/time. errCount++'s. exman.cpp. - { rer( (char *)MH_R1250, (INT)Top.iter); + { rer( (char *)MH_R1250, Top.iter); break; // "Air handler - Terminals convergence failure: %d iterations" } @@ -200,7 +200,7 @@ RC FC hvacIterSubhr() { rc = rInfo( // display runtime "Information" message, exman.cpp. returns RCBAD. (char *)MH_R1251, // handle for text "More than %d errors. Terminating run." - (INT)maxErrors ); // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. + maxErrors ); // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. goto er; } } @@ -2640,7 +2640,7 @@ RC ZNR::ztuMdSeq() // build zone hvac terminal mode sequence table else if (x->spPri==nx->spPri) // "Equal setpoints (%g) with equal priorities (%d) in zone '%s' -- \n" { return rer( (char *)MH_R1257, // " %s and %s" - x->sp, (INT)x->spPri, Name(), + x->sp, x->spPri, Name(), x->ui ? strtprintf( (char *)MH_R1258, TuB.p[x->ui].Name()) : "natvent", // "terminal '%s'" nx->ui ? strtprintf( (char *)MH_R1258, TuB.p[nx->ui].Name()) : "natvent" ); // ditto } @@ -2874,7 +2874,7 @@ haveFlow: ; // other air handler cases join here with flow cz set wcO1 = wc; break; // sigma( c * ah_wSup) for calculating wz Rob's way, as aw/bw default: - rer( PWRN, (char *)MH_R1260, (INT)Top.humMeth); // "Bad Top.humMeth %d in cnztu.cpp:ZNR::ztuAbs" + rer( PWRN, (char *)MH_R1260, Top.humMeth); // "Bad Top.humMeth %d in cnztu.cpp:ZNR::ztuAbs" } // ... So and StO members can now be combined? diff --git a/src/cse.cpp b/src/cse.cpp index 03f185646..a22eaa24b 100644 --- a/src/cse.cpp +++ b/src/cse.cpp @@ -170,9 +170,9 @@ struct BrHans* hans = NULL; /* NULL, or dm pointer to structure (cnewin.h) for r #ifdef WINorDLL LOCAL void ourGlobalFree( HGLOBAL *pHan, char *desc); #endif -LOCAL INT cse1( INT argc, const char* argv[]); -LOCAL INT cse2( INT argc, const char* argv[]); -LOCAL INT cse3( INT argc, const char* argv[]); +LOCAL int cse1( int argc, const char* argv[]); +LOCAL int cse2( int argc, const char* argv[]); +LOCAL int cse3( int argc, const char* argv[]); LOCAL void zStaticVrhs( void); LOCAL void cnClean( CLEANCASE cs); @@ -242,7 +242,7 @@ _DLLImpExp void cneHansFree( // free memory whose handles previously returned to ourGlobalFree( &hans->hBrs, "Brhans.hBrs"); ourGlobalFree( &hans->hBrhHdr, "Brhans.hBrhHdr"); - for (INT i = 0; i < 12; i++) + for (int i = 0; i < 12; i++) ourGlobalFree( &hans->hBrhMon[i], "Brhans.hBrhMon[i]"); } } // cneHansFree @@ -416,7 +416,7 @@ _DLLImpExp int cse( // CSE main function, called by console main(), Windows Wi //---- call next level - INT errlvl = cse1( argc, argv); // below. returns 0 ok, 255 ^C 1-95, other non-0 other error. + int errlvl = cse1( argc, argv); // below. returns 0 ok, 255 ^C 1-95, other non-0 other error. //---- return info @@ -509,7 +509,7 @@ _DLLImpExp int CSEProgInfo( // returns } // extern "C" //------------------------------------------------------------------------ -LOCAL INT cse1( INT argc, const char* argv[]) +LOCAL int cse1( int argc, const char* argv[]) // This function level rearranges arguments when multiple input files are given, // calling cse2 (below) for each input file with cumulative flag (switch) arguments @@ -522,7 +522,7 @@ LOCAL INT cse1( INT argc, const char* argv[]) // return value is 'or' of return values from the multiple calls to cse2(). { - INT errlvl = 0; + int errlvl = 0; const char* argvx[ 64]; // argv[] for cse2: one filename, all flags to present filename, args after if last file. argvx[0] = argv[0]; // exe file name always passes thru int argci = 1; // input arg counter @@ -571,7 +571,7 @@ LOCAL INT cse1( INT argc, const char* argv[]) return errlvl; // 0 ok, nz error, 255 if ^C, 1-95. } // cse1run //------------------------------------------------------------------------ -LOCAL INT cse2( INT argc, const char* argv[]) +LOCAL int cse2( int argc, const char* argv[]) // This function level calls cse3 (below) and handles exceptions. // called by cse1(), above @@ -618,7 +618,7 @@ LOCAL BOO brDiscardable = FALSE; // TRUE to return bin res in discardable memor #endif static char* _repTestPfx = NULL; // from -x: testing prefix for some report data (hides e.g. rundatetime) //--------------------------------------------------------------------------------------------------------------------- -LOCAL INT cse3( INT argc, const char* argv[]) +LOCAL int cse3( int argc, const char* argv[]) // CSE primary function: inits, decodes input, does runs & reports, terminates. @@ -634,7 +634,7 @@ LOCAL INT cse3( INT argc, const char* argv[]) // Initialize the program - INT errorlevel = 0; // value to return to caller. 0 says all ok, 255 indicates ^C'd, other nz is error. + int errorlevel = 0; // value to return to caller. 0 says all ok, 255 indicates ^C'd, other nz is error. // Caller may return it as errorlevel. clearErrCount(); // clear the error count incremented by err, etc, etc, calls. rmkerr.cpp. rob 5-97. diff --git a/src/cueval.cpp b/src/cueval.cpp index 59a284059..7b700d65d 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -93,7 +93,8 @@ LOCAL const char * FC ivlTx( IVLCH ivl); /*lint -e52 "Expected an lvalue" on every "((SI*)evSp)--" etc */ /*lint -e63 "Expected an lvalue" on every "(char *)evSp += ..." */ -#if 1 // idea, used in test program, may not be pertinent +#ifdef wanted +// idea, used in test program, may not be pertinent //=========================================================================== RC FC cuEvalTop( void *ip) // evaluate psuedocode at ip, check for empty stack when done @@ -157,19 +158,19 @@ RC FC cuEvalR( // evaluate pseudocode & return ptr to value rc = cuEval( ip, pmsg, pBadH); // evaluate to *evStk if (ppv != NULL) // return pointer to value in eval stack *ppv = evSp; -#if 0 // TODO64 +#if defined( _DEBUG) if (rc==RCOK) // if ok, check size of value: devel aid { // remove if other sizes become possible - SI sz = (SI)((char *)evStkBase - (char *)evSp); - if (sz != 2 && sz != 4) + int sz = int((const char*)evStkBase - (const char*)evSp); + if (sz != 2 && sz != 4 && sz != 8) { - const char* ms = strtprintf( (char *)MH_R0202, sz); // "cuEvalR internal error: \n value %d bytes: neither 2 nor 4" + const char* ms = strtprintf((const char*)MH_R0202, sz); // "cuEvalR internal error: \n value %d bytes: neither 2 nor 4" if (pmsg) *pmsg = ms; // return TRANSITORY message pointer else - err( PWRN, ms); // issue internal error msg - return RCBAD; + err(PWRN, ms); // issue internal error msg + rc = RCBAD; } } #endif @@ -257,14 +258,6 @@ LOCAL RC FC cuEvalI( void* tIp; void* tSp; NANDAT vND; -#if 0 -#if 0 && defined( ND3264) -made things worse TODO (MP) - NANDAT p; -#else - void *p; -#endif -#endif BP b; record *e; float fv; @@ -874,7 +867,6 @@ made things worse TODO (MP) (char *)b->what, pName ); goto breakbreak; } - // ?? cupfree( DMPP( p)); // free dm for consumed string, if not ptr into pseudoCode } break; @@ -902,37 +894,21 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign break; /*lint +e70 */ // add UNSET ck if need found. case PSRATLODA: POINT; -#if 1 * --SPP = strsave( (const char*)v); -#else - *--SPP = AsCULSTR(v).Strsave(); -#endif break; // char[], eg ANAME: put in dm. NAN not expected. case PSRATLODS: // CULSTR: 4 byte value - if ((rc = cuRmGet(vND,&ms,pBadH)) != RCOK) // char *. 1st fetch/check/fix 4 bytes. - goto breakbreak; // if unset data or uneval'd expr, ms set. -#if 0 - if (p) - cupIncRef( DMPP( p)); // ++ ref count of ptr if not into code (below) - else - p = strsave(""); // supply dm "" for NULL pointer -#endif - { const char* s = AsCULSTR(&vND).CStr(); + { if ((rc = cuRmGet(vND,&ms,pBadH)) != RCOK) // char *. 1st fetch/check/fix 4 bytes. + goto breakbreak; // if unset data or uneval'd expr, ms set. + const char* s = AsCULSTR(&vND).CStr(); *--SPP = (void*)s; // stack pointer } break; case PSRATLOD4: -#if 1 if ((rc = cuRmGet( vND, &ms, pBadH)) != RCOK) // 4 bytes: float/INT/UINT. 1st fetch/check/fix 4 bytes. goto breakbreak; // if unset data or uneval'd expr, ms set. *--SPL = vND; // push value fetched -#else - if ((rc = cuRmGet(&p,&ms,pBadH)) != RCOK) // 4 bytes: float/INT/UINT. 1st fetch/check/fix 4 bytes. - goto breakbreak; // if unset data or uneval'd expr, ms set. - *--SPP = p; // push value fetched -#endif break; //--- expression data loads: used when (immediate input) locn already containing expr is probed. 12-91. @@ -1142,7 +1118,6 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che } // fetch and check 4-byte quantity -#if defined( ND3264) NANDAT v = *(NANDAT *)((char *)e + fir->fi_off); // fetch 4-byte value from record at offset if (ISNANDLE(v)) { @@ -1182,68 +1157,7 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che } } } -#if 1 vRet = v; -#elif 0 - if (fir->fi_GetDT() == DTCULSTR) - *(const char**)pv = AsCULSTR(&v); - else - *(NANDAT*)pv = v; -#elif 0 - if (fir->fi_GetDT() == DTCULSTR) - CopyCULSTR(pv, &v); - else - *(NANDAT*)pv = v; -#else - if (fir->fi_GetDT() == DTCULSTR) - *(const char**)pv = AsCULSTR(&v).Strsave(); - else - *(NANDAT *)pv = v; -#endif -#else - 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->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->fi_off)); // describe probed mbr. exman.cpp - return RCBAD; - } -#endif - else // other nandles are expression handles - { - USI h = EXN(v); // extract expression number, exman.h macro. - 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->fi_off)); - return RCBAD; - } - if (ISNANDLE(v)) // if expr table contains nan, expr is not eval'd yet. - { - /* DON'T evaluate it now from here without a way to reorder later evaluations, - because stale values would be used on iterations after the first (unless constant). **** */ - - *pms = strtprintf((char*)MH_R0228, // "%s has not been evaluated yet." Also used below. - whatEx(h)); /* whatEx: describes expression origin per exTab, exman.cpp. - whatNio produces similar text in cases tried but - suspect whatEx may be better in obscure cases. */ - if (pBadH) // if caller gave info return pointer - *pBadH = h; // return expression number of uneval'd expr (0 if UNSET) - return RCUNSET; // specific "uneval'd expr" error code, callers may test. - } - } - } - *pv = v; -#endif return RCOK; } // cuRmGet //============================================================================ diff --git a/src/cueval.h b/src/cueval.h index 10a06e00b..62030d2e7 100644 --- a/src/cueval.h +++ b/src/cueval.h @@ -234,7 +234,9 @@ extern SI runtrace; // non-0 to display debugging info during execution /*------------------------- FUNCTION DECLARATIONS -------------------------*/ // cueval.c +#ifdef wanted RC FC cuEvalTop( void *ip); +#endif RC FC cuEvalR( void *ip, void **ppv, const char **pmsg, USI *pBadH); RC FC cupfree( DMP *p); RC FC cupIncRef( DMP *p, int erOp=ABT); diff --git a/src/cuparse.cpp b/src/cuparse.cpp index e28705854..c610d183f 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -964,7 +964,7 @@ RC FC funcsVarsClear() // remove all user functions and (future) variables from RC FC exOrk( // compile expression from current input file, return constant value or pseudo-code SI toprec, // precedence to which to parse, or -1 to default - USI wanTy, // desired type (cuparse.h) TYSI TYFL TYSTR TYFLSTR TYSTR|TYSI TYID (rets TYSTR) TYID|TYSI + USI wanTy, // desired type (cuparse.h) TYSI TYINT TYFL TYSTR TYFLSTR TYSTR|TYSI TYID (rets TYSTR) TYID|TYSI // TYCH (2 or 4 byte) TYNC (rets TYFL / TYCH / TYNC=runtime determined) USI choiDtPar, // DTxxx data type (dtype.h) when wanTy is TYCH or TYNC, else not used. USI evfOkPar, // 0xffff or acceptable eval freq (and EVxxxIVL) bits: other evf's error @@ -972,16 +972,17 @@ RC FC exOrk( // compile expression from current input file, return constant valu USI *pGotTy, // NULL or receives data type found (useful eg when TYFLSTR requested) USI *pEvf, // receives cleaned evaluation frequency bits SI *pisKon, // receives non-0 if expression is constant - void *pvPar, // if constant, rcvs value, <= 4 bytes (ptr if TYSTR), else not changed -- caller may pre-store nandle. + NANDAT* pvPar, // if constant, rcvs value, <= 4 bytes, else not changed -- caller may pre-store nandle. // RECEIVES 4 BYTES even for SI or 2-byte choice value (caller truncates). PSOP **pip ) // rcvs ptr to code in dm (if not constant) else NULL -/* also, on return, tokty reflects terminating token. - ; , ) ] terminators passed; verb or other ungotten. */ -/* design intended to facilitate making parStk, psp, etc internal to this file - while leaving EXTAB internal to calling file. */ +// also, on return, tokty reflects terminating token. +// ; , ) ] terminators passed; verb or other ungotten. -/* if not RCOK, attempts to return functional constant zero or null value. */ +// design intended to facilitate making parStk, psp, etc internal to this file +// while leaving EXTAB internal to calling file. */ + +// if not RCOK, attempts to return functional constant zero or null value. { #define Eer(f) { rc = (f); if (rc!=RCOK) goto er; } // local err handler @@ -1015,27 +1016,27 @@ RC FC exOrk( // compile expression from current input file, return constant valu Eer( finPile( &codeSize) ) // now terminate compilation / get size // for constant, return value and no code - ULI v = 0; // TODO64 -- ULI? + NANDAT v = 0; if (isKon) // if konstize found (or made) a constant value { // fetch from konstize's storage, condition value if (gotTy == TYSTR) // pv points to ptr to text -#if 1 { - CULSTR sv = *(const char**)pv; - sv.IsValid(); - v = *reinterpret_cast(&sv); + CULSTR sv = *(const char**)pv; // convert to CULSTR (copies) + sv.IsValid(); // msg if invalid + v = AsNANDAT(sv); + } + else if (gotTy==TYSI // SI (short int) + || (gotTy==TYCH && (choiDt & DTBCHOICB) && !ISNCHOICE(*(void**)pv))) // choice, 2-byte ch req'd, didn't get 4-byte ch + // (redundancy: distrust choiDt global) + { + USI iV = *(USI*)pv; + v = iV; // make hi word 0 (not a nan!) } -#else - v = (ULI)cuStrsaveIf( *(char **)pv); // if text is inline in code, copy to dm, - // so caller can discard code & retain value. cueval.cpp -#endif - else if (gotTy==TYSI // (short) int, or - || gotTy==TYCH && choiDt & DTBCHOICB && !ISNCHOICE(*(void**)pv)) // choice, 2-byte ch req'd, didn't get 4-byte ch - // (redundancy: distrust choiDt global) - v = (ULI)*(USI*)pv; // make hi word 0 (not a nan!) else - v = *(ULI*)pv; // fetch float, 4-byte choice, etc value + { UINT iV = *(UINT*)pv; // fetch float, 4-byte choice, etc value + v = iV; + } //ip = NULL; // NULL to return in pseudo-code pointer set above //gotEvf = 0; init at entry } @@ -1047,8 +1048,8 @@ RC FC exOrk( // compile expression from current input file, return constant valu memcpy( ip, ps, codeSize); // put pseudocode in the space // ip returned in *pip below. // *pvPar left unchanged (caller may preset to nandle) - gotEvf = cleanEvf( parSp->evf, evfOk); /* clear redundant bits, - convert MON & HR & !DAY to/from MH per context. below. */ + gotEvf = cleanEvf( parSp->evf, evfOk); // clear redundant bits, + // convert MON & HR & !DAY to/from MH per context. below. #if 1 // 11-25-95 making fcns work: Add here cuz removed in cleanEvf. Also changes in expr, evfTx. if (gotEvf & EVFDUMMY) // 'contains dummy arg' bit should not get here (cleared in funcDef). perlc( "Internal error in cuparse.cpp:exOrk: Unexpected 'EVFDUMMY' flag"); @@ -1059,11 +1060,9 @@ RC FC exOrk( // compile expression from current input file, return constant valu if (rc != RCOK) { er: // Eer macro comes here on non-RCOK fcn return - isKon = 1; // say is constant (ret *pisKon) - if (gotTy==TYSTR) // gotTy init to wanTy above - v = (ULI)""; // for string return null string TODO64 -- ULI? - else - v = 0L; // for float or int return zero + isKon = 1; // say is constant (ret *pisKon) + v = 0; // return 0 for numeric types + // for CULSTR, 0 = "" // ip = NULL preset above. gotEvf=0 init. } @@ -1078,7 +1077,7 @@ RC FC exOrk( // compile expression from current input file, return constant valu *pip = ip; // NULL or pointer to pseudo-code if (isKon) // *pvPar left unchanged if non-constant if (pvPar) - *(NANDAT*)pvPar = v; // TODO64: was ULI*, NANDAT* seems right + *pvPar = v; return rc; #undef Eer @@ -3268,7 +3267,6 @@ LOCAL SI FC isKonExp( // test if *parSp is a constant expression 2: constant expression, but not last subexpression emitted 3: constant expression that can be evaluated now and replaced in place with a constant */ { - static char *p; // TODO64 -- yikes, return value in static? See return 1 case // test if has side effect -- if so, better do at run time if (parSp->did) // if contains assignment, fcn w side effect, etc @@ -3278,9 +3276,13 @@ LOCAL SI FC isKonExp( // test if *parSp is a constant expression if (parSp->evf != 0) // or contains dummy ref (EVFDUMMY) return 0; // some element in expr not constant + static const char* p; // persistent return for string pointer + // see return 1 case. RISKY? see issue #437 + // cases by type PSOP kop; USI szkon{ 0 }; + switch (parSp->ty) { /* case TYANY: TYNUM: TYNONE: TYDONE: */ @@ -3328,7 +3330,8 @@ LOCAL SI FC isKonExp( // test if *parSp is a constant expression } /*lint +e616 */ // test if already just a constant - USI sz = (USI)((char *)parSp->psp2 - (char *)parSp->psp1); + + USI sz = USI((char *)parSp->psp2 - (char *)parSp->psp1); if (sz==szkon) // if right size incl args { if (*parSp->psp1==kop) // if op code already constant-load @@ -3337,7 +3340,7 @@ LOCAL SI FC isKonExp( // test if *parSp is a constant expression #if defined( USE_PSPKONN) if (kop==PSPKONN) // string inline in code { - p = (char *)(parSp->psp1 + 2); // is after op code & length + p = (const char *)(parSp->psp1 + 2); // is after op code & length *ppv = &p; // indirect like cuEvalR() } else // other types [or string ptr in code] diff --git a/src/cuparse.h b/src/cuparse.h index 88347b57e..b39c36ef4 100644 --- a/src/cuparse.h +++ b/src/cuparse.h @@ -17,7 +17,7 @@ void FC cuParseClean(CLEANCASE cs); RC FC fov(); RC FC funcsVarsClear(); RC FC exOrk( SI toprec, USI wanTy, USI choiDt, USI evfOkPar, const char* ermTx, - USI *pGotTy, USI *pEvf, SI *pisKon, void *pv, PSOP **pip ); + USI *pGotTy, USI *pEvf, SI *pisKon, NANDAT* pv, PSOP **pip ); RC FC itPile( PSOP *dest, USI sizeofDest); RC FC finPile( USI *pCodeSize); RC FC expTy( SI toprec, USI wanTy, const char* tx, SI aN); diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index fb1e5aa66..4daa16d76 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -609,8 +609,6 @@ LOCAL RC FC lopNty4dt( // for DT- data type, get TY- type and PSOP to load it f break; case DTLDATETIME: // show dateTime as number (?) - case DTLI: // TODO64 probably don't want DTLI here - case DTULI: lop = PSRATLODL; // record load long: converts it float, potentially loosing some precision. ty = TYFL; sz = 4; @@ -639,6 +637,7 @@ w sz = 2; w break; #else // DTCH un-probe-able: only used in field type CH, which is not used in any records 12-91 + case DTCH: #endif @@ -653,6 +652,10 @@ w break; case DTUCH: #endif + // DTLI / DTULI un-probable. 32 or 64 bit. No fields with this DT 10-23. Could add load / convert to int? + case DTLI: + case DTULI: + // unprobe-able: pointers to basic types (or add a way fetch?) case DTSGTARGP: diff --git a/src/cvpak.cpp b/src/cvpak.cpp index bf959977d..88c78329d 100644 --- a/src/cvpak.cpp +++ b/src/cvpak.cpp @@ -1377,11 +1377,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for continue; if (dt & DTBCHOICN) // for choice in number-choice store bit pattern of { if (pv) -#if defined( ND3264) *reinterpret_cast(pv) = NCHOICE(v | NCNAN); -#else - *(void **)pv = NCHOICE( v | NCNAN); -#endif // .. NCNAN (7f80, cnglob.h) + choice 1,2,3.. in hi word of float. if (pSz) *pSz = sizeof(float); // tell caller value size is 4 bytes @@ -1742,7 +1738,8 @@ t} /* main */ //=========================================================================== #if 0 -unused, 2-2022 +unused, keep 2-2022 +reconcile with similar code in cutok.cpp See gitub issue #435 (10/2023) RC FC cvatol( /* convert string to (signed) long integer */ char *s, /* string */ @@ -2014,50 +2011,4 @@ RC FC cvatof( // Convert a string to a double value return RCOK; } /* cvatof */ -#if 0 -unused -#if 1 /* add 'w' 7-25-90 */ -#pragma optimize("aw",off) /* turn off no-aliases options because args -s1 and s2 point into same string. (With - -Oa on, compiler moved "*s2 = c;" before - cvatof, defeating partial-string decode). -"w" added as insurance 7-25-90 since deflt -optimization now includes -Ow. Did NOT -verify that -Ow makes bad code. chip */ -#else -x #pragma optimize("a",off) /* turn off no-aliases option becuase args -x s1 and s2 point into same string. (With -x -Oa on, compiler moved "*s2 = c;" before -x cvatof, defeating partial-string decode) */ -#endif /* 7-25-90 */ -//======================================================================== -RC FC cvatof2( /* Substring variant of cvatof() */ - - char *s1, /* Pointer to beg of string to be converted */ - char *s2, /* Pointer to end+1 of string to be converted */ - double *vp, /* Pointer to double to receive converted value */ - SI percent ) /* nz: trailing '%' is acceptable (and ignored) - 0: '%' treated as error */ - -/* This function temporarily replaces *s2 with '\0' and then calls - cvatof(). Return RC describes outcome of conversion. See cvatof(). */ -{ - char c; - RC rc; - - c = *s2; - *s2 = '\0'; - rc = cvatof( s1, vp, percent); - *s2 = c; - return rc; -} /* cvatof2 */ - -#if 1 /* restore back prior options only, chip 7-25-90 */ -#pragma optimize("",on) /* restore cmd line/default optimization */ -#else -x #pragma optimize("a",on) /* restore */ -#endif /* 7-25-90 */ - -#endif - -// end of cvpak.c +// end of cvpak.cpp diff --git a/src/cvpak.h b/src/cvpak.h index a9b0e9ad8..963f169fa 100644 --- a/src/cvpak.h +++ b/src/cvpak.h @@ -83,7 +83,6 @@ RC FC cvS2Choi( const char *s, USI dt, void *pv, USI *pSz, const char** pms); RC FC cvatof( const char *_str, double *vp, bool percent=false ); #if 0 x RC FC cvatol(char* s, INT* pn, SI hexoct); // convert string to long integer -x RC FC cvatof2( char *s1, char *s2, double *vp, SI percent ); #endif // end of cvpak.h diff --git a/src/exman.cpp b/src/exman.cpp index 4f89b2986..acc86e046 100644 --- a/src/exman.cpp +++ b/src/exman.cpp @@ -152,7 +152,8 @@ LOCAL RC addStore(int h, const WHERE& w); /*---------- Expression Table ----------*/ -#undef USEVECT +#undef USEVECT // define to enable rework using std::vector + // throws out of library code; TODO: debug struct EXTAB // expression table (*exTab[i]) struct { @@ -364,11 +365,7 @@ void FC extDup(record* nuE, record* e) // duplicate expression table entries fo { USI off = ex->ext_srcB->fir[ex->ext_srcFn].fi_off; if (ex->ext_ty == TYSI // if integer (too small for nandle) -#if defined( ND3264) || *(NANDAT*)((char*)e + off) == NANDLE(h)) // or field has correct nandle -- insurance -#else - || *(NANDAT*)((char*)e + off) == NANDLE(h)) // or field has correct nandle -- insurance -#endif { USI nuH; if (extAdd(&nuH) == RCOK) // add exTab entry / if ok @@ -399,11 +396,7 @@ void FC extDup(record* nuE, record* e) // duplicate expression table entries fo // put its expression handle in its record member if (nuEx->ext_ty != TYSI) -#if defined( ND3264) * (NANDAT*)((char*)nuE + off) = NANDLE(nuH); -#else - * (void**)((char*)nuE + off) = NANDLE(nuH); -#endif } } } @@ -651,12 +644,7 @@ RC FC exPile( // compile an expression from current input /* on RCOK return, tokTy reflects terminator and , ; ) ] terminators passed. on error return, msg issued and rest of input statement passed (we hope).*/ { - USI gotTy, gotEvf, h; - SI isKon; - NANDAT v=0; - PSOP *ip; - EXTAB *ex; - RC rc; + // arg checks @@ -676,10 +664,18 @@ RC FC exPile( // compile an expression from current input if (!(choiDt & DTBCHOICN)) return perlc( (char *)MH_E0092, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" " called with TYNC wanTy 0x%x but 2-byte choiDt 0x%x" */ - /* compile expression from current input file to pseudocode OR constant value */ - CSE_E( /* CSE_E: if not RCOK, return error code rc now. */ - exOrk( /* cuparse.cpp */ + // compile expression from current input file to pseudocode OR constant value + + USI gotTy, gotEvf, h; + SI isKon; + NANDAT v=0; + PSOP *ip; + EXTAB *ex; + RC rc; + + CSE_E( // CSE_E: if not RCOK, return error code rc now. + exOrk( toprec, /* terminating precedence, exOrk defaults. */ wanTy==TYLLI ? TYSI : wanTy, /* for limited-long-integer get 16-bit value (4 byte size used to hold nandle) */ choiDt, @@ -692,7 +688,7 @@ RC FC exPile( // compile an expression from current input &ip ) ) // rcvs NULL if constant, or ptr to pseudo-code in dm // leaves tokTy set; comma ; ) ] terminators gobbled. - /* check/return constant now */ + // check/return constant now if (isKon) { CSE_E(uniLimCt(fdTy, gotTy, _ermTx, &v)); // check limits & apply units, with errMsg suitable for compile time. below. @@ -700,7 +696,8 @@ RC FC exPile( // compile an expression from current input if (gotTy == TYSI // return the constant value in destination. SI has 16 bit storage only || gotTy == TYCH && choiDt & DTBCHOICB) // choice types with this bit on are 16 bits only { - *(SI*)pDest = (SI)(INT)v; // return lo 16 bits of value + SI iV = static_cast(v); + *(SI*)pDest = iV; // return lo 16 bits of value if (ISNCHOICE(v)) // redundantly check for not a 4-byte choice value (cnglob.h macro) perlc((char*)MH_E0093); // "exman.cpp:exPile: Internal error:\n" // " 4-byte choice value returned by exOrk for 2-byte type". devel aid @@ -715,7 +712,7 @@ RC FC exPile( // compile an expression from current input extDelFn( b, i, fn); // delete any pre-existing expression table entry for this member } - /* if not an already-evaluated constant, enter in expr table, return nandle in caller's destination. */ + // if not an already-evaluated constant, enter in expr table, return nandle in caller's destination. else { @@ -764,7 +761,7 @@ RC FC exPile( // compile an expression from current input EXTDUMPIF( "exPile new end"); } -#if 1 && defined( _DEBUG) +#if defined( _DEBUG) extValidate( "exPile"); #endif diff --git a/src/msgtbl.cpp b/src/msgtbl.cpp index 3fd2ff593..4db24de97 100644 --- a/src/msgtbl.cpp +++ b/src/msgtbl.cpp @@ -1134,7 +1134,7 @@ x { MH_T0003, "\nReport file name: %s" }, // cueval.cpp: runtime errors in expression evaluator -- 7-92 { MH_R0201, "R0201: cuEvalTop: %d words left on eval stack" }, - { MH_R0202, "R0202: cuEvalR internal error: \n value %d bytes: neither 2 nor 4" }, + { MH_R0202, "R0202: cuEvalR internal error: \n value %d bytes: not 2, 4, or 8" }, // { MH_R0203, "R0203: " }, // out of service { MH_R0204, "R0204: cuEvalI internal error: \n eval stack overflow at ps ip=%p" }, { MH_R0205, "R0205: cuEvalI internal error: \n eval stack underflow at ps ip=%p" }, diff --git a/src/strpak.cpp b/src/strpak.cpp index 68daf6036..70539bb4a 100644 --- a/src/strpak.cpp +++ b/src/strpak.cpp @@ -131,8 +131,9 @@ bool CULSTR::us_HasCULSTREL() const return !IsNANDLE() && !IsNull(); } // CULSTR::us_HasCULSTREL //----------------------------------------------------------------------------- -void CULSTR::Set( - const char* str) +void CULSTR::Set( // set from const char* + const char* str) // source string + // if nullptr, release { if (!str) { @@ -148,8 +149,7 @@ void CULSTR::Set( us_Alloc(); // can move! } - if (!us_hCulStr) - printf("\nSetting str0"); + assert(us_hCulStr != 0); us_GetCULSTREL().usl_Set(str); } @@ -166,15 +166,20 @@ void CULSTR::FixAfterCopy() } // CULSTR::FixAfterCopy //----------------------------------------------------------------------------- bool CULSTR::IsValid() const +// returns true iff CULSTR is valid { + // check handle: s/b NANDLE or within known range bool bValid = IsNANDLE() || (us_hCulStr >= 0 && us_hCulStr < us_csc.us_vectCULSTREL.size()); if (!bValid) - printf("\nBad hCulStr %d", us_hCulStr); + err( PERR, "Invalid CULSTR %d", us_hCulStr); +#if defined( _DEBUG) + // CULSTR 0 should always be "" const char* str0 = us_csc.us_vectCULSTREL[0].usl_str; if (!str0 || strlen(str0) > 0) - printf("\nBad str0"); + err( PERR, "Bad str0"); +#endif return bValid; } // CULSTR::IsValid @@ -1261,7 +1266,7 @@ char* strMakeTextList( // combine strings into text list (for msgs) // returns combined list in Tmpstr (or static). strsave to make permanent. { - int nStr = strs.size(); + int nStr = static_cast(strs.size()); if (nStr == 0) return ""; // no strings From 4a5b007e992e5f2e11a27dfb32c8acb4af3b18d1 Mon Sep 17 00:00:00 2001 From: Chip Barnaby Date: Tue, 3 Oct 2023 13:44:54 -0400 Subject: [PATCH 9/9] Remove unwanted #pragma in timer.cpp --- src/timer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index eadaf73a1..411901dd5 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -10,8 +10,6 @@ #include "vrpak.h" // vrPrintf #include "timer.h" -#pragma optimize( "", off) - // local data struct TMRDATA {