import type { Brand } from "../util/brand"; import type { ClassDeclaration } from "./class"; import type { VariableDeclaration } from "./declaration"; import type { DeclarableExpression, Expression } from "./expression"; import type { FunctionDeclaration } from "./function"; import type { LabelIdentifier } from "./identifier"; import type { DeclarablePattern, Pattern } from "./pattern"; export type Statement = | ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | VariableDeclaration | FunctionDeclaration | ClassDeclaration; export type SwitchCase = X & { type: "SwitchCase"; test: Expression | null; consequent: Statement[]; }; export type CatchClause = X & { type: "CatchClause"; param: Pattern | null; body: BlockStatement; }; export type EmptyStatement = X & { type: "EmptyStatement"; }; export type BlockStatement = X & { type: "BlockStatement"; body: Statement[]; }; export type Directive = Brand; export type ExpressionStatement = X & { type: "ExpressionStatement"; expression: Expression; directive: Directive | null; }; export type IfStatement = X & { type: "IfStatement"; test: Expression; consequent: Statement; alternate: Statement | null; }; export type LabeledStatement = X & { type: "LabeledStatement"; label: LabelIdentifier; body: Statement; }; export type BreakStatement = X & { type: "BreakStatement"; label: LabelIdentifier | null; }; export type ContinueStatement = X & { type: "ContinueStatement"; label: LabelIdentifier | null; }; export type WithStatement = X & { type: "WithStatement"; object: Expression; body: Statement; }; export type SwitchStatement = X & { type: "SwitchStatement"; discriminant: Expression; cases: SwitchCase[]; }; export type ReturnStatement = X & { type: "ReturnStatement"; argument: Expression | null; }; export type ThrowStatement = X & { type: "ThrowStatement"; argument: Expression; }; export type TryStatement = X & { type: "TryStatement"; block: BlockStatement; handler: CatchClause | null; finalizer: BlockStatement | null; }; export type WhileStatement = X & { type: "WhileStatement"; test: Expression; body: Statement; }; export type DoWhileStatement = X & { type: "DoWhileStatement"; body: Statement; test: Expression; }; export type ForStatement = X & { type: "ForStatement"; init: DeclarableExpression | null; test: Expression | null; update: Expression | null; body: Statement; }; export type ForInStatement = X & { type: "ForInStatement"; left: DeclarablePattern; right: Expression; body: Statement; }; export type ForOfStatement = X & { type: "ForOfStatement"; await: boolean | null; left: DeclarablePattern; right: Expression; body: Statement; }; export type DebuggerStatement = X & { type: "DebuggerStatement"; };