Diff
Not logged in

Differences From Artifact [3657b4781a]:

To Artifact [746ee4a81f]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclProc.c --
 *
 *	This file contains routines that implement Tcl procedures,
 *	including the "proc" and "uplevel" commands.
 *
 * Copyright (c) 1987-1993 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclProc.c,v 1.61 2004/10/15 21:02:36 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"

/*
 * Prototypes for static functions in this file












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclProc.c --
 *
 *	This file contains routines that implement Tcl procedures,
 *	including the "proc" and "uplevel" commands.
 *
 * Copyright (c) 1987-1993 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclProc.c,v 1.62 2004/10/18 21:15:42 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"

/*
 * Prototypes for static functions in this file
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479

/*
 *----------------------------------------------------------------------
 *
 * TclUpdateReturnInfo --
 *
 *	This procedure is called when procedures return, and at other
 *	points where the TCL_RETURN code is used.  It examines values
 *	stored in the iPtr->returnOpts dictionary and modifies
 *	the real return status accordingly.
 *
 * Results:
 *	The return value is the true completion code to use for
 *	the procedure, instead of TCL_RETURN.
 *
 * Side effects:
 *	The errorInfo and errorCode fields may get set.
 *
 *----------------------------------------------------------------------
 */

int
TclUpdateReturnInfo(iPtr)
    Interp *iPtr;		/* Interpreter for which TCL_RETURN
				 * exception is being processed. */
{
    int level, code = TCL_RETURN;
    Tcl_Obj *valuePtr;

    Tcl_DictObjGet(NULL, iPtr->returnOpts, iPtr->returnLevelKey, &valuePtr);
    Tcl_GetIntFromObj(NULL, valuePtr, &level);
    level--;
    if (level < 0) {
	Tcl_Panic("TclUpdateReturnInfo: negative return level");
    }
    if (Tcl_IsShared(iPtr->returnOpts)) {
	Tcl_DecrRefCount(iPtr->returnOpts);
	iPtr->returnOpts = Tcl_DuplicateObj(iPtr->returnOpts);
	Tcl_IncrRefCount(iPtr->returnOpts);
    }
    Tcl_DictObjPut(NULL, iPtr->returnOpts,
	    iPtr->returnLevelKey, Tcl_NewIntObj(level));

    if (level == 0) {
	/* Now we've reached the level to return the requested -code */
	Tcl_DictObjGet(NULL, iPtr->returnOpts, iPtr->returnCodeKey, &valuePtr);
	Tcl_GetIntFromObj(NULL, valuePtr, &code);
    }
    return code;
}

/*
 *----------------------------------------------------------------------
 *







|
<
|



|


|









|
<

<
<
|
|


<
<
<
<
<
<
<
<
|

|
<







1426
1427
1428
1429
1430
1431
1432
1433

1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451

1452


1453
1454
1455
1456








1457
1458
1459

1460
1461
1462
1463
1464
1465
1466

/*
 *----------------------------------------------------------------------
 *
 * TclUpdateReturnInfo --
 *
 *	This procedure is called when procedures return, and at other
 *	points where the TCL_RETURN code is used.  It examines the

 *	returnLevel and returnCode to determine the real return status.
 *
 * Results:
 *	The return value is the true completion code to use for
 *	the procedure or script, instead of TCL_RETURN.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int
TclUpdateReturnInfo(iPtr)
    Interp *iPtr;		/* Interpreter for which TCL_RETURN
				 * exception is being processed. */
{
    int code = TCL_RETURN;




    iPtr->returnLevel--;
    if (iPtr->returnLevel < 0) {
	Tcl_Panic("TclUpdateReturnInfo: negative return level");
    }








    if (iPtr->returnLevel == 0) {
	/* Now we've reached the level to return the requested -code */
	return iPtr->returnCode;

    }
    return code;
}

/*
 *----------------------------------------------------------------------
 *