1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import * as format from 'string-template';
- import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement';
- import { TObfuscationEvent } from '../../types/TObfuscationEvent';
- import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
- import { IOptions } from '../../interfaces/IOptions';
- import { IStorage } from '../../interfaces/IStorage';
- import { ObfuscationEvents } from '../../enums/ObfuscationEvents';
- import { ControlFlowStorageTemplate } from '../../templates/custom-nodes/control-flow-storage-nodes/ControlFlowStorageTemplate';
- import { AbstractCustomNode } from '../AbstractCustomNode';
- import { NodeAppender } from '../../node/NodeAppender';
- export class ControlFlowStorageNode extends AbstractCustomNode {
- /**
- * @type {TObfuscationEvent}
- */
- protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.AfterObfuscation;
- /**
- * @type {IStorage <ICustomNode>}
- */
- private controlFlowStorage: IStorage <ICustomNode>;
- /**
- * @type {string}
- */
- private controlFlowStorageName: string;
- /**
- * @param controlFlowStorage
- * @param controlFlowStorageName
- * @param options
- */
- constructor (
- controlFlowStorage: IStorage <ICustomNode>,
- controlFlowStorageName: string,
- options: IOptions
- ) {
- super(options);
- this.controlFlowStorage = controlFlowStorage;
- this.controlFlowStorageName = controlFlowStorageName;
- }
- /**
- * @param blockScopeNode
- */
- public appendNode (blockScopeNode: TNodeWithBlockStatement): void {
- NodeAppender.prependNode(blockScopeNode, this.getNode());
- }
- /**
- * @returns {string}
- */
- public getCode (): string {
- return format(ControlFlowStorageTemplate(), {
- controlFlowStorage: this.controlFlowStorage.toString(),
- controlFlowStorageName: this.controlFlowStorageName
- });
- }
- }
|