@specs-feup/clava
Version:
A C/C++ source-to-source compiler written in Typescript
42 lines • 1.83 kB
TypeScript
import { BinaryOp, Call, DeclStmt, ExprStmt, Expression, ReturnStmt, Statement, TernaryOp, UnaryOp } from "../../Joinpoints.js";
import DecomposeResult from "./DecomposeResult.js";
/**
* Decomposes complex statements into several simpler ones.
*/
export default class StatementDecomposer {
tempPrefix: string;
startIndex: number;
constructor(tempPrefix?: string, startIndex?: number);
private newTempVarname;
/**
* Some Joinpoints might generate invalid code under certain conditions. This method checks
* for those cases and adds an empty statement to the AST to fix them.
*
* @param $jp - Joinpoint to be scrutinized
*/
private ensureValidNode;
/**
* If the given statement can be decomposed in two or more statements, replaces the statement with the decomposition.
*
* @param $stmt - A statement that will be decomposed.
*/
decomposeAndReplace($stmt: Statement): void;
/**
* @param $stmt - A statement that will be decomposed.
* @returns An array with the new statements, or an empty array if no decomposition could be made
*/
decompose($stmt: Statement): Statement[];
decomposeStmt($stmt: Statement): Statement[];
decomposeExprStmt($stmt: ExprStmt): Statement[];
decomposeReturnStmt($stmt: ReturnStmt): Statement[];
decomposeDeclStmt($stmt: DeclStmt): Statement[];
private decomposeDecl;
decomposeExpr($expr: Expression): DecomposeResult;
decomposeCall($call: Call): DecomposeResult;
private copyCall;
decomposeBinaryOp($binaryOp: BinaryOp): DecomposeResult;
decomposeAssignment($assign: BinaryOp): DecomposeResult;
decomposeTernaryOp($ternaryOp: TernaryOp): DecomposeResult;
decomposeUnaryOp($unaryOp: UnaryOp): DecomposeResult;
}
//# sourceMappingURL=StatementDecomposer.d.ts.map