From 7c3dc60455b251517713096f2162c2bfccbd5b00 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 22 Jul 2005 23:56:28 +0000 Subject: Improve the incrementer code for INST_DICT_INCR_IMM, removing a gcc-ism. --- ChangeLog | 5 +++++ generic/tclExecute.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d045ce..d9457ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-07-23 Donal K. Fellows + + * generic/tclExecute.c (TEBC:INST_DICT_INCR_IMM): Fix the + incrementor to work correctly with wide values. + 2005-07-21 Donal K. Fellows * generic/tclCompCmds.c (TclCompileDictCmd): First run at a compiler diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 9dd242e..aff2bc3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -12,7 +12,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.196 2005/07/21 21:49:05 dkf Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.197 2005/07/22 23:56:34 dkf Exp $ */ #include "tclInt.h" @@ -4866,9 +4866,7 @@ TclExecuteByteCode(interp, codePtr) result = Tcl_DictObjPutKeyList(interp, dictPtr, opnd, tosPtr-opnd, *tosPtr); break; - case INST_DICT_INCR_IMM: { - long value; - + case INST_DICT_INCR_IMM: cleanup = 1; opnd = TclGetInt4AtPtr(pc+1); result = Tcl_DictObjGet(interp, dictPtr, *tosPtr, &valPtr); @@ -4877,17 +4875,35 @@ TclExecuteByteCode(interp, codePtr) } if (valPtr == NULL) { Tcl_DictObjPut(NULL, dictPtr, *tosPtr, Tcl_NewLongObj(opnd)); + } else if (valPtr->typePtr == &tclWideIntType) { + Tcl_WideInt wvalue; + + Tcl_GetWideIntFromObj(NULL, valPtr, &wvalue); + Tcl_DictObjPut(NULL, dictPtr, *tosPtr, + Tcl_NewWideIntObj(wvalue + opnd)); + } else if (valPtr->typePtr == &tclIntType) { + long value; + + Tcl_GetLongFromObj(NULL, valPtr, &value); + Tcl_DictObjPut(NULL, dictPtr, *tosPtr, + Tcl_NewLongObj(value + opnd)); } else { -#warning non-long incrementing broken - result = Tcl_GetLongFromObj(interp, valPtr, &value); + long value; + Tcl_WideInt wvalue; + + REQUIRE_WIDE_OR_INT(result, valPtr, value, wvalue); if (result != TCL_OK) { break; } - Tcl_DictObjPut(NULL, dictPtr, *tosPtr, - Tcl_NewLongObj(value + opnd)); + if (valPtr->typePtr == &tclWideIntType) { + Tcl_DictObjPut(NULL, dictPtr, *tosPtr, + Tcl_NewWideIntObj(wvalue + opnd)); + } else { + Tcl_DictObjPut(NULL, dictPtr, *tosPtr, + Tcl_NewLongObj(value + opnd)); + } } break; - } case INST_DICT_UNSET: cleanup = opnd; result = Tcl_DictObjRemoveKeyList(interp, dictPtr, opnd, -- cgit v0.12