|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mozilla.javascript.Context
This class represents the runtime context of an executing script. Before executing a script, an instance of Context must be created and associated with the thread that will be executing the script. The Context will be used to store information about the executing of the script such as the call stack. Contexts are associated with the current thread using the enter() method.
The behavior of the execution engine may be altered through methods such as setErrorReporter.
Different forms of script execution are supported. Scripts may be evaluated from the source directly, or first compiled and then later executed. Interactive execution is also supported.
Some aspects of script execution, such as type conversions and object creation, may be accessed directly through methods of Context.
Scriptable
Field Summary | |
static java.lang.String |
errorReporterProperty
|
static java.lang.String |
languageVersionProperty
|
static int |
VERSION_1_0
JavaScript 1.0 |
static int |
VERSION_1_1
JavaScript 1.1 |
static int |
VERSION_1_2
JavaScript 1.2 |
static int |
VERSION_1_3
JavaScript 1.3 |
static int |
VERSION_1_4
JavaScript 1.4 |
static int |
VERSION_1_5
JavaScript 1.5 |
static int |
VERSION_DEFAULT
The default version. |
static int |
VERSION_UNKNOWN
The unknown version. |
Constructor Summary | |
Context()
Create a new Context. |
|
Context(SecuritySupport securitySupport)
Create a new context with the associated security support. |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Register an object to receive notifications when a bound property has changed |
Function |
compileFunction(Scriptable scope,
java.lang.String source,
java.lang.String sourceName,
int lineno,
java.lang.Object securityDomain)
Compile a JavaScript function. |
Script |
compileReader(Scriptable scope,
java.io.Reader in,
java.lang.String sourceName,
int lineno,
java.lang.Object securityDomain)
Compiles the source in the given reader. |
java.lang.String |
decompileFunction(Function fun,
int indent)
Decompile a JavaScript Function. |
java.lang.String |
decompileFunctionBody(Function fun,
int indent)
Decompile the body of a JavaScript Function. |
java.lang.String |
decompileScript(Script script,
Scriptable scope,
int indent)
Decompile the script. |
static Context |
enter()
Get a context associated with the current thread, creating one if need be. |
static Context |
enter(Context cx)
Get a Context associated with the current thread, using the given Context if need be. |
java.lang.Object |
evaluateReader(Scriptable scope,
java.io.Reader in,
java.lang.String sourceName,
int lineno,
java.lang.Object securityDomain)
Evaluate a reader as JavaScript source. |
java.lang.Object |
evaluateString(Scriptable scope,
java.lang.String source,
java.lang.String sourceName,
int lineno,
java.lang.Object securityDomain)
Evaluate a JavaScript source string. |
static void |
exit()
Exit a block of code requiring a Context. |
protected void |
firePropertyChange(java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
Notify any registered listeners that a bounded property has changed |
org.mozilla.javascript.DeepBytecodeHook |
getBytecodeHook()
Get the current byte code hook (for debugging). |
org.mozilla.javascript.DeepCallHook |
getCallHook()
Get the current call hook (for debugging). |
static Context |
getCurrentContext()
Get the current Context. |
int |
getDebugLevel()
Get the current debug level (for debugging). |
java.lang.Object[] |
getElements(Scriptable object)
Get the elements of a JavaScript array. |
ErrorReporter |
getErrorReporter()
Get the current error reporter. |
org.mozilla.javascript.DeepErrorReporterHook |
getErrorReporterHook()
Get the current error reporter hook (for debugging). |
org.mozilla.javascript.DeepExecuteHook |
getExecuteHook()
Get the current execute hook (for debugging). |
java.lang.String |
getImplementationVersion()
Get the implementation version. |
java.lang.Object |
getInterpreterSecurityDomain()
Returns the security context associated with the innermost script or function being executed by the interpreter. |
int |
getLanguageVersion()
Get the current language version. |
java.util.Locale |
getLocale()
Get the current locale. |
org.mozilla.javascript.DeepNewObjectHook |
getNewObjectHook()
Get the current new object hook (for debugging). |
int |
getOptimizationLevel()
Get the current optimization level. |
org.mozilla.javascript.DeepScriptHook |
getScriptHook()
Get the current script hook (for debugging). |
org.mozilla.javascript.SourceTextManager |
getSourceTextManager()
Get the current source text hook (for debugging). |
java.lang.String |
getTargetClassFileName()
Get the current target class file name. |
java.lang.String |
getTargetPackage()
Get the current package to generate classes into. |
java.lang.Object |
getThreadLocal(java.lang.Object key)
Get a value corresponding to a key. |
static java.lang.Object |
getUndefinedValue()
Get the singleton object that represents the JavaScript Undefined value. |
boolean |
hasCompileFunctionsWithDynamicScope()
Return whether functions are compiled by this context using dynamic scope. |
Scriptable |
initStandardObjects(ScriptableObject scope)
Initialize the standard objects. |
ScriptableObject |
initStandardObjects(ScriptableObject scope,
boolean sealed)
Initialize the standard objects. |
boolean |
isGeneratingDebug()
Tell whether debug information is being generated. |
boolean |
isGeneratingSource()
Tell whether source information is being generated. |
boolean |
isInterpreterClass(java.lang.Class cl)
Returns true if the class parameter is a class in the interpreter. |
static boolean |
isSecurityDomainRequired()
Return true if a security domain is required on calls to compile and evaluate scripts. |
Scriptable |
newArray(Scriptable scope,
int length)
Create an array with a specified initial length. |
Scriptable |
newArray(Scriptable scope,
java.lang.Object[] elements)
Create an array with a set of initial elements. |
Scriptable |
newObject(Scriptable scope)
Create a new JavaScript object. |
Scriptable |
newObject(Scriptable scope,
java.lang.String constructorName)
Create a new JavaScript object by executing the named constructor. |
Scriptable |
newObject(Scriptable scope,
java.lang.String constructorName,
java.lang.Object[] args)
Creates a new JavaScript object by executing the named constructor. |
void |
putThreadLocal(java.lang.Object key,
java.lang.Object value)
Put a value that can later be retrieved using a given key. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove an object from the list of objects registered to receive notification of changes to a bounded property |
static void |
reportError(java.lang.String message)
Report an error using the error reporter for the current thread. |
static void |
reportError(java.lang.String message,
java.lang.String sourceName,
int lineno,
java.lang.String lineSource,
int lineOffset)
Report an error using the error reporter for the current thread. |
static org.mozilla.javascript.EvaluatorException |
reportRuntimeError(java.lang.String message)
Report a runtime error using the error reporter for the current thread. |
static org.mozilla.javascript.EvaluatorException |
reportRuntimeError(java.lang.String message,
java.lang.String sourceName,
int lineno,
java.lang.String lineSource,
int lineOffset)
Report a runtime error using the error reporter for the current thread. |
static void |
reportWarning(java.lang.String message)
Report a warning using the error reporter for the current thread. |
static void |
reportWarning(java.lang.String message,
java.lang.String sourceName,
int lineno,
java.lang.String lineSource,
int lineOffset)
Report a warning using the error reporter for the current thread. |
org.mozilla.javascript.DeepBytecodeHook |
setBytecodeHook(org.mozilla.javascript.DeepBytecodeHook hook)
Set the current byte code hook (for debugging). |
static void |
setCachingEnabled(boolean cachingEnabled)
Set whether to cache some values statically. |
org.mozilla.javascript.DeepCallHook |
setCallHook(org.mozilla.javascript.DeepCallHook hook)
Set the current call hook (for debugging). |
void |
setCompileFunctionsWithDynamicScope(boolean flag)
Set whether functions compiled by this context should use dynamic scope. |
int |
setDebugLevel(int debugLevel)
Set the current debug level (for debugging). |
ErrorReporter |
setErrorReporter(ErrorReporter reporter)
Change the current error reporter. |
org.mozilla.javascript.DeepErrorReporterHook |
setErrorReporterHook(org.mozilla.javascript.DeepErrorReporterHook hook)
Set the current error reporter hook (for debugging). |
org.mozilla.javascript.DeepExecuteHook |
setExecuteHook(org.mozilla.javascript.DeepExecuteHook hook)
Set the current execute hook (for debugging). |
void |
setGeneratingDebug(boolean generatingDebug)
Specify whether or not debug information should be generated. |
void |
setGeneratingSource(boolean generatingSource)
Specify whether or not source information should be generated. |
void |
setLanguageVersion(int version)
Set the language version. |
java.util.Locale |
setLocale(java.util.Locale loc)
Set the current locale. |
org.mozilla.javascript.DeepNewObjectHook |
setNewObjectHook(org.mozilla.javascript.DeepNewObjectHook hook)
Set the current new object hook (for debugging). |
void |
setOptimizationLevel(int optimizationLevel)
Set the current optimization level. |
org.mozilla.javascript.DeepScriptHook |
setScriptHook(org.mozilla.javascript.DeepScriptHook hook)
Set the current script hook (for debugging). |
org.mozilla.javascript.SourceTextManager |
setSourceTextManager(org.mozilla.javascript.SourceTextManager debug_stm)
Set the current source text hook (for debugging). |
void |
setTargetClassFileName(java.lang.String classFileName)
Set the current target class file name. |
void |
setTargetExtends(java.lang.Class extendsClass)
Set the class that the generated target will extend. |
void |
setTargetImplements(java.lang.Class[] implementsClasses)
Set the interfaces that the generated target will implement. |
void |
setTargetPackage(java.lang.String targetPackage)
Set the package to generate classes into. |
boolean |
stringIsCompilableUnit(java.lang.String source)
Check whether a string is ready to be compiled. |
static boolean |
toBoolean(java.lang.Object value)
Convert the value to a JavaScript boolean value. |
static double |
toNumber(java.lang.Object value)
Convert the value to a JavaScript Number value. |
static Scriptable |
toObject(java.lang.Object value,
Scriptable scope)
Convert the value to an JavaScript object value. |
static Scriptable |
toObject(java.lang.Object value,
Scriptable scope,
java.lang.Class staticType)
Convert the value to an JavaScript object value. |
static java.lang.String |
toString(java.lang.Object value)
Convert the value to a JavaScript String value. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static java.lang.String languageVersionProperty
public static java.lang.String errorReporterProperty
public static final int VERSION_UNKNOWN
public static final int VERSION_DEFAULT
public static final int VERSION_1_0
public static final int VERSION_1_1
public static final int VERSION_1_2
public static final int VERSION_1_3
public static final int VERSION_1_4
public static final int VERSION_1_5
Constructor Detail |
public Context()
enter()
public Context(SecuritySupport securitySupport)
securitySupport
- an encapsulation of the functionality
needed to support security for scripts.SecuritySupport
Method Detail |
public static Context enter()
Calling enter()
will
return either the Context currently associated with the
thread, or will create a new context and associate it
with the current thread. Each call to enter()
must have a matching call to exit()
. For example,
Context cx = Context.enter(); ... cx.evaluateString(...); Context.exit();
getCurrentContext()
,
exit()
public static Context enter(Context cx)
The same as enter()
except that cx
is associated with the current thread and returned if
the current thread has no associated context and cx
is not associated with any other thread.
cx
- a Context to associate with the thread if possiblepublic static void exit()
exit()
will remove the association between
the current thread and a Context if the prior call to
enter()
on this thread newly associated a Context
with this thread.
Once the current thread no longer has an associated Context,
it cannot be used to execute JavaScript until it is again associated
with a Context.enter()
public static Context getCurrentContext()
enter()
,
exit()
public int getLanguageVersion()
The language version number affects JavaScript semantics as detailed in the overview documentation.
public void setLanguageVersion(int version)
Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior.
version
- the version as specified by VERSION_1_0, VERSION_1_1, etc.public java.lang.String getImplementationVersion()
The implementation version is of the form
"name langVer release
relNum date"
where name is the name of the product, langVer is
the language version, relNum is the release number, and
date is the release date for that specific
release in the form "yyyy mm dd".public ErrorReporter getErrorReporter()
ErrorReporter
public ErrorReporter setErrorReporter(ErrorReporter reporter)
ErrorReporter
public java.util.Locale getLocale()
Locale
public java.util.Locale setLocale(java.util.Locale loc)
Locale
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the listenerPropertyChangeEvent
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the listenerPropertyChangeEvent
,
addPropertyChangeListener(java.beans.PropertyChangeListener)
protected void firePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
property
- the bound propertyoldValue
- the old valuenewVale
- the new valueaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
,
PropertyChangeListener
,
PropertyChangeEvent
public static void reportWarning(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)
message
- the warning message to reportsourceName
- a string describing the source, such as a filenamelineno
- the starting line numberlineSource
- the text of the line (may be null)lineOffset
- the offset into lineSource where problem was detectedErrorReporter
public static void reportWarning(java.lang.String message)
message
- the warning message to reportErrorReporter
public static void reportError(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)
message
- the error message to reportsourceName
- a string describing the source, such as a filenamelineno
- the starting line numberlineSource
- the text of the line (may be null)lineOffset
- the offset into lineSource where problem was detectedErrorReporter
public static void reportError(java.lang.String message)
message
- the error message to reportErrorReporter
public static org.mozilla.javascript.EvaluatorException reportRuntimeError(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)
message
- the error message to reportsourceName
- a string describing the source, such as a filenamelineno
- the starting line numberlineSource
- the text of the line (may be null)lineOffset
- the offset into lineSource where problem was detectedErrorReporter
public static org.mozilla.javascript.EvaluatorException reportRuntimeError(java.lang.String message)
message
- the error message to reportErrorReporter
public Scriptable initStandardObjects(ScriptableObject scope)
This method must be called to initialize a scope before scripts can be evaluated in that scope.
scope
- the scope to initialize, or null, in which case a new
object will be created to serve as the scopepublic ScriptableObject initStandardObjects(ScriptableObject scope, boolean sealed)
This method must be called to initialize a scope before scripts can be evaluated in that scope.
This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added or removed. This is useful to create a "superglobal" that can be shared among several top-level objects. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.
scope
- the scope to initialize, or null, in which case a new
object will be created to serve as the scopesealed
- whether or not to create sealed standard objects that
cannot be modified.public static java.lang.Object getUndefinedValue()
public java.lang.Object evaluateString(Scriptable scope, java.lang.String source, java.lang.String sourceName, int lineno, java.lang.Object securityDomain) throws JavaScriptException
scope
- the scope to execute insource
- the JavaScript sourcesourceName
- a string describing the source, such as a filenamelineno
- the starting line numbersecurityDomain
- an arbitrary object that specifies security
information about the origin or owner of the script. For
implementations that don't care about security, this value
may be null.SecuritySupport
public java.lang.Object evaluateReader(Scriptable scope, java.io.Reader in, java.lang.String sourceName, int lineno, java.lang.Object securityDomain) throws java.io.IOException, JavaScriptException
scope
- the scope to execute inin
- the Reader to get JavaScript source fromsourceName
- a string describing the source, such as a filenamelineno
- the starting line numbersecurityDomain
- an arbitrary object that specifies security
information about the origin or owner of the script. For
implementations that don't care about security, this value
may be null.public boolean stringIsCompilableUnit(java.lang.String source)
stringIsCompilableUnit is intended to support interactive compilation of javascript. If compiling the string would result in an error that might be fixed by appending more source, this method returns false. In every other case, it returns true.
Interactive shells may accumulate source lines, using this method after each new line is appended to check whether the statement being entered is complete.
source
- the source buffer to checkpublic Script compileReader(Scriptable scope, java.io.Reader in, java.lang.String sourceName, int lineno, java.lang.Object securityDomain) throws java.io.IOException
Returns a script that may later be executed. Will consume all the source in the reader.
scope
- if nonnull, will be the scope in which the script object
is created. The script object will be a valid JavaScript object
as if it were created using the JavaScript1.3 Script constructorin
- the input readersourceName
- a string describing the source, such as a filenamelineno
- the starting line number for reporting errorssecurityDomain
- an arbitrary object that specifies security
information about the origin or owner of the script. For
implementations that don't care about security, this value
may be null.Script.exec(org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable)
public Function compileFunction(Scriptable scope, java.lang.String source, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)
The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").
scope
- the scope to compile relative tosource
- the function definition sourcesourceName
- a string describing the source, such as a filenamelineno
- the starting line numbersecurityDomain
- an arbitrary object that specifies security
information about the origin or owner of the script. For
implementations that don't care about security, this value
may be null.Function
public java.lang.String decompileScript(Script script, Scriptable scope, int indent)
The canonical source of the script is returned.
script
- the script to decompilescope
- the scope under which to decompileindent
- the number of spaces to indent the resultpublic java.lang.String decompileFunction(Function fun, int indent)
Decompiles a previously compiled JavaScript function object to canonical source.
Returns function body of '[native code]' if no decompilation information is available.
fun
- the JavaScript function to decompileindent
- the number of spaces to indent the resultpublic java.lang.String decompileFunctionBody(Function fun, int indent)
Decompiles the body a previously compiled JavaScript Function object to canonical source, omitting the function header and trailing brace. Returns '[native code]' if no decompilation information is available.
fun
- the JavaScript function to decompileindent
- the number of spaces to indent the resultpublic Scriptable newObject(Scriptable scope) throws PropertyException, NotAFunctionException, JavaScriptException
scope
- the scope to search for the constructor and to evaluate
againstpublic Scriptable newObject(Scriptable scope, java.lang.String constructorName) throws PropertyException, NotAFunctionException, JavaScriptException
newObject("Foo")
is equivalent to
evaluating "new Foo()".scope
- the scope to search for the constructor and to evaluate againstconstructorName
- the name of the constructor to callpublic Scriptable newObject(Scriptable scope, java.lang.String constructorName, java.lang.Object[] args) throws PropertyException, NotAFunctionException, JavaScriptException
scope
for the named constructor, calls it with
the given arguments, and returns the result.The code
Object[] args = { "a", "b" }; newObject(scope, "Foo", args)is equivalent to evaluating "new Foo('a', 'b')", assuming that the Foo constructor has been defined in
scope
.scope
- The scope to search for the constructor and to evaluate
againstconstructorName
- the name of the constructor to callargs
- the array of arguments for the constructorpublic Scriptable newArray(Scriptable scope, int length)
scope
- the scope to create the object inlength
- the initial length (JavaScript arrays may have
additional properties added dynamically).public Scriptable newArray(Scriptable scope, java.lang.Object[] elements)
scope
- the scope to create the object inelements
- the initial elements. Each object in this array
must be an acceptable JavaScript type.public java.lang.Object[] getElements(Scriptable object)
If the object defines a length property, a Java array with that length is created and initialized with the values obtained by calling get() on object for each value of i in [0,length-1]. If there is not a defined value for a property the Undefined value is used to initialize the corresponding element in the array. The Java array is then returned. If the object doesn't define a length property, null is returned.
object
- the JavaScript array or array-like objectpublic static boolean toBoolean(java.lang.Object value)
See ECMA 9.2.
value
- a JavaScript valuepublic static double toNumber(java.lang.Object value)
Returns a Java double for the JavaScript Number.
See ECMA 9.3.
value
- a JavaScript valuepublic static java.lang.String toString(java.lang.Object value)
See ECMA 9.8.
value
- a JavaScript valuepublic static Scriptable toObject(java.lang.Object value, Scriptable scope)
Note that a scope must be provided to look up the constructors for Number, Boolean, and String.
See ECMA 9.9.
Additionally, arbitrary Java objects and classes will be wrapped in a Scriptable object with its Java fields and methods reflected as JavaScript properties of the object.
value
- any Java objectscope
- global scope containing constructors for Number,
Boolean, and Stringpublic static Scriptable toObject(java.lang.Object value, Scriptable scope, java.lang.Class staticType)
Note that a scope must be provided to look up the constructors for Number, Boolean, and String.
See ECMA 9.9.
Additionally, arbitrary Java objects and classes will be wrapped in a Scriptable object with its Java fields and methods reflected as JavaScript properties of the object. If the "staticType" parameter is provided, it will be used as the static type of the Java value to create.
value
- any Java objectscope
- global scope containing constructors for Number,
Boolean, and StringstaticType
- the static type of the Java value to createpublic boolean isGeneratingDebug()
public void setGeneratingDebug(boolean generatingDebug)
Setting the generation of debug information on will set the optimization level to zero.
public boolean isGeneratingSource()
public void setGeneratingSource(boolean generatingSource)
Without source information, evaluating the "toString" method on JavaScript functions produces only "[native code]" for the body of the function. Note that code generated without source is not fully ECMA conformant.
public int getOptimizationLevel()
The optimization level is expressed as an integer between -1 and 9.
public void setOptimizationLevel(int optimizationLevel)
The optimization level is expected to be an integer between -1 and 9. Any negative values will be interpreted as -1, and any values greater than 9 will be interpreted as 9. An optimization level of -1 indicates that interpretive mode will always be used. Levels 0 through 9 indicate that class files may be generated. Higher optimization levels trade off compile time performance for runtime performance. The optimizer level can't be set greater than -1 if the optimizer package doesn't exist at run time.
optimizationLevel
- an integer indicating the level of
optimization to performpublic java.lang.String getTargetClassFileName()
If nonnull, requests to compile source will result in one or more class files being generated.
public void setTargetClassFileName(java.lang.String classFileName)
If nonnull, requests to compile source will result in one or more class files being generated. If null, classes will only be generated in memory.
public java.lang.String getTargetPackage()
public void setTargetPackage(java.lang.String targetPackage)
public static boolean isSecurityDomainRequired()
public java.lang.Object getInterpreterSecurityDomain()
public boolean isInterpreterClass(java.lang.Class cl)
cl
- a class to test whether or not it is an interpreter
classpublic void setTargetExtends(java.lang.Class extendsClass)
extendsClass
- the class it extendspublic void setTargetImplements(java.lang.Class[] implementsClasses)
implementsClasses
- an array of Class objects, one for each
interface the target will extendpublic java.lang.Object getThreadLocal(java.lang.Object key)
Since the Context is associated with a thread it can be used to maintain values that can be later retrieved using the current thread.
Note that the values are maintained with the Context, so if the Context is disassociated from the thread the values cannot be retreived. Also, if private data is to be maintained in this manner the key should be a java.lang.Object whose reference is not divulged to untrusted code.
key
- the key used to lookup the valuepublic void putThreadLocal(java.lang.Object key, java.lang.Object value)
key
- the key used to index the valuevalue
- the value to savepublic boolean hasCompileFunctionsWithDynamicScope()
If functions are compiled with dynamic scope, then they execute in the scope of their caller, rather than in their parent scope. This is useful for sharing functions across multiple scopes.
public void setCompileFunctionsWithDynamicScope(boolean flag)
flag
- if true, compile functions with dynamic scopepublic static void setCachingEnabled(boolean cachingEnabled)
By default, the engine will cache some values statically (reflected Java classes, for instance). This can speed execution dramatically, but increases the memory footprint. Also, with caching enabled, references may be held to objects past the lifetime of any real usage.
If caching is enabled and this method is called with a
false
argument, the caches will be emptied.
So one strategy could be to clear the caches at times
appropriate to the application.
Caching is enabled by default.
cachingEnabled
- if true, caching is enabledpublic org.mozilla.javascript.SourceTextManager getSourceTextManager()
CURRRENTLY UNSUPPORTED.
SourceTextManager
,
setSourceTextManager(org.mozilla.javascript.SourceTextManager)
public org.mozilla.javascript.SourceTextManager setSourceTextManager(org.mozilla.javascript.SourceTextManager debug_stm)
CURRRENTLY UNSUPPORTED.
When using the org.mozilla.javascript.debug system to debug within the context of a particular embedding if the Context has this hook set then all parsed JavaScript source will be passed to the hook. In some embeddings of JavaScript it may be better to not use this low level hook and instead have the embedding itself feed the source text to the SourceTextManager.
debug_stm
- new hookSourceTextManager
public org.mozilla.javascript.DeepScriptHook getScriptHook()
CURRRENTLY UNSUPPORTED.
DeepScriptHook
,
setScriptHook(org.mozilla.javascript.DeepScriptHook)
public org.mozilla.javascript.DeepScriptHook setScriptHook(org.mozilla.javascript.DeepScriptHook hook)
CURRRENTLY UNSUPPORTED.
At debugLevel >= 3 the script hook is called when compiled scripts (and functions) are loaded and unloaded.
hook
- new hookDeepScriptHook
public org.mozilla.javascript.DeepCallHook getCallHook()
CURRRENTLY UNSUPPORTED.
DeepCallHook
,
setCallHook(org.mozilla.javascript.DeepCallHook)
public org.mozilla.javascript.DeepCallHook setCallHook(org.mozilla.javascript.DeepCallHook hook)
CURRRENTLY UNSUPPORTED.
At debugLevel >= 3 the call hook is called when compiled scripts and functions make function calls.
hook
- new hookDeepCallHook
public org.mozilla.javascript.DeepExecuteHook getExecuteHook()
CURRRENTLY UNSUPPORTED.
DeepExecuteHook
,
setExecuteHook(org.mozilla.javascript.DeepExecuteHook)
public org.mozilla.javascript.DeepExecuteHook setExecuteHook(org.mozilla.javascript.DeepExecuteHook hook)
At debugLevel >= 3 the execute hook is called when top level compiled scripts (non-functions) are executed.
hook
- new hookDeepExecuteHook
public org.mozilla.javascript.DeepNewObjectHook getNewObjectHook()
CURRRENTLY UNSUPPORTED.
DeepNewObjectHook
,
setNewObjectHook(org.mozilla.javascript.DeepNewObjectHook)
public org.mozilla.javascript.DeepNewObjectHook setNewObjectHook(org.mozilla.javascript.DeepNewObjectHook hook)
CURRRENTLY UNSUPPORTED.
At debugLevel >= 3 the new object hook is called when JavaScript objects are created by compiled scripts and functions; i.e. when constructor functions run.
hook
- new hookDeepNewObjectHook
public org.mozilla.javascript.DeepBytecodeHook getBytecodeHook()
CURRRENTLY UNSUPPORTED.
DeepBytecodeHook
,
setBytecodeHook(org.mozilla.javascript.DeepBytecodeHook)
public org.mozilla.javascript.DeepBytecodeHook setBytecodeHook(org.mozilla.javascript.DeepBytecodeHook hook)
CURRRENTLY UNSUPPORTED.
At debugLevel >= 6 generated scripts and functions support setting traps and interrupts on a per statement basis. If a trap or interrupt is encountered while running in this Context, then this hook is called to handle it.
hook
- new hookDeepBytecodeHook
public org.mozilla.javascript.DeepErrorReporterHook getErrorReporterHook()
CURRRENTLY UNSUPPORTED.
DeepErrorReporterHook
,
setErrorReporter(org.mozilla.javascript.ErrorReporter)
public org.mozilla.javascript.DeepErrorReporterHook setErrorReporterHook(org.mozilla.javascript.DeepErrorReporterHook hook)
CURRRENTLY UNSUPPORTED.
This hook allows a debugger to trap error reports before there are sent to the error reporter. This is not meant to be used in place of the normal error reporting system.
hook
- new hookDeepErrorReporterHook
,
ErrorReporter
,
setErrorReporter(org.mozilla.javascript.ErrorReporter)
public int getDebugLevel()
CURRRENTLY UNSUPPORTED.
setDebugLevel(int)
public int setDebugLevel(int debugLevel)
CURRRENTLY UNSUPPORTED.
Set the debug level. Note that a non-zero debug level will force the optimization level to 0.
Currently supported debug levels:
debugLevel == 0 - all debug support off (except error reporter hooks) debugLevel >= 1 - name of source file stored in NativeFunction debugLevel >= 3 - load/unload hooks called - base/end lineno info stored in NativeFunction - call, new object, and execute hooks called debugLevel >= 6 - interrupts and traps supported
debugLevel
- new debugLevel
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |