UNPKG

@specs-feup/clava

Version:

A C/C++ source-to-source compiler written in Typescript

76 lines 2.89 kB
import { Call, ExprStmt, Expression, FunctionJp } from "../../Joinpoints.js"; export interface InlinerOptions { prefix?: string; } type InlineData = { type: "assignment"; $target: Expression; $call: Call; } | { type: "call"; $target: undefined; $call: Call; }; export default class Inliner { private options; private variableIndex; private labelNumber; /** * * @param options - Object with options. Supported options: 'prefix' (default: "__inline"), the prefix that will be used in the name of variables inserted by the Inliner */ constructor(options?: InlinerOptions); private getInlinedVarName; private hasCycle; inlineFunctionTree($function: FunctionJp, _visited?: Set<string>): boolean; private getInitStmts; /** * * @param $exprStmt - * @returns An object with the properties below or undefined if this exprStmt cannot be inlined. * Only exprStmt that are an isolated call, or that are an assignment with a single call * in the right-hand side can be inlined. * * - type: a string with either the value 'call' or 'assign', indicating the type of inlining * that can be applied to the given exprStmt. * - $target: if the type is 'assign', contains the left-hand side of the assignment. Otherwise, is undefined. * - $call: the call to be inlined * */ private extractInlineData; /** * Check if the given $exprStmt can be inlined or not. If it can, returns an object with information important for inlining, * otherwise returns undefined. * * A call can be inline if the following rules apply: * - The exprStmt is an isolated call, or an assignment with a single call in the right-hand side. * - The call has a definition/implementation available. * - The call is not a function that is part of the system headers. * * @param $exprStmt - * @returns An object with the properties below or undefined if this exprStmt cannot be inlined. * * - type: a string with either the value 'call' or 'assign', indicating the type of inlining * that can be applied to the given exprStmt. * - $target: if the type is 'assign', contains the left-hand side of the assignment. Otherwise, is undefined. * - $call: the call to be inlined * */ checkInline($exprStmt: ExprStmt): InlineData | undefined; inline($exprStmt: ExprStmt): boolean; private inlinePrivate; private processBodyToInline; /** * Labels need to be renamed, to avoid duplicated labels. */ private renameLabels; static LABEL_PREFIX_REGEX: RegExp; private createNewLabelName; private updateVarDecls; private updateVarrefs; private updateVarrefsInTypes; private updateType; private updateVarRef; } export {}; //# sourceMappingURL=Inliner.d.ts.map