@@ -931,32 +931,35 @@ function makeRetainedCompilerSettings() {
931
931
const WASM_PAGE_SIZE = 65536 ;
932
932
933
933
// Receives a function as text, and a function that constructs a modified
934
- // function, to which we pass the parsed-out name, arguments, and body of the
935
- // function. Returns the output of that function.
934
+ // function, to which we pass the parsed-out name, arguments, body, and possible
935
+ // "async" prefix of the input function. Returns the output of that function.
936
936
function modifyFunction ( text , func ) {
937
937
// Match a function with a name.
938
- let match = text . match ( / ^ \s * f u n c t i o n \s + ( [ ^ ( ] * ) ? \s * \( ( [ ^ ) ] * ) \) / ) ;
938
+ let match = text . match ( / ^ \s * ( a s y n c \s + ) ? f u n c t i o n \s + ( [ ^ ( ] * ) ? \s * \( ( [ ^ ) ] * ) \) / ) ;
939
+ let async_ ;
939
940
let names ;
940
941
let args ;
941
942
let rest ;
942
943
if ( match ) {
943
- name = match [ 1 ] ;
944
- args = match [ 2 ] ;
944
+ async_ = match [ 1 ] || '' ;
945
+ name = match [ 2 ] ;
946
+ args = match [ 3 ] ;
945
947
rest = text . substr ( match [ 0 ] . length ) ;
946
948
} else {
947
949
// Match a function without a name (we could probably use a single regex
948
950
// for both, but it would be more complex).
949
- match = text . match ( / ^ \s * f u n c t i o n \( ( [ ^ ) ] * ) \) / ) ;
951
+ match = text . match ( / ^ \s * ( a s y n c \s + ) ? f u n c t i o n \( ( [ ^ ) ] * ) \) / ) ;
950
952
assert ( match , 'could not match function ' + text + '.' ) ;
951
953
name = '' ;
952
- args = match [ 1 ] ;
954
+ async_ = match [ 1 ] || '' ;
955
+ args = match [ 2 ] ;
953
956
rest = text . substr ( match [ 0 ] . length ) ;
954
957
}
955
958
const bodyStart = rest . indexOf ( '{' ) ;
956
959
assert ( bodyStart >= 0 ) ;
957
960
const bodyEnd = rest . lastIndexOf ( '}' ) ;
958
961
assert ( bodyEnd > 0 ) ;
959
- return func ( name , args , rest . substring ( bodyStart + 1 , bodyEnd ) ) ;
962
+ return func ( name , args , rest . substring ( bodyStart + 1 , bodyEnd ) , async_ ) ;
960
963
}
961
964
962
965
function runOnMainThread ( text ) {
0 commit comments