(
this: Parser,
body: N.Statement[],
directives: N.Directive[] | undefined | null,
topLevel: boolean,
end: TokenType,
afterBlockParse?: (hasStrictModeDirective: boolean) => void,
)
| 1281 | // https://tc39.es/ecma262/#prod-Block |
| 1282 | // https://tc39.es/ecma262/#prod-ModuleBody |
| 1283 | parseBlockOrModuleBlockBody( |
| 1284 | this: Parser, |
| 1285 | body: N.Statement[], |
| 1286 | directives: N.Directive[] | undefined | null, |
| 1287 | topLevel: boolean, |
| 1288 | end: TokenType, |
| 1289 | afterBlockParse?: (hasStrictModeDirective: boolean) => void, |
| 1290 | ): void { |
| 1291 | const oldStrict = this.state.strict; |
| 1292 | let hasStrictModeDirective = false; |
| 1293 | let parsedNonDirective = false; |
| 1294 | |
| 1295 | while (!this.match(end)) { |
| 1296 | const stmt = topLevel |
| 1297 | ? this.parseModuleItem() |
| 1298 | : this.parseStatementListItem(); |
| 1299 | |
| 1300 | if (directives && !parsedNonDirective) { |
| 1301 | if (this.isValidDirective(stmt)) { |
| 1302 | const directive = this.stmtToDirective(stmt); |
| 1303 | directives.push(directive); |
| 1304 | |
| 1305 | if ( |
| 1306 | !hasStrictModeDirective && |
| 1307 | directive.value.value === "use strict" |
| 1308 | ) { |
| 1309 | hasStrictModeDirective = true; |
| 1310 | this.setStrict(true); |
| 1311 | } |
| 1312 | |
| 1313 | continue; |
| 1314 | } |
| 1315 | parsedNonDirective = true; |
| 1316 | // clear strict errors since the strict mode will not change within the block |
| 1317 | this.state.strictErrors.clear(); |
| 1318 | } |
| 1319 | body.push(stmt); |
| 1320 | } |
| 1321 | |
| 1322 | afterBlockParse?.call(this, hasStrictModeDirective); |
| 1323 | |
| 1324 | if (!oldStrict) { |
| 1325 | this.setStrict(false); |
| 1326 | } |
| 1327 | |
| 1328 | this.next(); |
| 1329 | } |
| 1330 | |
| 1331 | // Parse a regular `for` loop. The disambiguation code in |
| 1332 | // `parseStatement` will already have parsed the init statement or |
nothing calls this directly
no test coverage detected