|
@@ -121,6 +121,90 @@ implementation
|
|
|
list.Concat(tai_comment.Create(strpnew('TODO: handle_nested_exception')));
|
|
|
end;
|
|
|
|
|
|
+{*****************************************************************************
|
|
|
+ twasmexceptionstatehandler_nativeexnrefexceptions
|
|
|
+*****************************************************************************}
|
|
|
+
|
|
|
+ type
|
|
|
+
|
|
|
+ { twasmexceptionstatehandler_nativeexnrefexceptions }
|
|
|
+
|
|
|
+ twasmexceptionstatehandler_nativeexnrefexceptions = class(tcgexceptionstatehandler)
|
|
|
+ class procedure new_exception(list:TAsmList;const t:texceptiontemps; const exceptframekind: texceptframekind; out exceptstate: texceptionstate); override;
|
|
|
+ class procedure free_exception(list: TAsmList; const t: texceptiontemps; const s: texceptionstate; a: aint; endexceptlabel: tasmlabel; onlyfree:boolean); override;
|
|
|
+ class procedure handle_nested_exception(list:TAsmList;var t:texceptiontemps;var entrystate: texceptionstate); override;
|
|
|
+ { start of an "on" (catch) block }
|
|
|
+ class procedure begin_catch(list: TAsmList; excepttype: tobjectdef; nextonlabel: tasmlabel; out exceptlocdef: tdef; out exceptlocreg: tregister); override;
|
|
|
+ { end of an "on" (catch) block }
|
|
|
+ class procedure end_catch(list: TAsmList); override;
|
|
|
+ end;
|
|
|
+
|
|
|
+ class procedure twasmexceptionstatehandler_nativeexnrefexceptions.new_exception(list:TAsmList;const t:texceptiontemps; const exceptframekind: texceptframekind; out exceptstate: texceptionstate);
|
|
|
+ begin
|
|
|
+ exceptstate.exceptionlabel:=nil;
|
|
|
+ exceptstate.oldflowcontrol:=flowcontrol;
|
|
|
+ exceptstate.finallycodelabel:=nil;
|
|
|
+
|
|
|
+ flowcontrol:=[fc_inflowcontrol,fc_catching_exceptions];
|
|
|
+ end;
|
|
|
+
|
|
|
+ class procedure twasmexceptionstatehandler_nativeexnrefexceptions.free_exception(list: TAsmList; const t: texceptiontemps; const s: texceptionstate; a: aint; endexceptlabel: tasmlabel; onlyfree:boolean);
|
|
|
+ begin
|
|
|
+ end;
|
|
|
+
|
|
|
+ class procedure twasmexceptionstatehandler_nativeexnrefexceptions.handle_nested_exception(list:TAsmList;var t:texceptiontemps;var entrystate: texceptionstate);
|
|
|
+ begin
|
|
|
+ Message1(parser_f_unsupported_feature,'nested exception');
|
|
|
+ end;
|
|
|
+
|
|
|
+ class procedure twasmexceptionstatehandler_nativeexnrefexceptions.begin_catch(list: TAsmList; excepttype: tobjectdef; nextonlabel: tasmlabel; out exceptlocdef: tdef; out exceptlocreg: tregister);
|
|
|
+ var
|
|
|
+ pd: tprocdef;
|
|
|
+ href2: treference;
|
|
|
+ fpc_catches_res,
|
|
|
+ paraloc1: tcgpara;
|
|
|
+ exceptloc: tlocation;
|
|
|
+ indirect: boolean;
|
|
|
+ otherunit: boolean;
|
|
|
+ begin
|
|
|
+ paraloc1.init;
|
|
|
+ otherunit:=findunitsymtable(excepttype.owner).moduleid<>findunitsymtable(current_procinfo.procdef.owner).moduleid;
|
|
|
+ indirect:=(tf_supports_packages in target_info.flags) and
|
|
|
+ (target_info.system in systems_indirect_var_imports) and
|
|
|
+ (cs_imported_data in current_settings.localswitches) and
|
|
|
+ otherunit;
|
|
|
+
|
|
|
+ { send the vmt parameter }
|
|
|
+ pd:=search_system_proc('fpc_catches');
|
|
|
+ reference_reset_symbol(href2, current_asmdata.RefAsmSymbol(excepttype.vmt_mangledname, AT_DATA, indirect), 0, sizeof(pint), []);
|
|
|
+ if otherunit then
|
|
|
+ current_module.add_extern_asmsym(excepttype.vmt_mangledname, AB_EXTERNAL, AT_DATA);
|
|
|
+ paramanager.getcgtempparaloc(list, pd, 1, paraloc1);
|
|
|
+ hlcg.a_loadaddr_ref_cgpara(list, excepttype.vmt_def, href2, paraloc1);
|
|
|
+ paramanager.freecgpara(list, paraloc1);
|
|
|
+ fpc_catches_res:=hlcg.g_call_system_proc(list, pd, [@paraloc1], nil);
|
|
|
+ location_reset(exceptloc, LOC_REGISTER, def_cgsize(fpc_catches_res.def));
|
|
|
+ exceptloc.register:=hlcg.getaddressregister(list, fpc_catches_res.def);
|
|
|
+ hlcg.gen_load_cgpara_loc(list, fpc_catches_res.def, fpc_catches_res, exceptloc, true);
|
|
|
+
|
|
|
+ { is it this catch? }
|
|
|
+ thlcgwasm(hlcg).a_cmp_const_reg_stack(list, fpc_catches_res.def, OC_NE, 0, exceptloc.register);
|
|
|
+
|
|
|
+ current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
|
|
|
+ thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
|
|
|
+
|
|
|
+ paraloc1.done;
|
|
|
+
|
|
|
+ exceptlocdef:=fpc_catches_res.def;
|
|
|
+ exceptlocreg:=exceptloc.register;
|
|
|
+ end;
|
|
|
+
|
|
|
+ class procedure twasmexceptionstatehandler_nativeexnrefexceptions.end_catch(list: TAsmList);
|
|
|
+ begin
|
|
|
+ current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{*****************************************************************************
|
|
|
twasmexceptionstatehandler_nativelegacyexceptions
|
|
|
*****************************************************************************}
|
|
@@ -416,7 +500,9 @@ implementation
|
|
|
|
|
|
procedure tcpuprocinfo.setup_eh;
|
|
|
begin
|
|
|
- if ts_wasm_native_legacy_exceptions in current_settings.targetswitches then
|
|
|
+ if ts_wasm_native_exnref_exceptions in current_settings.targetswitches then
|
|
|
+ cexceptionstatehandler:=twasmexceptionstatehandler_nativeexnrefexceptions
|
|
|
+ else if ts_wasm_native_legacy_exceptions in current_settings.targetswitches then
|
|
|
cexceptionstatehandler:=twasmexceptionstatehandler_nativelegacyexceptions
|
|
|
else if ts_wasm_no_exceptions in current_settings.targetswitches then
|
|
|
cexceptionstatehandler:=twasmexceptionstatehandler_noexceptions
|