mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 07:09:09 +02:00
+ introduced methods for converting WebAssembly global var types from a Pascal type to TWasmBasicType
This commit is contained in:
parent
7bd1ac4507
commit
6e1d7b4e57
@ -166,6 +166,9 @@ type
|
|||||||
|
|
||||||
tcpustaticvarsym = class(tstaticvarsym)
|
tcpustaticvarsym = class(tstaticvarsym)
|
||||||
function is_wasm_global: Boolean;
|
function is_wasm_global: Boolean;
|
||||||
|
function try_get_wasm_global_vardef_type(out res: TWasmBasicType): Boolean;
|
||||||
|
function get_wasm_global_vardef_type: TWasmBasicType;
|
||||||
|
function has_valid_wasm_global_vardef_type: Boolean;
|
||||||
end;
|
end;
|
||||||
tcpustaticvarsymclass = class of tcpustaticvarsym;
|
tcpustaticvarsymclass = class of tcpustaticvarsym;
|
||||||
|
|
||||||
@ -199,6 +202,7 @@ implementation
|
|||||||
uses
|
uses
|
||||||
verbose,cutils,cclasses,globals,cgbase,
|
verbose,cutils,cclasses,globals,cgbase,
|
||||||
symconst,symbase,symtable,symcreat,wasmdef,
|
symconst,symbase,symtable,symcreat,wasmdef,
|
||||||
|
defutil,
|
||||||
pdecsub,pparautl,paramgr,
|
pdecsub,pparautl,paramgr,
|
||||||
// high-level code generator is needed to get access to type index for ncall
|
// high-level code generator is needed to get access to type index for ncall
|
||||||
hlcgobj,hlcgcpu,
|
hlcgobj,hlcgcpu,
|
||||||
@ -321,6 +325,36 @@ implementation
|
|||||||
Result:=UpCase(section)='WEBASSEMBLY.GLOBAL';
|
Result:=UpCase(section)='WEBASSEMBLY.GLOBAL';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function tcpustaticvarsym.try_get_wasm_global_vardef_type(out res: TWasmBasicType): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=True;
|
||||||
|
if is_64bitint(vardef) then
|
||||||
|
res:=wbt_i64
|
||||||
|
else if is_pointer(vardef) then
|
||||||
|
res:=wbt_i32
|
||||||
|
else if is_32bitint(vardef) then
|
||||||
|
res:=wbt_i32
|
||||||
|
else if is_single(vardef) then
|
||||||
|
res:=wbt_f32
|
||||||
|
else if is_double(vardef) then
|
||||||
|
res:=wbt_f64
|
||||||
|
else
|
||||||
|
Result:=False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function tcpustaticvarsym.get_wasm_global_vardef_type: TWasmBasicType;
|
||||||
|
begin
|
||||||
|
if not try_get_wasm_global_vardef_type(Result) then
|
||||||
|
internalerror(2022072501);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function tcpustaticvarsym.has_valid_wasm_global_vardef_type: Boolean;
|
||||||
|
var
|
||||||
|
TempWBT: TWasmBasicType;
|
||||||
|
begin
|
||||||
|
result:=try_get_wasm_global_vardef_type(TempWBT);
|
||||||
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
tcpufieldvarsym
|
tcpufieldvarsym
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
Loading…
Reference in New Issue
Block a user