UnicodeArrayNodesGroup.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { IOptions } from "../interfaces/IOptions";
  2. import { NodesGroup } from './NodesGroup';
  3. import { UnicodeArrayCallsWrapper } from "../custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper";
  4. import { UnicodeArrayDecodeNode } from "../custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode";
  5. import { UnicodeArrayNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayNode';
  6. import { UnicodeArrayRotateFunctionNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode';
  7. import { Utils } from '../Utils';
  8. export class UnicodeArrayNodesGroup extends NodesGroup {
  9. /**
  10. * @type {string}
  11. */
  12. private unicodeArrayName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH);
  13. /**
  14. * @type {number}
  15. */
  16. private unicodeArrayRotateValue: number = Utils.getRandomInteger(100, 500);
  17. /**
  18. * @type {string}
  19. */
  20. private unicodeArrayTranslatorName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH);
  21. /**
  22. * @param options
  23. */
  24. constructor (options: IOptions = {}) {
  25. super(options);
  26. let unicodeArrayNode: UnicodeArrayNode = new UnicodeArrayNode(
  27. this.unicodeArrayName,
  28. this.unicodeArrayRotateValue
  29. ),
  30. unicodeArray: string [] = unicodeArrayNode.getNodeData();
  31. this.nodes.set(
  32. 'unicodeArrayNode',
  33. unicodeArrayNode
  34. );
  35. if (this.options['wrapUnicodeArrayCalls']) {
  36. this.nodes.set(
  37. 'unicodeArrayCallsWrapper',
  38. new UnicodeArrayCallsWrapper(
  39. this.unicodeArrayTranslatorName,
  40. this.unicodeArrayName,
  41. unicodeArray
  42. )
  43. );
  44. }
  45. if (this.options['rotateUnicodeArray']) {
  46. this.nodes.set(
  47. 'unicodeArrayRotateFunctionNode',
  48. new UnicodeArrayRotateFunctionNode(
  49. this.unicodeArrayName,
  50. unicodeArray,
  51. this.unicodeArrayRotateValue
  52. )
  53. );
  54. }
  55. if (this.options['encodeUnicodeArray']) {
  56. this.nodes.set(
  57. 'unicodeArrayDecodeNode',
  58. new UnicodeArrayDecodeNode (
  59. this.unicodeArrayName,
  60. unicodeArray
  61. )
  62. );
  63. }
  64. }
  65. }