tcl.lang
Class Interp

java.lang.Object
  extended by tcl.lang.Interp

public class Interp
extends Object

Implements the core Tcl interpreter. Copyright (c) 1997 Cornell University. Copyright (c) 1997-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.


Field Summary
 HashMap aliasTable
          Table which maps from names of commands in slave interpreter to InterpAliasCmd objects.
 int cmdCount
          Total number of times a command procedure has been called for this interpreter.
protected  tcl.lang.DebugInfo dbg
           
protected  boolean deleted
          True means the interpreter has been deleted: don't process any more commands for it, and destroy the structure as soon as all nested invocations of eval() are done.
 boolean errAlreadyLogged
          True means information has already been logged in $errorInfo for the current eval() instance, so eval() needn't log it (used to implement the "error" command).
protected  boolean errCodeSet
          True means that addErrorInfo has been called to record information for the current error.
 boolean errInProgress
          True means an error unwind is already in progress.
 String errorCode
          If returnCode is TCL.ERROR, stores the errorCode.
 String errorInfo
          If returnCode is TCL.ERROR, stores the errorInfo.
 int errorLine
          When TCL_ERROR is returned, this gives the line number within the command where the error occurred (1 means first line).
 int evalFlags
          Flags used when evaluating a command.
 Expression expr
          The expression parser for this interp.
 CallFrame frame
          Points to top-most in stack of all nested procedure invocations.
 Namespace.GetNamespaceForQualNameResult getnfqnResult
          Used only with Namespace.getNamespaceForQualName()
 HashMap hiddenCmdTable
          Hash table used to keep track of hidden commands on a per-interp basis.
 HashMap[] importTable
          Used ONLY by JavaImportCmd: classTable, packageTable, wildcardTable
 HashMap<String,Channel> interpChanTable
          Table of channels currently registered in this interp.
static int INVOKE_HIDDEN
           
static int INVOKE_NO_TRACEBACK
           
static int INVOKE_NO_UNKNOWN
           
 boolean isSafe
          Is this interpreted marked as safe?
 int nestLevel
          Number of times the interp.eval() routine has been recursively invoked.
 HashMap packageTable
           
 String packageUnknown
           
 HashMap reflectConflictTable
          Table used to store reflect hash index conflicts, see ReflectObject implementation for more details
 long reflectObjCount
          Number of reflect objects created so far inside this Interp (including those that have be freed)
 HashMap reflectObjTable
          Translates Object to ReflectObject.
 int returnCode
          Completion code to return if current procedure exits with a TCL_RETURN code.
 String scriptFile
          The script file currently under execution.
 InterpSlaveCmd slave
          Information necessary for this interp to function as a slave.
 HashMap slaveTable
          Information used by InterpCmd.java to keep track of master/slave interps on a per-interp basis.
 StrtodResult strtodResult
          Used by callers of Util.strtod().
 StrtoulResult strtoulResult
          Used by callers of Util.strtoul(), also used in FormatCmd.strtoul().
 boolean systemEncodingChangesStdoutStderr
          Set to true if [encoding system] can set the encoding for stdout and stderr.
static ManagedSystemInStream systemIn
          Using System.in directly creates non-interruptible block during System.in.read().
 HashMap targetTable
          Hash table for Target Records.
 int termOffset
          Offset of character just after last one compiled or executed by Parser.eval2().
 CallFrame varFrame
          Points to the call frame whose variables are currently in use (same as frame unless an "uplevel" command is being executed).
 
Constructor Summary
Interp()
          Side effects: Various parts of the interpreter are initialized; built-in commands are created; global variables are initialized, etc.
 
Method Summary
 void addErrorInfo(String message)
          Add information to the "errorInfo" variable that describes the current error.
 void addInterpResolver(String name, Resolver resolver)
          ---------------------------------------------------------------------- Tcl_AddInterpResolvers -> addInterpResolver Adds a set of command/variable resolution procedures to an interpreter.
 void allowExceptions()
          Sets a flag in an interpreter so that exceptions can occur in the next call to Tcl_Eval without them being turned into errors.
 void appendElement(String string)
          Convert a string to a valid Tcl list element and append it to the result (which is ostensibly a list).
 void backgroundError()
          This procedure is invoked to handle errors that occur in Tcl commands that are invoked in "background" (e.g.
static BackSlashResult backslash(String s, int i, int len)
          Figure out how to handle a backslash sequence.
 TclObject checkCommonCharacter(int c)
          It is very common to create a TclObject that contains a single character.
 TclObject checkCommonInteger(long value)
          checkCommonInteger() If a given integer value is in the common value pool then return a shared object for that integer.
 TclObject checkCommonString(String value)
          If a given String value is in the common value pool the return a shared object for that String.
 void checkInterrupted()
          This method is invoked after an eval operation to check if a running interp has been marked as interrupted.
static boolean commandComplete(String string)
           
 void createCommand(String cmdName, Command cmdImpl)
          Define a new command in the interpreter.
protected  void createCommands()
          Create the build-in commands.
 void deleteAssocData(String name)
          Deletes a named association of user-specified data with the specified interpreter.
 int deleteCommand(String cmdName)
          Remove the given command from the this interpreter.
 int deleteCommandFromToken(WrappedCommand cmd)
          Remove the given command from the given interpreter.
 void dispose()
          Invoked to indicate that the interp should be disposed of.
 void eval(String script)
          Execute a Tcl command in a string.
 void eval(String string, int flags)
          Evaluate a TCL script in a string
 void eval(TclObject tobj, int flags)
          Execute a Tcl script in a TclObject.
 void evalFile(String s)
          Loads a Tcl script from a file using the system encoding and evaluates it in the current interpreter.
 void evalFile(String s, String encoding)
          Loads a Tcl script from a file and evaluates it in the current interpreter.
 void evalResource(String resName)
          Execute a Tcl script stored in the given Java resource location, encoded in the system encoding Results: The return value is void.
 void evalResource(String resName, String javaEncoding)
          Execute a Tcl script stored in the given Java resource location.
 void evalURL(URL context, String s)
          Loads a Tcl script (encoded in system encoding) from a URL and evaluate it in the current interpreter.
 void evalURL(URL context, String s, String javaEncoding)
          Loads a Tcl script from a URL and evaluate it in the current interpreter.
 void eventuallyDispose()
          This method cleans up the state of the interpreter so that it can be garbage collected safely.
 void exposeCommand(String hiddenCmdToken, String cmdName)
          Makes a previously hidden command callable from inside the interpreter instead of only by its ancestors.
 int getArgLineNumber(int index)
          Returns the line number where the given command argument begins.
 AssocData getAssocData(String name)
          Returns the AssocData instance associated with this name in the specified interpreter.
 ClassLoader getClassLoader()
          Get the TclClassLoader used for the interp.
 Command getCommand(String cmdName)
          Returns the command procedure of the given command.
 String getCommandFullName(WrappedCommand cmd)
          Given a token returned by, e.g., Tcl_CreateCommand or Tcl_FindCommand, this procedure returns the command's full name, qualified by a sequence of parent namespace names.
 String getCommandName(WrappedCommand cmd)
          Given a token returned by, e.g., Tcl_CreateCommand or Tcl_FindCommand, this procedure returns the command's name.
 Map<String,String> getenv()
          Replacement for System.getenv().
 int getErrorLine()
          Query the interp.errorLine member.
 Resolver getInterpResolver(String name)
          Looks for a set of command/variable resolution procedures with the given name in an interpreter.
 int getMaxNestingDepth()
          setMaxNestingDepth --
 String getNameOfExecutable()
          Get the name of the executable file to invoke JTcl.
 Notifier getNotifier()
          Retrieve the Notifier associated with this Interp.
 TclObject getResult()
          Queries the value of this interpreter's result value
 String getScriptFile()
          Returns the name of the script file currently under execution.
 String getShellClassName()
          Get the name of the shell class name to invoke JTcl.
 TclObject getVar(String name, int flags)
          Get the value of a variable.
 TclObject getVar(String name1, String name2, int flags)
          Get the value of a variable.
 TclObject getVar(TclObject nameObj, int flags)
          Get the value of a variable.
 File getWorkingDir()
          Retrieve the current working directory for this interpreter.
 WrappedCommand getWrappedCommand(String cmdName)
           
 void hideCommand(String cmdName, String hiddenCmdToken)
          Makes a command hidden so that it cannot be invoked from within an interpreter, only from within an ancestor.
 void hideUnsafeCommands()
          ---------------------------------------------------------------------- TclHideUnsafeCommands -> hideUnsafeCommands Hides base commands that are not marked as safe from this interpreter.
protected  tcl.lang.DebugInfo initDebugInfo()
          Initialize the debugging information.
 int invoke(TclObject[] objv, int flags)
          Invokes a Tcl command, given an objv/objc, from either the exposed or the hidden sets of commands in the given interpreter.
 int invokeGlobal(TclObject[] objv, int flags)
          Invokes a Tcl command, given an objv/objc, from either the exposed or hidden set of commands in the given interpreter.
 CallFrame newCallFrame()
          Creates a new callframe.
protected  CallFrame newCallFrame(Procedure proc, TclObject[] objv)
          Creates a new callframe.
 void pkgProvide(String name, String version)
          This procedure is invoked to declare that a particular version of a particular package is now present in an interpreter.
 String pkgRequire(String pkgname, String version, boolean exact)
          This procedure is called by code that depends on a particular version of a particular package.
 void preserve()
          ---------------------------------------------------------------------- Tcl_Preserve -> preserve This method is used by another method to declare its interest in this particular object, so that the object will not be disposed until a matching call to release() has been made.
 void preventAliasLoop(Interp cmdInterp, WrappedCommand cmd)
          TclPreventAliasLoop -> preventAliasLoop When defining an alias or renaming a command, prevent an alias loop from being formed.
 void processUnexpectedResult(int returnCode)
          Procedure called by Tcl_EvalObj to set the interpreter's result value to an appropriate error message when the code it evaluates returns an unexpected result code (not TCL_OK and not TCL_ERROR) to the topmost evaluation level.
 void ready()
          Check if an interpreter is ready to eval commands or scripts, i.e., if it was not deleted and if the nesting level is not too high.
 void recordAndEval(TclObject script, int flags)
          This procedure adds its command argument to the current list of recorded events and then executes the command by calling eval.
 void release()
           
 boolean removeInterpResolver(String name)
          Removes a set of command/variable resolution procedures previously added by addInterpResolver.
 void renameCommand(String oldName, String newName)
          Called to give an existing Tcl command a different name.
 void resetResult()
          This procedure resets this interpreter's result object.
 void setAssocData(String name, AssocData data)
          Creates a named association between user-specified data and this interpreter.
 void setErrorCode(TclObject code)
          This procedure is called to record machine-readable information about an error that is about to be returned.
 void setInterrupted()
          Invoke this method to indicate that an executing interp should be interrupted at the next safe moment.
 int setMaxNestingDepth(int depth)
          Set new value for maxNestingDepth
 void setNameOfExecutable(String name)
          Set the name of the executable file to invoke JTcl.
 void setResult(boolean r)
          Set this interpreter's result object to a boolean value.
 void setResult(double r)
          Set this interpreter's result object to a double value.
 void setResult(long r)
          Set this interpreter's result object to a long value.
 void setResult(String r)
          Set this interpreter's result object to a String value.
 void setResult(TclObject newResult)
          Arrange for the given Tcl Object to be placed as the result object for the interpreter.
 void setShellClassName(String name)
          Set the name of the shell class name to invoke JTcl.
 TclObject setVar(String name1, String name2, boolean bValue, int flags)
          Set a variable to the value of a boolean
 TclObject setVar(String name1, String name2, double dValue, int flags)
          Set a variable to the value of a double
 TclObject setVar(String name, String strValue, int flags)
          Set the value of a variable
 TclObject setVar(String name1, String name2, long intValue, int flags)
          Set a variable to the value in a long argument.
 TclObject setVar(String name1, String name2, String strValue, int flags)
          Set a variable to the value of a String
 TclObject setVar(String name1, String name2, TclObject value, int flags)
          Set the value of a variable
 TclObject setVar(String name, TclObject value, int flags)
          Set the value of a variable
 TclObject setVar(TclObject nameObj, TclObject value, int flags)
          Set the value of a variable
 void setWorkingDir(String dirName)
          Set the current working directory for this interpreter.
 String toString()
          Debug print info about the interpreter.
 void traceCommand(String command, CommandTrace trace)
          Set a command trace on a command
 TclObject traceCommandInfo(String command)
          Get a list of all command traces on a command
 void traceExecution(String command, ExecutionTrace trace)
          Set a execution trace on a command
 TclObject traceExecutionInfo(String command)
          Get a list of all execution traces on a command
 void traceVar(String part1, String part2, VarTrace trace, int flags)
          Add a trace to a variable.
 void traceVar(String name, VarTrace trace, int flags)
          Add a trace to a variable.
 void transferResult(Interp sourceInterp, int result)
          Copy the result (and error information) from one interp to another.
 void unsetVar(String name, int flags)
          Unset a variable.
 void unsetVar(String name1, String name2, int flags)
          Unset a variable.
 void unsetVar(TclObject nameObj, int flags)
          Unset a variable.
 void untraceCommand(String command, int type, TclObject callbackCmd)
          Remove a command trace on a command
 void untraceExecution(String command, int type, TclObject callbackCmd)
          Remove an execution trace on a command
 void untraceVar(String part1, String part2, VarTrace trace, int flags)
          Remove a trace from a variable.
 void untraceVar(String name, VarTrace trace, int flags)
          ---------------------------------------------------------------------- untraceVar -- Remove a trace from a variable.
 int updateReturnInfo()
          This method is used by various parts of the Jacl and external packages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reflectObjTable

public HashMap reflectObjTable
Translates Object to ReflectObject. This makes sure we have only one ReflectObject internalRep for the same Object -- this way Object identity can be done by string comparison.


reflectObjCount

public long reflectObjCount
Number of reflect objects created so far inside this Interp (including those that have be freed)


reflectConflictTable

public HashMap reflectConflictTable
Table used to store reflect hash index conflicts, see ReflectObject implementation for more details


cmdCount

public int cmdCount
Total number of times a command procedure has been called for this interpreter.


interpChanTable

public HashMap<String,Channel> interpChanTable
Table of channels currently registered in this interp.


systemEncodingChangesStdoutStderr

public boolean systemEncodingChangesStdoutStderr
Set to true if [encoding system] can set the encoding for stdout and stderr. This is an attempt to replicate TCL behavior seen in encoding.test encoding-24.3


frame

public CallFrame frame
Points to top-most in stack of all nested procedure invocations. null means there are no active procedures.


varFrame

public CallFrame varFrame
Points to the call frame whose variables are currently in use (same as frame unless an "uplevel" command is being executed). null means no procedure is active or "uplevel 0" is being exec'ed.


hiddenCmdTable

public HashMap hiddenCmdTable
Hash table used to keep track of hidden commands on a per-interp basis.


slaveTable

public HashMap slaveTable
Information used by InterpCmd.java to keep track of master/slave interps on a per-interp basis. Keeps track of all interps for which this interp is the Master. First, slaveTable (a hashtable) maps from names of commands to slave interpreters. This hashtable is used to store information about slave interpreters of this interpreter, to map over all slaves, etc.


targetTable

public HashMap targetTable
Hash table for Target Records. Contains all Target records which denote aliases from slaves or sibling interpreters that direct to commands in this interpreter. This table is used to remove dangling pointers from the slave (or sibling) interpreters when this interpreter is deleted.


slave

public InterpSlaveCmd slave
Information necessary for this interp to function as a slave.


aliasTable

public HashMap aliasTable
Table which maps from names of commands in slave interpreter to InterpAliasCmd objects.


scriptFile

public String scriptFile
The script file currently under execution. Can be null if the interpreter is not evaluating any script file.


nestLevel

public int nestLevel
Number of times the interp.eval() routine has been recursively invoked.


evalFlags

public int evalFlags
Flags used when evaluating a command.


isSafe

public boolean isSafe
Is this interpreted marked as safe?


termOffset

public int termOffset
Offset of character just after last one compiled or executed by Parser.eval2().


expr

public Expression expr
The expression parser for this interp.


errorInfo

public String errorInfo
If returnCode is TCL.ERROR, stores the errorInfo.


errorCode

public String errorCode
If returnCode is TCL.ERROR, stores the errorCode.


returnCode

public int returnCode
Completion code to return if current procedure exits with a TCL_RETURN code.


deleted

protected boolean deleted
True means the interpreter has been deleted: don't process any more commands for it, and destroy the structure as soon as all nested invocations of eval() are done.


errInProgress

public boolean errInProgress
True means an error unwind is already in progress. False means a command proc has been invoked since last error occured.


errAlreadyLogged

public boolean errAlreadyLogged
True means information has already been logged in $errorInfo for the current eval() instance, so eval() needn't log it (used to implement the "error" command).


errCodeSet

protected boolean errCodeSet
True means that addErrorInfo has been called to record information for the current error. False means Interp.eval must clear the errorCode variable if an error is returned.


errorLine

public int errorLine
When TCL_ERROR is returned, this gives the line number within the command where the error occurred (1 means first line).


packageTable

public HashMap packageTable

packageUnknown

public String packageUnknown

importTable

public HashMap[] importTable
Used ONLY by JavaImportCmd: classTable, packageTable, wildcardTable


strtoulResult

public StrtoulResult strtoulResult
Used by callers of Util.strtoul(), also used in FormatCmd.strtoul(). There is typically only one instance of a StrtoulResult around at any one time. Callers should exercise care to use the results before any other code could call strtoul() again.


strtodResult

public StrtodResult strtodResult
Used by callers of Util.strtod(). Usage is same as strtoulResult


getnfqnResult

public Namespace.GetNamespaceForQualNameResult getnfqnResult
Used only with Namespace.getNamespaceForQualName()


INVOKE_HIDDEN

public static final int INVOKE_HIDDEN
See Also:
Constant Field Values

INVOKE_NO_UNKNOWN

public static final int INVOKE_NO_UNKNOWN
See Also:
Constant Field Values

INVOKE_NO_TRACEBACK

public static final int INVOKE_NO_TRACEBACK
See Also:
Constant Field Values

systemIn

public static ManagedSystemInStream systemIn
Using System.in directly creates non-interruptible block during System.in.read(). This instance prevents the read() block. The first instance created will replace System.in with itself, so code doesn't have to use this instance directly.


dbg

protected tcl.lang.DebugInfo dbg
Constructor Detail

Interp

public Interp()
Side effects: Various parts of the interpreter are initialized; built-in commands are created; global variables are initialized, etc.

Method Detail

dispose

public void dispose()
Invoked to indicate that the interp should be disposed of. If there are no Tcl_Preserve calls in effect for this interpreter, it is deleted immediately, otherwise the interpreter is deleted when the last Tcl_Preserve is matched by a call to Tcl_Release. Results: None. Side effects: Cleans up the interpreter.


eventuallyDispose

public void eventuallyDispose()
This method cleans up the state of the interpreter so that it can be garbage collected safely. This routine needs to break any circular references that might keep the interpreter alive indefinitely. This proc should never be called directly. Instead it is called via the EventuallyFreed superclass. This method will only ever be invoked once. Results: None. Side effects: Cleans up the interpreter.


ready

public void ready()
           throws TclException
Check if an interpreter is ready to eval commands or scripts, i.e., if it was not deleted and if the nesting level is not too high. Results: Raises a TclExcetpion is the interp is not ready. Side effects: The interpreters result is cleared.

Throws:
TclException

createCommands

protected void createCommands()
Create the build-in commands. These commands are loaded on demand -- the class file of a Command class are loaded into the JVM the first time the given command is executed.


setAssocData

public void setAssocData(String name,
                         AssocData data)
Creates a named association between user-specified data and this interpreter. If the association already exists the data is overwritten with the new data. The data.deleteAssocData() method will be invoked when the interpreter is deleted. NOTE: deleteAssocData() is not called when an old data is replaced by a new data. Caller of setAssocData() is responsible with deleting the old data. Results: None. Side effects: Sets the associated data, creates the association if needed.

Parameters:
name - name for the association
data - Object associated with the name

deleteAssocData

public void deleteAssocData(String name)
Deletes a named association of user-specified data with the specified interpreter. Results: None. Side effects: Deletes the association.

Parameters:
name - name of the association

getAssocData

public AssocData getAssocData(String name)
Returns the AssocData instance associated with this name in the specified interpreter. Results: The AssocData instance in the AssocData record denoted by the named association, or null. Side effects: None.

Parameters:
name - name of the association
Returns:
AssocData instance indicated by name, or null if it does not exist

backgroundError

public void backgroundError()
This procedure is invoked to handle errors that occur in Tcl commands that are invoked in "background" (e.g. from event or timer bindings). Results: None. Side effects: The command "bgerror" is invoked later as an idle handler to process the error, passing it the error message. If that fails, then an error message is output on stderr.


setVar

public final TclObject setVar(TclObject nameObj,
                              TclObject value,
                              int flags)
                       throws TclException
Set the value of a variable

Parameters:
nameObj - name of variable, array or array element
value - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
new value for variable
Throws:
TclException

setVar

public final TclObject setVar(String name,
                              TclObject value,
                              int flags)
                       throws TclException
Set the value of a variable

Parameters:
name - name of variable, array or array element
value - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
new value for variable
Throws:
TclException

setVar

public final TclObject setVar(String name1,
                              String name2,
                              TclObject value,
                              int flags)
                       throws TclException
Set the value of a variable

Parameters:
name1 - name of variable if name2 is null, or an array
name2 - name of an array element, or null
value - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
new value for variable
Throws:
TclException

setVar

public final TclObject setVar(String name,
                              String strValue,
                              int flags)
                       throws TclException
Set the value of a variable

Parameters:
name - name of variable, array or array element
strValue - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
new value for variable
Throws:
TclException

setVar

public final TclObject setVar(String name1,
                              String name2,
                              String strValue,
                              int flags)
                       throws TclException
Set a variable to the value of a String

Parameters:
name1 - If name2 is null, this is the name of a scalar variable; otherwise it is the name of an array
name2 - name of element within an array, or null
strValue - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
the new value of the variable
Throws:
TclException

setVar

public final TclObject setVar(String name1,
                              String name2,
                              long intValue,
                              int flags)
                       throws TclException
Set a variable to the value in a long argument.

Parameters:
name1 - name of scalar variable, or name of array if name2 is non-null
name2 - Name of element within an array, or null if setting a scalar
intValue - new value for avariable
flags - Various flags that tell how to set valu any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
Variable with new value
Throws:
TclException

setVar

public final TclObject setVar(String name1,
                              String name2,
                              double dValue,
                              int flags)
                       throws TclException
Set a variable to the value of a double

Parameters:
name1 - If name2 is null, this is the name of a scalar variable; otherwise it is the name of an array
name2 - name of element within an array, or null
dValue - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
the new value of the variable
Throws:
TclException

setVar

public final TclObject setVar(String name1,
                              String name2,
                              boolean bValue,
                              int flags)
                       throws TclException
Set a variable to the value of a boolean

Parameters:
name1 - If name2 is null, this is the name of a scalar variable; otherwise it is the name of an array
name2 - name of element within an array, or null
bValue - new value for variable
flags - any of TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY, TCL.APPEND_VALUE, or TCL.LIST_ELEMENT.
Returns:
the new value of the variable
Throws:
TclException

getVar

public final TclObject getVar(TclObject nameObj,
                              int flags)
                       throws TclException
Get the value of a variable. Side effects: May trigger traces.

Parameters:
nameObj - the name of a variable, array or array element
flags - TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Returns:
the value of the variable.
Throws:
TclException - If the variable is not

getVar

public final TclObject getVar(String name,
                              int flags)
                       throws TclException
Get the value of a variable. Side effects: May trigger traces.

Parameters:
name - the name of a variable, array or array element
flags - TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Returns:
the value of the variable.
Throws:
TclException - If the variable is not

getVar

public final TclObject getVar(String name1,
                              String name2,
                              int flags)
                       throws TclException
Get the value of a variable. Side effects: May trigger traces.

Parameters:
name1 - if name2 is null, this is the name of a scalar. Otherwise, it is the name of an array
name2 - name of an element within an array, or null
flags - TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Returns:
the value of the variable.
Throws:
TclException - If the variable is not

getenv

public Map<String,String> getenv()
Replacement for System.getenv(). Returns JTcl's view of the environment, as stored in the ::env() array. JTcl modifications to values in the env array are not visible to System.getenv() due to Java API restrictions.

Returns:
an unmodifiable Map view of JTcl's ::env array.

unsetVar

public final void unsetVar(TclObject nameObj,
                           int flags)
                    throws TclException
Unset a variable. May trigget traces.

Parameters:
nameObj - name of a variable, array or array element
flags - any of TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Throws:
TclException

unsetVar

public final void unsetVar(String name,
                           int flags)
                    throws TclException
Unset a variable. May trigget traces.

Parameters:
name - name of a variable, array or array element
flags - any of TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Throws:
TclException

unsetVar

public final void unsetVar(String name1,
                           String name2,
                           int flags)
                    throws TclException
Unset a variable. May trigget traces.

Parameters:
name1 - if name2 is null, this is the name of a scalar. Otherwise it is the name of an array
name2 - name of an element within an array, or null
flags - any of TCL.GLOBAL_ONLY or TCL.NAMESPACE_ONLY.
Throws:
TclException

traceVar

public void traceVar(String name,
                     VarTrace trace,
                     int flags)
              throws TclException
Add a trace to a variable.

Parameters:
name - name of variable, may contain a parenthesized index value
trace - object to notify when specified ops are invoked upon the variable
flags - OR-ed collection of bits, including any of TCL.TRACE_READS, TCL.TRACE_WRITES, TCL.TRACE_UNSETS, TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY.
Throws:
TclException

traceVar

public void traceVar(String part1,
                     String part2,
                     VarTrace trace,
                     int flags)
              throws TclException
Add a trace to a variable.

Parameters:
part1 - name of variable
part2 - name of element in within an array, null means part1 is a scalar or entire array
trace - object to notify when specified ops are invoked upon the variable
flags - OR-ed collection of bits, including any of TCL.TRACE_READS, TCL.TRACE_WRITES, TCL.TRACE_UNSETS, TCL.GLOBAL_ONLY, TCL.NAMESPACE_ONLY.
Throws:
TclException

untraceVar

public void untraceVar(String name,
                       VarTrace trace,
                       int flags)
---------------------------------------------------------------------- untraceVar -- Remove a trace from a variable. Results: None. Side effects: None.

Parameters:
name - Name of variable; may end with "(index)" to signify an array reference.
trace - Object associated with trace.
flags - OR-ed collection of bits describing current trace, including any of TCL.TRACE_READS, TCL.TRACE_WRITES, TCL.TRACE_UNSETS, TCL.GLOBAL_ONLY and TCL.NAMESPACE_ONLY.

untraceVar

public void untraceVar(String part1,
                       String part2,
                       VarTrace trace,
                       int flags)
Remove a trace from a variable. Results: None. Side effects: None.

Parameters:
part1 - Name of scalar variable or array.
part2 - Name of element within array; null means trace applies to scalar variable or array as-a-whole.
trace - Object associated with trace.
flags - OR-ed collection of bits describing current trace, including any of TCL.TRACE_READS, TCL.TRACE_WRITES, TCL.TRACE_UNSETS, TCL.GLOBAL_ONLY and TCL.NAMESPACE_ONLY.

createCommand

public void createCommand(String cmdName,
                          Command cmdImpl)
Define a new command in the interpreter. Side effects: If a command named cmdName already exists for interp, it is deleted. In the future, when cmdName is seen as the name of a command by eval(), cmd will be called. When the command is deleted from the table, cmd.disposeCmd() be called if cmd implements the CommandWithDispose interface.

Parameters:
cmdName - name of the command
cmdImpl - Command instance that implements the command

getCommandFullName

public String getCommandFullName(WrappedCommand cmd)
Given a token returned by, e.g., Tcl_CreateCommand or Tcl_FindCommand, this procedure returns the command's full name, qualified by a sequence of parent namespace names. The command's fully-qualified name may have changed due to renaming.

Parameters:
cmd - command of which to get the full name
Returns:
full name, including namepaces, of the command

getCommandName

public String getCommandName(WrappedCommand cmd)
Given a token returned by, e.g., Tcl_CreateCommand or Tcl_FindCommand, this procedure returns the command's name. The command's fully-qualified name may have changed due to renaming.

Parameters:
cmd - command of which to get the name of
Returns:
name of the command

deleteCommand

public int deleteCommand(String cmdName)
Remove the given command from the this interpreter. Side effects: CmdName will no longer be recognized as a valid command for the interpreter.

Parameters:
cmdName - name of command to remove in this interpreter
Returns:
0 is returned if the command was deleted successfully. -1 is returned if there didn't exist a command by that name.

deleteCommandFromToken

public int deleteCommandFromToken(WrappedCommand cmd)
Remove the given command from the given interpreter. Side effects: cmdName will no longer be recognized as a valid command for the interpreter.

Parameters:
cmd - wrapper token for the command to delete; may be null
Returns:
0 is returned if the command was deleted successfully. -1 is returned if there didn't exist a command by that name (cmd is null)

renameCommand

public void renameCommand(String oldName,
                          String newName)
                   throws TclException
Called to give an existing Tcl command a different name. Both the old command name and the new command name can have "::" namespace qualifiers. If the new command has a different namespace context, the command will be moved to that namespace and will execute in the context of that new namespace. If the new command name is null or the empty string, the command is deleted.

Parameters:
oldName - existing command name
newName - new name
Throws:
TclException

preventAliasLoop

public void preventAliasLoop(Interp cmdInterp,
                             WrappedCommand cmd)
                      throws TclException
TclPreventAliasLoop -> preventAliasLoop When defining an alias or renaming a command, prevent an alias loop from being formed. Results: A standard Tcl object result. Side effects: If TCL_ERROR is returned, the function also stores an error message in the interpreter's result object. NOTE: This function is public internal (instead of being static to this file) because it is also used from TclRenameCommand.

Parameters:
cmdInterp - Interp in which the command is being defined.
cmd - Tcl command we are attempting to define.
Throws:
TclException

getCommand

public Command getCommand(String cmdName)
Returns the command procedure of the given command.

Parameters:
cmdName - string name of the command
Returns:
The command procedure of the given command, or null if the command doesn't exist. Do not directly call getCommand().cmdProc(); see WrappedCommand.invoke() and WrappedCommand.mustCallInvoke()

getWrappedCommand

public WrappedCommand getWrappedCommand(String cmdName)
Parameters:
cmdName - name of command to get
Returns:
WrappedCommand object for given command

commandComplete

public static boolean commandComplete(String string)

traceCommand

public void traceCommand(String command,
                         CommandTrace trace)
                  throws TclException
Set a command trace on a command

Parameters:
command - fully qualified command name
trace - trace to add to command
Throws:
TclException

untraceCommand

public void untraceCommand(String command,
                           int type,
                           TclObject callbackCmd)
                    throws TclException
Remove a command trace on a command

Parameters:
command - fully qualified command name
type - CommandTrace.RENAME or CommandTrace.DELETE
callbackCmd - callback command to remove
Throws:
TclException

traceCommandInfo

public TclObject traceCommandInfo(String command)
                           throws TclException
Get a list of all command traces on a command

Parameters:
command - fully qualified name of command
Returns:
List, in the form of [trace command info]
Throws:
TclException

traceExecution

public void traceExecution(String command,
                           ExecutionTrace trace)
                    throws TclException
Set a execution trace on a command

Parameters:
command - fully qualified command name
trace - trace to add to command
Throws:
TclException

untraceExecution

public void untraceExecution(String command,
                             int type,
                             TclObject callbackCmd)
                      throws TclException
Remove an execution trace on a command

Parameters:
command - fully qualified command name
type - ExecutionTrace.ENTER, ExecutionTrace.LEAVE, ExecutionTrace.ENTERSTEP, ExecutionTrace.LEAVESTEP
callbackCmd - callback command to remove
Throws:
TclException

traceExecutionInfo

public TclObject traceExecutionInfo(String command)
                             throws TclException
Get a list of all execution traces on a command

Parameters:
command - fully qualified name of command
Returns:
List, in the form of [trace command info]
Throws:
TclException

getResult

public final TclObject getResult()
Queries the value of this interpreter's result value

Returns:
The current result in the interpreter.

setResult

public final void setResult(TclObject newResult)
Arrange for the given Tcl Object to be placed as the result object for the interpreter. Convenience functions are also available to create a Tcl Object out of the most common Java types. Note that the ref count for m_nullResult is not changed.

Parameters:
newResult - A Tcl Object to be set as the result of this interpreter

setResult

public final void setResult(String r)
Set this interpreter's result object to a String value.

Parameters:
r - value to set result to

setResult

public final void setResult(long r)
Set this interpreter's result object to a long value.

Parameters:
r - value to set result to

setResult

public final void setResult(double r)
Set this interpreter's result object to a double value.

Parameters:
r - value to set result to

setResult

public final void setResult(boolean r)
Set this interpreter's result object to a boolean value.

Parameters:
r - value to set result to

resetResult

public final void resetResult()
This procedure resets this interpreter's result object. Results: None. Side effects: It resets the result object to an unshared empty object. It also clears any error information for the interpreter.


appendElement

public void appendElement(String string)
                   throws TclException
Convert a string to a valid Tcl list element and append it to the result (which is ostensibly a list). Results: None. Side effects: The result in the interpreter given by the first argument is extended with a list element converted from string. A separator space is added before the converted list element unless the current result is empty, contains the single character "{", or ends in " {". If the string result is empty, the object result is moved to the string result, then the object result is reset.

Parameters:
string - String to append to list result
Throws:
TclException

eval

public void eval(String script)
          throws TclException
Execute a Tcl command in a string. A standard Tcl Exception may be generated. The interpreter's result object will contain the value of the evaluation but will persist only until the next call to one of the eval functions.

Parameters:
script - The script to be evaluated
Throws:
TclException - on any TCL errors generated by the script

eval

public void eval(String string,
                 int flags)
          throws TclException
Evaluate a TCL script in a string

Parameters:
string - containing the TCL script
flags - Either 0 or TCL.EVAL_GLOBAL
Throws:
TclException - on any TCL error

eval

public void eval(TclObject tobj,
                 int flags)
          throws TclException
Execute a Tcl script in a TclObject.

Parameters:
tobj - A Tcl object holding a script to evaluate
flags - either 0 or TCL.EVAL_GLOBAL
Throws:
TclException - on any TCL error

recordAndEval

public void recordAndEval(TclObject script,
                          int flags)
                   throws TclException
This procedure adds its command argument to the current list of recorded events and then executes the command by calling eval. Results: The return value is void. However, a standard Tcl Exception may be generated. The interpreter's result object will contain the value of the evaluation but will persist only until the next call to one of the eval functions. Side effects: The side effects will be determined by the exact Tcl code to be evaluated.

Parameters:
script - a script to evaluate
flags - TCL.NO_EVAL records only; TCL.EVAL_GLOBAL evalutes the script in a global context
Throws:
TclException

evalFile

public void evalFile(String s)
              throws TclException
Loads a Tcl script from a file using the system encoding and evaluates it in the current interpreter.

Parameters:
s - Name of the file to evaluate
Throws:
TclException - on any TCL error or on a file read error

evalFile

public void evalFile(String s,
                     String encoding)
              throws TclException
Loads a Tcl script from a file and evaluates it in the current interpreter.

Parameters:
s - Name of the file to evaluate
encoding - Java charset name of file's encoding
Throws:
TclException - on any TCL error or on a file read error

evalURL

public void evalURL(URL context,
                    String s)
             throws TclException
Loads a Tcl script (encoded in system encoding) from a URL and evaluate it in the current interpreter.

Parameters:
context - URL context under which s is to be interpreted
s - the URL
Throws:
TclException - on any TCL or read error

evalURL

public void evalURL(URL context,
                    String s,
                    String javaEncoding)
             throws TclException
Loads a Tcl script from a URL and evaluate it in the current interpreter.

Parameters:
context - URL context under which s is to be interpreted
s - the URL
javaEncoding - Java charset name in which script is encoded
Throws:
TclException - on any TCL or read error

evalResource

public void evalResource(String resName)
                  throws TclException
Execute a Tcl script stored in the given Java resource location, encoded in the system encoding Results: The return value is void. However, a standard Tcl Exception may be generated. The interpreter's result object will contain the value of the evaluation but will persist only until the next call to one of the eval functions. Side effects: The side effects will be determined by the exact Tcl code to be evaluated.

Parameters:
resName - the location of the Java resource. See the Java documentation of Class.getResourceAsStream() for details on resource naming.
Throws:
TclException

evalResource

public void evalResource(String resName,
                         String javaEncoding)
                  throws TclException
Execute a Tcl script stored in the given Java resource location. Results: The return value is void. However, a standard Tcl Exception may be generated. The interpreter's result object will contain the value of the evaluation but will persist only until the next call to one of the eval functions. Side effects: The side effects will be determined by the exact Tcl code to be evaluated.

Parameters:
resName - the location of the Java resource. See the Java documentation of Class.getResourceAsStream() for details on resource naming.
javaEncoding - Java charset name for Unicode encoding of resource
Throws:
TclException

backslash

public static BackSlashResult backslash(String s,
                                        int i,
                                        int len)
Figure out how to handle a backslash sequence. The index of the ChapPointer must be pointing to the first /. Results: The return value is an instance of BackSlashResult that contains the character that should be substituted in place of the backslash sequence that starts at src.index, and an index to the next character after the backslash sequence. Side effects: None.

Parameters:
s -
i -
len -
Returns:
an instance of BackSlashResult that contains the character that should be substituted in place of the backslash sequence that starts at src.index, and an index to the next character after the backslash sequence.

setErrorCode

public void setErrorCode(TclObject code)
This procedure is called to record machine-readable information about an error that is about to be returned. The caller should build a list object up and pass it to this routine. Results: None. Side effects: The errorCode global variable is modified to be the new value. A flag is set internally to remember that errorCode has been set, so the variable doesn't get set automatically when the error is returned. If the errorCode variable have write traces, any arbitrary side effects may happen in those traces. TclException's caused by the traces, however, are ignored and not passed back to the caller of this function.

Parameters:
code - the errorCode object

addErrorInfo

public void addErrorInfo(String message)
Add information to the "errorInfo" variable that describes the current error. Side effects: The contents of message are added to the "errorInfo" variable. If eval() has been called since the current value of errorInfo was set, errorInfo is cleared before adding the new message. If we are just starting to log an error, errorInfo is initialized from the error message in the interpreter's result. If the errorInfo variable have write traces, any arbitrary side effects may happen in those traces. TclException's caused by the traces, however, are ignored and not passed back to the caller of this function.

Parameters:
message - message to record in errorInfo

processUnexpectedResult

public void processUnexpectedResult(int returnCode)
                             throws TclException
Procedure called by Tcl_EvalObj to set the interpreter's result value to an appropriate error message when the code it evaluates returns an unexpected result code (not TCL_OK and not TCL_ERROR) to the topmost evaluation level. Results: None. Side effects: The interpreter result is set to an error message appropriate to the result code.

Parameters:
returnCode - the unexpected result code
Throws:
TclException

updateReturnInfo

public int updateReturnInfo()
This method is used by various parts of the Jacl and external packages. interpreter when a TclException of TCL.RETURN is received. The most common case is when the "return" command is executed inside a Tcl procedure. This method examines fields such as interp.returnCode and interp.errorCode and determines the real return status of the Tcl procedure accordingly. Side effects: The errorInfo and errorCode variables may get modified.

Returns:
The return value is the true completion code to use for the Tcl procedure, instead of TCL.RETURN. It's the same value that was given to the "return -code" option. If TCL.OK is returned, it means than the caller of this method should ignore any TclException that it has received.

newCallFrame

protected CallFrame newCallFrame(Procedure proc,
                                 TclObject[] objv)
                          throws TclException
Creates a new callframe. This method can be overrided to provide debugging support.

Parameters:
proc - the procedure which will later execute in the new CallFrame
objv - the arguments that will be passed to the procedure
Returns:
A new CallFrame.
Throws:
TclException - incorrect arguments passed.

newCallFrame

public CallFrame newCallFrame()
Creates a new callframe. This method can be overrided to provide debugging support.

Returns:
A new CallFrame.

getWorkingDir

public File getWorkingDir()
Retrieve the current working directory for this interpreter. Side effects: If the working dir is null, set it to env(HOME)

Returns:
the File for the current directory

setWorkingDir

public void setWorkingDir(String dirName)
                   throws TclException
Set the current working directory for this interpreter.

Parameters:
dirName - name of directory that will become working directory
Throws:
TclException

getNotifier

public Notifier getNotifier()
Retrieve the Notifier associated with this Interp. This method can safely be invoked from a thread other than the thread the Interp was created in. If this method is invoked after the Interp object has been disposed of then null will be returned.

Returns:
the Notifier for the thread the interp was created in.

pkgProvide

public final void pkgProvide(String name,
                             String version)
                      throws TclException
This procedure is invoked to declare that a particular version of a particular package is now present in an interpreter. There must not be any other version of this package already provided in the interpreter. Results: Normally does nothing; if there is already another version of the package loaded then an error is raised. Side effects: The interpreter remembers that this package is available, so that no other version of the package may be provided for the interpreter.

Parameters:
name - name of package
version - version of package
Throws:
TclException

pkgRequire

public final String pkgRequire(String pkgname,
                               String version,
                               boolean exact)
                        throws TclException
This procedure is called by code that depends on a particular version of a particular package. If the package is not already provided in the interpreter, this procedure invokes a Tcl script to provide it. If the package is already provided, this procedure makes sure that the caller's needs don't conflict with the version that is present. Side effects: The script from some previous "package ifneeded" command may be invoked to provide the package.

Parameters:
pkgname - name of the package to require
version - version to require
exact - if true, require the exact versions specified
Returns:
If successful, returns the version string for the currently provided version of the package, which may be different from the "version" argument.
Throws:
TclException - If the caller's requirements cannot be met (e.g. the version requested conflicts with a currently provided version, or the required version cannot be found, or the script to provide the required version generates an error), a TclException is raised.

initDebugInfo

protected tcl.lang.DebugInfo initDebugInfo()
Initialize the debugging information. * Debugging API. The following section defines two debugging API functions for logging information about the point of execution of Tcl scripts: - pushDebugStack() is called when a procedure body is executed, or when a file is source'd. - popDebugStack() is called when the flow of control is about to return from a procedure body, or from a source'd file. Two other API functions are used to determine the current point of execution: - getScriptFile() returns the script file current being executed. - getArgLineNumber(i) returns the line number of the i-th argument of the current command. Note: The point of execution is automatically maintained for control structures such as while, if, for and foreach, as long as they use Interp.eval(argv[?]) to evaluate control blocks. The case and switch commands need to set dbg.cmdLine explicitly because they may evaluate control blocks that are not elements inside the argv[] array. ** This feature not yet implemented. ** The proc command needs to call getScriptFile() and getArgLineNumber(3) to find out the location of the proc body. The debugging API functions in the Interp class are just dummy stub functions. These functions are usually implemented in a subclass of Interp (e.g. DbgInterp) that has real debugging support.

Returns:
a DebugInfo object used by Interp in non-debugging mode.

getScriptFile

public String getScriptFile()
Returns the name of the script file currently under execution.

Returns:
the name of the script file currently under execution.

getArgLineNumber

public int getArgLineNumber(int index)
Returns the line number where the given command argument begins. E.g, if the following command is at line 10: foo {a b } c getArgLine(0) = 10 getArgLine(1) = 10 getArgLine(2) = 11

Parameters:
index - specifies an argument.
Returns:
the line number of the given argument.

transferResult

public void transferResult(Interp sourceInterp,
                           int result)
                    throws TclException
Copy the result (and error information) from one interp to another. Used when one interp has caused another interp to evaluate a script and then wants to transfer the results back to itself. This routine copies the string reps of the result and error information. It does not simply increment the refcounts of the result and error information objects themselves. It is not legal to exchange objects between interps, because an object may be kept alive by one interp, but have an internal rep that is only valid while some other interp is alive. Results: The target interp's result is set to a copy of the source interp's result. The source's error information "$errorInfo" may be appended to the target's error information and the source's error code "$errorCode" may be stored in the target's error code. Side effects: None.

Parameters:
sourceInterp - interp whose result and error information should be moved to the target interp. AFter moving the results, the interp's result is reset
result - TCL.OK if just the result should be copied, TCL.ERROR if both teh result and the error information should be copied
Throws:
TclException

hideCommand

public void hideCommand(String cmdName,
                        String hiddenCmdToken)
                 throws TclException
Makes a command hidden so that it cannot be invoked from within an interpreter, only from within an ancestor. Results: A standard Tcl result; also leaves a message in the interp's result if an error occurs. Side effects: Removes a command from the command table and create an entry into the hidden command table under the specified token name.

Parameters:
cmdName - Name of command to hide.
hiddenCmdToken - Token name of the to-be-hidden command.
Throws:
TclException

exposeCommand

public void exposeCommand(String hiddenCmdToken,
                          String cmdName)
                   throws TclException
Makes a previously hidden command callable from inside the interpreter instead of only by its ancestors. Results: A standard Tcl result. If an error occurs, a message is left in the interp's result. Side effects: Moves commands from one hash table to another.

Parameters:
hiddenCmdToken - Token name of the to-be-hidden command.
cmdName - Name of command to hide.
Throws:
TclException

hideUnsafeCommands

public void hideUnsafeCommands()
                        throws TclException
---------------------------------------------------------------------- TclHideUnsafeCommands -> hideUnsafeCommands Hides base commands that are not marked as safe from this interpreter. Results: None Side effects: Hides functionality in an interpreter. ----------------------------------------------------------------------

Throws:
TclException

invokeGlobal

public int invokeGlobal(TclObject[] objv,
                        int flags)
                 throws TclException
Invokes a Tcl command, given an objv/objc, from either the exposed or hidden set of commands in the given interpreter. NOTE: The command is invoked in the global stack frame of the interpreter, thus it cannot see any current state on the stack of that interpreter. Results: A standard Tcl result. Side effects: Whatever the command does.

Parameters:
objv - Argument objects; objv[0] points to the name of the command to invoke.
flags - Combination of flags controlling the call: INVOKE_HIDDEN,_INVOKE_NO_UNKNOWN, or INVOKE_NO_TRACEBACK.
Returns:
result
Throws:
TclException

invoke

public int invoke(TclObject[] objv,
                  int flags)
           throws TclException
Invokes a Tcl command, given an objv/objc, from either the exposed or the hidden sets of commands in the given interpreter.

Parameters:
objv - argument objects, objv[0] is the name of the command to invoke
flags - Combination of flags controlling the call: INVOKE_HIDDEN,_INVOKE_NO_UNKNOWN, or INVOKE_NO_TRACEBACK.
Returns:
A standard Tcl object result.
Throws:
TclException

allowExceptions

public void allowExceptions()
Sets a flag in an interpreter so that exceptions can occur in the next call to Tcl_Eval without them being turned into errors. Results: None. Side effects: The TCL_ALLOW_EXCEPTIONS flag gets set in the interpreter's evalFlags structure. See the reference documentation for more details.


addInterpResolver

public void addInterpResolver(String name,
                              Resolver resolver)
---------------------------------------------------------------------- Tcl_AddInterpResolvers -> addInterpResolver Adds a set of command/variable resolution procedures to an interpreter. These procedures are consulted when commands are resolved in Namespace.findCommand, and when variables are resolved in Namespace.findNamespaceVar and thus Var.lookupVar. Each namespace may also have its own resolution object which take precedence over those for the interpreter. When a name is resolved, it is handled as follows. First, the name is passed to the resolution objects for the namespace. If not resolved, the name is passed to each of the resolution procedures added to the interpreter. Finally, if still not resolved, the name is handled using the default Tcl rules for name resolution. Results: None. Side effects: The list of resolvers of the given interpreter is modified.

Parameters:
name - Name of this resolution scheme
resolver - Object to resolve commands/variables.

getInterpResolver

public Resolver getInterpResolver(String name)
Looks for a set of command/variable resolution procedures with the given name in an interpreter. These procedures are registered by calling addInterpResolver. Results: If the name is recognized, this procedure returns the object implementing the name resolution procedures. If the name is not recognized, this procedure returns null. Side effects: None.

Parameters:
name - Look for a scheme with scheme.
Returns:
the object implementing the name resolution procedures.

removeInterpResolver

public boolean removeInterpResolver(String name)
Removes a set of command/variable resolution procedures previously added by addInterpResolver. The next time a command/variable name is resolved, these procedures won't be consulted. Results: Returns true if the name was recognized and the resolution scheme was deleted. Returns false otherwise. Side effects: The list of resolvers of the given interpreter may be modified.

Parameters:
name - Name of the scheme to be removed.
Returns:
true if the name was recognized and the resolution scheme was deleted. Returns false otherwise.

checkCommonInteger

public final TclObject checkCommonInteger(long value)
checkCommonInteger() If a given integer value is in the common value pool then return a shared object for that integer. If the integer value is not in the common pool then use to use the recycled int value or a new TclObject.

Parameters:
value - integer to test
Returns:
TclObject containing 'value'

checkCommonString

public final TclObject checkCommonString(String value)
If a given String value is in the common value pool the return a shared object for that String. If the String value is not in the common pool then a new TclString wrapped in a TclObject will be created.


checkCommonCharacter

public final TclObject checkCommonCharacter(int c)
It is very common to create a TclObject that contains a single character. It can be costly to allocate a TclObject, a TclString internal rep, and a String to represent a character. This method avoids that overhead for the most common characters. This method will return null if a character does not have a cached value.


getErrorLine

public int getErrorLine()
Query the interp.errorLine member. This is like accessing the public Tcl_Interp.errorLine field in the C impl. this method should be used by classes outside the tcl.lang package. Results: None. Side effects: None.


getClassLoader

public ClassLoader getClassLoader()
Get the TclClassLoader used for the interp. This class loader delagates to the context class loader which delagates to the system class loader. The TclClassLoader will read classes and resources from the env(TCL_CLASSPATH). Results: This method will return the classloader in use, it will never return null. Side effects: None.


setInterrupted

public void setInterrupted()
Invoke this method to indicate that an executing interp should be interrupted at the next safe moment. Interrupting a running interpreter will unwind the stack by throwing an exception. This method can safely be called from a thread other than the one processsing events. No explicit synchronization is needed. Once a thread has been interrupted or disposed of, setInterrupted() calls will do nothing. Results: Stops execution of the Interp via an Exception. Side effects: None.


checkInterrupted

public final void checkInterrupted()
This method is invoked after an eval operation to check if a running interp has been marked as interrupted. This method is not public since it should only be used by the Jacl internal implementation. Results: This method will raise a TclInterruptedException if the Interp.setInterrupted() method was invoked for this interp. This method will only raise a TclInterruptedException once. Side effects: None.


setMaxNestingDepth

public int setMaxNestingDepth(int depth)
Set new value for maxNestingDepth

Parameters:
depth - If > 0, set as new depth; otherwise don't set new value
Returns:
old value, or current value if depth <= 0

getMaxNestingDepth

public int getMaxNestingDepth()
setMaxNestingDepth --

Returns:
value of maxNestingDepth

toString

public String toString()
Debug print info about the interpreter.

Overrides:
toString in class Object

getNameOfExecutable

public String getNameOfExecutable()
Get the name of the executable file to invoke JTcl. Typically set on the first call to [info nameofexecutable]

Returns:
name of executable

setNameOfExecutable

public void setNameOfExecutable(String name)
Set the name of the executable file to invoke JTcl. Typically set on the first call to [info nameofexecutable]


getShellClassName

public String getShellClassName()
Get the name of the shell class name to invoke JTcl. Set by default as the constructer of Interp. If shellClassName was set as null, return the name of "tcl.lang.NoInteractiveShell"

Returns:
shell class name

setShellClassName

public void setShellClassName(String name)
Set the name of the shell class name to invoke JTcl. Can be null, which causes "tcl.lang.NoInteractiveShell" to be returned by getshellClassName()


preserve

public void preserve()
---------------------------------------------------------------------- Tcl_Preserve -> preserve This method is used by another method to declare its interest in this particular object, so that the object will not be disposed until a matching call to release() has been made. Results: None. Side effects: Information is retained so that the object will not be disposed until at least the matching call to release(). ----------------------------------------------------------------------


release

public void release()


Copyright © 2015. All rights reserved.