File tree Expand file tree Collapse file tree 5 files changed +37
-12
lines changed Expand file tree Collapse file tree 5 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 12
12
use PHPCfg \Operand ;
13
13
use PHPCompiler \Runtime ;
14
14
use PHPCompiler \Block ;
15
+ use PHPCompiler \Module ;
15
16
use PHPCompiler \VM \Variable as VMVariable ;
16
17
use PHPTypes \Type ;
17
18
@@ -43,6 +44,7 @@ class Context {
43
44
private array $ stringConstant = [];
44
45
private array $ builtins ;
45
46
private array $ stringConstantMap = [];
47
+ private array $ modules = [];
46
48
47
49
private ?Result $ result = null ;
48
50
public Builtin \MemoryManager $ memory ;
@@ -117,6 +119,11 @@ public function popScope(): void {
117
119
$ this ->scope = array_pop ($ this ->scopeStack );
118
120
}
119
121
122
+ public function registerModule (Module $ module ): void {
123
+ $ this ->modules [] = $ module ;
124
+ $ module ->jitInit ($ this );
125
+ }
126
+
120
127
public function registerBuiltin (Builtin $ builtin ): void {
121
128
$ this ->builtins [] = $ builtin ;
122
129
}
@@ -196,6 +203,9 @@ public function compileInPlace() {
196
203
}
197
204
198
205
private function compileCommon () {
206
+ foreach ($ this ->modules as $ module ) {
207
+ $ module ->jitShutdown ($ this );
208
+ }
199
209
foreach ($ this ->builtins as $ builtin ) {
200
210
$ builtin ->shutdown ();
201
211
}
Original file line number Diff line number Diff line change @@ -19,5 +19,9 @@ public function getFunctions(): array;
19
19
20
20
public function init (Runtime $ runtime ): void ;
21
21
22
+ public function jitInit (JIT \Context $ context ): void ;
23
+
24
+ public function jitShutdown (JIT \Context $ context ): void ;
25
+
22
26
public function shutdown (): void ;
23
27
}
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ public function shutdown(): void {
30
30
31
31
}
32
32
33
+ public function jitInit (JIT \Context $ context ): void {
34
+
35
+ }
36
+
37
+ public function jitShutdown (JIT \Context $ context ): void {
38
+
39
+ }
40
+
33
41
protected function parseAndCompileFunction (string $ name , string $ filename ): Func {
34
42
$ script = $ this ->runtime ->parse (file_get_contents ($ filename ), $ filename );
35
43
$ func = $ this ->findFunction ($ name , $ script );
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ public function loadJitContext(): JITContext {
107
107
if (!is_null ($ this ->debugFile )) {
108
108
$ this ->jitContext ->setDebugFile ($ this ->debugFile );
109
109
}
110
+ foreach ($ this ->modules as $ module ) {
111
+ $ this ->jitContext ->registerModule ($ module );
112
+ }
110
113
}
111
114
return $ this ->jitContext ;
112
115
}
You can’t perform that action at this time.
0 commit comments