C# 클래스 Rhino.Context

This class represents the runtime context of an executing script.
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 Call(ContextAction) or Enter() methods.

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.

파일 보기 프로젝트 열기: hazzik/Rhino.Net 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
emptyArgs object[]
generateObserverCount bool

공개 메소드들

메소드 설명
AddActivationName ( string name ) : void

Add a name to the list of names forcing the creation of real activation objects for functions.

Add a name to the list of names forcing the creation of real activation objects for functions.

AddPropertyChangeListener ( PropertyChangeListener l ) : void

Register an object to receive notifications when a bound property has changed

Call ( ContextFactory factory, Callable callable, Scriptable scope, Scriptable thisObj, object args ) : object

Call Callable.Call(Context, Scriptable, Scriptable, object[]) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.MakeContext() will be called to construct new Context instance. The instance will be temporary associated with the thread during call to ContextAction.Run(Context) .

It is allowed but not advisable to use null for factory argument in which case the global static singleton ContextFactory instance will be used to create new context instances.

CallFunctionWithContinuations ( Callable function, Scriptable scope, object args ) : object

Call function that may pause execution by capturing a continuation.

Call function that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling ResumeContinuation(object, Scriptable, object) .

CaptureContinuation ( ) : ContinuationPending

Capture a continuation from the current execution.

Capture a continuation from the current execution. The execution must have been started via a call to ExecuteScriptWithContinuations(Script, Scriptable) or CallFunctionWithContinuations(Callable, Scriptable, object[]) . This implies that the code calling this method must have been called as a function from the JavaScript script. Also, there cannot be any non-JavaScript code between the JavaScript frames (e.g., a call to eval()). The ContinuationPending exception returned must be thrown.

CheckLanguageVersion ( int version ) : void
CheckOptimizationLevel ( int optimizationLevel ) : void
CompileFunction ( Scriptable scope, string source, string sourceName, int lineno, object securityDomain ) : System.Function

Compile a JavaScript function.

Compile a JavaScript function.

The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").

CompileReader ( TextReader @in, string sourceName, int lineno, object securityDomain ) : System.Script

Compiles the source in the given reader.

Compiles the source in the given reader.

Returns a script that may later be executed. Will consume all the source in the reader.

CompileString ( string source, string sourceName, int lineno, object securityDomain ) : System.Script

Compiles the source in the given string.

Compiles the source in the given string.

Returns a script that may later be executed.

CreateClassLoader ( ClassLoader parent ) : GeneratedClassLoader

Create class loader for generated classes.

Create class loader for generated classes. The method calls ContextFactory.CreateClassLoader(Sharpen.ClassLoader) using the result of GetFactory() .

DecompileFunction ( System.Function fun, int indent ) : string

Decompile a JavaScript Function.

Decompile a JavaScript Function.

Decompiles a previously compiled JavaScript function object to canonical source.

Returns function body of '[native code]' if no decompilation information is available.

DecompileFunctionBody ( System.Function fun, int indent ) : string

Decompile the body of a JavaScript Function.

Decompile the body of a JavaScript Function.

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.

DecompileScript ( System.Script script, int indent ) : string

Decompile the script.

Decompile the script.

The canonical source of the script is returned.

Enter ( ) : Context

Same as calling ContextFactory.EnterContext() on the global ContextFactory instance.

EvaluateReader ( Scriptable scope, TextReader @in, string sourceName, int lineno, object securityDomain ) : object

Evaluate a reader as JavaScript source.

Evaluate a reader as JavaScript source. All characters of the reader are consumed.

EvaluateString ( Scriptable scope, string source, string sourceName, int lineno, object securityDomain ) : object

Evaluate a JavaScript source string.

Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information.

ExecuteScriptWithContinuations ( System.Script script, Scriptable scope ) : object

Execute script that may pause execution by capturing a continuation.

Execute script that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling ResumeContinuation(object, Scriptable, object) .

Exit ( ) : void

Exit a block of code requiring a Context.

Exit a block of code requiring a Context. Calling exit() will remove the association between the current thread and a Context if the prior call to ContextFactory.EnterContext() 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.

GetApplicationClassLoader ( ) : ClassLoader
GetClassShutterSetter ( ) : Context.ClassShutterSetter
GetCurrentContext ( ) : Context

Get the current Context.

Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.

GetDebuggableView ( System.Script script ) : DebuggableScript

Return DebuggableScript instance if any associated with the script.

Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it. Otherwise null is returned.

GetDebugger ( ) : Debugger

Return the current debugger.

Return the current debugger.

GetDebuggerContextData ( ) : object

Return the debugger context data associated with current context.

Return the debugger context data associated with current context.

GetE4xImplementationFactory ( ) : XMLLib.Factory

Returns an object which specifies an E4X implementation to use within this Context.

Returns an object which specifies an E4X implementation to use within this Context. Note that the XMLLib.Factory interface should be considered experimental. The default implementation uses the implementation provided by this Context's ContextFactory .

GetElements ( Scriptable @object ) : object[]

Get the elements of a JavaScript array.

Get the elements of a JavaScript array.

If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is 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 or it is not a number, empty array is returned.

GetErrorReporter ( ) : ErrorReporter

Get the current error reporter.

Get the current error reporter.

GetFactory ( ) : ContextFactory

Return ContextFactory instance used to create this Context.

GetImplementationVersion ( ) : string

Get the implementation version.

Get the implementation version.

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".
GetInstructionObserverThreshold ( ) : int

Get threshold of executed instructions counter that triggers call to observeInstructionCount().

Get threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.

GetLanguageVersion ( ) : int

Get the current language version.

Get the current language version.

The language version number affects JavaScript semantics as detailed in the overview documentation.

GetLocale ( ) : CultureInfo

Get the current locale.

Get the current locale. Returns the default locale if none has been set.

GetMaximumInterpreterStackDepth ( ) : int

Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.

Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.

GetOptimizationLevel ( ) : int

Get the current optimization level.

Get the current optimization level.

The optimization level is expressed as an integer between -1 and 9.

GetThreadLocal ( object key ) : object

Get a value corresponding to a key.

Get a value corresponding to a 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 retrieved. 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.

GetUndefinedValue ( ) : object

Get the singleton object that represents the JavaScript Undefined value.

Get the singleton object that represents the JavaScript Undefined value.

GetWrapFactory ( ) : WrapFactory

Return the current WrapFactory, or null if none is defined.

Return the current WrapFactory, or null if none is defined.

HasFeature ( int featureIndex ) : bool

Controls certain aspects of script semantics.

Controls certain aspects of script semantics. Should be overwritten to alter default behavior.

The default implementation calls ContextFactory.HasFeature(Context, int) that allows to customize Context behavior without introducing Context subclasses. ContextFactory documentation gives an example of hasFeature implementation.

InitStandardObjects ( ScriptableObject scope ) : Scriptable

Initialize the standard objects.

Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

InitStandardObjects ( ) : ScriptableObject

Initialize the standard objects.

Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

InitStandardObjects ( ScriptableObject scope, bool @sealed ) : ScriptableObject

Initialize the standard objects.

Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added, changed, 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.

IsActivationNeeded ( string name ) : bool

Check whether the name is in the list of names of objects forcing the creation of activation objects.

Check whether the name is in the list of names of objects forcing the creation of activation objects.

IsGeneratingDebug ( ) : bool

Tell whether debug information is being generated.

Tell whether debug information is being generated.

IsGeneratingDebugChanged ( ) : bool
IsGeneratingSource ( ) : bool

Tell whether source information is being generated.

Tell whether source information is being generated.

IsSealed ( ) : bool

Checks if this is a sealed Context.

Checks if this is a sealed Context. A sealed Context instance does not allow to modify any of its properties and will throw an exception on any such attempt.

IsValidLanguageVersion ( int version ) : bool
IsValidOptimizationLevel ( int optimizationLevel ) : bool
JavaToJS ( object value, Scriptable scope ) : object

Convenient method to convert java value to its closest representation in JavaScript.

Convenient method to convert java value to its closest representation in JavaScript.

If value is an instance of String, Number, Boolean, Function or Scriptable, it is returned as it and will be treated as the corresponding JavaScript type of string, number, boolean, function and object.

Note that for Number instances during any arithmetic operation in JavaScript the engine will always use the result of Number.doubleValue() resulting in a precision loss if the number can not fit into double.

If value is an instance of Character, it will be converted to string of length 1 and its JavaScript type will be string.

The rest of values will be wrapped as LiveConnect objects by calling WrapFactory.Wrap(Context, Scriptable, object, System.Type<T>) as in:

 Context cx = Context.getCurrentContext(); return cx.getWrapFactory().wrap(cx, scope, value, null); 
JsToJava ( object value, Type desiredType ) : object

Convert a JavaScript value into the desired type.

Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed.

NewArray ( Scriptable scope, int length ) : Scriptable

Create an array with a specified initial length.

Create an array with a specified initial length.

NewArray ( Scriptable scope, object elements ) : Scriptable

Create an array with a set of initial elements.

Create an array with a set of initial elements.

NewObject ( Scriptable scope ) : Scriptable

Create a new JavaScript object.

Create a new JavaScript object. Equivalent to evaluating "new Object()".

NewObject ( Scriptable scope, string constructorName ) : Scriptable

Create a new JavaScript object by executing the named constructor.

Create a new JavaScript object by executing the named constructor. The call newObject(scope, "Foo") is equivalent to evaluating "new Foo()".

NewObject ( Scriptable scope, string constructorName, object args ) : Scriptable

Creates a new JavaScript object by executing the named constructor.

Creates a new JavaScript object by executing the named constructor. Searches 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.
PutThreadLocal ( object key, object value ) : void

Put a value that can later be retrieved using a given key.

Put a value that can later be retrieved using a given key.

RemoveActivationName ( string name ) : void

Remove a name from the list of names forcing the creation of real activation objects for functions.

Remove a name from the list of names forcing the creation of real activation objects for functions.

RemovePropertyChangeListener ( PropertyChangeListener l ) : void

Remove an object from the list of objects registered to receive notification of changes to a bounded property

RemoveThreadLocal ( object key ) : void

Remove values from thread-local storage.

Remove values from thread-local storage.

ReportError ( string message ) : void

Report an error using the error reporter for the current thread.

Report an error using the error reporter for the current thread.

ReportError ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : void

Report an error using the error reporter for the current thread.

Report an error using the error reporter for the current thread.

ReportRuntimeError ( string message ) : EvaluatorException

Report a runtime error using the error reporter for the current thread.

Report a runtime error using the error reporter for the current thread.

ReportRuntimeError ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : EvaluatorException

Report a runtime error using the error reporter for the current thread.

Report a runtime error using the error reporter for the current thread.

ReportWarning ( string message ) : void

Report a warning using the error reporter for the current thread.

Report a warning using the error reporter for the current thread.

ReportWarning ( string message, Exception t ) : void
ReportWarning ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : void

Report a warning using the error reporter for the current thread.

Report a warning using the error reporter for the current thread.

ResumeContinuation ( object continuation, Scriptable scope, object functionResult ) : object

Restarts execution of the JavaScript suspended at the call to CaptureContinuation() . Execution of the code will resume with the functionResult as the result of the call that captured the continuation. Execution of the script will either conclude normally and the result returned, another continuation will be captured and thrown, or the script will terminate abnormally and throw an exception.

Seal ( object sealKey ) : void

Seal this Context object so any attempt to modify any of its properties including calling Enter() and Exit() methods will throw an exception.

If sealKey is not null, calling Unseal(object) with the same key unseals the object. If sealKey is null, unsealing is no longer possible.

SetApplicationClassLoader ( ClassLoader loader ) : void
SetClassShutter ( ClassShutter shutter ) : void

Set the LiveConnect access filter for this context.

Set the LiveConnect access filter for this context.

ClassShutter may only be set if it is currently null. Otherwise a SecurityException is thrown.

SetDebugger ( Debugger debugger, object contextData ) : void

Set the associated debugger.

Set the associated debugger.

SetErrorReporter ( ErrorReporter reporter ) : ErrorReporter

Change the current error reporter.

Change the current error reporter.

SetGenerateObserverCount ( bool generateObserverCount ) : void

Turn on or off generation of code with callbacks to track the count of executed instructions.

Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.

SetGeneratingDebug ( bool generatingDebug ) : void

Specify whether or not debug information should be generated.

Specify whether or not debug information should be generated.

Setting the generation of debug information on will set the optimization level to zero.

SetGeneratingSource ( bool generatingSource ) : void

Specify whether or not source information should be generated.

Specify whether or not source information should be generated.

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.

SetInstructionObserverThreshold ( int threshold ) : void

Set threshold of executed instructions counter that triggers call to observeInstructionCount().

Set threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.

Note that the meaning of "instruction" is not guaranteed to be consistent between compiled and interpretive modes: executing a given script or function in the different modes will result in different instruction counts against the threshold. SetGenerateObserverCount(bool) is called with true if threshold is greater than zero, false otherwise.

SetLanguageVersion ( int version ) : void

Set the language version.

Set the language version.

Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior.

SetLocale ( CultureInfo loc ) : CultureInfo

Set the current locale.

Set the current locale.

SetMaximumInterpreterStackDepth ( int max ) : void

Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.

Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.

SetOptimizationLevel ( int optimizationLevel ) : void

Set the current optimization level.

Set the current optimization level.

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.

SetSecurityController ( SecurityController controller ) : void

Set the security controller for this context.

Set the security controller for this context.

SecurityController may only be set if it is currently null and SecurityController.HasGlobal() is false. Otherwise a SecurityException is thrown.

SetWrapFactory ( WrapFactory wrapFactory ) : void

Set a WrapFactory for this Context.

Set a WrapFactory for this Context.

The WrapFactory allows custom object wrapping behavior for Java object manipulated with JavaScript.

StringIsCompilableUnit ( string source ) : bool

Check whether a string is ready to be compiled.

Check whether a string is ready to be compiled.

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.

ThrowAsScriptRuntimeEx ( Exception e ) : Exception

Rethrow the exception wrapping it as the script runtime exception.

Rethrow the exception wrapping it as the script runtime exception. Unless the exception is instance of EcmaError or EvaluatorException it will be wrapped as WrappedException , a subclass of EvaluatorException . The resulting exception object always contains source name and line number of script that triggered exception.

This method always throws an exception, its return value is provided only for convenience to allow a usage like:

 throw Context.throwAsScriptRuntimeEx(ex); 
to indicate that code after the method is unreachable.
ToBoolean ( object value ) : bool

Convert the value to a JavaScript boolean value.

Convert the value to a JavaScript boolean value.

See ECMA 9.2.

ToNumber ( object value ) : double

Convert the value to a JavaScript Number value.

Convert the value to a JavaScript Number value.

Returns a Java double for the JavaScript Number.

See ECMA 9.3.

ToObject ( object value, Scriptable scope ) : Scriptable

Convert the value to an JavaScript object value.

Convert the value to an JavaScript object value.

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.

ToString ( object value ) : string

Convert the value to a JavaScript String value.

Convert the value to a JavaScript String value.

See ECMA 9.8.

Unseal ( object sealKey ) : void

Unseal previously sealed Context object.

Unseal previously sealed Context object. The sealKey argument should not be null and should match sealKey suplied with the last call to Seal(object) or an exception will be thrown.

보호된 메소드들

메소드 설명
Context ( ContextFactory factory ) : System

Creates a new context.

Creates a new context. Provided as a preferred super constructor for subclasses in place of the deprecated default public constructor.

ObserveInstructionCount ( int instructionCount ) : void

Allow application to monitor counter of executed script instructions in Context subclasses.

Allow application to monitor counter of executed script instructions in Context subclasses. Run-time calls this when instruction counting is enabled and the counter reaches limit set by setInstructionObserverThreshold(). The method is useful to observe long running scripts and if necessary to terminate them.

The default implementation calls ContextFactory.ObserveInstructionCount(Context, int) that allows to customize Context behavior without introducing Context subclasses.

비공개 메소드들

메소드 설명
AddContextListener ( ContextListener listener ) : void
Call ( ContextAction action ) : object
Call ( ContextFactory factory, ContextAction action ) : object

The method implements ContextFactory.Call(ContextAction) logic.

CompileFunction ( Scriptable scope, string source, Evaluator compiler, ErrorReporter compilationErrorReporter, string sourceName, int lineno, object securityDomain ) : System.Function
CompileImpl ( Scriptable scope, TextReader sourceReader, string sourceString, string sourceName, int lineno, object securityDomain, bool returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter ) : object
CompileReader ( Scriptable scope, TextReader @in, string sourceName, int lineno, object securityDomain ) : System.Script
CompileString ( string source, Evaluator compiler, ErrorReporter compilationErrorReporter, string sourceName, int lineno, object securityDomain ) : System.Script
Context ( ) : System
CreateCompiler ( ) : Evaluator
CreateInterpreter ( ) : Evaluator
Enter ( Rhino cx ) : Context
Enter ( Rhino cx, ContextFactory factory ) : Context
FirePropertyChange ( string property, object oldValue, object newValue ) : void

Notify any registered listeners that a bounded property has changed

FirePropertyChangeImpl ( object listeners, string property, object oldValue, object newValue ) : void
GetClassShutter ( ) : ClassShutter
GetContext ( ) : Context

Internal method that reports an error for missing calls to enter().

Internal method that reports an error for missing calls to enter().

GetRegExpProxy ( ) : RegExpProxy
GetSecurityController ( ) : SecurityController
GetSourcePositionFromStack ( int linep ) : string
IsVersionECMA1 ( ) : bool
NotifyDebugger_r ( Context cx, DebuggableScript dscript, string debugSource ) : void
OnSealedMutation ( ) : void
RemoveContextListener ( ContextListener listener ) : void
ReportRuntimeError0 ( string messageId ) : EvaluatorException
ReportRuntimeError1 ( string messageId, object arg1 ) : EvaluatorException
ReportRuntimeError2 ( string messageId, object arg1, object arg2 ) : EvaluatorException
ReportRuntimeError3 ( string messageId, object arg1, object arg2, object arg3 ) : EvaluatorException
ReportRuntimeError4 ( string messageId, object arg1, object arg2, object arg3, object arg4 ) : EvaluatorException
SetCachingEnabled ( bool cachingEnabled ) : void
ToObject ( object value, Scriptable scope, Type staticType ) : Scriptable
ToType ( object value, Type desiredType ) : object

메소드 상세

AddActivationName() 공개 메소드

Add a name to the list of names forcing the creation of real activation objects for functions.
Add a name to the list of names forcing the creation of real activation objects for functions.
public AddActivationName ( string name ) : void
name string the name of the object to add to the list
리턴 void

AddPropertyChangeListener() 공개 메소드

Register an object to receive notifications when a bound property has changed
public AddPropertyChangeListener ( PropertyChangeListener l ) : void
l PropertyChangeListener the listener
리턴 void

Call() 공개 정적인 메소드

Call Callable.Call(Context, Scriptable, Scriptable, object[]) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.MakeContext() will be called to construct new Context instance. The instance will be temporary associated with the thread during call to ContextAction.Run(Context) .

It is allowed but not advisable to use null for factory argument in which case the global static singleton ContextFactory instance will be used to create new context instances.

public static Call ( ContextFactory factory, Callable callable, Scriptable scope, Scriptable thisObj, object args ) : object
factory ContextFactory
callable Callable
scope Scriptable
thisObj Scriptable
args object
리턴 object

CallFunctionWithContinuations() 공개 메소드

Call function that may pause execution by capturing a continuation.
Call function that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling ResumeContinuation(object, Scriptable, object) .
/// if the script calls a function that results /// in a call to /// CaptureContinuation() ///
public CallFunctionWithContinuations ( Callable function, Scriptable scope, object args ) : object
function Callable /// The function to call. The function must have been /// compiled with interpreted mode (optimization level -1) ///
scope Scriptable The scope to execute the script against
args object The arguments for the function
리턴 object

CaptureContinuation() 공개 메소드

Capture a continuation from the current execution.
Capture a continuation from the current execution. The execution must have been started via a call to ExecuteScriptWithContinuations(Script, Scriptable) or CallFunctionWithContinuations(Callable, Scriptable, object[]) . This implies that the code calling this method must have been called as a function from the JavaScript script. Also, there cannot be any non-JavaScript code between the JavaScript frames (e.g., a call to eval()). The ContinuationPending exception returned must be thrown.
public CaptureContinuation ( ) : ContinuationPending
리턴 ContinuationPending

CheckLanguageVersion() 공개 정적인 메소드

public static CheckLanguageVersion ( int version ) : void
version int
리턴 void

CheckOptimizationLevel() 공개 정적인 메소드

public static CheckOptimizationLevel ( int optimizationLevel ) : void
optimizationLevel int
리턴 void

CompileFunction() 공개 메소드

Compile a JavaScript function.
Compile a JavaScript function.

The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").

public CompileFunction ( Scriptable scope, string source, string sourceName, int lineno, object securityDomain ) : System.Function
scope Scriptable the scope to compile relative to
source string the function definition source
sourceName string a string describing the source, such as a filename
lineno int the starting line number
securityDomain object /// 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. ///
리턴 System.Function

CompileReader() 공개 메소드

Compiles the source in the given reader.
Compiles the source in the given reader.

Returns a script that may later be executed. Will consume all the source in the reader.

/// IOException /// if an IOException was generated by the Reader ///
public CompileReader ( TextReader @in, string sourceName, int lineno, object securityDomain ) : System.Script
@in System.IO.TextReader
sourceName string a string describing the source, such as a filename
lineno int the starting line number for reporting errors
securityDomain object /// 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. ///
리턴 System.Script

CompileString() 공개 메소드

Compiles the source in the given string.
Compiles the source in the given string.

Returns a script that may later be executed.

public CompileString ( string source, string sourceName, int lineno, object securityDomain ) : System.Script
source string the source string
sourceName string a string describing the source, such as a filename
lineno int /// the starting line number for reporting errors. Use /// 0 if the line number is unknown. ///
securityDomain object /// 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. ///
리턴 System.Script

Context() 보호된 메소드

Creates a new context.
Creates a new context. Provided as a preferred super constructor for subclasses in place of the deprecated default public constructor.
if factory parameter is null.
protected Context ( ContextFactory factory ) : System
factory ContextFactory /// the context factory associated with this context (most /// likely, the one that created the context). Can not be null. The context /// features are inherited from the factory, and the context will also /// otherwise use its factory's services. ///
리턴 System

CreateClassLoader() 공개 메소드

Create class loader for generated classes.
Create class loader for generated classes. The method calls ContextFactory.CreateClassLoader(Sharpen.ClassLoader) using the result of GetFactory() .
public CreateClassLoader ( ClassLoader parent ) : GeneratedClassLoader
parent ClassLoader
리턴 GeneratedClassLoader

DecompileFunction() 공개 메소드

Decompile a JavaScript Function.
Decompile a JavaScript Function.

Decompiles a previously compiled JavaScript function object to canonical source.

Returns function body of '[native code]' if no decompilation information is available.

public DecompileFunction ( System.Function fun, int indent ) : string
fun System.Function the JavaScript function to decompile
indent int the number of spaces to indent the result
리턴 string

DecompileFunctionBody() 공개 메소드

Decompile the body of a JavaScript Function.
Decompile the body of a JavaScript Function.

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.

public DecompileFunctionBody ( System.Function fun, int indent ) : string
fun System.Function the JavaScript function to decompile
indent int the number of spaces to indent the result
리턴 string

DecompileScript() 공개 메소드

Decompile the script.
Decompile the script.

The canonical source of the script is returned.

public DecompileScript ( System.Script script, int indent ) : string
script System.Script the script to decompile
indent int the number of spaces to indent the result
리턴 string

Enter() 공개 정적인 메소드

Same as calling ContextFactory.EnterContext() on the global ContextFactory instance.
public static Enter ( ) : Context
리턴 Context

EvaluateReader() 공개 메소드

Evaluate a reader as JavaScript source.
Evaluate a reader as JavaScript source. All characters of the reader are consumed.
/// IOException /// if an IOException was generated by the Reader ///
public EvaluateReader ( Scriptable scope, TextReader @in, string sourceName, int lineno, object securityDomain ) : object
scope Scriptable the scope to execute in
@in System.IO.TextReader
sourceName string a string describing the source, such as a filename
lineno int the starting line number
securityDomain object /// 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. ///
리턴 object

EvaluateString() 공개 메소드

Evaluate a JavaScript source string.
Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information.
public EvaluateString ( Scriptable scope, string source, string sourceName, int lineno, object securityDomain ) : object
scope Scriptable the scope to execute in
source string the JavaScript source
sourceName string a string describing the source, such as a filename
lineno int the starting line number
securityDomain object /// 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. ///
리턴 object

ExecuteScriptWithContinuations() 공개 메소드

Execute script that may pause execution by capturing a continuation.
Execute script that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling ResumeContinuation(object, Scriptable, object) .
/// if the script calls a function that results /// in a call to /// CaptureContinuation() ///
public ExecuteScriptWithContinuations ( System.Script script, Scriptable scope ) : object
script System.Script /// The script to execute. Script must have been compiled /// with interpreted mode (optimization level -1) ///
scope Scriptable The scope to execute the script against
리턴 object

Exit() 공개 정적인 메소드

Exit a block of code requiring a Context.
Exit a block of code requiring a Context. Calling exit() will remove the association between the current thread and a Context if the prior call to ContextFactory.EnterContext() 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.
public static Exit ( ) : void
리턴 void

GetApplicationClassLoader() 공개 메소드

public GetApplicationClassLoader ( ) : ClassLoader
리턴 ClassLoader

GetClassShutterSetter() 공개 메소드

public GetClassShutterSetter ( ) : Context.ClassShutterSetter
리턴 Context.ClassShutterSetter

GetCurrentContext() 공개 정적인 메소드

Get the current Context.
Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.

public static GetCurrentContext ( ) : Context
리턴 Context

GetDebuggableView() 공개 정적인 메소드

Return DebuggableScript instance if any associated with the script.
Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it. Otherwise null is returned.
public static GetDebuggableView ( System.Script script ) : DebuggableScript
script System.Script
리턴 DebuggableScript

GetDebugger() 공개 메소드

Return the current debugger.
Return the current debugger.
public GetDebugger ( ) : Debugger
리턴 Debugger

GetDebuggerContextData() 공개 메소드

Return the debugger context data associated with current context.
Return the debugger context data associated with current context.
public GetDebuggerContextData ( ) : object
리턴 object

GetE4xImplementationFactory() 공개 메소드

Returns an object which specifies an E4X implementation to use within this Context.
Returns an object which specifies an E4X implementation to use within this Context. Note that the XMLLib.Factory interface should be considered experimental. The default implementation uses the implementation provided by this Context's ContextFactory .
public GetE4xImplementationFactory ( ) : XMLLib.Factory
리턴 Rhino.Xml.XMLLib.Factory

GetElements() 공개 메소드

Get the elements of a JavaScript array.
Get the elements of a JavaScript array.

If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is 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 or it is not a number, empty array is returned.

public GetElements ( Scriptable @object ) : object[]
@object Scriptable
리턴 object[]

GetErrorReporter() 공개 메소드

Get the current error reporter.
Get the current error reporter.
public GetErrorReporter ( ) : ErrorReporter
리턴 ErrorReporter

GetFactory() 공개 메소드

Return ContextFactory instance used to create this Context.
public GetFactory ( ) : ContextFactory
리턴 ContextFactory

GetImplementationVersion() 공개 메소드

Get the implementation version.
Get the implementation version.

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 GetImplementationVersion ( ) : string
리턴 string

GetInstructionObserverThreshold() 공개 메소드

Get threshold of executed instructions counter that triggers call to observeInstructionCount().
Get threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.
public GetInstructionObserverThreshold ( ) : int
리턴 int

GetLanguageVersion() 공개 메소드

Get the current language version.
Get the current language version.

The language version number affects JavaScript semantics as detailed in the overview documentation.

public GetLanguageVersion ( ) : int
리턴 int

GetLocale() 공개 메소드

Get the current locale.
Get the current locale. Returns the default locale if none has been set.
public GetLocale ( ) : CultureInfo
리턴 System.Globalization.CultureInfo

GetMaximumInterpreterStackDepth() 공개 메소드

Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
public GetMaximumInterpreterStackDepth ( ) : int
리턴 int

GetOptimizationLevel() 공개 메소드

Get the current optimization level.
Get the current optimization level.

The optimization level is expressed as an integer between -1 and 9.

public GetOptimizationLevel ( ) : int
리턴 int

GetThreadLocal() 공개 메소드

Get a value corresponding to a key.
Get a value corresponding to a 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 retrieved. 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.

public GetThreadLocal ( object key ) : object
key object the key used to lookup the value
리턴 object

GetUndefinedValue() 공개 정적인 메소드

Get the singleton object that represents the JavaScript Undefined value.
Get the singleton object that represents the JavaScript Undefined value.
public static GetUndefinedValue ( ) : object
리턴 object

GetWrapFactory() 공개 메소드

Return the current WrapFactory, or null if none is defined.
Return the current WrapFactory, or null if none is defined.
public GetWrapFactory ( ) : WrapFactory
리턴 WrapFactory

HasFeature() 공개 메소드

Controls certain aspects of script semantics.
Controls certain aspects of script semantics. Should be overwritten to alter default behavior.

The default implementation calls ContextFactory.HasFeature(Context, int) that allows to customize Context behavior without introducing Context subclasses. ContextFactory documentation gives an example of hasFeature implementation.

public HasFeature ( int featureIndex ) : bool
featureIndex int feature index to check
리턴 bool

InitStandardObjects() 공개 메소드

Initialize the standard objects.
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

public InitStandardObjects ( ScriptableObject scope ) : Scriptable
scope ScriptableObject /// the scope to initialize, or null, in which case a new /// object will be created to serve as the scope ///
리턴 Scriptable

InitStandardObjects() 공개 메소드

Initialize the standard objects.
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

public InitStandardObjects ( ) : ScriptableObject
리턴 ScriptableObject

InitStandardObjects() 공개 메소드

Initialize the standard objects.
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added, changed, 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.

public InitStandardObjects ( ScriptableObject scope, bool @sealed ) : ScriptableObject
scope ScriptableObject /// the scope to initialize, or null, in which case a new /// object will be created to serve as the scope ///
@sealed bool
리턴 ScriptableObject

IsActivationNeeded() 공개 메소드

Check whether the name is in the list of names of objects forcing the creation of activation objects.
Check whether the name is in the list of names of objects forcing the creation of activation objects.
public IsActivationNeeded ( string name ) : bool
name string the name of the object to test
리턴 bool

IsGeneratingDebug() 공개 메소드

Tell whether debug information is being generated.
Tell whether debug information is being generated.
public IsGeneratingDebug ( ) : bool
리턴 bool

IsGeneratingDebugChanged() 공개 메소드

public IsGeneratingDebugChanged ( ) : bool
리턴 bool

IsGeneratingSource() 공개 메소드

Tell whether source information is being generated.
Tell whether source information is being generated.
public IsGeneratingSource ( ) : bool
리턴 bool

IsSealed() 공개 메소드

Checks if this is a sealed Context.
Checks if this is a sealed Context. A sealed Context instance does not allow to modify any of its properties and will throw an exception on any such attempt.
public IsSealed ( ) : bool
리턴 bool

IsValidLanguageVersion() 공개 정적인 메소드

public static IsValidLanguageVersion ( int version ) : bool
version int
리턴 bool

IsValidOptimizationLevel() 공개 정적인 메소드

public static IsValidOptimizationLevel ( int optimizationLevel ) : bool
optimizationLevel int
리턴 bool

JavaToJS() 공개 정적인 메소드

Convenient method to convert java value to its closest representation in JavaScript.
Convenient method to convert java value to its closest representation in JavaScript.

If value is an instance of String, Number, Boolean, Function or Scriptable, it is returned as it and will be treated as the corresponding JavaScript type of string, number, boolean, function and object.

Note that for Number instances during any arithmetic operation in JavaScript the engine will always use the result of Number.doubleValue() resulting in a precision loss if the number can not fit into double.

If value is an instance of Character, it will be converted to string of length 1 and its JavaScript type will be string.

The rest of values will be wrapped as LiveConnect objects by calling WrapFactory.Wrap(Context, Scriptable, object, System.Type<T>) as in:

 Context cx = Context.getCurrentContext(); return cx.getWrapFactory().wrap(cx, scope, value, null); 
public static JavaToJS ( object value, Scriptable scope ) : object
value object any Java object
scope Scriptable top scope object
리턴 object

JsToJava() 공개 정적인 메소드

Convert a JavaScript value into the desired type.
Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed.
if the conversion cannot be performed
public static JsToJava ( object value, Type desiredType ) : object
value object the JavaScript value to convert
desiredType System.Type /// the Java type to convert to. Primitive Java /// types are represented using the TYPE fields in the corresponding /// wrapper class in java.lang. ///
리턴 object

NewArray() 공개 메소드

Create an array with a specified initial length.
Create an array with a specified initial length.

public NewArray ( Scriptable scope, int length ) : Scriptable
scope Scriptable the scope to create the object in
length int /// the initial length (JavaScript arrays may have /// additional properties added dynamically). ///
리턴 Scriptable

NewArray() 공개 메소드

Create an array with a set of initial elements.
Create an array with a set of initial elements.
public NewArray ( Scriptable scope, object elements ) : Scriptable
scope Scriptable the scope to create the object in.
elements object /// the initial elements. Each object in this array /// must be an acceptable JavaScript type and type /// of array should be exactly Object[], not /// SomeObjectSubclass[]. ///
리턴 Scriptable

NewObject() 공개 메소드

Create a new JavaScript object.
Create a new JavaScript object. Equivalent to evaluating "new Object()".
public NewObject ( Scriptable scope ) : Scriptable
scope Scriptable /// the scope to search for the constructor and to evaluate /// against ///
리턴 Scriptable

NewObject() 공개 메소드

Create a new JavaScript object by executing the named constructor.
Create a new JavaScript object by executing the named constructor. The call newObject(scope, "Foo") is equivalent to evaluating "new Foo()".
public NewObject ( Scriptable scope, string constructorName ) : Scriptable
scope Scriptable the scope to search for the constructor and to evaluate against
constructorName string the name of the constructor to call
리턴 Scriptable

NewObject() 공개 메소드

Creates a new JavaScript object by executing the named constructor.
Creates a new JavaScript object by executing the named constructor. Searches 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.
public NewObject ( Scriptable scope, string constructorName, object args ) : Scriptable
scope Scriptable /// The scope to search for the constructor and to evaluate /// against ///
constructorName string the name of the constructor to call
args object the array of arguments for the constructor
리턴 Scriptable

ObserveInstructionCount() 보호된 메소드

Allow application to monitor counter of executed script instructions in Context subclasses.
Allow application to monitor counter of executed script instructions in Context subclasses. Run-time calls this when instruction counting is enabled and the counter reaches limit set by setInstructionObserverThreshold(). The method is useful to observe long running scripts and if necessary to terminate them.

The default implementation calls ContextFactory.ObserveInstructionCount(Context, int) that allows to customize Context behavior without introducing Context subclasses.

to terminate the script
protected ObserveInstructionCount ( int instructionCount ) : void
instructionCount int /// amount of script instruction executed since /// last call to observeInstructionCount ///
리턴 void

PutThreadLocal() 공개 메소드

Put a value that can later be retrieved using a given key.
Put a value that can later be retrieved using a given key.

public PutThreadLocal ( object key, object value ) : void
key object the key used to index the value
value object the value to save
리턴 void

RemoveActivationName() 공개 메소드

Remove a name from the list of names forcing the creation of real activation objects for functions.
Remove a name from the list of names forcing the creation of real activation objects for functions.
public RemoveActivationName ( string name ) : void
name string the name of the object to remove from the list
리턴 void

RemovePropertyChangeListener() 공개 메소드

Remove an object from the list of objects registered to receive notification of changes to a bounded property
public RemovePropertyChangeListener ( PropertyChangeListener l ) : void
l PropertyChangeListener the listener
리턴 void

RemoveThreadLocal() 공개 메소드

Remove values from thread-local storage.
Remove values from thread-local storage.
public RemoveThreadLocal ( object key ) : void
key object the key for the entry to remove.
리턴 void

ReportError() 공개 정적인 메소드

Report an error using the error reporter for the current thread.
Report an error using the error reporter for the current thread.
public static ReportError ( string message ) : void
message string the error message to report
리턴 void

ReportError() 공개 정적인 메소드

Report an error using the error reporter for the current thread.
Report an error using the error reporter for the current thread.
public static ReportError ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : void
message string the error message to report
sourceName string a string describing the source, such as a filename
lineno int the starting line number
lineSource string the text of the line (may be null)
lineOffset int the offset into lineSource where problem was detected
리턴 void

ReportRuntimeError() 공개 정적인 메소드

Report a runtime error using the error reporter for the current thread.
Report a runtime error using the error reporter for the current thread.
public static ReportRuntimeError ( string message ) : EvaluatorException
message string the error message to report
리턴 EvaluatorException

ReportRuntimeError() 공개 정적인 메소드

Report a runtime error using the error reporter for the current thread.
Report a runtime error using the error reporter for the current thread.
public static ReportRuntimeError ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : EvaluatorException
message string the error message to report
sourceName string a string describing the source, such as a filename
lineno int the starting line number
lineSource string the text of the line (may be null)
lineOffset int the offset into lineSource where problem was detected
리턴 EvaluatorException

ReportWarning() 공개 정적인 메소드

Report a warning using the error reporter for the current thread.
Report a warning using the error reporter for the current thread.
public static ReportWarning ( string message ) : void
message string the warning message to report
리턴 void

ReportWarning() 공개 정적인 메소드

public static ReportWarning ( string message, Exception t ) : void
message string
t System.Exception
리턴 void

ReportWarning() 공개 정적인 메소드

Report a warning using the error reporter for the current thread.
Report a warning using the error reporter for the current thread.
public static ReportWarning ( string message, string sourceName, int lineno, string lineSource, int lineOffset ) : void
message string the warning message to report
sourceName string a string describing the source, such as a filename
lineno int the starting line number
lineSource string the text of the line (may be null)
lineOffset int the offset into lineSource where problem was detected
리턴 void

ResumeContinuation() 공개 메소드

Restarts execution of the JavaScript suspended at the call to CaptureContinuation() . Execution of the code will resume with the functionResult as the result of the call that captured the continuation. Execution of the script will either conclude normally and the result returned, another continuation will be captured and thrown, or the script will terminate abnormally and throw an exception.
/// if another continuation is captured before /// the code terminates ///
public ResumeContinuation ( object continuation, Scriptable scope, object functionResult ) : object
continuation object /// The value returned by /// ContinuationPending.GetContinuation() ///
scope Scriptable
functionResult object /// This value will appear to the code being resumed /// as the result of the function that captured the continuation ///
리턴 object

Seal() 공개 메소드

Seal this Context object so any attempt to modify any of its properties including calling Enter() and Exit() methods will throw an exception.

If sealKey is not null, calling Unseal(object) with the same key unseals the object. If sealKey is null, unsealing is no longer possible.

public Seal ( object sealKey ) : void
sealKey object
리턴 void

SetApplicationClassLoader() 공개 메소드

public SetApplicationClassLoader ( ClassLoader loader ) : void
loader ClassLoader
리턴 void

SetClassShutter() 공개 메소드

Set the LiveConnect access filter for this context.
Set the LiveConnect access filter for this context.

ClassShutter may only be set if it is currently null. Otherwise a SecurityException is thrown.

/// if there is already a ClassShutter /// object for this Context ///
public SetClassShutter ( ClassShutter shutter ) : void
shutter ClassShutter a ClassShutter object
리턴 void

SetDebugger() 공개 메소드

Set the associated debugger.
Set the associated debugger.
public SetDebugger ( Debugger debugger, object contextData ) : void
debugger Debugger /// the debugger to be used on callbacks from /// the engine. ///
contextData object /// arbitrary object that debugger can use to store /// per Context data. ///
리턴 void

SetErrorReporter() 공개 메소드

Change the current error reporter.
Change the current error reporter.
public SetErrorReporter ( ErrorReporter reporter ) : ErrorReporter
reporter ErrorReporter
리턴 ErrorReporter

SetGenerateObserverCount() 공개 메소드

Turn on or off generation of code with callbacks to track the count of executed instructions.
Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
public SetGenerateObserverCount ( bool generateObserverCount ) : void
generateObserverCount bool /// if true, generated code will contain /// calls to accumulate an estimate of the instructions executed. ///
리턴 void

SetGeneratingDebug() 공개 메소드

Specify whether or not debug information should be generated.
Specify whether or not debug information should be generated.

Setting the generation of debug information on will set the optimization level to zero.

public SetGeneratingDebug ( bool generatingDebug ) : void
generatingDebug bool
리턴 void

SetGeneratingSource() 공개 메소드

Specify whether or not source information should be generated.
Specify whether or not source information should be generated.

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 SetGeneratingSource ( bool generatingSource ) : void
generatingSource bool
리턴 void

SetInstructionObserverThreshold() 공개 메소드

Set threshold of executed instructions counter that triggers call to observeInstructionCount().
Set threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.

Note that the meaning of "instruction" is not guaranteed to be consistent between compiled and interpretive modes: executing a given script or function in the different modes will result in different instruction counts against the threshold. SetGenerateObserverCount(bool) is called with true if threshold is greater than zero, false otherwise.

public SetInstructionObserverThreshold ( int threshold ) : void
threshold int The instruction threshold
리턴 void

SetLanguageVersion() 공개 메소드

Set the language version.
Set the language version.

Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior.

public SetLanguageVersion ( int version ) : void
version int the version as specified by VERSION_1_0, VERSION_1_1, etc.
리턴 void

SetLocale() 공개 메소드

Set the current locale.
Set the current locale.
public SetLocale ( CultureInfo loc ) : CultureInfo
loc CultureInfo
리턴 CultureInfo

SetMaximumInterpreterStackDepth() 공개 메소드

Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
/// if this context's optimization level is not /// -1 /// if the new depth is not at least 1
public SetMaximumInterpreterStackDepth ( int max ) : void
max int the new maximum interpreter stack depth
리턴 void

SetOptimizationLevel() 공개 메소드

Set the current optimization level.
Set the current optimization level.

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.

public SetOptimizationLevel ( int optimizationLevel ) : void
optimizationLevel int /// an integer indicating the level of /// optimization to perform ///
리턴 void

SetSecurityController() 공개 메소드

Set the security controller for this context.
Set the security controller for this context.

SecurityController may only be set if it is currently null and SecurityController.HasGlobal() is false. Otherwise a SecurityException is thrown.

/// if there is already a SecurityController /// object for this Context or globally installed. ///
public SetSecurityController ( SecurityController controller ) : void
controller SecurityController a SecurityController object
리턴 void

SetWrapFactory() 공개 메소드

Set a WrapFactory for this Context.
Set a WrapFactory for this Context.

The WrapFactory allows custom object wrapping behavior for Java object manipulated with JavaScript.

public SetWrapFactory ( WrapFactory wrapFactory ) : void
wrapFactory WrapFactory
리턴 void

StringIsCompilableUnit() 공개 메소드

Check whether a string is ready to be compiled.
Check whether a string is ready to be compiled.

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.

public StringIsCompilableUnit ( string source ) : bool
source string the source buffer to check
리턴 bool

ThrowAsScriptRuntimeEx() 공개 정적인 메소드

Rethrow the exception wrapping it as the script runtime exception.
Rethrow the exception wrapping it as the script runtime exception. Unless the exception is instance of EcmaError or EvaluatorException it will be wrapped as WrappedException , a subclass of EvaluatorException . The resulting exception object always contains source name and line number of script that triggered exception.

This method always throws an exception, its return value is provided only for convenience to allow a usage like:

 throw Context.throwAsScriptRuntimeEx(ex); 
to indicate that code after the method is unreachable.
EvaluatorException EcmaError
public static ThrowAsScriptRuntimeEx ( Exception e ) : Exception
e Exception
리턴 Exception

ToBoolean() 공개 정적인 메소드

Convert the value to a JavaScript boolean value.
Convert the value to a JavaScript boolean value.

See ECMA 9.2.

public static ToBoolean ( object value ) : bool
value object a JavaScript value
리턴 bool

ToNumber() 공개 정적인 메소드

Convert the value to a JavaScript Number value.
Convert the value to a JavaScript Number value.

Returns a Java double for the JavaScript Number.

See ECMA 9.3.

public static ToNumber ( object value ) : double
value object a JavaScript value
리턴 double

ToObject() 공개 정적인 메소드

Convert the value to an JavaScript object value.
Convert the value to an JavaScript object value.

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.

public static ToObject ( object value, Scriptable scope ) : Scriptable
value object any Java object
scope Scriptable /// global scope containing constructors for Number, /// Boolean, and String ///
리턴 Scriptable

ToString() 공개 정적인 메소드

Convert the value to a JavaScript String value.
Convert the value to a JavaScript String value.

See ECMA 9.8.

public static ToString ( object value ) : string
value object a JavaScript value
리턴 string

Unseal() 공개 메소드

Unseal previously sealed Context object.
Unseal previously sealed Context object. The sealKey argument should not be null and should match sealKey suplied with the last call to Seal(object) or an exception will be thrown.
public Unseal ( object sealKey ) : void
sealKey object
리턴 void

프로퍼티 상세

emptyArgs 공개적으로 정적으로 프로퍼티

Convenient value to use as zero-length array of objects.
Convenient value to use as zero-length array of objects.
public static object[] emptyArgs
리턴 object[]

generateObserverCount 공개적으로 프로퍼티

public bool generateObserverCount
리턴 bool