+ added TWasmFuncType.ToString implementation

This commit is contained in:
Nikolay Nikolov 2023-12-31 21:49:35 +02:00
parent 4f4beb6225
commit 52f0ec579e

View File

@ -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.