Index: Makefile.in =================================================================== diff -u -ree73265e036871a0e6f5b83544ff0982c24864ed -r721a118d34e93f4149da419436efa5b17bab9b35 --- Makefile.in (.../Makefile.in) (revision ee73265e036871a0e6f5b83544ff0982c24864ed) +++ Makefile.in (.../Makefile.in) (revision 721a118d34e93f4149da419436efa5b17bab9b35) @@ -470,7 +470,7 @@ xotclStubInit.$(OBJEXT): $(PKG_HEADERS) xotclStubLib.$(OBJEXT): $(src_generic_dir)/xotclStubLib.c $(PKG_HEADERS) -xotcl.$(OBJEXT): $(src_generic_dir)/xotcl.c $(src_generic_dir)/predefined.h $(src_generic_dir)/tclAPI.h $(PKG_HEADERS) +xotcl.$(OBJEXT): $(src_generic_dir)/xotcl.c $(src_generic_dir)/predefined.h $(src_generic_dir)/tclAPI.h $(PKG_HEADERS) $(src_generic_dir)/xotclStack.c $(src_generic_dir)/xotclStack85.c xotclError.$(OBJEXT): $(src_generic_dir)/xotclError.c $(PKG_HEADERS) xotclMetaData.$(OBJEXT): $(src_generic_dir)/xotclMetaData.c $(PKG_HEADERS) xotclObjectData.$(OBJEXT): $(src_generic_dir)/xotclObjectData.c $(PKG_HEADERS) Index: generic/xotcl.c =================================================================== diff -u -rf30ceced09ff0ac4fa96660291e254fdd92b1675 -r721a118d34e93f4149da419436efa5b17bab9b35 --- generic/xotcl.c (.../xotcl.c) (revision f30ceced09ff0ac4fa96660291e254fdd92b1675) +++ generic/xotcl.c (.../xotcl.c) (revision 721a118d34e93f4149da419436efa5b17bab9b35) @@ -728,48 +728,16 @@ XOTCLINLINE static XOTclClass* GetSelfClass(Tcl_Interp *interp) { - /*return RUNTIME_STATE(interp)->cs.top->cl;*/ return CallStackGetFrame(interp)->cl; } #if defined(TCL85STACK) -XOTCLINLINE static XOTclObject* -GetSelfObj(Tcl_Interp *interp) { - Tcl_CallFrame *varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); - - /*fprintf(stderr, "GetSelfObj interp has frame %p and varframe %p\n", - Tcl_Interp_framePtr(interp),Tcl_Interp_varFramePtr(interp));*/ - for (; varFramePtr; varFramePtr = Tcl_CallFrame_callerPtr(varFramePtr)) { -#if defined(TCL85STACK_TRACE) - fprintf(stderr, "GetSelfObj check frame %p flags %.6x cd %p objv[0] %s\n", - varFramePtr, Tcl_CallFrame_isProcCallFrame(varFramePtr), - Tcl_CallFrame_clientData(varFramePtr), - Tcl_CallFrame_objc(varFramePtr) ? ObjStr(Tcl_CallFrame_objv(varFramePtr)[0]) : "(null)"); -#endif - if (Tcl_CallFrame_isProcCallFrame(varFramePtr) & FRAME_IS_XOTCL_OBJECT) { -#if defined(TCL85STACK_TRACE) - fprintf(stderr, "... self returns %s\n", - objectName(((XOTclObject*)Tcl_CallFrame_clientData(varFramePtr)))); -#endif - return (XOTclObject *)Tcl_CallFrame_clientData(varFramePtr); - } - if (Tcl_CallFrame_isProcCallFrame(varFramePtr) & FRAME_IS_XOTCL_METHOD) { - XOTclCallStackContent *csc = (XOTclCallStackContent *)Tcl_CallFrame_clientData(varFramePtr); -#if defined(TCL85STACK_TRACE) - fprintf(stderr, "... self returns %s\n",objectName(csc->self)); -#endif - return csc->self; - } - } - return NULL; -} +# include "xotclStack85.c" #else -XOTCLINLINE static XOTclObject* -GetSelfObj(Tcl_Interp *interp) { - return CallStackGetFrame(interp)->self; -} +# include "xotclStack.c" #endif + /* extern callable GetSelfObj */ XOTcl_Object* XOTclGetSelfObj(Tcl_Interp *interp) { @@ -778,7 +746,6 @@ XOTCLINLINE static Tcl_Command GetSelfProcCmdPtr(Tcl_Interp *interp) { - /*return RUNTIME_STATE(interp)->cs.top->cmdPtr;*/ return CallStackGetFrame(interp)->cmdPtr; } @@ -2602,11 +2569,10 @@ else csc->filterStackEntry = NULL; #if defined(TCL85STACK_TRACE) - fprintf(stderr, "PUSH obj %s, self=%p cmd=%p (%s) objc=%d id=%p (%s) csc=%p type %d, frame %p\n", - objectName(obj), obj, + fprintf(stderr, "PUSH csc %p type %d frame %p, obj %s, self=%p cmd=%p (%s) objc=%d id=%p (%s)\n", + csc, frameType, Tcl_Interp_framePtr(interp), objectName(obj), obj, cmd, (char *) Tcl_GetCommandName(interp, cmd), - objc, obj->id, Tcl_GetCommandName(interp, obj->id), csc, frameType, - Tcl_Interp_framePtr(interp)); + objc, obj->id, Tcl_GetCommandName(interp, obj->id)); #endif #if defined(TCL85STACK) /* if CallStackPush() is called with objc==0, this means that the @@ -2705,24 +2671,7 @@ return cs->top; } -static XOTclCallStackContent* -CallStackGetFrame(Tcl_Interp *interp) { - XOTclCallStack *cs = &RUNTIME_STATE(interp)->cs; - register XOTclCallStackContent *top = cs->top; - Tcl_CallFrame *varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); - /* fprintf(stderr, "Tcl_Interp_framePtr(interp) %p != varFramePtr %p && top->currentFramePtr %p\n", Tcl_Interp_framePtr(interp), varFramePtr, top->currentFramePtr);*/ - if (Tcl_Interp_framePtr(interp) != varFramePtr && top->currentFramePtr) { - XOTclCallStackContent *bot = cs->content + 1; - - /* we are in a uplevel */ - while (varFramePtr != top->currentFramePtr && top>bot) { - top--; - } - } - return top; -} - /* * cmd list handling */ @@ -3155,13 +3104,13 @@ INCR_REF_COUNT(sr); XOTclVarErrMsg(interp, "Error in Assertion: {", ObjStr(checkFailed->content), "} in proc '", - GetSelfProc(interp), "'\n\n", ObjStr(sr), (char *) NULL); + methodName, "'\n\n", ObjStr(sr), (char *) NULL); DECR_REF_COUNT(sr); return TCL_ERROR; } return XOTclVarErrMsg(interp, "Assertion failed check: {", ObjStr(checkFailed->content), "} in proc '", - GetSelfProc(interp), "'", (char *) NULL); + methodName, "'", (char *) NULL); } Tcl_SetObjResult(interp, savedObjResult); @@ -5367,8 +5316,8 @@ framePtr->objc = objc; framePtr->objv = objv; framePtr->procPtr = procPtr; -#if defined(TCL85STACK) - /*fprintf(stderr,"push csc %p into frame %p flags %.4x\n",csc,framePtr,framePtr->isProcCallFrame);*/ +#if defined(TCL85STACK_TRACE) + fprintf(stderr," put csc %p into frame %p flags %.4x\n",csc,framePtr,framePtr->isProcCallFrame); #endif framePtr->clientData = (ClientData)csc; @@ -5440,15 +5389,16 @@ #endif #if defined(TCL85STACK_TRACE) - fprintf(stderr, "+++ callProcCheck teardown %p, method=%s, isTclProc %d csc %p\n",obj->teardown,methodName,isTclProc,csc); + fprintf(stderr, "+++ callProcCheck %s, isTclProc %d csc %p, teardown %p\n", + methodName,isTclProc,csc,obj->teardown); #endif if (!obj->teardown) { goto finish; } if (isTclProc == 0) { - /*fprintf(stderr,"... calling cmd %s isTclProc %d tearDown %p csc %p\n",methodName,isTclProc,obj->teardown,csc);*/ + /*fprintf(stderr,".. calling cmd %s isTclProc %d tearDown %p csc %p\n",methodName,isTclProc,obj->teardown,csc);*/ if (obj->opt) { co = obj->opt->checkoptions; @@ -5598,39 +5548,38 @@ if (rc == TCL_CONTINUE) { result = PushProcCallFrame(cp, interp, objc, objv, /*isLambda*/ 0, csc); } else if (rc == TCL_OK) { -#if 0 +# if 0 {int j; for(j=0; jcs.top->currentFramePtr = (Tcl_CallFrame *) Tcl_Interp_varFramePtr(interp); result = TclObjInterpProcCore(interp, objv[0], 1, &MakeProcError); } else { result = TCL_ERROR; } -#else - result = (*Tcl_Command_objProc(cmd))(cp, interp, objc, objv); - -#if defined(TCL85STACK_TRACE) +# if defined(TCL85STACK_TRACE) fprintf(stderr,"POP OBJECT_FRAME (implicit) frame %p csc %p\n", NULL, csc); +# endif +#else /* BEFORE TCL85 */ + result = (*Tcl_Command_objProc(cmd))(cp, interp, objc, objv); #endif -#endif #ifdef DISPATCH_TRACE printExit(interp,"callProcCheck tclCmd", objc, objv, result); Index: generic/xotcl.h =================================================================== diff -u -rf30ceced09ff0ac4fa96660291e254fdd92b1675 -r721a118d34e93f4149da419436efa5b17bab9b35 --- generic/xotcl.h (.../xotcl.h) (revision f30ceced09ff0ac4fa96660291e254fdd92b1675) +++ generic/xotcl.h (.../xotcl.h) (revision 721a118d34e93f4149da419436efa5b17bab9b35) @@ -85,11 +85,10 @@ /* #define CANONICAL_ARGS 1 #define TCL85STACK_TRACE 1 +#define TCL85STACK 1 */ - #define TCL85STACK 1 - #if defined PARSE_TRACE_FULL # define PARSE_TRACE 1 #endif Index: generic/xotclStack.c =================================================================== diff -u --- generic/xotclStack.c (revision 0) +++ generic/xotclStack.c (revision 721a118d34e93f4149da419436efa5b17bab9b35) @@ -0,0 +1,33 @@ +#if !defined(TCL85STACK) + +static XOTclCallStackContent* +CallStackGetFrame(Tcl_Interp *interp) { + XOTclCallStack *cs = &RUNTIME_STATE(interp)->cs; + register XOTclCallStackContent *top = cs->top; + Tcl_CallFrame *varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); + + /*fprintf(stderr, "framePtr %p != varFramePtr %p && top->currentFramePtr %p => %d\n", + Tcl_Interp_framePtr(interp), varFramePtr, top->currentFramePtr, + (Tcl_Interp_framePtr(interp) != varFramePtr && top->currentFramePtr) + );*/ + + if (Tcl_Interp_framePtr(interp) != varFramePtr && top->currentFramePtr) { + XOTclCallStackContent *bot = cs->content + 1; + + /* we are in a uplevel */ + while (varFramePtr != top->currentFramePtr && top>bot) { + top--; + } + } + + return top; +} + +XOTCLINLINE static XOTclObject* +GetSelfObj(Tcl_Interp *interp) { + return CallStackGetFrame(interp)->self; +} + +#endif /* TCL85STACK */ + + Index: generic/xotclStack85.c =================================================================== diff -u --- generic/xotclStack85.c (revision 0) +++ generic/xotclStack85.c (revision 721a118d34e93f4149da419436efa5b17bab9b35) @@ -0,0 +1,55 @@ +#if defined(TCL85STACK) + +XOTCLINLINE static XOTclObject* +GetSelfObj(Tcl_Interp *interp) { + register Tcl_CallFrame *varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); + + /*fprintf(stderr, "GetSelfObj interp has frame %p and varframe %p\n", + Tcl_Interp_framePtr(interp),Tcl_Interp_varFramePtr(interp));*/ + for (; varFramePtr; varFramePtr = Tcl_CallFrame_callerPtr(varFramePtr)) { +#if defined(TCL85STACK_TRACE) + fprintf(stderr, "GetSelfObj check frame %p flags %.6x cd %p objv[0] %s\n", + varFramePtr, Tcl_CallFrame_isProcCallFrame(varFramePtr), + Tcl_CallFrame_clientData(varFramePtr), + Tcl_CallFrame_objc(varFramePtr) ? ObjStr(Tcl_CallFrame_objv(varFramePtr)[0]) : "(null)"); +#endif + if (Tcl_CallFrame_isProcCallFrame(varFramePtr) & FRAME_IS_XOTCL_OBJECT) { +#if defined(TCL85STACK_TRACE) + fprintf(stderr, "... self returns %s\n", + objectName(((XOTclObject*)Tcl_CallFrame_clientData(varFramePtr)))); +#endif + return (XOTclObject *)Tcl_CallFrame_clientData(varFramePtr); + } + if (Tcl_CallFrame_isProcCallFrame(varFramePtr) & FRAME_IS_XOTCL_METHOD) { + XOTclCallStackContent *csc = (XOTclCallStackContent *)Tcl_CallFrame_clientData(varFramePtr); +#if defined(TCL85STACK_TRACE) + fprintf(stderr, "... self returns %s\n",objectName(csc->self)); +#endif + return csc->self; + } + } + return NULL; +} + + +static XOTclCallStackContent* +CallStackGetFrame(Tcl_Interp *interp) { + register Tcl_CallFrame *varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); + + for (; varFramePtr; varFramePtr = Tcl_CallFrame_callerPtr(varFramePtr)) { +# if defined(TCL85STACK_TRACE) + fprintf(stderr, "... check frame %p flags %.6x cd %p objv[0] %s\n", + varFramePtr, Tcl_CallFrame_isProcCallFrame(varFramePtr), + Tcl_CallFrame_clientData(varFramePtr), + Tcl_CallFrame_objc(varFramePtr) ? ObjStr(Tcl_CallFrame_objv(varFramePtr)[0]) : "(null)"); +# endif + if (Tcl_CallFrame_isProcCallFrame(varFramePtr) & FRAME_IS_XOTCL_METHOD) { + return (XOTclCallStackContent *)Tcl_CallFrame_clientData(varFramePtr); + } + } + return NULL; +} + +#endif /* TCL85STACK */ + +