ControlFlowFlatteningThresholdRule.ts 664 B

1234567891011121314151617181920
  1. import { TInputOptions } from '../../types/options/TInputOptions';
  2. import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule';
  3. import { IOptions } from '../../interfaces/options/IOptions';
  4. const DISABLED_CONTROL_FLOW_FLATTENING_OPTIONS: TInputOptions = {
  5. controlFlowFlattening: false,
  6. controlFlowFlatteningThreshold: 0
  7. };
  8. export const ControlFlowFlatteningThresholdRule: TOptionsNormalizerRule = (options: IOptions): IOptions => {
  9. if (options.controlFlowFlatteningThreshold === 0) {
  10. options = {
  11. ...options,
  12. ...DISABLED_CONTROL_FLOW_FLATTENING_OPTIONS
  13. };
  14. }
  15. return options;
  16. };