diff options
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); |
