forked from rollup/rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThrowStatement.ts
27 lines (23 loc) · 935 Bytes
/
ThrowStatement.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type MagicString from 'magic-string';
import type { RenderOptions } from '../../utils/renderHelpers';
import { type InclusionContext } from '../ExecutionContext';
import type * as NodeType from './NodeType';
import { type ExpressionNode, type IncludeChildren, StatementBase } from './shared/Node';
export default class ThrowStatement extends StatementBase {
declare argument: ExpressionNode;
declare type: NodeType.tThrowStatement;
hasEffects(): boolean {
return true;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.argument.include(context, includeChildrenRecursively);
context.brokenFlow = true;
}
render(code: MagicString, options: RenderOptions): void {
this.argument.render(code, options, { preventASI: true });
if (this.argument.start === this.start + 5 /* 'throw'.length */) {
code.prependLeft(this.start + 5, ' ');
}
}
}