From d55c7819cb1046ea3760cf53770885f0e2b1785c Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Tue, 13 Jun 2023 09:56:44 +0300 Subject: [PATCH] + also allow declaring an external as 'suspending first' --- compiler/pdecsub.pas | 4 +++- compiler/tokens.pas | 2 ++ tests/test/wasm/tjspromise1a.pp | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/test/wasm/tjspromise1a.pp diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index 593cbce1b6..ccf20659c6 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -2406,7 +2406,9 @@ begin consume(_SUSPENDING); include(procoptions,po_wasm_suspending); synthetickind:=tsk_wasm_suspending; - if idtoken=_LAST then + if idtoken=_FIRST then + consume(_FIRST) + else if idtoken=_LAST then begin consume(_LAST); synthetickind:=tsk_wasm_suspending_last; diff --git a/compiler/tokens.pas b/compiler/tokens.pas index 692e144959..adb2fc61be 100644 --- a/compiler/tokens.pas +++ b/compiler/tokens.pas @@ -163,6 +163,7 @@ type _EQUAL, _FAR16, _FINAL, + _FIRST, _INDEX, _LABEL, _LOCAL, @@ -509,6 +510,7 @@ const (str:'EQUAL' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name } (str:'FAR16' ;special:false;keyword:[m_none];op:NOTOKEN), (str:'FINAL' ;special:false;keyword:[m_none];op:NOTOKEN), + (str:'FIRST' ;special:false;keyword:[m_none];op:NOTOKEN), (str:'INDEX' ;special:false;keyword:[m_none];op:NOTOKEN), (str:'LABEL' ;special:false;keyword:alllanguagemodes;op:NOTOKEN), (str:'LOCAL' ;special:false;keyword:[m_none];op:NOTOKEN), diff --git a/tests/test/wasm/tjspromise1a.pp b/tests/test/wasm/tjspromise1a.pp new file mode 100644 index 0000000000..8fcd3a017f --- /dev/null +++ b/tests/test/wasm/tjspromise1a.pp @@ -0,0 +1,34 @@ +{ %cpu=wasm32 } +{ %norun } + +library tjspromise1; + +var + state: double; + +function init_state: double; external 'js'; +function compute_delta: double; external 'js' suspending first; + +procedure init; +begin + state := init_state; +end; + +function get_state: double; +begin + get_state := state; +end; + +function update_state: double; +begin + state := state + compute_delta; + update_state := state; +end; + +exports + get_state, + update_state promising; + +begin + init; +end.