Every piece of information related to a loaded script. This includes the scripts runtime environment, code in compiled
form, variable information, and listeners for runtime issues.
DEBUG_NONE
public static final int DEBUG_NONE
debug should be absolutely quiet, never fire any runtime warnings
DEBUG_REQUIRE_STRICT
public static final int DEBUG_REQUIRE_STRICT
fire runtime warning whenever an undeclared variable is fired
DEBUG_SHOW_ERRORS
public static final int DEBUG_SHOW_ERRORS
fire runtime warnings for all critical flow interrupting errors
DEBUG_SHOW_WARNINGS
public static final int DEBUG_SHOW_WARNINGS
fire runtime warnings for anything flagged for retrieval with checkError()
DEBUG_TRACE_CALLS
public static final int DEBUG_TRACE_CALLS
fire a runtime warning describing each function call
DEBUG_TRACE_PROFILE_ONLY
public static final int DEBUG_TRACE_PROFILE_ONLY
forces function call tracing to occur (for the sake of profiling a script) but supresses
all runtime warnings as a result of the tracing
debug
protected int debug
track all of the flagged debug options for this script (set to DEBUG_SHOW_ERRORS by default)
environment
protected ScriptEnvironment environment
The script environment which contains all of the runtime info for a script
loaded
protected boolean loaded
true by default, indicates wether or not the script is loaded. Once unloaded this variable must be flagged to false so
the bridges know data related to this script is stale
name
protected String name
the name of this script
script
protected Block script
The compiled sleep code for this script, the ScriptLoader will set this value upon loading a script.
variables
protected ScriptVariables variables
The script variables which contains all of the variable information for a script
watchers
protected LinkedList watchers
A list of listeners watching for a runtime error
addWarningWatcher
public void addWarningWatcher(RuntimeWarningWatcher w)
Register a runtime warning watcher listener. If an error occurs while the script is running these listeners will
be notified
callFunction
public Scalar callFunction(String funcName,
Stack parameters)
Calls a subroutine/built-in function using this scripts
collect
public void collect(String function,
int lineNo,
long ticks)
this function is used internally by the sleep interpreter to collect profiler statistics
when DEBUG_TRACE_CALLS or DEBUG_TRACE_PROFILE_ONLY is enabled
fireWarning
public void fireWarning(String message,
int line)
Fire a runtime script warning
fireWarning
public void fireWarning(String message,
int line,
boolean isTrace)
Fire a runtime script warning
fork
public ScriptInstance fork()
Creates a forked script instance. This does not work like fork in an operating system. Variables are not copied, period.
The idea is to create a fork that shares the same environment as this script instance.
getDebugFlags
public int getDebugFlags()
retrieve the debug flags for this script
getName
public String getName()
Returns the name of this script (typically a full pathname) as a String
getProfilerStatistics
public List getProfilerStatistics()
Returns a sorted (in order of total ticks used) list of function call statistics for this
script environment. The list contains ScriptInstance.ProfileStatistic objects.
Note!!! For Sleep to provide profiler statistics, DEBUG_TRACE_CALLS or DEBUG_TRACE_PROFILE_ONLY must be enabled!
getRunnableBlock
public Block getRunnableBlock()
Returns the compiled form of this script
getScriptEnvironment
public ScriptEnvironment getScriptEnvironment()
Returns this scripts runtime environment
getScriptVariables
public ScriptVariables getScriptVariables()
Returns the variable container used by this script
installBlock
public void installBlock(Block _script)
Install a block as the compiled script code
isLoaded
public boolean isLoaded()
Returns wether or not this script is loaded. If it is unloaded it should be removed from data structures and
its modifications to the environment should be ignored
isProfileOnly
public boolean isProfileOnly()
a quick way to check if we are profiling and not tracing the script steps
printProfileStatistics
public void printProfileStatistics(OutputStream out)
Dumps the profiler statistics to the specified stream
removeWarningWatcher
public void removeWarningWatcher(RuntimeWarningWatcher w)
Removes a runtime warning watcher listener
run
public void run()
Executes this script, same as runScript() just here for Runnable compatability
runScript
public Scalar runScript()
Executes this script, should be done first thing once a script is loaded
setDebugFlags
public void setDebugFlags(int options)
set the debug flags for this script
setName
public void setName(String sn)
Sets the name of this script
setParent
public void setParent(IOObject p)
Sets up the parent of this script (in case it is being run via &fork()). When this script returns a value, the return value will be passed to the parent IOObject to allow retrieval with the &wait function.
setScriptVariables
public void setScriptVariables(ScriptVariables v)
Sets the variable container to be used by this script
setUnloaded
public void setUnloaded()
Flag this script as unloaded