summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-05-18 20:54:54 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-05-18 20:54:54 (GMT)
commit4459bed11ee445f9e2a6f0263e2b93a31add3dfe (patch)
treef6520152938217e3e1b7c6844e04e8cd77c8c63b /generic/tclExecute.c
parent50396dd2bcd7655741791d49bc4ba7a88fa5c2b9 (diff)
downloadtcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.zip
tcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.tar.gz
tcl-4459bed11ee445f9e2a6f0263e2b93a31add3dfe.tar.bz2
* generic/tclBasic.c (Tcl_ExprBoolean): Rewrite as wrapper around
Tcl_ExprBooleanObj. * generic/tclCmdMZ.c ([string is boolean/true/false]): Rewrite dropping string-based Tcl_GetBoolean call, so that internal reps are kept for subsequent quick boolean operations. * generic/tclExecute.c: Dropped most special handling of the "boolean" Tcl_ObjType, since that type should now be rarely encountered. * doc/BoolObj.3: Rewrite of documentation dropping many details about the internals of Tcl_Objs. Shorter documentation focuses on the function and use of the routines.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c77
1 files changed, 31 insertions, 46 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 0557515..c86be8f 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.189 2005/05/13 17:12:17 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.190 2005/05/18 20:55:04 dgp Exp $
*/
#include "tclInt.h"
@@ -2478,8 +2478,7 @@ TclExecuteByteCode(interp, codePtr)
doCondJump:
valuePtr = *tosPtr;
- if ((valuePtr->typePtr == &tclIntType)
- || (valuePtr->typePtr == &tclBooleanType)) {
+ if (valuePtr->typePtr == &tclIntType) {
b = (valuePtr->internalRep.longValue != 0);
} else if (valuePtr->typePtr == &tclDoubleType) {
b = (valuePtr->internalRep.doubleValue != 0.0);
@@ -2553,7 +2552,7 @@ TclExecuteByteCode(interp, codePtr)
t1Ptr = valuePtr->typePtr;
t2Ptr = value2Ptr->typePtr;
- if ((t1Ptr == &tclIntType) || (t1Ptr == &tclBooleanType)) {
+ if (t1Ptr == &tclIntType) {
i1 = (valuePtr->internalRep.longValue != 0);
} else if (t1Ptr == &tclWideIntType) {
TclGetWide(w,valuePtr);
@@ -2572,9 +2571,7 @@ TclExecuteByteCode(interp, codePtr)
i1 = (w != W0);
}
} else {
- result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL,
- valuePtr, &i1);
- i1 = (i1 != 0);
+ result = Tcl_GetBooleanFromObj(NULL, valuePtr, &i1);
}
if (result != TCL_OK) {
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr),
@@ -2584,7 +2581,7 @@ TclExecuteByteCode(interp, codePtr)
}
}
- if ((t2Ptr == &tclIntType) || (t2Ptr == &tclBooleanType)) {
+ if (t2Ptr == &tclIntType) {
i2 = (value2Ptr->internalRep.longValue != 0);
} else if (t2Ptr == &tclWideIntType) {
TclGetWide(w,value2Ptr);
@@ -2603,7 +2600,7 @@ TclExecuteByteCode(interp, codePtr)
i2 = (w != W0);
}
} else {
- result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL, value2Ptr, &i2);
+ result = Tcl_GetBooleanFromObj(NULL, value2Ptr, &i2);
}
if (result != TCL_OK) {
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(value2Ptr),
@@ -4254,28 +4251,22 @@ TclExecuteByteCode(interp, codePtr)
* Otherwise, we need to generate a numeric internal rep.
* from the string rep.
*/
- if ((tPtr == &tclBooleanType) && (valuePtr->bytes == NULL)) {
- valuePtr->typePtr = &tclIntType;
+ int length;
+ char *s = Tcl_GetStringFromObj(valuePtr, &length);
+ if (TclLooksLikeInt(s, length)) {
+ GET_WIDE_OR_INT(result, valuePtr, i, w);
} else {
- int length;
- char *s = Tcl_GetStringFromObj(valuePtr, &length);
- if (TclLooksLikeInt(s, length)) {
- GET_WIDE_OR_INT(result, valuePtr, i, w);
- } else {
- result = Tcl_GetDoubleFromObj((Tcl_Interp *) NULL,
- valuePtr, &d);
- }
- if (result == TCL_ERROR && *pc == INST_LNOT) {
- result = Tcl_GetBooleanFromObj((Tcl_Interp *)NULL,
- valuePtr, &boolvar);
- i = (long)boolvar; /* i is long, not int! */
- }
- if (result != TCL_OK) {
- TRACE(("\"%.20s\" => ILLEGAL TYPE %s\n",
- s, (tPtr? tPtr->name : "null")));
- IllegalExprOperandType(interp, pc, valuePtr);
- goto checkForCatch;
- }
+ result = Tcl_GetDoubleFromObj(NULL, valuePtr, &d);
+ }
+ if (result == TCL_ERROR && *pc == INST_LNOT) {
+ result = Tcl_GetBooleanFromObj(NULL, valuePtr, &boolvar);
+ i = (long)boolvar; /* i is long, not int! */
+ }
+ if (result != TCL_OK) {
+ TRACE(("\"%.20s\" => ILLEGAL TYPE %s\n", s,
+ (tPtr? tPtr->name : "null")));
+ IllegalExprOperandType(interp, pc, valuePtr);
+ goto checkForCatch;
}
tPtr = valuePtr->typePtr;
}
@@ -4285,7 +4276,7 @@ TclExecuteByteCode(interp, codePtr)
/*
* Create a new object.
*/
- if ((tPtr == &tclIntType) || (tPtr == &tclBooleanType)) {
+ if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
TclNewLongObj(objResultPtr, -i);
TRACE_WITH_OBJ(("%ld => ", i), objResultPtr);
@@ -4303,7 +4294,7 @@ TclExecuteByteCode(interp, codePtr)
/*
* valuePtr is unshared. Modify it directly.
*/
- if ((tPtr == &tclIntType) || (tPtr == &tclBooleanType)) {
+ if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
TclSetLongObj(valuePtr, -i);
TRACE_WITH_OBJ(("%ld => ", i), valuePtr);
@@ -4435,22 +4426,16 @@ TclExecuteByteCode(interp, codePtr)
* Otherwise, we need to generate a numeric internal rep.
* from the string rep.
*/
- if ((tPtr == &tclBooleanType) && (valuePtr->bytes == NULL)) {
- valuePtr->typePtr = &tclIntType;
- converted = 1;
+ s = Tcl_GetStringFromObj(valuePtr, &length);
+ if (TclLooksLikeInt(s, length)) {
+ GET_WIDE_OR_INT(result, valuePtr, i, w);
} else {
- s = Tcl_GetStringFromObj(valuePtr, &length);
- if (TclLooksLikeInt(s, length)) {
- GET_WIDE_OR_INT(result, valuePtr, i, w);
- } else {
- result = Tcl_GetDoubleFromObj((Tcl_Interp *) NULL,
- valuePtr, &d);
- }
- if (result == TCL_OK) {
- converted = 1;
- }
- result = TCL_OK; /* reset the result variable */
+ result = Tcl_GetDoubleFromObj(NULL, valuePtr, &d);
+ }
+ if (result == TCL_OK) {
+ converted = 1;
}
+ result = TCL_OK; /* reset the result variable */
tPtr = valuePtr->typePtr;
}