diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2008-09-18 15:43:10 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2008-09-18 15:43:10 (GMT) |
commit | 412f81264a0156c5c2b473db6adcfba85dc81ed6 (patch) | |
tree | df04c0d67616b2726bd4ad4eafc777bdf1b82462 /generic/tclExecute.c | |
parent | 68778453cedcc72078811676bbb0ae096624bb61 (diff) | |
download | tcl-412f81264a0156c5c2b473db6adcfba85dc81ed6.zip tcl-412f81264a0156c5c2b473db6adcfba85dc81ed6.tar.gz tcl-412f81264a0156c5c2b473db6adcfba85dc81ed6.tar.bz2 |
* generic/tclExecute.c (NEXT_INST_F):
* generic/tclInt.h (TCL_CT_ASSERT): new compile-time assertions,
adapted from www.pixelbeat.org/programming/gcc/static_assert.html
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index ba7bd62..fd79931 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -14,7 +14,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.411 2008/09/10 13:24:12 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.412 2008/09/18 15:43:15 msofer Exp $ */ #include "tclInt.h" @@ -257,35 +257,37 @@ VarHashCreateVar( * resultHandling: 0 indicates no object should be pushed on the stack; * otherwise, push objResultPtr. If (result < 0), objResultPtr already * has the correct reference count. + * + * We use the new compile-time assertions to cheack that nCleanup is constant + * and within range. */ #define NEXT_INST_F(pcAdjustment, nCleanup, resultHandling) \ - if (nCleanup == 0) {\ - if (resultHandling != 0) {\ - if ((resultHandling) > 0) {\ - PUSH_OBJECT(objResultPtr);\ - } else {\ - *(++tosPtr) = objResultPtr;\ - }\ - } \ - pc += (pcAdjustment);\ - goto cleanup0;\ - } else if (resultHandling != 0) {\ - if ((resultHandling) > 0) {\ - Tcl_IncrRefCount(objResultPtr);\ - }\ - pc += (pcAdjustment);\ - switch (nCleanup) {\ - case 1: goto cleanup1_pushObjResultPtr;\ - case 2: goto cleanup2_pushObjResultPtr;\ - default: Tcl_Panic("bad usage of macro NEXT_INST_F");\ + TCL_CT_ASSERT((nCleanup >= 0) && (nCleanup <= 2)); \ + if (nCleanup == 0) { \ + if (resultHandling != 0) { \ + if ((resultHandling) > 0) { \ + PUSH_OBJECT(objResultPtr); \ + } else { \ + *(++tosPtr) = objResultPtr; \ + } \ + } \ + pc += (pcAdjustment); \ + goto cleanup0; \ + } else if (resultHandling != 0) { \ + if ((resultHandling) > 0) { \ + Tcl_IncrRefCount(objResultPtr); \ + } \ + pc += (pcAdjustment); \ + switch (nCleanup) { \ + case 1: goto cleanup1_pushObjResultPtr; \ + case 2: goto cleanup2_pushObjResultPtr; \ }\ } else {\ pc += (pcAdjustment);\ switch (nCleanup) {\ case 1: goto cleanup1;\ case 2: goto cleanup2;\ - default: Tcl_Panic("bad usage of macro NEXT_INST_F");\ }\ } @@ -2399,7 +2401,7 @@ TclExecuteByteCode( TclNewObj(newObjResultPtr); Tcl_IncrRefCount(newObjResultPtr); iPtr->objResultPtr = newObjResultPtr; - NEXT_INST_V(opnd, 0, -1); + NEXT_INST_F(opnd, 0, -1); } case INST_DUP: |