@@ -184,6 +184,17 @@ public boolean equals(Object that) {
184184 public int hashCode () {
185185 return value ;
186186 }
187+
188+ @ Override
189+ public String toString () {
190+ return switch (value ()) {
191+ case WasmType .I32_TYPE -> "i32" ;
192+ case WasmType .I64_TYPE -> "i64" ;
193+ case WasmType .F32_TYPE -> "f32" ;
194+ case WasmType .F64_TYPE -> "f64" ;
195+ default -> throw CompilerDirectives .shouldNotReachHere ();
196+ };
197+ }
187198 }
188199
189200 public static final class VectorType extends ClosedValueType {
@@ -228,6 +239,11 @@ public boolean equals(Object that) {
228239 public int hashCode () {
229240 return value ;
230241 }
242+
243+ @ Override
244+ public String toString () {
245+ return "v128" ;
246+ }
231247 }
232248
233249 public static final class ClosedReferenceType extends ClosedValueType {
@@ -285,6 +301,27 @@ public boolean equals(Object obj) {
285301 public int hashCode () {
286302 return Boolean .hashCode (nullable ) ^ closedHeapType .hashCode ();
287303 }
304+
305+ @ Override
306+ public String toString () {
307+ CompilerAsserts .neverPartOfCompilation ();
308+ if (this == FUNCREF ) {
309+ return "funcref" ;
310+ } else if (this == EXTERNREF ) {
311+ return "externref" ;
312+ } else if (this == EXNREF ) {
313+ return "exnref" ;
314+ } else {
315+ StringBuilder buf = new StringBuilder ();
316+ buf .append ("(ref " );
317+ if (nullable ) {
318+ buf .append ("null " );
319+ }
320+ buf .append (closedHeapType .toString ());
321+ buf .append (")" );
322+ return buf .toString ();
323+ }
324+ }
288325 }
289326
290327 public static final class AbstractHeapType extends ClosedHeapType {
@@ -341,6 +378,16 @@ public boolean equals(Object that) {
341378 public int hashCode () {
342379 return value ;
343380 }
381+
382+ @ Override
383+ public String toString () {
384+ return switch (this .value ) {
385+ case WasmType .FUNC_HEAPTYPE -> "func" ;
386+ case WasmType .EXTERN_HEAPTYPE -> "extern" ;
387+ case WasmType .EXN_HEAPTYPE -> "exn" ;
388+ default -> throw CompilerDirectives .shouldNotReachHere ();
389+ };
390+ }
344391 }
345392
346393 public static final class ClosedFunctionType extends ClosedHeapType {
@@ -436,6 +483,20 @@ public boolean equals(Object obj) {
436483 public int hashCode () {
437484 return Arrays .hashCode (paramTypes ) ^ Arrays .hashCode (resultTypes );
438485 }
486+
487+ @ Override
488+ public String toString () {
489+ CompilerAsserts .neverPartOfCompilation ();
490+ String [] paramNames = new String [paramTypes .length ];
491+ for (int i = 0 ; i < paramTypes .length ; i ++) {
492+ paramNames [i ] = paramTypes [i ].toString ();
493+ }
494+ String [] resultNames = new String [resultTypes .length ];
495+ for (int i = 0 ; i < resultTypes .length ; i ++) {
496+ resultNames [i ] = resultTypes [i ].toString ();
497+ }
498+ return "(" + String .join (" " , paramNames ) + ")->(" + String .join (" " , resultNames ) + ")" ;
499+ }
439500 }
440501
441502 /**
0 commit comments