@@ -931,32 +931,35 @@ function makeRetainedCompilerSettings() {
931931const WASM_PAGE_SIZE = 65536 ;
932932
933933// 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.
936936function modifyFunction ( text , func ) {
937937 // 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_ ;
939940 let names ;
940941 let args ;
941942 let rest ;
942943 if ( match ) {
943- name = match [ 1 ] ;
944- args = match [ 2 ] ;
944+ async_ = match [ 1 ] || '' ;
945+ name = match [ 2 ] ;
946+ args = match [ 3 ] ;
945947 rest = text . substr ( match [ 0 ] . length ) ;
946948 } else {
947949 // Match a function without a name (we could probably use a single regex
948950 // 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 \( ( [ ^ ) ] * ) \) / ) ;
950952 assert ( match , 'could not match function ' + text + '.' ) ;
951953 name = '' ;
952- args = match [ 1 ] ;
954+ async_ = match [ 1 ] || '' ;
955+ args = match [ 2 ] ;
953956 rest = text . substr ( match [ 0 ] . length ) ;
954957 }
955958 const bodyStart = rest . indexOf ( '{' ) ;
956959 assert ( bodyStart >= 0 ) ;
957960 const bodyEnd = rest . lastIndexOf ( '}' ) ;
958961 assert ( bodyEnd > 0 ) ;
959- return func ( name , args , rest . substring ( bodyStart + 1 , bodyEnd ) ) ;
962+ return func ( name , args , rest . substring ( bodyStart + 1 , bodyEnd ) , async_ ) ;
960963}
961964
962965function runOnMainThread ( text ) {
0 commit comments