v8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Static Public Member Functions | List of all members
v8::ScriptCompiler Class Reference

#include <v8.h>

Classes

struct  CachedData
 
class  ExternalSourceStream
 
class  ScriptStreamingTask
 
class  Source
 
class  StreamedSource
 

Public Types

enum  CompileOptions {
  kNoCompileOptions = 0, kProduceParserCache, kConsumeParserCache, kProduceCodeCache,
  kConsumeCodeCache, kProduceDataToCache
}
 

Static Public Member Functions

static V8_DEPRECATE_SOON ("Use maybe version", Local< UnboundScript > CompileUnbound(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions))
 
static V8_WARN_UNUSED_RESULT
MaybeLocal< UnboundScript
CompileUnboundScript (Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
 
static V8_DEPRECATE_SOON ("Use maybe version", Local< Script > Compile(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions))
 
static V8_WARN_UNUSED_RESULT
MaybeLocal< Script
Compile (Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions)
 
static ScriptStreamingTaskStartStreamingScript (Isolate *isolate, StreamedSource *source, CompileOptions options=kNoCompileOptions)
 
static V8_DEPRECATE_SOON ("Use maybe version", Local< Script > Compile(Isolate *isolate, StreamedSource *source, Handle< String > full_source_string, const ScriptOrigin &origin))
 
static V8_WARN_UNUSED_RESULT
MaybeLocal< Script
Compile (Local< Context > context, StreamedSource *source, Handle< String > full_source_string, const ScriptOrigin &origin)
 
static uint32_t CachedDataVersionTag ()
 
static V8_DEPRECATE_SOON ("Use maybe version", Local< Script > CompileModule(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions))
 
static V8_WARN_UNUSED_RESULT
MaybeLocal< Script
CompileModule (Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions)
 
static V8_DEPRECATE_SOON ("Use maybe version", Local< Function > CompileFunctionInContext(Isolate *isolate, Source *source, Local< Context > context, size_t arguments_count, Local< String > arguments[], size_t context_extension_count, Local< Object > context_extensions[]))
 
static V8_WARN_UNUSED_RESULT
MaybeLocal< Function
CompileFunctionInContext (Local< Context > context, Source *source, size_t arguments_count, Local< String > arguments[], size_t context_extension_count, Local< Object > context_extensions[])
 

Detailed Description

For compiling scripts.

Member Enumeration Documentation

Enumerator
kNoCompileOptions 
kProduceParserCache 
kConsumeParserCache 
kProduceCodeCache 
kConsumeCodeCache 
kProduceDataToCache 

Member Function Documentation

static uint32_t v8::ScriptCompiler::CachedDataVersionTag ( )
static

Return a version tag for CachedData for the current V8 version & flags.

This value is meant only for determining whether a previously generated CachedData instance is still valid; the tag has no other meaing.

Background: The data carried by CachedData may depend on the exact V8 version number or currently compiler flags. This means when persisting CachedData, the embedder must take care to not pass in data from another V8 version, or the same version with different features enabled.

The easiest way to do so is to clear the embedder's cache on any such change.

Alternatively, this tag can be stored alongside the cached data and compared when it is being used.

static V8_WARN_UNUSED_RESULT MaybeLocal<Script> v8::ScriptCompiler::Compile ( Local< Context context,
Source source,
CompileOptions  options = kNoCompileOptions 
)
static
static V8_WARN_UNUSED_RESULT MaybeLocal<Script> v8::ScriptCompiler::Compile ( Local< Context context,
StreamedSource source,
Handle< String full_source_string,
const ScriptOrigin origin 
)
static
static V8_WARN_UNUSED_RESULT MaybeLocal<Function> v8::ScriptCompiler::CompileFunctionInContext ( Local< Context context,
Source source,
size_t  arguments_count,
Local< String arguments[],
size_t  context_extension_count,
Local< Object context_extensions[] 
)
static
static V8_WARN_UNUSED_RESULT MaybeLocal<Script> v8::ScriptCompiler::CompileModule ( Local< Context context,
Source source,
CompileOptions  options = kNoCompileOptions 
)
static
static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> v8::ScriptCompiler::CompileUnboundScript ( Isolate isolate,
Source source,
CompileOptions  options = kNoCompileOptions 
)
static
static ScriptStreamingTask* v8::ScriptCompiler::StartStreamingScript ( Isolate isolate,
StreamedSource source,
CompileOptions  options = kNoCompileOptions 
)
static

Returns a task which streams script data into V8, or NULL if the script cannot be streamed. The user is responsible for running the task on a background thread and deleting it. When ran, the task starts parsing the script, and it will request data from the StreamedSource as needed. When ScriptStreamingTask::Run exits, all data has been streamed and the script can be compiled (see Compile below).

This API allows to start the streaming with as little data as possible, and the remaining data (for example, the ScriptOrigin) is passed to Compile.

static v8::ScriptCompiler::V8_DEPRECATE_SOON ( "Use maybe version"  ,
Local< UnboundScript >   CompileUnboundIsolate *isolate, Source *source, CompileOptions options=kNoCompileOptions 
)
static

Compiles the specified script (context-independent). Cached data as part of the source object can be optionally produced to be consumed later to speed up compilation of identical source scripts.

Note that when producing cached data, the source must point to NULL for cached data. When consuming cached data, the cached data must have been produced by the same version of V8.

Parameters
sourceScript source code.
Returns
Compiled script object (context independent; for running it must be bound to a context).
static v8::ScriptCompiler::V8_DEPRECATE_SOON ( "Use maybe version"  ,
Local< Script >   CompileIsolate *isolate, Source *source, CompileOptions options=kNoCompileOptions 
)
static

Compiles the specified script (bound to current context).

Parameters
sourceScript source code.
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 this function returns.
Returns
Compiled script object, bound to the context that was active when this function was called. When run it will always use this context.
static v8::ScriptCompiler::V8_DEPRECATE_SOON ( "Use maybe version"  ,
Local< Script >   CompileIsolate *isolate, StreamedSource *source, Handle< String > full_source_string, const ScriptOrigin &origin 
)
static

Compiles a streamed script (bound to current context).

This can only be called after the streaming has finished (ScriptStreamingTask has been run). V8 doesn't construct the source string during streaming, so the embedder needs to pass the full source here.

static v8::ScriptCompiler::V8_DEPRECATE_SOON ( "Use maybe version"  ,
Local< Script >   CompileModuleIsolate *isolate, Source *source, CompileOptions options=kNoCompileOptions 
)
static

Compile an ES6 module.

This is an experimental feature.

TODO(adamk): Script is likely the wrong return value for this; should return some new Module type.

static v8::ScriptCompiler::V8_DEPRECATE_SOON ( "Use maybe version"  ,
Local< Function >   CompileFunctionInContextIsolate *isolate, Source *source, Local< Context > context, size_t arguments_count, Local< String > arguments[], size_t context_extension_count, Local< Object > context_extensions[] 
)
static

Compile a function for a given context. This is equivalent to running

with (obj) { return function(args) { ... } }

It is possible to specify multiple context extensions (obj in the above example).


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