From 2984d445831ebf0cd8c909f589dc203018ae2b0b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 10 Jul 2024 19:30:09 +0900 Subject: test: implement "register" action of WAST --- src/Execution/Runtime.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/Execution/Runtime.php') 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,9 +56,28 @@ final class Runtime } /** - * @param list $externVals + * @param array> $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 $externVals + */ + private static function doInstantiate( Store $store, Module $module, array $externVals, -- cgit v1.2.3-70-g09d2