From 52f0ec579ed810035db0886b266fecb1934038d2 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Sun, 31 Dec 2023 21:49:35 +0200 Subject: [PATCH] + added TWasmFuncType.ToString implementation --- compiler/wasm32/cpubase.pas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/compiler/wasm32/cpubase.pas b/compiler/wasm32/cpubase.pas index 7dbc3aecd1..e432f38264 100644 --- a/compiler/wasm32/cpubase.pas +++ b/compiler/wasm32/cpubase.pas @@ -151,6 +151,7 @@ uses procedure add_param(param: TWasmBasicType); procedure add_result(res: TWasmBasicType); function Equals(Obj: TObject): boolean; override; + function ToString: ansistring; override; end; {# This should define the array of instructions as string } @@ -677,4 +678,27 @@ uses Result:=inherited Equals(Obj); end; + function TWasmFuncType.ToString: ansistring; + const + wasm_basic_type_str : array [TWasmBasicType] of string = ('i32','i64','f32','f64','funcref','externref','v128'); + var + i: Integer; + begin + Result:='('; + for i:=0 to high(params) do + begin + if i<>0 then + Result:=Result+', '; + Result:=Result+wasm_basic_type_str[params[i]]; + end; + Result:=Result+') -> ('; + for i:=0 to high(results) do + begin + if i<>0 then + Result:=Result+', '; + Result:=Result+wasm_basic_type_str[results[i]]; + end; + Result:=Result+')'; + end; + end.