UNPKG

@specs-feup/lara

Version:

A js port of the popular framework for building source-to-source compilers

72 lines 2.58 kB
import { LaraJoinPoint } from "../../LaraJoinPoint.js"; /** * Base class that represents a code mutator. * * This should not be instantiated directly, instead it should be extended. * * @param name - the name of the mutator * */ export default abstract class Mutator { name: string; /** * True if the current code is mutated, false otherwise */ isMutated: boolean; /** * If true, before each call to .mutate() will check if the code is already mutated, * and call restore before the mutation is applied */ automaticRestore: boolean; constructor(name?: string); /** * @returns The name of this mutator */ getName(): string; /** * Enables/disables automatic restore. Is enabled by default. * * If enabled, before each call to .mutate() will check if the code is already mutated, and call restore before the mutation is applied. * * @param value - true to enable, false to disable */ setAutomaticRestore(value?: boolean): void; /** * Introduces a single mutation to the code. * If the code has been mutated already, restores the code before mutating again. * If there are no mutations left, does nothing. */ mutate(): void; /** * If the code has been mutated, restores the code to its original state. If not, does nothing. */ restore(): void; /** * @returns The number of mutations this mutator will apply */ getTotalMutantions(): number; /** * @returns True, if the Mutator still has mutations left to do, false otherwise. */ abstract hasMutations(): boolean; /** * @returns The point in the code where the mutation will occur or his occurring, or undefined if there are not more mutations left, or if this concept is not applicable to this mutator. */ abstract getMutationPoint(): LaraJoinPoint | undefined; /** * @returns The point with currently mutated code, or undefined if this concept is not applicable to this mutator. */ abstract getCurrentMutation(): LaraJoinPoint | undefined; /** * Adds a join point to this Mutator. Is only added if the Mutator can be applied over this join point, otherwise it will be ignored. */ abstract addJp($joinpoint: LaraJoinPoint): void; /** * @deprecated use getName() instead * @returns The name of this Mutator */ getType(): string; protected abstract mutatePrivate(): void; protected abstract restorePrivate(): void; } //# sourceMappingURL=Mutator.d.ts.map