1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import { injectable, inject } from 'inversify';
- import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
- import * as format from 'string-template';
- import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement';
- import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent';
- import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
- import { IOptions } from '../../interfaces/options/IOptions';
- import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData';
- import { IStorage } from '../../interfaces/storages/IStorage';
- import { ObfuscationEvents } from '../../enums/ObfuscationEvents';
- import { initializable } from '../../decorators/Initializable';
- import { ControlFlowStorageTemplate } from '../../templates/custom-nodes/control-flow-storage-nodes/ControlFlowStorageTemplate';
- import { AbstractCustomNode } from '../AbstractCustomNode';
- import { NodeAppender } from '../../node/NodeAppender';
- @injectable()
- export class ControlFlowStorageNode extends AbstractCustomNode {
- /**
- * @type {TObfuscationEvent}
- */
- protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.AfterObfuscation;
- /**
- * @type {IStorage <ICustomNode>}
- */
- @initializable()
- private controlFlowStorage: IStorage <ICustomNode>;
- /**
- * @type {string}
- */
- @initializable()
- private controlFlowStorageName: string;
- /**
- * @param options
- */
- constructor (
- @inject(ServiceIdentifiers.IOptions) options: IOptions
- ) {
- super(options);
- }
- /**
- * @param controlFlowStorage
- * @param controlFlowStorageName
- */
- public initialize (controlFlowStorage: IStorage <ICustomNode>, controlFlowStorageName: string): void {
- this.controlFlowStorage = controlFlowStorage;
- this.controlFlowStorageName = controlFlowStorageName;
- }
- /**
- * @param blockScopeNode
- * @param stackTraceData
- */
- public appendNode (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
- NodeAppender.prependNode(blockScopeNode, this.getNode());
- }
- /**
- * @returns {string}
- */
- public getCode (): string {
- return format(ControlFlowStorageTemplate(), {
- controlFlowStorage: this.controlFlowStorage.toString(),
- controlFlowStorageName: this.controlFlowStorageName
- });
- }
- }
|