summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-04-29 20:33:43 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-04-29 20:33:43 (GMT)
commitc22277cf6a24458c9ffd0fdbbf4aaa7229725a0b (patch)
tree83b31ba5ca267df68dc2a8546b5818f896bcc261
parent2e23e829d9cd7ea52665d333482cedf5255464e5 (diff)
downloadtcl-c22277cf6a24458c9ffd0fdbbf4aaa7229725a0b.zip
tcl-c22277cf6a24458c9ffd0fdbbf4aaa7229725a0b.tar.gz
tcl-c22277cf6a24458c9ffd0fdbbf4aaa7229725a0b.tar.bz2
more revisions
-rw-r--r--generic/tclCompile.c23
-rw-r--r--generic/tclCompile.h10
2 files changed, 24 insertions, 9 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 96b418c..9485d98 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -967,7 +967,10 @@ static void
FreeByteCodeInternalRep(
register Tcl_Obj *objPtr) /* Object whose internal rep to free. */
{
- register ByteCode *codePtr = objPtr->internalRep.twoPtrValue.ptr1;
+ ByteCode *codePtr;
+
+ ByteCodeGetIntRep(objPtr, &tclByteCodeType, codePtr);
+ assert(codePtr != NULL);
TclReleaseByteCode(codePtr);
}
@@ -1297,10 +1300,11 @@ CompileSubstObj(
Interp *iPtr = (Interp *) interp;
ByteCode *codePtr = NULL;
- if (objPtr->typePtr == &substCodeType) {
+ ByteCodeGetIntRep(objPtr, &subsCodeType, codePtr);
+
+ if (codePtr != NULL) {
Namespace *nsPtr = iPtr->varFramePtr->nsPtr;
- codePtr = objPtr->internalRep.twoPtrValue.ptr1;
if (flags != PTR2INT(objPtr->internalRep.twoPtrValue.ptr2)
|| ((Interp *) *codePtr->interpHandle != iPtr)
|| (codePtr->compileEpoch != iPtr->compileEpoch)
@@ -1309,9 +1313,10 @@ CompileSubstObj(
|| (codePtr->localCachePtr !=
iPtr->varFramePtr->localCachePtr)) {
TclFreeIntRep(objPtr);
+ codePtr = NULL;
}
}
- if (objPtr->typePtr != &substCodeType) {
+ if (codePtr == NULL) {
CompileEnv compEnv;
int numBytes;
const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes);
@@ -1325,7 +1330,6 @@ CompileSubstObj(
codePtr = TclInitByteCodeObj(objPtr, &substCodeType, &compEnv);
TclFreeCompileEnv(&compEnv);
- objPtr->internalRep.twoPtrValue.ptr1 = codePtr;
objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(flags);
if (iPtr->varFramePtr->localCachePtr) {
codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
@@ -1365,7 +1369,10 @@ static void
FreeSubstCodeInternalRep(
register Tcl_Obj *objPtr) /* Object whose internal rep to free. */
{
- register ByteCode *codePtr = objPtr->internalRep.twoPtrValue.ptr1;
+ register ByteCode *codePtr;
+
+ ByteCodeGetIntRep(objPtr, &substCodeType, codePtr);
+ assert(codePtr != NULL);
TclReleaseByteCode(codePtr);
}
@@ -2897,9 +2904,7 @@ TclInitByteCodeObj(
* by making its internal rep point to the just compiled ByteCode.
*/
- TclFreeIntRep(objPtr);
- objPtr->internalRep.twoPtrValue.ptr1 = codePtr;
- objPtr->typePtr = typePtr;
+ ByteCodeSetIntRep(objPtr, typePtr, codePtr);
return codePtr;
}
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 502dcf8..2f7a180 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -515,6 +515,16 @@ typedef struct ByteCode {
#endif /* TCL_COMPILE_STATS */
} ByteCode;
+#define ByteCodeSetIntRep(objPtr, typePtr, codePtr) \
+ do { \
+ Tcl_ObjIntRep ir; \
+ ir.twoPtrValue.ptr1 = (codePtr); \
+ ir.twoPtrValue.ptr2 = NULL; \
+ Tcl_StoreIntRep((objPtr), (typePtr), &ir); \
+ } while (0)
+
+
+
#define ByteCodeGetIntRep(objPtr, typePtr, codePtr) \
do { \
const Tcl_ObjIntRep *irPtr; \