This repository was archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathScriptCompiler.php
122 lines (109 loc) · 3.61 KB
/
ScriptCompiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php declare(strict_types=1);
/**
* This file is part of the phpv8/php-v8 PHP extension.
*
* Copyright (c) 2015-2018 Bogdan Padalko <thepinepain@gmail.com>
*
* Licensed under the MIT license: http://opensource.org/licenses/MIT
*
* For the full copyright and license information, please view the
* LICENSE file that was distributed with this source or visit
* http://opensource.org/licenses/MIT
*/
namespace V8;
use V8\ScriptCompiler\CachedData;
use V8\ScriptCompiler\Source;
/**
* For compiling scripts.
*/
class ScriptCompiler
{
const OPTION_NO_COMPILE_OPTIONS = 0;
const OPTION_CONSUME_CODE_CACHE = 5;
const OPTION_EAGER_COMPILE = 6;
private function __construct()
{
}
/**
* 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.
*
* @return float
*/
public static function getCachedDataVersionTag(): float
{
}
/**
* 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 have no cached data set.
* When consuming cached data, the cached data must have been produced by the same version of V8.
*
* @param Context $context
* @param Source $source
* @param int $options
*
* @return UnboundScript
*/
public static function compileUnboundScript(Context $context, Source $source, int $options = ScriptCompiler::OPTION_NO_COMPILE_OPTIONS): UnboundScript
{
}
/**
* Compiles the specified script (bound to current context).
*
* @param Context $context
* @param Source $source
* @param int $options
*
* @return Script
*/
public static function compile(Context $context, Source $source, int $options = ScriptCompiler::OPTION_NO_COMPILE_OPTIONS): Script
{
}
/**
* 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).
*
* @param Context $context
* @param Source $source
* @param StringValue[] $arguments
* @param ObjectValue[] $context_extensions
*
* @return FunctionObject
*/
public static function compileFunctionInContext(Context $context, Source $source, array $arguments = [], array $context_extensions = []): FunctionObject
{
}
/**
* Creates and returns code cache for the specified unbound_script.
*
* @param UnboundScript $unbound_script
* @param StringValue $source_string
*
* @return CachedData
*/
public static function createCodeCache(UnboundScript $unbound_script, StringValue $source_string): CachedData
{
}
}