diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-11 03:50:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-11 04:14:03 +0900 |
| commit | 8a083ed74e9f4472441175e187208012927ed357 (patch) | |
| tree | 3686a0f61f3fccc5ded3eda28b92b8bf7765fd2f /src/WebAssembly/Debug | |
| parent | 26f49b7e27076e689541b9e13a1b54f60a4ee5c2 (diff) | |
| download | php-waddiwasi-8a083ed74e9f4472441175e187208012927ed357.tar.gz php-waddiwasi-8a083ed74e9f4472441175e187208012927ed357.tar.zst php-waddiwasi-8a083ed74e9f4472441175e187208012927ed357.zip | |
feat: simplify ValType structure
Diffstat (limited to 'src/WebAssembly/Debug')
| -rw-r--r-- | src/WebAssembly/Debug/Debug.php | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/WebAssembly/Debug/Debug.php b/src/WebAssembly/Debug/Debug.php index 738dff2..60ac99b 100644 --- a/src/WebAssembly/Debug/Debug.php +++ b/src/WebAssembly/Debug/Debug.php @@ -11,12 +11,9 @@ use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\GlobalType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\Limits; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\Mut; -use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\NumType; -use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\RefType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ResultType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValType; -use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValTypes; final readonly class Debug { @@ -52,7 +49,7 @@ final readonly class Debug private static function tableTypeToString(TableType $type): string { - return self::valTypeToString(ValType::RefType($type->refType)) . ' ' . self::limitsToString($type->limits); + return self::valTypeToString($type->refType) . ' ' . self::limitsToString($type->limits); } private static function memTypeToString(MemType $type): string @@ -74,19 +71,14 @@ final readonly class Debug private static function valTypeToString(ValType $type): string { - return match ($type::class) { - ValTypes\NumType::class => match ($type->inner) { - NumType::I32 => 'i32', - NumType::I64 => 'i64', - NumType::F32 => 'f32', - NumType::F64 => 'f64', - }, - ValTypes\VecType::class => 'v128', - ValTypes\RefType::class => match ($type->inner) { - RefType::FuncRef => 'funcref', - RefType::ExternRef => 'externref', - }, - default => 'unknown', + return match ($type) { + ValType::I32 => 'i32', + ValType::I64 => 'i64', + ValType::F32 => 'f32', + ValType::F64 => 'f64', + ValType::V128 => 'v128', + ValType::ExternRef => 'externref', + ValType::FuncRef => 'funcref', }; } |
