(
this: Parser,
program: Undone<N.Program>,
end: TokenType,
sourceType: N.Program["sourceType"],
)
| 112 | } |
| 113 | |
| 114 | parseProgram( |
| 115 | this: Parser, |
| 116 | program: Undone<N.Program>, |
| 117 | end: TokenType, |
| 118 | sourceType: N.Program["sourceType"], |
| 119 | ): N.Program { |
| 120 | program.sourceType = sourceType; |
| 121 | program.interpreter = this.parseInterpreterDirective(); |
| 122 | this.parseBlockBody(program, true, true, end); |
| 123 | if (this.inModule) { |
| 124 | if ( |
| 125 | !(this.optionFlags & OptionFlags.AllowUndeclaredExports) && |
| 126 | this.scope.undefinedExports.size > 0 |
| 127 | ) { |
| 128 | for (const [localName, at] of Array.from(this.scope.undefinedExports)) { |
| 129 | this.raise(Errors.ModuleExportUndefined, at, { localName }); |
| 130 | } |
| 131 | } |
| 132 | this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait); |
| 133 | } |
| 134 | let finishedProgram: N.Program; |
| 135 | if (end === tt.eof) { |
| 136 | // finish at eof for top level program |
| 137 | finishedProgram = this.finishNode(program, "Program"); |
| 138 | } else { |
| 139 | // finish immediately before the end token |
| 140 | finishedProgram = this.finishNodeAt( |
| 141 | program, |
| 142 | "Program", |
| 143 | createPositionWithColumnOffset(this.state.startLoc, -1), |
| 144 | ); |
| 145 | } |
| 146 | return finishedProgram; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * cast a Statement to a Directive. This method mutates input statement. |
nothing calls this directly
no test coverage detected