CustomNodesModule.ts 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import { InversifyContainerFacade } from '../../InversifyContainerFacade';
  2. import { ContainerModule, interfaces } from 'inversify';
  3. import { ServiceIdentifiers } from '../../ServiceIdentifiers';
  4. import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
  5. import { ICustomNodeGroup } from '../../../interfaces/custom-nodes/ICustomNodeGroup';
  6. import { ControlFlowCustomNode } from "../../../enums/custom-nodes/ControlFlowCustomNode";
  7. import { CustomNode } from '../../../enums/custom-nodes/CustomNode';
  8. import { CustomNodeGroup } from '../../../enums/custom-nodes/CustomNodeGroup';
  9. import { ConsoleOutputCustomNodeGroup } from '../../../custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup';
  10. import { DebugProtectionCustomNodeGroup } from '../../../custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup';
  11. import { DomainLockCustomNodeGroup } from '../../../custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup';
  12. import { SelfDefendingCustomNodeGroup } from '../../../custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup';
  13. import { StringArrayCustomNodeGroup } from '../../../custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup';
  14. import { BinaryExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode';
  15. import { BlockStatementControlFlowFlatteningNode } from '../../../custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode';
  16. import { CallExpressionControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode';
  17. import { CallExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode';
  18. import { ControlFlowStorageNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode';
  19. import { ConsoleOutputDisableExpressionNode } from '../../../custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode';
  20. import { DebugProtectionFunctionCallNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode';
  21. import { DebugProtectionFunctionIntervalNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode';
  22. import { DebugProtectionFunctionNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode';
  23. import { DomainLockNode } from '../../../custom-nodes/domain-lock-nodes/DomainLockNode';
  24. import { ExpressionWithOperatorControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode';
  25. import { LogicalExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode';
  26. import { NodeCallsControllerFunctionNode } from '../../../custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode';
  27. import { SelfDefendingUnicodeNode } from '../../../custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode';
  28. import { StringArrayCallsWrapper } from '../../../custom-nodes/string-array-nodes/StringArrayCallsWrapper';
  29. import { StringArrayNode } from '../../../custom-nodes/string-array-nodes/StringArrayNode';
  30. import { StringArrayRotateFunctionNode } from '../../../custom-nodes/string-array-nodes/StringArrayRotateFunctionNode';
  31. import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode';
  32. import { StringLiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/StringLiteralNode';
  33. export const customNodesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
  34. // custom nodes
  35. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  36. .to(ConsoleOutputDisableExpressionNode)
  37. .whenTargetNamed(CustomNode.ConsoleOutputDisableExpressionNode);
  38. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  39. .to(DebugProtectionFunctionCallNode)
  40. .whenTargetNamed(CustomNode.DebugProtectionFunctionCallNode);
  41. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  42. .to(DebugProtectionFunctionIntervalNode)
  43. .whenTargetNamed(CustomNode.DebugProtectionFunctionIntervalNode);
  44. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  45. .to(DebugProtectionFunctionNode)
  46. .whenTargetNamed(CustomNode.DebugProtectionFunctionNode);
  47. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  48. .to(DomainLockNode)
  49. .whenTargetNamed(CustomNode.DomainLockNode);
  50. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  51. .to(NodeCallsControllerFunctionNode)
  52. .whenTargetNamed(CustomNode.NodeCallsControllerFunctionNode);
  53. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  54. .to(SelfDefendingUnicodeNode)
  55. .whenTargetNamed(CustomNode.SelfDefendingUnicodeNode);
  56. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  57. .to(StringArrayCallsWrapper)
  58. .whenTargetNamed(CustomNode.StringArrayCallsWrapper);
  59. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  60. .to(StringArrayNode)
  61. .whenTargetNamed(CustomNode.StringArrayNode);
  62. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  63. .to(StringArrayRotateFunctionNode)
  64. .whenTargetNamed(CustomNode.StringArrayRotateFunctionNode);
  65. // control flow custom nodes
  66. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  67. .toConstructor(BinaryExpressionFunctionNode)
  68. .whenTargetNamed(ControlFlowCustomNode.BinaryExpressionFunctionNode);
  69. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  70. .toConstructor(BlockStatementControlFlowFlatteningNode)
  71. .whenTargetNamed(ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);
  72. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  73. .toConstructor(CallExpressionControlFlowStorageCallNode)
  74. .whenTargetNamed(ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode);
  75. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  76. .toConstructor(CallExpressionFunctionNode)
  77. .whenTargetNamed(ControlFlowCustomNode.CallExpressionFunctionNode);
  78. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  79. .toConstructor(ControlFlowStorageNode)
  80. .whenTargetNamed(ControlFlowCustomNode.ControlFlowStorageNode);
  81. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  82. .toConstructor(ExpressionWithOperatorControlFlowStorageCallNode)
  83. .whenTargetNamed(ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode);
  84. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  85. .toConstructor(LogicalExpressionFunctionNode)
  86. .whenTargetNamed(ControlFlowCustomNode.LogicalExpressionFunctionNode);
  87. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  88. .toConstructor(StringLiteralNode)
  89. .whenTargetNamed(ControlFlowCustomNode.StringLiteralNode);
  90. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  91. .toConstructor(StringLiteralControlFlowStorageCallNode)
  92. .whenTargetNamed(ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode);
  93. // node groups
  94. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  95. .to(ConsoleOutputCustomNodeGroup)
  96. .whenTargetNamed(CustomNodeGroup.ConsoleOutputCustomNodeGroup);
  97. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  98. .to(DebugProtectionCustomNodeGroup)
  99. .whenTargetNamed(CustomNodeGroup.DebugProtectionCustomNodeGroup);
  100. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  101. .to(DomainLockCustomNodeGroup)
  102. .whenTargetNamed(CustomNodeGroup.DomainLockCustomNodeGroup);
  103. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  104. .to(SelfDefendingCustomNodeGroup)
  105. .whenTargetNamed(CustomNodeGroup.SelfDefendingCustomNodeGroup);
  106. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  107. .to(StringArrayCustomNodeGroup)
  108. .whenTargetNamed(CustomNodeGroup.StringArrayCustomNodeGroup);
  109. // customNode factory
  110. bind<ICustomNode>(ServiceIdentifiers.Factory__ICustomNode)
  111. .toFactory<ICustomNode>(InversifyContainerFacade
  112. .getFactory<CustomNode, ICustomNode>(ServiceIdentifiers.ICustomNode));
  113. // control flow storage customNode constructor factory
  114. bind<ICustomNode>(ServiceIdentifiers.Factory__IControlFlowCustomNode)
  115. .toFactory<ICustomNode>(InversifyContainerFacade
  116. .getConstructorFactory<ControlFlowCustomNode, ICustomNode>(
  117. ServiceIdentifiers.Newable__ICustomNode,
  118. ServiceIdentifiers.IRandomGenerator,
  119. ServiceIdentifiers.IOptions
  120. ));
  121. // customNodeGroup factory
  122. bind<ICustomNodeGroup>(ServiceIdentifiers.Factory__ICustomNodeGroup)
  123. .toFactory<ICustomNodeGroup>(InversifyContainerFacade
  124. .getFactory<CustomNodeGroup, ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup));
  125. });