tcl.lang
Class CallFrame

java.lang.Object
  extended by tcl.lang.CallFrame

public class CallFrame
extends Object

This class implements a frame in the call stack. This class can be overridden to define new variable scoping rules for the Tcl interpreter.


Field Summary
 CallFrame caller
          Value of interp.frame when this procedure was invoked (i.e.
 CallFrame callerVar
          Value of interp.varFrame when this procedure was invoked (i.e.
 Var[] compiledLocals
          Array of local variables in a compiled proc frame.
 String[] compiledLocalsNames
           
 boolean isProcCallFrame
          If true, the frame was pushed to execute a Tcl procedure and may have local vars.
 int level
          Level of recursion.
 Namespace ns
          The Namespace this CallFrame is executing in.
 TclObject[] objv
          Stores the arguments of the procedure associated with this CallFrame.
 HashMap varTable
          Stores the variables of this CallFrame.
 
Constructor Summary
CallFrame(Interp i)
          Creates a CallFrame for the global variables.
 
Method Summary
 void dispose()
          This method is called when this CallFrame is no longer needed.
static int getFrame(Interp interp, String string, CallFrame[] frameArr)
          Tcl_GetFrame -> getFrame Given a description of a procedure frame, such as the first argument to an "uplevel" or "upvar" command, locate the call frame for the appropriate level of procedure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ns

public Namespace ns
The Namespace this CallFrame is executing in. Used to resolve commands and global variables.


isProcCallFrame

public boolean isProcCallFrame
If true, the frame was pushed to execute a Tcl procedure and may have local vars. If false, the frame was pushed to execute a namespace command and var references are treated as references to namespace vars; varTable is ignored.


objv

public TclObject[] objv
Stores the arguments of the procedure associated with this CallFrame. Is null for global level.


caller

public CallFrame caller
Value of interp.frame when this procedure was invoked (i.e. next in stack of all active procedures).


callerVar

public CallFrame callerVar
Value of interp.varFrame when this procedure was invoked (i.e. determines variable scoping within caller; same as caller unless an "uplevel" command or something equivalent was active in the caller).


level

public int level
Level of recursion. = 0 for the global level.


varTable

public HashMap varTable
Stores the variables of this CallFrame.


compiledLocals

public Var[] compiledLocals
Array of local variables in a compiled proc frame. These include locals set in the proc, globals or other variable brought into the proc scope, and compiler generated aliases to globals. This array is always null for an interpreted proc. A compiled proc implementation known which variable is associated with each slot at compile time, so it is able to avoid a hashtable lookup each time the variable is accessed. Both scalar variables and array variables could appear in this array.


compiledLocalsNames

public String[] compiledLocalsNames
Constructor Detail

CallFrame

public CallFrame(Interp i)
Creates a CallFrame for the global variables.

Parameters:
i - current interpreter.
Method Detail

getFrame

public static int getFrame(Interp interp,
                           String string,
                           CallFrame[] frameArr)
                    throws TclException
Tcl_GetFrame -> getFrame Given a description of a procedure frame, such as the first argument to an "uplevel" or "upvar" command, locate the call frame for the appropriate level of procedure. The return value is 1 if string was either a number or a number preceded by "#" and it specified a valid frame. 0 is returned if string isn't one of the two things above (in this case, the lookup acts as if string were "1"). The frameArr[0] reference will be filled by the reference of the desired frame (unless an error occurs, in which case it isn't modified).

Parameters:
string - a string that specifies the level.
Throws:
TclException - if s is a valid level specifier but refers to a bad level that doesn't exist.

dispose

public void dispose()
This method is called when this CallFrame is no longer needed. Removes the reference of this object from the interpreter so that this object can be garbage collected.

For this procedure to work correctly, it must not be possible for any of the variable in the table to be accessed from Tcl commands (e.g. from trace procedures).



Copyright © 2015. All rights reserved.