mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 18:08:15 +02:00
+ implemented second_ansistring_to_pchar for WebAssembly
git-svn-id: branches/wasm@48213 -
This commit is contained in:
parent
0f235f38ab
commit
c5fae9f214
@ -36,15 +36,16 @@ interface
|
||||
function first_int_to_real: tnode; override;
|
||||
procedure second_int_to_real;override;
|
||||
procedure second_int_to_bool;override;
|
||||
procedure second_ansistring_to_pchar;override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
verbose,globals,globtype,aasmdata,
|
||||
defutil,cpubase,
|
||||
defutil,fmodule,cpubase,
|
||||
cgbase,cgutils,pass_1,pass_2,
|
||||
aasmcpu,
|
||||
aasmbase,aasmcpu,
|
||||
symdef,
|
||||
hlcgobj,hlcgcpu;
|
||||
|
||||
@ -136,6 +137,36 @@ implementation
|
||||
thlcgwasm(hlcg).a_load_stack_loc(current_asmdata.CurrAsmList,resultdef,location);
|
||||
end;
|
||||
|
||||
|
||||
procedure twasmtypeconvnode.second_ansistring_to_pchar;
|
||||
var
|
||||
hr : treference;
|
||||
begin
|
||||
thlcgwasm(hlcg).a_cmp_const_loc_stack(current_asmdata.CurrAsmList,left.resultdef,OC_NE,0,left.location);
|
||||
|
||||
current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
|
||||
thlcgwasm(hlcg).incblock;
|
||||
thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
|
||||
|
||||
thlcgwasm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);
|
||||
|
||||
current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_else));
|
||||
thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
|
||||
|
||||
{ FPC_EMPTYCHAR is a widechar -> 2 bytes }
|
||||
reference_reset(hr,2,[]);
|
||||
hr.symbol:=current_asmdata.RefAsmSymbol('FPC_EMPTYCHAR',AT_DATA);
|
||||
current_module.add_extern_asmsym('FPC_EMPTYCHAR',AB_EXTERNAL,AT_DATA);
|
||||
thlcgwasm(hlcg).a_loadaddr_ref_stack(current_asmdata.CurrAsmList,cwidechartype,resultdef,hr);
|
||||
|
||||
current_asmdata.CurrAsmList.Concat( taicpu.op_none(a_end_if) );
|
||||
thlcgwasm(hlcg).decblock;
|
||||
|
||||
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
||||
location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,resultdef);
|
||||
thlcgwasm(hlcg).a_load_stack_loc(current_asmdata.CurrAsmList,resultdef,location);
|
||||
end;
|
||||
|
||||
begin
|
||||
ctypeconvnode:=twasmtypeconvnode;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user