Browse Source

+ introduced twasmexceptionstatehandler_nativeexceptions and
twasmexceptionstatehandler_jsexceptions

Nikolay Nikolov 3 years ago
parent
commit
2bcc8d65ff
1 changed files with 61 additions and 2 deletions
  1. 61 2
      compiler/wasm32/cpupi.pas

+ 61 - 2
compiler/wasm32/cpupi.pas

@@ -45,7 +45,7 @@ interface
 implementation
 
     uses
-      systems,globals,cpubase,tgcpu,aasmdata,aasmcpu,aasmtai,cgexcept,
+      systems,verbose,globals,cpubase,tgcpu,aasmdata,aasmcpu,aasmtai,cgexcept,
       tgobj,paramgr,symconst,symcpu;
 
 {*****************************************************************************
@@ -74,6 +74,58 @@ implementation
         list.Concat(tai_comment.Create(strpnew('TODO: handle_nested_exception')));
       end;
 
+{*****************************************************************************
+                     twasmexceptionstatehandler_jsexceptions
+*****************************************************************************}
+
+    type
+      twasmexceptionstatehandler_jsexceptions = 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;
+      end;
+
+    class procedure twasmexceptionstatehandler_jsexceptions.new_exception(list:TAsmList;const t:texceptiontemps; const exceptframekind: texceptframekind; out exceptstate: texceptionstate);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: new_exception')));
+      end;
+
+    class procedure twasmexceptionstatehandler_jsexceptions.free_exception(list: TAsmList; const t: texceptiontemps; const s: texceptionstate; a: aint; endexceptlabel: tasmlabel; onlyfree:boolean);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: free_exception')));
+      end;
+
+    class procedure twasmexceptionstatehandler_jsexceptions.handle_nested_exception(list:TAsmList;var t:texceptiontemps;var entrystate: texceptionstate);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: handle_nested_exception')));
+      end;
+
+{*****************************************************************************
+                     twasmexceptionstatehandler_nativeexceptions
+*****************************************************************************}
+
+    type
+      twasmexceptionstatehandler_nativeexceptions = 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;
+      end;
+
+    class procedure twasmexceptionstatehandler_nativeexceptions.new_exception(list:TAsmList;const t:texceptiontemps; const exceptframekind: texceptframekind; out exceptstate: texceptionstate);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: new_exception')));
+      end;
+
+    class procedure twasmexceptionstatehandler_nativeexceptions.free_exception(list: TAsmList; const t: texceptiontemps; const s: texceptionstate; a: aint; endexceptlabel: tasmlabel; onlyfree:boolean);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: free_exception')));
+      end;
+
+    class procedure twasmexceptionstatehandler_nativeexceptions.handle_nested_exception(list:TAsmList;var t:texceptiontemps;var entrystate: texceptionstate);
+      begin
+        list.Concat(tai_comment.Create(strpnew('TODO: handle_nested_exception')));
+      end;
+
 {*****************************************************************************
                            tcpuprocinfo
 *****************************************************************************}
@@ -86,7 +138,14 @@ implementation
 
     procedure tcpuprocinfo.setup_eh;
       begin
-        cexceptionstatehandler:=twasmexceptionstatehandler_noexceptions;
+        if ts_wasm_native_exceptions in current_settings.targetswitches then
+          cexceptionstatehandler:=twasmexceptionstatehandler_nativeexceptions
+        else if ts_wasm_js_exceptions in current_settings.targetswitches then
+          cexceptionstatehandler:=twasmexceptionstatehandler_jsexceptions
+        else if ts_wasm_no_exceptions in current_settings.targetswitches then
+          cexceptionstatehandler:=twasmexceptionstatehandler_noexceptions
+        else
+          internalerror(2021091701);
       end;
 
     procedure tcpuprocinfo.postprocess_code;