From 334ea46b44eae63a9fdff984a584c4423770477d Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Sat, 18 Sep 2021 02:48:51 +0300 Subject: [PATCH] * cloned twasmraisenode.pass_1_no_exceptions into twasmraisenode.pass_1_native_exceptions --- compiler/wasm32/nwasmflw.pas | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/compiler/wasm32/nwasmflw.pas b/compiler/wasm32/nwasmflw.pas index b8f6c92a54..c59276cab8 100644 --- a/compiler/wasm32/nwasmflw.pas +++ b/compiler/wasm32/nwasmflw.pas @@ -54,6 +54,7 @@ interface twasmraisenode = class(tcgraisenode) private function pass_1_no_exceptions : tnode; + function pass_1_native_exceptions : tnode; public function pass_1 : tnode;override; end; @@ -281,10 +282,69 @@ implementation end; + function twasmraisenode.pass_1_native_exceptions : tnode; + var + statements : tstatementnode; + //current_addr : tlabelnode; + raisenode : tcallnode; + begin + result:=internalstatements(statements); + + if assigned(left) then + begin + { first para must be a class } + firstpass(left); + { insert needed typeconvs for addr,frame } + if assigned(right) then + begin + { addr } + firstpass(right); + { frame } + if assigned(third) then + firstpass(third) + else + third:=cpointerconstnode.Create(0,voidpointertype); + end + else + begin + third:=cinlinenode.create(in_get_frame,false,nil); + //current_addr:=clabelnode.create(cnothingnode.create,clabelsym.create('$raiseaddr')); + //addstatement(statements,current_addr); + //right:=caddrnode.create(cloadnode.create(current_addr.labsym,current_addr.labsym.owner)); + right:=cnilnode.create; + + { raise address off by one so we are for sure inside the action area for the raise } + if tf_use_psabieh in target_info.flags then + right:=caddnode.create_internal(addn,right,cordconstnode.create(1,sizesinttype,false)); + end; + + raisenode:=ccallnode.createintern('fpc_raiseexception', + ccallparanode.create(third, + ccallparanode.create(right, + ccallparanode.create(left,nil))) + ); + include(raisenode.callnodeflags,cnf_call_never_returns); + addstatement(statements,raisenode); + end + else + begin + addstatement(statements,ccallnode.createintern('fpc_popaddrstack',nil)); + raisenode:=ccallnode.createintern('fpc_reraise',nil); + include(raisenode.callnodeflags,cnf_call_never_returns); + addstatement(statements,raisenode); + end; + left:=nil; + right:=nil; + third:=nil; + end; + + function twasmraisenode.pass_1 : tnode; begin if ts_wasm_no_exceptions in current_settings.targetswitches then result:=pass_1_no_exceptions + else if ts_wasm_native_exceptions in current_settings.targetswitches then + result:=pass_1_native_exceptions else result:=inherited; end;