Selaa lähdekoodia

+ emit a catch instruction in the try/end_try block, generated for
try..finally in native wasm exceptions mode

Nikolay Nikolov 3 vuotta sitten
vanhempi
commit
87702b58c5
2 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 1 1
      compiler/wasm32/itcpugas.pas
  2. 6 1
      compiler/wasm32/nwasmflw.pas

+ 1 - 1
compiler/wasm32/itcpugas.pas

@@ -84,7 +84,7 @@ interface
       // additional memory
       'memory.grow 0', 'memory.size 0',
       // exceptions
-      'try','catch','catch_all','delegate','throw','rethrow','end_try'
+      'try','catch __FPC_exception','catch_all','delegate','throw','rethrow','end_try'
     );
 
     gas_wasm_basic_type_str : array [TWasmBasicType] of string = ('i32','i64','f32','f64');

+ 6 - 1
compiler/wasm32/nwasmflw.pas

@@ -627,9 +627,14 @@ implementation
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
         current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,4)); // jump to the 'finally' section
 
+        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_catch));
+        thlcgwasm(hlcg).decblock;
+        { exceptionreason:=1 (exception) }
+        hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);
+        current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,3)); // jump to the 'finally' section
+
         { exit the inner 'try..end_try' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));