summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-04-16 23:31:33 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-04-16 23:31:33 (GMT)
commit98546bb8b6be883f790f5d6ba1ef37151165116a (patch)
tree467609e01abca9216802d76c8cfaa88a2d166c0c /generic/tclExecute.c
parentb97ca5b2bb3826e20a13ff1583baf7df0d8754f6 (diff)
downloadtcl-98546bb8b6be883f790f5d6ba1ef37151165116a.zip
tcl-98546bb8b6be883f790f5d6ba1ef37151165116a.tar.gz
tcl-98546bb8b6be883f790f5d6ba1ef37151165116a.tar.bz2
* generic/tcl.h Made changes so that the "wideInt" Tcl_ObjType
* generic/tclObj.c is defined on all platforms, even those where * generic/tclPort.h TCL_WIDE_INT_IS_LONG is defined. Also made the Tcl_Value struct have a wideValue field on all platforms. This is a ***POTENTIAL INCOMPATIBILITY*** for TCL_WIDE_INT_IS_LONG platforms because that struct changes size. This is the same TIP 72 incompatibility that was seen on other platforms at the 8.4.0 release, when this change should have happened as well. [Bug 713562] * generic/tclInt.h: New internal macros TclGetWide() and TclGetLongFromWide() to deal with both forms of the "wideInt" Tcl_ObjType, so that conditional TCL_WIDE_INT_IS_LONG code is confined to the header file. * generic/tclCmdAH.c: Replaced most coding that was conditional * generic/tclCmdIL.c: on TCL_WIDE_INT_IS_LONG with code that * generic/tclExecute.c: works across platforms, sometimes using * generic/tclTest.c: the new macros above to do it. * generic/tclUtil.c: * generic/tclVar.c:
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c253
1 files changed, 63 insertions, 190 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 18bba5d..e0dd860 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.94 2003/02/19 14:33:39 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.94.2.1 2003/04/16 23:31:43 dgp Exp $
*/
#include "tclInt.h"
@@ -258,18 +258,6 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
# define O2S(objPtr)
#endif /* TCL_COMPILE_DEBUG */
-
-/*
- * Most of the code to support working with wide values is factored
- * out here because it greatly reduces the number of conditionals
- * through the rest of the file. Note that this needs to be
- * conditional because we do not want to alter Tcl's behaviour on
- * native-64bit platforms...
- */
-
-#ifndef TCL_WIDE_INT_IS_LONG
-#define W0 Tcl_LongAsWide(0)
-
/*
* Macro to read a string containing either a wide or an int and
* decide which it is while decoding it at the same time. This
@@ -297,19 +285,6 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
(objPtr)->internalRep.longValue = (longVar) \
= Tcl_WideAsLong(wideVar); \
}
-#define IS_INTEGER_TYPE(typePtr) \
- ((typePtr) == &tclIntType || (typePtr) == &tclWideIntType)
-/*
- * Extract a double value from a general numeric object.
- */
-#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
- if ((typePtr) == &tclIntType) { \
- (doubleVar) = (double) (objPtr)->internalRep.longValue; \
- } else if ((typePtr) == &tclWideIntType) { \
- (doubleVar) = Tcl_WideAsDouble((objPtr)->internalRep.wideValue);\
- } else { \
- (doubleVar) = (objPtr)->internalRep.doubleValue; \
- }
/*
* Combined with REQUIRE_WIDE_OR_INT, this gets a long value from
* an obj.
@@ -318,34 +293,37 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
if ((objPtr)->typePtr == &tclWideIntType) { \
(longVar) = Tcl_WideAsLong(wideVar); \
}
+#define IS_INTEGER_TYPE(typePtr) \
+ ((typePtr) == &tclIntType || (typePtr) == &tclWideIntType)
+#define IS_NUMERIC_TYPE(typePtr) \
+ (IS_INTEGER_TYPE(typePtr) || (typePtr) == &tclDoubleType)
+
+#define W0 Tcl_LongAsWide(0)
/*
* For tracing that uses wide values.
*/
-#define LLTRACE(a) TRACE(a)
-#define LLTRACE_WITH_OBJ(a,b) TRACE_WITH_OBJ(a,b)
#define LLD "%" TCL_LL_MODIFIER "d"
-#else /* TCL_WIDE_INT_IS_LONG */
+
+#ifndef TCL_WIDE_INT_IS_LONG
/*
- * Versions of the above that do not use wide values.
+ * Extract a double value from a general numeric object.
*/
-#define REQUIRE_WIDE_OR_INT(resultVar, objPtr, longVar, wideVar) \
- (resultVar) = Tcl_GetLongFromObj(interp, (objPtr), &(longVar));
-#define GET_WIDE_OR_INT(resultVar, objPtr, longVar, wideVar) \
- (resultVar) = Tcl_GetLongFromObj((Tcl_Interp *) NULL, (objPtr), \
- &(longVar));
-#define IS_INTEGER_TYPE(typePtr) ((typePtr) == &tclIntType)
#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
if ((typePtr) == &tclIntType) { \
(doubleVar) = (double) (objPtr)->internalRep.longValue; \
+ } else if ((typePtr) == &tclWideIntType) { \
+ (doubleVar) = Tcl_WideAsDouble((objPtr)->internalRep.wideValue);\
+ } else { \
+ (doubleVar) = (objPtr)->internalRep.doubleValue; \
+ }
+#else /* TCL_WIDE_INT_IS_LONG */
+#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
+ if (((typePtr) == &tclIntType) || ((typePtr) == &tclWideIntType)) { \
+ (doubleVar) = (double) (objPtr)->internalRep.longValue; \
} else { \
(doubleVar) = (objPtr)->internalRep.doubleValue; \
}
-#define FORCE_LONG(objPtr, longVar, wideVar)
-#define LLTRACE(a)
-#define LLTRACE_WITH_OBJ(a,b)
#endif /* TCL_WIDE_INT_IS_LONG */
-#define IS_NUMERIC_TYPE(typePtr) \
- (IS_INTEGER_TYPE(typePtr) || (typePtr) == &tclDoubleType)
/*
* Declarations for local procedures to this file:
@@ -371,10 +349,8 @@ static int ExprSrandFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
static int ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
-#ifndef TCL_WIDE_INT_IS_LONG
static int ExprWideFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
-#endif /* TCL_WIDE_INT_IS_LONG */
#ifdef TCL_COMPILE_STATS
static int EvalStatsCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
@@ -437,11 +413,7 @@ BuiltinFunc tclBuiltinFuncTable[] = {
{"rand", 0, {TCL_EITHER}, ExprRandFunc, 0}, /* NOTE: rand takes no args. */
{"round", 1, {TCL_EITHER}, ExprRoundFunc, 0},
{"srand", 1, {TCL_INT}, ExprSrandFunc, 0},
-#ifdef TCL_WIDE_INT_IS_LONG
- {"wide", 1, {TCL_EITHER}, ExprIntFunc, 0},
-#else
{"wide", 1, {TCL_EITHER}, ExprWideFunc, 0},
-#endif /* TCL_WIDE_INT_IS_LONG */
{0},
};
@@ -1097,9 +1069,7 @@ TclExecuteByteCode(interp, codePtr)
char *bytes;
int length;
long i = 0; /* Init. avoids compiler warning. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w;
-#endif
register int cleanup;
Tcl_Obj *objResultPtr;
char *part1, *part2;
@@ -1909,10 +1879,8 @@ TclExecuteByteCode(interp, codePtr)
valuePtr = stackPtr[stackTop];
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- i = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(i,valuePtr);
} else {
REQUIRE_WIDE_OR_INT(result, valuePtr, i, w);
if (result != TCL_OK) {
@@ -2099,10 +2067,9 @@ TclExecuteByteCode(interp, codePtr)
b = (valuePtr->internalRep.longValue != 0);
} else if (valuePtr->typePtr == &tclDoubleType) {
b = (valuePtr->internalRep.doubleValue != 0.0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- b = (valuePtr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
+ b = (w != W0);
} else {
result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
if (result != TCL_OK) {
@@ -2154,27 +2121,20 @@ TclExecuteByteCode(interp, codePtr)
if ((t1Ptr == &tclIntType) || (t1Ptr == &tclBooleanType)) {
i1 = (valuePtr->internalRep.longValue != 0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
- i1 = (valuePtr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
+ i1 = (w != W0);
} else if (t1Ptr == &tclDoubleType) {
i1 = (valuePtr->internalRep.doubleValue != 0.0);
} else {
s = Tcl_GetStringFromObj(valuePtr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL,
- valuePtr, &i);
- i1 = (i != 0);
-#else /* !TCL_WIDE_INT_IS_LONG */
GET_WIDE_OR_INT(result, valuePtr, i, w);
if (valuePtr->typePtr == &tclIntType) {
i1 = (i != 0);
} else {
i1 = (w != W0);
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL,
valuePtr, &i1);
@@ -2190,27 +2150,20 @@ TclExecuteByteCode(interp, codePtr)
if ((t2Ptr == &tclIntType) || (t2Ptr == &tclBooleanType)) {
i2 = (value2Ptr->internalRep.longValue != 0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t2Ptr == &tclWideIntType) {
- i2 = (value2Ptr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,value2Ptr);
+ i2 = (w != W0);
} else if (t2Ptr == &tclDoubleType) {
i2 = (value2Ptr->internalRep.doubleValue != 0.0);
} else {
s = Tcl_GetStringFromObj(value2Ptr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL,
- value2Ptr, &i);
- i2 = (i != 0);
-#else /* !TCL_WIDE_INT_IS_LONG */
GET_WIDE_OR_INT(result, value2Ptr, i, w);
if (value2Ptr->typePtr == &tclIntType) {
i2 = (i != 0);
} else {
i2 = (w != W0);
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL, value2Ptr, &i2);
}
@@ -2825,7 +2778,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = d1 >= d2;
break;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if ((t1Ptr == &tclWideIntType)
|| (t2Ptr == &tclWideIntType)) {
Tcl_WideInt w2;
@@ -2834,13 +2786,13 @@ TclExecuteByteCode(interp, codePtr)
*/
if (t1Ptr == &tclIntType) {
w = Tcl_LongAsWide(valuePtr->internalRep.longValue);
- w2 = value2Ptr->internalRep.wideValue;
+ TclGetWide(w2,value2Ptr);
} else if (t2Ptr == &tclIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
w2 = Tcl_LongAsWide(value2Ptr->internalRep.longValue);
} else {
- w = valuePtr->internalRep.wideValue;
- w2 = value2Ptr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
+ TclGetWide(w2,value2Ptr);
}
switch (*pc) {
case INST_EQ:
@@ -2862,7 +2814,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = w >= w2;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
/*
* Compare as ints.
@@ -2929,19 +2880,15 @@ TclExecuteByteCode(interp, codePtr)
long i2 = 0, rem, negative;
long iResult = 0; /* Init. avoids compiler warning. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w2, wResult = W0;
int doWide = 0;
-#endif /* TCL_WIDE_INT_IS_LONG */
value2Ptr = stackPtr[stackTop];
valuePtr = stackPtr[stackTop - 1];
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
} else { /* try to convert to int */
REQUIRE_WIDE_OR_INT(result, valuePtr, i, w);
if (result != TCL_OK) {
@@ -2955,10 +2902,8 @@ TclExecuteByteCode(interp, codePtr)
}
if (value2Ptr->typePtr == &tclIntType) {
i2 = value2Ptr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (value2Ptr->typePtr == &tclWideIntType) {
- w2 = value2Ptr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w2,value2Ptr);
} else {
REQUIRE_WIDE_OR_INT(result, value2Ptr, i2, w2);
if (result != TCL_OK) {
@@ -2979,17 +2924,11 @@ TclExecuteByteCode(interp, codePtr)
* remainder always has the same sign as the divisor and
* a smaller absolute value.
*/
-#ifdef TCL_WIDE_INT_IS_LONG
- if (i2 == 0) {
- TRACE(("%ld %ld => DIVIDE BY ZERO\n", i, i2));
- goto divideByZero;
- }
-#else /* !TCL_WIDE_INT_IS_LONG */
if (value2Ptr->typePtr == &tclWideIntType && w2 == W0) {
if (valuePtr->typePtr == &tclIntType) {
- LLTRACE(("%ld "LLD" => DIVIDE BY ZERO\n", i, w2));
+ TRACE(("%ld "LLD" => DIVIDE BY ZERO\n", i, w2));
} else {
- LLTRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
+ TRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
}
goto divideByZero;
}
@@ -2997,13 +2936,11 @@ TclExecuteByteCode(interp, codePtr)
if (valuePtr->typePtr == &tclIntType) {
TRACE(("%ld %ld => DIVIDE BY ZERO\n", i, i2));
} else {
- LLTRACE((LLD" %ld => DIVIDE BY ZERO\n", w, i2));
+ TRACE((LLD" %ld => DIVIDE BY ZERO\n", w, i2));
}
goto divideByZero;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
negative = 0;
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
Tcl_WideInt wRemainder;
@@ -3031,7 +2968,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (i2 < 0) {
i2 = -i2;
i = -i;
@@ -3047,7 +2983,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = rem;
break;
case INST_LSHIFT:
-#ifndef TCL_WIDE_INT_IS_LONG
/*
* Shifts are never usefully 64-bits wide!
*/
@@ -3060,7 +2995,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i << i2;
break;
case INST_RSHIFT:
@@ -3069,7 +3003,6 @@ TclExecuteByteCode(interp, codePtr)
* right shifts propagate the sign bit even on machines
* where ">>" won't do it by default.
*/
-#ifndef TCL_WIDE_INT_IS_LONG
/*
* Shifts are never usefully 64-bits wide!
*/
@@ -3086,7 +3019,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (i < 0) {
iResult = ~((~i) >> i2);
} else {
@@ -3094,7 +3026,6 @@ TclExecuteByteCode(interp, codePtr)
}
break;
case INST_BITOR:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3109,11 +3040,9 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i | i2;
break;
case INST_BITXOR:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3128,11 +3057,9 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i ^ i2;
break;
case INST_BITAND:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3147,7 +3074,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i & i2;
break;
}
@@ -3157,30 +3083,22 @@ TclExecuteByteCode(interp, codePtr)
*/
if (Tcl_IsShared(valuePtr)) {
-#ifndef TCL_WIDE_INT_IS_LONG
if (doWide) {
objResultPtr = Tcl_NewWideIntObj(wResult);
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
objResultPtr = Tcl_NewLongObj(iResult);
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
NEXT_INST_F(1, 2, 1);
} else { /* reuse the valuePtr object */
-#ifndef TCL_WIDE_INT_IS_LONG
if (doWide) {
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
Tcl_SetWideIntObj(valuePtr, wResult);
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
Tcl_SetLongObj(valuePtr, iResult);
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
NEXT_INST_F(1, 1, 0);
}
}
@@ -3201,11 +3119,9 @@ TclExecuteByteCode(interp, codePtr)
long iResult = 0; /* Init. avoids compiler warning. */
double dResult = 0.0; /* Init. avoids compiler warning. */
int doDouble = 0; /* 1 if doing floating arithmetic */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w2, wquot, wrem;
Tcl_WideInt wResult = W0; /* Init. avoids compiler warning. */
int doWide = 0; /* 1 if doing wide arithmetic. */
-#endif /* TCL_WIDE_INT_IS_LONG */
value2Ptr = stackPtr[stackTop];
valuePtr = stackPtr[stackTop - 1];
@@ -3214,10 +3130,8 @@ TclExecuteByteCode(interp, codePtr)
if (t1Ptr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
} else if ((t1Ptr == &tclDoubleType)
&& (valuePtr->bytes == NULL)) {
/*
@@ -3248,10 +3162,8 @@ TclExecuteByteCode(interp, codePtr)
if (t2Ptr == &tclIntType) {
i2 = value2Ptr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t2Ptr == &tclWideIntType) {
- w2 = value2Ptr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w2,value2Ptr);
} else if ((t2Ptr == &tclDoubleType)
&& (value2Ptr->bytes == NULL)) {
/*
@@ -3289,12 +3201,10 @@ TclExecuteByteCode(interp, codePtr)
d1 = i; /* promote value 1 to double */
} else if (t2Ptr == &tclIntType) {
d2 = i2; /* promote value 2 to double */
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
d1 = Tcl_WideAsDouble(w);
} else if (t2Ptr == &tclWideIntType) {
d2 = Tcl_WideAsDouble(w2);
-#endif /* TCL_WIDE_INT_IS_LONG */
}
switch (*pc) {
case INST_ADD:
@@ -3326,7 +3236,6 @@ TclExecuteByteCode(interp, codePtr)
result = TCL_ERROR;
goto checkForCatch;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if ((t1Ptr == &tclWideIntType)
|| (t2Ptr == &tclWideIntType)) {
/*
@@ -3356,7 +3265,7 @@ TclExecuteByteCode(interp, codePtr)
* divisor and a smaller absolute value.
*/
if (w2 == W0) {
- LLTRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
+ TRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
goto divideByZero;
}
if (w2 < 0) {
@@ -3371,7 +3280,6 @@ TclExecuteByteCode(interp, codePtr)
wResult = wquot;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
/*
* Do integer arithmetic.
@@ -3419,11 +3327,9 @@ TclExecuteByteCode(interp, codePtr)
if (doDouble) {
objResultPtr = Tcl_NewDoubleObj(dResult);
TRACE(("%.6g %.6g => %.6g\n", d1, d2, dResult));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (doWide) {
objResultPtr = Tcl_NewWideIntObj(wResult);
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
} else {
objResultPtr = Tcl_NewLongObj(iResult);
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
@@ -3433,11 +3339,9 @@ TclExecuteByteCode(interp, codePtr)
if (doDouble) { /* NB: stack top is off by 1 */
TRACE(("%.6g %.6g => %.6g\n", d1, d2, dResult));
Tcl_SetDoubleObj(valuePtr, dResult);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (doWide) {
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
Tcl_SetWideIntObj(valuePtr, wResult);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
Tcl_SetLongObj(valuePtr, iResult);
@@ -3487,11 +3391,9 @@ TclExecuteByteCode(interp, codePtr)
if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
objResultPtr = Tcl_NewLongObj(i);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
objResultPtr = Tcl_NewWideIntObj(w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
objResultPtr = Tcl_NewDoubleObj(d);
@@ -3559,16 +3461,14 @@ TclExecuteByteCode(interp, codePtr)
objResultPtr = Tcl_NewLongObj(
(*pc == INST_UMINUS)? -i : !i);
TRACE_WITH_OBJ(("%ld => ", i), objResultPtr);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (*pc == INST_UMINUS) {
objResultPtr = Tcl_NewWideIntObj(-w);
} else {
objResultPtr = Tcl_NewLongObj(w == W0);
}
- LLTRACE_WITH_OBJ((LLD" => ", w), objResultPtr);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE_WITH_OBJ((LLD" => ", w), objResultPtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (*pc == INST_UMINUS) {
@@ -3592,16 +3492,14 @@ TclExecuteByteCode(interp, codePtr)
Tcl_SetLongObj(valuePtr,
(*pc == INST_UMINUS)? -i : !i);
TRACE_WITH_OBJ(("%ld => ", i), valuePtr);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (*pc == INST_UMINUS) {
Tcl_SetWideIntObj(valuePtr, -w);
} else {
Tcl_SetLongObj(valuePtr, w == W0);
}
- LLTRACE_WITH_OBJ((LLD" => ", w), valuePtr);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE_WITH_OBJ((LLD" => ", w), valuePtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (*pc == INST_UMINUS) {
@@ -3642,23 +3540,21 @@ TclExecuteByteCode(interp, codePtr)
}
}
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (Tcl_IsShared(valuePtr)) {
objResultPtr = Tcl_NewWideIntObj(~w);
- LLTRACE(("0x%llx => (%llu)\n", w, ~w));
+ TRACE(("0x%llx => (%llu)\n", w, ~w));
NEXT_INST_F(1, 1, 1);
} else {
/*
* valuePtr is unshared. Modify it directly.
*/
Tcl_SetWideIntObj(valuePtr, ~w);
- LLTRACE(("0x%llx => (%llu)\n", w, ~w));
+ TRACE(("0x%llx => (%llu)\n", w, ~w));
NEXT_INST_F(1, 0, 0);
}
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
i = valuePtr->internalRep.longValue;
if (Tcl_IsShared(valuePtr)) {
objResultPtr = Tcl_NewLongObj(~i);
@@ -3672,9 +3568,7 @@ TclExecuteByteCode(interp, codePtr)
TRACE(("0x%lx => (%lu)\n", i, ~i));
NEXT_INST_F(1, 0, 0);
}
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
}
case INST_CALL_BUILTIN_FUNC1:
@@ -3788,11 +3682,9 @@ TclExecuteByteCode(interp, codePtr)
if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
objResultPtr = Tcl_NewLongObj(i);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
objResultPtr = Tcl_NewWideIntObj(w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
objResultPtr = Tcl_NewDoubleObj(d);
@@ -4760,13 +4652,8 @@ VerifyExprObjType(interp, objPtr)
char *s = Tcl_GetStringFromObj(objPtr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- long i;
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL, objPtr, &i);
-#else /* !TCL_WIDE_INT_IS_LONG */
Tcl_WideInt w;
result = Tcl_GetWideIntFromObj((Tcl_Interp *) NULL, objPtr, &w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
double d;
result = Tcl_GetDoubleFromObj((Tcl_Interp *) NULL, objPtr, &d);
@@ -4991,9 +4878,9 @@ ExprAbsFunc(interp, eePtr, clientData)
iResult = i;
}
PUSH_OBJECT(Tcl_NewLongObj(iResult));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- Tcl_WideInt wResult, w = valuePtr->internalRep.wideValue;
+ Tcl_WideInt wResult, w;
+ TclGetWide(w,valuePtr);
if (w < W0) {
wResult = -w;
if (wResult < 0) {
@@ -5009,7 +4896,6 @@ ExprAbsFunc(interp, eePtr, clientData)
wResult = w;
}
PUSH_OBJECT(Tcl_NewWideIntObj(wResult));
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5120,10 +5006,8 @@ ExprIntFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
iResult = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- iResult = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(iResult,valuePtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5166,7 +5050,6 @@ ExprIntFunc(interp, eePtr, clientData)
return result;
}
-#ifndef TCL_WIDE_INT_IS_LONG
static int
ExprWideFunc(interp, eePtr, clientData)
Tcl_Interp *interp; /* The interpreter in which to execute the
@@ -5201,7 +5084,7 @@ ExprWideFunc(interp, eePtr, clientData)
}
if (valuePtr->typePtr == &tclWideIntType) {
- wResult = valuePtr->internalRep.wideValue;
+ TclGetWide(wResult,valuePtr);
} else if (valuePtr->typePtr == &tclIntType) {
wResult = Tcl_LongAsWide(valuePtr->internalRep.longValue);
} else {
@@ -5245,7 +5128,6 @@ ExprWideFunc(interp, eePtr, clientData)
DECACHE_STACK_INFO();
return result;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
static int
ExprRandFunc(interp, eePtr, clientData)
@@ -5383,11 +5265,11 @@ ExprRoundFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
iResult = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- PUSH_OBJECT(Tcl_NewWideIntObj(valuePtr->internalRep.wideValue));
+ Tcl_WideInt w;
+ TclGetWide(w,valuePtr);
+ PUSH_OBJECT(Tcl_NewWideIntObj(w));
goto done;
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5466,10 +5348,8 @@ ExprSrandFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- i = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(i,valuePtr);
} else {
/*
* At this point, the only other possible type is double
@@ -5606,39 +5486,34 @@ ExprCallMathFunc(interp, eePtr, objc, objv)
if (mathFuncPtr->argTypes[k] == TCL_DOUBLE) {
args[k].type = TCL_DOUBLE;
args[k].doubleValue = i;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (mathFuncPtr->argTypes[k] == TCL_WIDE_INT) {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = Tcl_LongAsWide(i);
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
args[k].type = TCL_INT;
args[k].intValue = i;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- Tcl_WideInt w = valuePtr->internalRep.wideValue;
+ Tcl_WideInt w;
+ TclGetWide(w,valuePtr);
if (mathFuncPtr->argTypes[k] == TCL_DOUBLE) {
args[k].type = TCL_DOUBLE;
- args[k].wideValue = (Tcl_WideInt) Tcl_WideAsDouble(w);
+ args[k].doubleValue = (Tcl_WideInt) Tcl_WideAsDouble(w);
} else if (mathFuncPtr->argTypes[k] == TCL_INT) {
args[k].type = TCL_INT;
- args[k].wideValue = Tcl_WideAsLong(w);
+ args[k].intValue = Tcl_WideAsLong(w);
} else {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = w;
}
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (mathFuncPtr->argTypes[k] == TCL_INT) {
args[k].type = TCL_INT;
args[k].intValue = (long) d;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (mathFuncPtr->argTypes[k] == TCL_WIDE_INT) {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = Tcl_DoubleAsWide(d);
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
args[k].type = TCL_DOUBLE;
args[k].doubleValue = d;
@@ -5672,10 +5547,8 @@ ExprCallMathFunc(interp, eePtr, objc, objv)
if (funcResult.type == TCL_INT) {
PUSH_OBJECT(Tcl_NewLongObj(funcResult.intValue));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (funcResult.type == TCL_WIDE_INT) {
PUSH_OBJECT(Tcl_NewWideIntObj(funcResult.wideValue));
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
d = funcResult.doubleValue;
if (IS_NAN(d) || IS_INF(d)) {