UnicodeArrayNodesGroup.ts 2.2 KB

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