v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Script Class Reference

#include <v8.h>

Public Member Functions

Local< ValueRun ()
 
Local< ValueId ()
 
void SetData (Handle< String > data)
 

Static Public Member Functions

static Local< ScriptNew (Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
 
static Local< ScriptNew (Handle< String > source, Handle< Value > file_name)
 
static Local< ScriptCompile (Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
 
static Local< ScriptCompile (Handle< String > source, Handle< Value > file_name, Handle< String > script_data=Handle< String >())
 

Detailed Description

A compiled JavaScript script.

Definition at line 592 of file v8.h.

Member Function Documentation

Local< Script > Compile ( v8::Handle< String source,
v8::ScriptOrigin origin = NULL,
v8::ScriptData pre_data = NULL,
v8::Handle< String script_data = Handle<String>() 
)
static

Compiles the specified script (bound to current context).

Parameters
sourceScript source code.
originScript origin, owned by caller, no references are kept when Compile() returns
pre_dataPre-parsing data, as obtained by ScriptData::PreCompile() using pre_data speeds compilation if it's done multiple times. Owned by caller, no references are kept when Compile() returns.
script_dataArbitrary data associated with script. Using this has same effect as calling SetData(), but makes data available earlier (i.e. to compile event handlers).
Returns
Compiled script object, bound to the context that was active when this function was called. When run it will always use this context.

Definition at line 1560 of file api.cc.

References SharedFunctionInfo::cast(), ENTER_V8, Isolate::factory(), Isolate::global_context(), LOG_API, Script::New(), Factory::NewFunctionFromSharedFunctionInfo(), ON_BAILOUT, and Utils::OpenHandle().

Referenced by CCatcher(), Script::Compile(), DEPENDENT_TEST(), DoLoop(), DoLoopNoCall(), ExecuteString(), Shell::ExecuteString(), Loop(), LoopGetProperty(), ReenterAfterTermination(), ThreadA::Run(), LoopingThread::Run(), RunMain(), TEST(), and THREADED_TEST().

Local< Script > Compile ( v8::Handle< String source,
v8::Handle< Value file_name,
v8::Handle< String script_data = Handle<String>() 
)
static

Compiles the specified script using the specified file name object (typically a string) as the script's origin.

Parameters
sourceScript source code.
file_nameFile name to use as script's origin
script_dataArbitrary data associated with script. Using this has same effect as calling SetData(), but makes data available earlier (i.e. to compile event handlers).
Returns
Compiled script object, bound to the context that was active when this function was called. When run it will always use this context.

Definition at line 1582 of file api.cc.

References Script::Compile().

Local< Value > Id ( )

Returns the script id value.

Definition at line 1635 of file api.cc.

References Script::cast(), LOG_API, NULL, ON_BAILOUT, and Utils::ToLocal().

Referenced by THREADED_TEST().

Local< Script > New ( v8::Handle< String source,
v8::ScriptOrigin origin = NULL,
v8::ScriptData pre_data = NULL,
v8::Handle< String script_data = Handle<String>() 
)
static

Compiles the specified script (context-independent).

Parameters
sourceScript source code.
originScript origin, owned by caller, no references are kept when New() returns
pre_dataPre-parsing data, as obtained by ScriptData::PreCompile() using pre_data speeds compilation if it's done multiple times. Owned by caller, no references are kept when New() returns.
script_dataArbitrary data associated with script. Using this has same effect as calling SetData(), but allows data to be available to compile event handlers.
Returns
Compiled script object (context independent; when run it will use the currently entered context).

Definition at line 1499 of file api.cc.

References ASSERT, Compiler::Compile(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, Handle< T >::is_null(), Handle< T >::IsEmpty(), LOG_API, v8::internal::NOT_NATIVES_CODE, NULL, ON_BAILOUT, Utils::OpenHandle(), ScriptOrigin::ResourceColumnOffset(), ScriptOrigin::ResourceLineOffset(), ScriptOrigin::ResourceName(), and ScriptDataImpl::SanityCheck().

Referenced by Script::Compile(), Script::New(), TEST(), and THREADED_TEST().

Local< Script > New ( v8::Handle< String source,
v8::Handle< Value file_name 
)
static

Compiles the specified script using the specified file name object (typically a string) as the script's origin.

Parameters
sourceScript source code.
file_namefile name object (typically a string) to be used as the script's origin.
Returns
Compiled script object (context independent; when run it will use the currently entered context).

Definition at line 1553 of file api.cc.

References Script::New().

Local< Value > Run ( )

Runs the script returning the resulting value. If the script is context independent (created using ::New) it will be run in the currently entered context. If it is context specific (created using ::Compile) it will be run in the context in which it was compiled.

Definition at line 1590 of file api.cc.

References Execution::Call(), SharedFunctionInfo::cast(), JSFunction::cast(), Isolate::context(), ENTER_V8, EXCEPTION_BAILOUT_CHECK_DO_CALLBACK, EXCEPTION_PREAMBLE, Isolate::factory(), Isolate::global_context(), Context::global_proxy(), LOG_API, Factory::NewFunctionFromSharedFunctionInfo(), NULL, ON_BAILOUT, Utils::OpenHandle(), and Utils::ToLocal().

Referenced by DEPENDENT_TEST(), ExecuteString(), Shell::ExecuteString(), ThreadA::Run(), RunMain(), TEST(), THREADED_TEST(), and WhammyPropertyGetter().

void SetData ( v8::Handle< String data)

Associate an additional data object with the script. This is mainly used with the debugger as this data object is only available through the debugger API.

Definition at line 1652 of file api.cc.

References Script::cast(), LOG_API, ON_BAILOUT, and Utils::OpenHandle().

Referenced by THREADED_TEST().


The documentation for this class was generated from the following files: