aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WebAssembly/Structure
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-11 04:20:25 +0900
committernsfisis <nsfisis@gmail.com>2024-07-11 04:20:25 +0900
commit5be97eadbb1065f842aad4341cd4732498e0553b (patch)
tree827560953ea0abf494b3bb7aae9a987d105a8da3 /src/WebAssembly/Structure
parent8a083ed74e9f4472441175e187208012927ed357 (diff)
downloadphp-waddiwasi-5be97eadbb1065f842aad4341cd4732498e0553b.tar.gz
php-waddiwasi-5be97eadbb1065f842aad4341cd4732498e0553b.tar.zst
php-waddiwasi-5be97eadbb1065f842aad4341cd4732498e0553b.zip
feat: simplify FuncType structure
Diffstat (limited to 'src/WebAssembly/Structure')
-rw-r--r--src/WebAssembly/Structure/Types/FuncType.php29
-rw-r--r--src/WebAssembly/Structure/Types/ResultType.php31
2 files changed, 25 insertions, 35 deletions
diff --git a/src/WebAssembly/Structure/Types/FuncType.php b/src/WebAssembly/Structure/Types/FuncType.php
index 6c53519..9ea2434 100644
--- a/src/WebAssembly/Structure/Types/FuncType.php
+++ b/src/WebAssembly/Structure/Types/FuncType.php
@@ -4,17 +4,38 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Types;
+use function count;
+
final readonly class FuncType
{
+ /**
+ * @param list<ValType> $params
+ * @param list<ValType> $results
+ */
public function __construct(
- public ResultType $params,
- public ResultType $results,
+ public array $params,
+ public array $results,
) {
}
public function equals(FuncType $other): bool
{
- return $this->params->equals($other->params)
- && $this->results->equals($other->results);
+ if (count($this->params) !== count($other->params)) {
+ return false;
+ }
+ if (count($this->results) !== count($other->results)) {
+ return false;
+ }
+ foreach ($this->params as $i => $type) {
+ if ($type !== $other->params[$i]) {
+ return false;
+ }
+ }
+ foreach ($this->results as $i => $type) {
+ if ($type !== $other->results[$i]) {
+ return false;
+ }
+ }
+ return true;
}
}
diff --git a/src/WebAssembly/Structure/Types/ResultType.php b/src/WebAssembly/Structure/Types/ResultType.php
deleted file mode 100644
index 9f44e81..0000000
--- a/src/WebAssembly/Structure/Types/ResultType.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Types;
-
-use function count;
-
-final readonly class ResultType
-{
- /**
- * @param list<ValType> $types
- */
- public function __construct(
- public array $types,
- ) {
- }
-
- public function equals(ResultType $other): bool
- {
- if (count($this->types) !== count($other->types)) {
- return false;
- }
- foreach ($this->types as $i => $type) {
- if ($type !== $other->types[$i]) {
- return false;
- }
- }
- return true;
- }
-}