diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-10 19:30:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-10 19:30:20 +0900 |
| commit | 2984d445831ebf0cd8c909f589dc203018ae2b0b (patch) | |
| tree | 465c6e304b85fcd322389dd8b530cea5acabd929 /src/Execution/Runtime.php | |
| parent | 1011da8798ba7370d914dbce9feac1b06ab81ed5 (diff) | |
| download | php-waddiwasi-2984d445831ebf0cd8c909f589dc203018ae2b0b.tar.gz php-waddiwasi-2984d445831ebf0cd8c909f589dc203018ae2b0b.tar.zst php-waddiwasi-2984d445831ebf0cd8c909f589dc203018ae2b0b.zip | |
test: implement "register" action of WAST
Diffstat (limited to 'src/Execution/Runtime.php')
| -rw-r--r-- | src/Execution/Runtime.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 02c526c..2cc37b2 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -56,11 +56,30 @@ final class Runtime } /** - * @param list<ExternVal> $externVals + * @param array<string, array<string, Extern>> $imports */ public static function instantiate( Store $store, Module $module, + array $imports, + ): self { + $externVals = []; + foreach ($module->imports as $import) { + $extern = $imports[$import->module][$import->name] ?? null; + if ($extern === null) { + throw new RuntimeException("instantiate: import not found: {$import->module}::{$import->name}"); + } + $externVals[] = $store->register($extern); + } + return self::doInstantiate($store, $module, $externVals); + } + + /** + * @param list<ExternVal> $externVals + */ + private static function doInstantiate( + Store $store, + Module $module, array $externVals, ): self { $allocator = new Allocator($store); |
