mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-04 15:50:30 +02:00
+ initial implementation of try..except in branchful exceptions mode
This commit is contained in:
parent
7ce19c1ad7
commit
a5dcd1c44d
@ -559,9 +559,11 @@ implementation
|
|||||||
destroytemps,
|
destroytemps,
|
||||||
excepttemps: tcgexceptionstatehandler.texceptiontemps;
|
excepttemps: tcgexceptionstatehandler.texceptiontemps;
|
||||||
afteronflowcontrol: tflowcontrol;
|
afteronflowcontrol: tflowcontrol;
|
||||||
|
oldRaiseBr: Integer;
|
||||||
label
|
label
|
||||||
errorexit;
|
errorexit;
|
||||||
begin
|
begin
|
||||||
|
oldRaiseBr:=0;
|
||||||
location_reset(location,LOC_VOID,OS_NO);
|
location_reset(location,LOC_VOID,OS_NO);
|
||||||
doobjectdestroyandreraisestate:=Default(tcgexceptionstatehandler.texceptionstate);
|
doobjectdestroyandreraisestate:=Default(tcgexceptionstatehandler.texceptionstate);
|
||||||
|
|
||||||
@ -575,8 +577,13 @@ implementation
|
|||||||
//flowcontrol:=[fc_inflowcontrol,fc_catching_exceptions];
|
//flowcontrol:=[fc_inflowcontrol,fc_catching_exceptions];
|
||||||
cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,excepttemps,tek_except,trystate);
|
cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,excepttemps,tek_except,trystate);
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
|
||||||
//thlcgwasm(hlcg).incblock;
|
thlcgwasm(hlcg).incblock;
|
||||||
|
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
|
||||||
|
thlcgwasm(hlcg).incblock;
|
||||||
|
oldRaiseBr:=thlcgwasm(hlcg).raiseBr;
|
||||||
|
thlcgwasm(hlcg).raiseBr:=thlcgwasm(hlcg).br_blocks;
|
||||||
|
|
||||||
{ try block }
|
{ try block }
|
||||||
secondpass(left);
|
secondpass(left);
|
||||||
@ -587,12 +594,17 @@ implementation
|
|||||||
//flowcontrol:=exceptionstate.oldflowcontrol;
|
//flowcontrol:=exceptionstate.oldflowcontrol;
|
||||||
cexceptionstatehandler.end_try_block(current_asmdata.CurrAsmList,tek_except,excepttemps,trystate,nil);
|
cexceptionstatehandler.end_try_block(current_asmdata.CurrAsmList,tek_except,excepttemps,trystate,nil);
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,1));
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
|
||||||
|
thlcgwasm(hlcg).decblock;
|
||||||
|
|
||||||
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_clear_exception_flag',[],nil).resetiftemp;
|
||||||
|
thlcgwasm(hlcg).raiseBr:=oldRaiseBr;
|
||||||
|
|
||||||
flowcontrol:=[fc_inflowcontrol]+trystate.oldflowcontrol*[fc_catching_exceptions];
|
flowcontrol:=[fc_inflowcontrol]+trystate.oldflowcontrol*[fc_catching_exceptions];
|
||||||
{ on statements }
|
{ on statements }
|
||||||
if assigned(right) then
|
//if assigned(right) then
|
||||||
secondpass(right);
|
// secondpass(right);
|
||||||
|
|
||||||
afteronflowcontrol:=flowcontrol;
|
afteronflowcontrol:=flowcontrol;
|
||||||
|
|
||||||
@ -626,19 +638,28 @@ implementation
|
|||||||
flowcontrol+
|
flowcontrol+
|
||||||
afteronflowcontrol;
|
afteronflowcontrol;
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
|
||||||
//thlcgwasm(hlcg).incblock;
|
thlcgwasm(hlcg).incblock;
|
||||||
|
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
|
||||||
|
thlcgwasm(hlcg).incblock;
|
||||||
|
oldRaiseBr:=thlcgwasm(hlcg).raiseBr;
|
||||||
|
thlcgwasm(hlcg).raiseBr:=thlcgwasm(hlcg).br_blocks;
|
||||||
|
|
||||||
secondpass(t1);
|
secondpass(t1);
|
||||||
|
|
||||||
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_doneexception',[],nil).resetiftemp;
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_doneexception',[],nil).resetiftemp;
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,1));
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
|
||||||
|
thlcgwasm(hlcg).decblock;
|
||||||
|
|
||||||
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_clear_exception_flag',[],nil).resetiftemp;
|
||||||
|
thlcgwasm(hlcg).raiseBr:=oldRaiseBr;
|
||||||
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
|
||||||
//thlcgwasm(hlcg).decblock;
|
thlcgwasm(hlcg).decblock;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -648,17 +669,18 @@ implementation
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_const(a_rethrow,0));
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_reraise',[],nil).resetiftemp;
|
||||||
doobjectdestroyandreraisestate.newflowcontrol:=afteronflowcontrol;
|
doobjectdestroyandreraisestate.newflowcontrol:=afteronflowcontrol;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
|
||||||
//thlcgwasm(hlcg).decblock;
|
thlcgwasm(hlcg).decblock;
|
||||||
|
|
||||||
errorexit:
|
errorexit:
|
||||||
{ return all used control flow statements }
|
{ return all used control flow statements }
|
||||||
flowcontrol:=trystate.oldflowcontrol+(doobjectdestroyandreraisestate.newflowcontrol +
|
flowcontrol:=trystate.oldflowcontrol+(doobjectdestroyandreraisestate.newflowcontrol +
|
||||||
trystate.newflowcontrol - [fc_inflowcontrol,fc_catching_exceptions]);
|
trystate.newflowcontrol - [fc_inflowcontrol,fc_catching_exceptions]);
|
||||||
|
thlcgwasm(hlcg).raiseBr:=oldRaiseBr;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure twasmtryexceptnode.pass_generate_code;
|
procedure twasmtryexceptnode.pass_generate_code;
|
||||||
|
Loading…
Reference in New Issue
Block a user