Jelajahi Sumber

refactoring

sanex3339 9 tahun lalu
induk
melakukan
561ef56fed

+ 0 - 45
src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionCallNode.js

@@ -1,45 +0,0 @@
-"use strict";
-const NodeType_1 = require("../../enums/NodeType");
-const Node_1 = require('../Node');
-const NodeUtils_1 = require("../../NodeUtils");
-class UnicodeArrayRotateFunctionCallNode extends Node_1.Node {
-    constructor(unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue) {
-        super();
-        this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
-        this.unicodeArrayName = unicodeArrayName;
-        this.unicodeArrayRotateValue = unicodeArrayRotateValue;
-        this.node = this.getNodeStructure();
-    }
-    appendNode(blockScopeNode) {
-        NodeUtils_1.NodeUtils.prependNode(blockScopeNode.body, this.getNode());
-    }
-    getNodeStructure() {
-        return {
-            'type': NodeType_1.NodeType.ExpressionStatement,
-            'expression': {
-                'type': NodeType_1.NodeType.CallExpression,
-                'callee': {
-                    'type': NodeType_1.NodeType.Identifier,
-                    'name': this.unicodeArrayRotateFunctionName
-                },
-                'arguments': [
-                    {
-                        'type': NodeType_1.NodeType.Identifier,
-                        'name': this.unicodeArrayName
-                    },
-                    {
-                        'type': NodeType_1.NodeType.Literal,
-                        'value': this.unicodeArrayRotateValue,
-                        'raw': `'${this.unicodeArrayRotateValue}'`
-                    },
-                    {
-                        'type': NodeType_1.NodeType.Literal,
-                        'value': true,
-                        'raw': 'true'
-                    }
-                ]
-            }
-        };
-    }
-}
-exports.UnicodeArrayRotateFunctionCallNode = UnicodeArrayRotateFunctionCallNode;

+ 0 - 81
src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionCallNode.ts

@@ -1,81 +0,0 @@
-import { BlockScopeNode } from "../../types/BlockScopeNode";
-
-import { NodeType } from "../../enums/NodeType";
-
-import { Node } from '../Node';
-import { NodeUtils } from "../../NodeUtils";
-
-export class UnicodeArrayRotateFunctionCallNode extends Node {
-    /**
-     * @type {string}
-     */
-    private unicodeArrayName: string;
-
-    /**
-     * @type {number}
-     */
-    private unicodeArrayRotateValue: number;
-
-    /**
-     * @param {string}
-     */
-    private unicodeArrayRotateFunctionName: string;
-
-    /**
-     * @param unicodeArrayRotateFunctionName
-     * @param unicodeArrayName
-     * @param unicodeArrayRotateValue
-     */
-    constructor (
-        unicodeArrayRotateFunctionName: string,
-        unicodeArrayName: string,
-        unicodeArrayRotateValue: number
-    ) {
-        super();
-
-        this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
-        this.unicodeArrayName = unicodeArrayName;
-        this.unicodeArrayRotateValue = unicodeArrayRotateValue;
-
-        this.node = this.getNodeStructure();
-    }
-
-    /**
-     * @param blockScopeNode
-     */
-    public appendNode (blockScopeNode: BlockScopeNode): void {
-        NodeUtils.prependNode(blockScopeNode.body, this.getNode());
-    }
-
-    /**
-     * @returns any
-     */
-    protected getNodeStructure (): any {
-        return {
-            'type': NodeType.ExpressionStatement,
-            'expression': {
-                'type': NodeType.CallExpression,
-                'callee': {
-                    'type': NodeType.Identifier,
-                    'name': this.unicodeArrayRotateFunctionName
-                },
-                'arguments': [
-                    {
-                        'type': NodeType.Identifier,
-                        'name': this.unicodeArrayName
-                    },
-                    {
-                        'type': NodeType.Literal,
-                        'value': this.unicodeArrayRotateValue,
-                        'raw': `'${this.unicodeArrayRotateValue}'`
-                    },
-                    {
-                        'type': NodeType.Literal,
-                        'value': true,
-                        'raw': 'true'
-                    }
-                ]
-            }
-        };
-    }
-}

+ 232 - 216
src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.js

@@ -4,256 +4,272 @@ const Node_1 = require('../Node');
 const NodeUtils_1 = require("../../NodeUtils");
 const NodeUtils_1 = require("../../NodeUtils");
 const Utils_1 = require('../../Utils');
 const Utils_1 = require('../../Utils');
 class UnicodeArrayRotateFunctionNode extends Node_1.Node {
 class UnicodeArrayRotateFunctionNode extends Node_1.Node {
-    constructor(unicodeArrayRotateFunctionName, unicodeArrayName) {
+    constructor(unicodeArrayName, unicodeArrayRotateValue) {
         super();
         super();
-        this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
         this.unicodeArrayName = unicodeArrayName;
         this.unicodeArrayName = unicodeArrayName;
+        this.unicodeArrayRotateValue = unicodeArrayRotateValue;
         this.node = this.getNodeStructure();
         this.node = this.getNodeStructure();
     }
     }
     appendNode(blockScopeNode) {
     appendNode(blockScopeNode) {
-        NodeUtils_1.NodeUtils.appendNode(blockScopeNode.body, this.getNode());
-    }
-    getNodeIdentifier() {
-        return this.unicodeArrayRotateFunctionName;
+        NodeUtils_1.NodeUtils.prependNode(blockScopeNode.body, this.getNode());
     }
     }
     getNodeStructure() {
     getNodeStructure() {
         return {
         return {
-            'type': NodeType_1.NodeType.FunctionExpression,
-            'id': {
-                'type': NodeType_1.NodeType.Identifier,
-                'name': this.unicodeArrayRotateFunctionName
-            },
-            'params': [
-                {
-                    'type': NodeType_1.NodeType.Identifier,
-                    'name': 'array'
-                },
-                {
-                    'type': NodeType_1.NodeType.Identifier,
-                    'name': 'times'
-                },
-                {
-                    'type': NodeType_1.NodeType.Identifier,
-                    'name': 'reverse'
-                }
-            ],
-            'defaults': [],
-            'body': {
-                'type': NodeType_1.NodeType.BlockStatement,
-                'body': [
-                    {
-                        'type': NodeType_1.NodeType.IfStatement,
-                        'test': {
-                            'type': NodeType_1.NodeType.BinaryExpression,
-                            'operator': '<',
-                            'left': {
-                                'type': NodeType_1.NodeType.Identifier,
-                                'name': 'times'
-                            },
-                            'right': {
-                                'type': NodeType_1.NodeType.Literal,
-                                'value': 0,
-                                'raw': '0'
-                            }
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    'type': NodeType_1.NodeType.FunctionExpression,
+                    'id': null,
+                    'params': [
+                        {
+                            'type': NodeType_1.NodeType.Identifier,
+                            'name': 'array'
                         },
                         },
-                        'consequent': {
-                            'type': NodeType_1.NodeType.BlockStatement,
-                            'body': [
-                                {
-                                    'type': NodeType_1.NodeType.ReturnStatement,
-                                    'argument': null
-                                }
-                            ]
+                        {
+                            'type': NodeType_1.NodeType.Identifier,
+                            'name': 'times'
                         },
                         },
-                        'alternate': null
-                    },
-                    {
-                        'type': NodeType_1.NodeType.ExpressionStatement,
-                        'expression': {
-                            'type': NodeType_1.NodeType.AssignmentExpression,
-                            'operator': '=',
-                            'left': {
-                                'type': NodeType_1.NodeType.Identifier,
-                                'name': 'reverse'
-                            },
-                            'right': {
-                                'type': NodeType_1.NodeType.LogicalExpression,
-                                'operator': '||',
-                                'left': {
-                                    'type': NodeType_1.NodeType.Identifier,
-                                    'name': 'reverse'
-                                },
-                                'right': {
-                                    'type': NodeType_1.NodeType.Literal,
-                                    'value': false,
-                                    'raw': 'false'
-                                }
-                            }
+                        {
+                            'type': NodeType_1.NodeType.Identifier,
+                            'name': 'reverse'
                         }
                         }
-                    },
-                    {
-                        'type': NodeType_1.NodeType.VariableDeclaration,
-                        'declarations': [
+                    ],
+                    'defaults': [],
+                    'body': {
+                        'type': NodeType_1.NodeType.BlockStatement,
+                        'body': [
                             {
                             {
-                                'type': NodeType_1.NodeType.VariableDeclarator,
-                                'id': {
-                                    'type': NodeType_1.NodeType.Identifier,
-                                    'name': 'temp'
+                                'type': NodeType_1.NodeType.IfStatement,
+                                'test': {
+                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                    'operator': '<',
+                                    'left': {
+                                        'type': NodeType_1.NodeType.Identifier,
+                                        'name': 'times'
+                                    },
+                                    'right': {
+                                        'type': NodeType_1.NodeType.Literal,
+                                        'value': 0,
+                                        'raw': '0'
+                                    }
                                 },
                                 },
-                                'init': null
-                            }
-                        ],
-                        'kind': 'var'
-                    },
-                    {
-                        'type': NodeType_1.NodeType.WhileStatement,
-                        'test': {
-                            'type': NodeType_1.NodeType.UpdateExpression,
-                            'operator': '--',
-                            'argument': {
-                                'type': NodeType_1.NodeType.Identifier,
-                                'name': 'times'
+                                'consequent': {
+                                    'type': NodeType_1.NodeType.BlockStatement,
+                                    'body': [
+                                        {
+                                            'type': NodeType_1.NodeType.ReturnStatement,
+                                            'argument': null
+                                        }
+                                    ]
+                                },
+                                'alternate': null
                             },
                             },
-                            'prefix': false
-                        },
-                        'body': {
-                            'type': NodeType_1.NodeType.BlockStatement,
-                            'body': [
-                                {
-                                    'type': NodeType_1.NodeType.IfStatement,
-                                    'test': {
-                                        'type': NodeType_1.NodeType.UnaryExpression,
-                                        'operator': '!',
-                                        'argument': {
+                            {
+                                'type': NodeType_1.NodeType.ExpressionStatement,
+                                'expression': {
+                                    'type': NodeType_1.NodeType.AssignmentExpression,
+                                    'operator': '=',
+                                    'left': {
+                                        'type': NodeType_1.NodeType.Identifier,
+                                        'name': 'reverse'
+                                    },
+                                    'right': {
+                                        'type': NodeType_1.NodeType.LogicalExpression,
+                                        'operator': '||',
+                                        'left': {
                                             'type': NodeType_1.NodeType.Identifier,
                                             'type': NodeType_1.NodeType.Identifier,
                                             'name': 'reverse'
                                             'name': 'reverse'
                                         },
                                         },
-                                        'prefix': true
+                                        'right': {
+                                            'type': NodeType_1.NodeType.Literal,
+                                            'value': false,
+                                            'raw': 'false'
+                                        }
+                                    }
+                                }
+                            },
+                            {
+                                'type': NodeType_1.NodeType.VariableDeclaration,
+                                'declarations': [
+                                    {
+                                        'type': NodeType_1.NodeType.VariableDeclarator,
+                                        'id': {
+                                            'type': NodeType_1.NodeType.Identifier,
+                                            'name': 'temp'
+                                        },
+                                        'init': null
+                                    }
+                                ],
+                                'kind': 'var'
+                            },
+                            {
+                                'type': NodeType_1.NodeType.WhileStatement,
+                                'test': {
+                                    'type': NodeType_1.NodeType.UpdateExpression,
+                                    'operator': '--',
+                                    'argument': {
+                                        'type': NodeType_1.NodeType.Identifier,
+                                        'name': 'times'
                                     },
                                     },
-                                    'consequent': {
-                                        'type': NodeType_1.NodeType.BlockStatement,
-                                        'body': [
-                                            {
-                                                'type': NodeType_1.NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType_1.NodeType.AssignmentExpression,
-                                                    'operator': '=',
-                                                    'left': {
-                                                        'type': NodeType_1.NodeType.Identifier,
-                                                        'name': 'temp'
-                                                    },
-                                                    'right': {
-                                                        'type': NodeType_1.NodeType.CallExpression,
-                                                        'callee': {
-                                                            'type': NodeType_1.NodeType.MemberExpression,
-                                                            'computed': true,
-                                                            'object': {
+                                    'prefix': false
+                                },
+                                'body': {
+                                    'type': NodeType_1.NodeType.BlockStatement,
+                                    'body': [
+                                        {
+                                            'type': NodeType_1.NodeType.IfStatement,
+                                            'test': {
+                                                'type': NodeType_1.NodeType.UnaryExpression,
+                                                'operator': '!',
+                                                'argument': {
+                                                    'type': NodeType_1.NodeType.Identifier,
+                                                    'name': 'reverse'
+                                                },
+                                                'prefix': true
+                                            },
+                                            'consequent': {
+                                                'type': NodeType_1.NodeType.BlockStatement,
+                                                'body': [
+                                                    {
+                                                        'type': NodeType_1.NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType_1.NodeType.AssignmentExpression,
+                                                            'operator': '=',
+                                                            'left': {
                                                                 'type': NodeType_1.NodeType.Identifier,
                                                                 'type': NodeType_1.NodeType.Identifier,
-                                                                'name': 'array'
+                                                                'name': 'temp'
                                                             },
                                                             },
-                                                            'property': {
-                                                                'type': NodeType_1.NodeType.Literal,
-                                                                'name': 'pop',
-                                                                'x-verbatim-property': Utils_1.Utils.stringToUnicode('pop')
+                                                            'right': {
+                                                                'type': NodeType_1.NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType_1.NodeType.MemberExpression,
+                                                                    'computed': true,
+                                                                    'object': {
+                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                        'name': 'array'
+                                                                    },
+                                                                    'property': {
+                                                                        'type': NodeType_1.NodeType.Literal,
+                                                                        'name': 'pop',
+                                                                        'x-verbatim-property': Utils_1.Utils.stringToUnicode('pop')
+                                                                    }
+                                                                },
+                                                                'arguments': []
                                                             }
                                                             }
-                                                        },
-                                                        'arguments': []
-                                                    }
-                                                }
-                                            },
-                                            {
-                                                'type': NodeType_1.NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType_1.NodeType.CallExpression,
-                                                    'callee': {
-                                                        'type': NodeType_1.NodeType.MemberExpression,
-                                                        'computed': true,
-                                                        'object': {
-                                                            'type': NodeType_1.NodeType.Identifier,
-                                                            'name': 'array'
-                                                        },
-                                                        'property': {
-                                                            'type': NodeType_1.NodeType.Literal,
-                                                            'name': 'unshift',
-                                                            'x-verbatim-property': Utils_1.Utils.stringToUnicode('unshift')
                                                         }
                                                         }
                                                     },
                                                     },
-                                                    'arguments': [
-                                                        {
-                                                            'type': NodeType_1.NodeType.Identifier,
-                                                            'name': 'temp'
+                                                    {
+                                                        'type': NodeType_1.NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType_1.NodeType.CallExpression,
+                                                            'callee': {
+                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                'computed': true,
+                                                                'object': {
+                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                    'name': 'array'
+                                                                },
+                                                                'property': {
+                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                    'name': 'unshift',
+                                                                    'x-verbatim-property': Utils_1.Utils.stringToUnicode('unshift')
+                                                                }
+                                                            },
+                                                            'arguments': [
+                                                                {
+                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                    'name': 'temp'
+                                                                }
+                                                            ]
                                                         }
                                                         }
-                                                    ]
-                                                }
-                                            }
-                                        ]
-                                    },
-                                    'alternate': {
-                                        'type': NodeType_1.NodeType.BlockStatement,
-                                        'body': [
-                                            {
-                                                'type': NodeType_1.NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType_1.NodeType.AssignmentExpression,
-                                                    'operator': '=',
-                                                    'left': {
-                                                        'type': NodeType_1.NodeType.Identifier,
-                                                        'name': 'temp'
-                                                    },
-                                                    'right': {
-                                                        'type': NodeType_1.NodeType.CallExpression,
-                                                        'callee': {
-                                                            'type': NodeType_1.NodeType.MemberExpression,
-                                                            'computed': true,
-                                                            'object': {
+                                                    }
+                                                ]
+                                            },
+                                            'alternate': {
+                                                'type': NodeType_1.NodeType.BlockStatement,
+                                                'body': [
+                                                    {
+                                                        'type': NodeType_1.NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType_1.NodeType.AssignmentExpression,
+                                                            'operator': '=',
+                                                            'left': {
                                                                 'type': NodeType_1.NodeType.Identifier,
                                                                 'type': NodeType_1.NodeType.Identifier,
-                                                                'name': 'array'
+                                                                'name': 'temp'
                                                             },
                                                             },
-                                                            'property': {
-                                                                'type': NodeType_1.NodeType.Literal,
-                                                                'name': 'shift',
-                                                                'x-verbatim-property': Utils_1.Utils.stringToUnicode('shift')
+                                                            'right': {
+                                                                'type': NodeType_1.NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType_1.NodeType.MemberExpression,
+                                                                    'computed': true,
+                                                                    'object': {
+                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                        'name': 'array'
+                                                                    },
+                                                                    'property': {
+                                                                        'type': NodeType_1.NodeType.Literal,
+                                                                        'name': 'shift',
+                                                                        'x-verbatim-property': Utils_1.Utils.stringToUnicode('shift')
+                                                                    }
+                                                                },
+                                                                'arguments': []
                                                             }
                                                             }
-                                                        },
-                                                        'arguments': []
-                                                    }
-                                                }
-                                            },
-                                            {
-                                                'type': NodeType_1.NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType_1.NodeType.CallExpression,
-                                                    'callee': {
-                                                        'type': NodeType_1.NodeType.MemberExpression,
-                                                        'computed': true,
-                                                        'object': {
-                                                            'type': NodeType_1.NodeType.Identifier,
-                                                            'name': 'array'
-                                                        },
-                                                        'property': {
-                                                            'type': NodeType_1.NodeType.Literal,
-                                                            'name': 'push',
-                                                            'x-verbatim-property': Utils_1.Utils.stringToUnicode('push')
                                                         }
                                                         }
                                                     },
                                                     },
-                                                    'arguments': [
-                                                        {
-                                                            'type': NodeType_1.NodeType.Identifier,
-                                                            'name': 'temp'
+                                                    {
+                                                        'type': NodeType_1.NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType_1.NodeType.CallExpression,
+                                                            'callee': {
+                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                'computed': true,
+                                                                'object': {
+                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                    'name': 'array'
+                                                                },
+                                                                'property': {
+                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                    'name': 'push',
+                                                                    'x-verbatim-property': Utils_1.Utils.stringToUnicode('push')
+                                                                }
+                                                            },
+                                                            'arguments': [
+                                                                {
+                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                    'name': 'temp'
+                                                                }
+                                                            ]
                                                         }
                                                         }
-                                                    ]
-                                                }
+                                                    }
+                                                ]
                                             }
                                             }
-                                        ]
-                                    }
+                                        }
+                                    ]
                                 }
                                 }
-                            ]
-                        }
+                            }
+                        ]
+                    },
+                    'generator': false,
+                    'expression': false
+                },
+                "arguments": [
+                    {
+                        'type': 'Identifier',
+                        'name': this.unicodeArrayName
+                    },
+                    {
+                        'type': 'Literal',
+                        'value': this.unicodeArrayRotateValue,
+                        'raw': `'${this.unicodeArrayRotateValue}'`
+                    },
+                    {
+                        'type': 'Literal',
+                        'value': true,
+                        'raw': 'true'
                     }
                     }
                 ]
                 ]
-            },
-            'generator': false,
-            'expression': false
+            }
         };
         };
     }
     }
 }
 }

+ 236 - 224
src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts

@@ -13,22 +13,22 @@ export class UnicodeArrayRotateFunctionNode extends Node {
     private unicodeArrayName: string;
     private unicodeArrayName: string;
 
 
     /**
     /**
-     * @param {string}
+     * @param {number}
      */
      */
-    private unicodeArrayRotateFunctionName: string;
+    private unicodeArrayRotateValue: number;
 
 
     /**
     /**
-     * @param unicodeArrayRotateFunctionName
      * @param unicodeArrayName
      * @param unicodeArrayName
+     * @param unicodeArrayRotateValue
      */
      */
     constructor (
     constructor (
-        unicodeArrayRotateFunctionName: string,
-        unicodeArrayName: string
+        unicodeArrayName: string,
+        unicodeArrayRotateValue
     ) {
     ) {
         super();
         super();
 
 
-        this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
         this.unicodeArrayName = unicodeArrayName;
         this.unicodeArrayName = unicodeArrayName;
+        this.unicodeArrayRotateValue = unicodeArrayRotateValue;
 
 
         this.node = this.getNodeStructure();
         this.node = this.getNodeStructure();
     }
     }
@@ -37,14 +37,7 @@ export class UnicodeArrayRotateFunctionNode extends Node {
      * @param blockScopeNode
      * @param blockScopeNode
      */
      */
     public appendNode (blockScopeNode: BlockScopeNode): void {
     public appendNode (blockScopeNode: BlockScopeNode): void {
-        NodeUtils.appendNode(blockScopeNode.body, this.getNode());
-    }
-
-    /**
-     * @returns {string}
-     */
-    public getNodeIdentifier (): string {
-        return this.unicodeArrayRotateFunctionName;
+        NodeUtils.prependNode(blockScopeNode.body, this.getNode());
     }
     }
 
 
     /**
     /**
@@ -52,242 +45,261 @@ export class UnicodeArrayRotateFunctionNode extends Node {
      */
      */
     protected getNodeStructure (): any {
     protected getNodeStructure (): any {
         return {
         return {
-            'type': NodeType.FunctionExpression,
-            'id': {
-                'type': NodeType.Identifier,
-                'name': this.unicodeArrayRotateFunctionName
-            },
-            'params': [
-                {
-                    'type': NodeType.Identifier,
-                    'name': 'array'
-                },
-                {
-                    'type': NodeType.Identifier,
-                    'name': 'times'
-                },
-                {
-                    'type': NodeType.Identifier,
-                    'name': 'reverse'
-                }
-            ],
-            'defaults': [],
-            'body': {
-                'type': NodeType.BlockStatement,
-                'body': [
-                    {
-                        'type': NodeType.IfStatement,
-                        'test': {
-                            'type': NodeType.BinaryExpression,
-                            'operator': '<',
-                            'left': {
-                                'type': NodeType.Identifier,
-                                'name': 'times'
-                            },
-                            'right': {
-                                'type': NodeType.Literal,
-                                'value': 0,
-                                'raw': '0'
-                            }
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    'type': NodeType.FunctionExpression,
+                    'id': null,
+                    'params': [
+                        {
+                            'type': NodeType.Identifier,
+                            'name': 'array'
                         },
                         },
-                        'consequent': {
-                            'type': NodeType.BlockStatement,
-                            'body': [
-                                {
-                                    'type': NodeType.ReturnStatement,
-                                    'argument': null
-                                }
-                            ]
+                        {
+                            'type': NodeType.Identifier,
+                            'name': 'times'
                         },
                         },
-                        'alternate': null
-                    },
-                    {
-                        'type': NodeType.ExpressionStatement,
-                        'expression': {
-                            'type': NodeType.AssignmentExpression,
-                            'operator': '=',
-                            'left': {
-                                'type': NodeType.Identifier,
-                                'name': 'reverse'
-                            },
-                            'right': {
-                                'type': NodeType.LogicalExpression,
-                                'operator': '||',
-                                'left': {
-                                    'type': NodeType.Identifier,
-                                    'name': 'reverse'
-                                },
-                                'right': {
-                                    'type': NodeType.Literal,
-                                    'value': false,
-                                    'raw': 'false'
-                                }
-                            }
+                        {
+                            'type': NodeType.Identifier,
+                            'name': 'reverse'
                         }
                         }
-                    },
-                    {
-                        'type': NodeType.VariableDeclaration,
-                        'declarations': [
+                    ],
+                    'defaults': [],
+                    'body': {
+                        'type': NodeType.BlockStatement,
+                        'body': [
                             {
                             {
-                                'type': NodeType.VariableDeclarator,
-                                'id': {
-                                    'type': NodeType.Identifier,
-                                    'name': 'temp'
+                                'type': NodeType.IfStatement,
+                                'test': {
+                                    'type': NodeType.BinaryExpression,
+                                    'operator': '<',
+                                    'left': {
+                                        'type': NodeType.Identifier,
+                                        'name': 'times'
+                                    },
+                                    'right': {
+                                        'type': NodeType.Literal,
+                                        'value': 0,
+                                        'raw': '0'
+                                    }
                                 },
                                 },
-                                'init': null
-                            }
-                        ],
-                        'kind': 'var'
-                    },
-                    {
-                        'type': NodeType.WhileStatement,
-                        'test': {
-                            'type': NodeType.UpdateExpression,
-                            'operator': '--',
-                            'argument': {
-                                'type': NodeType.Identifier,
-                                'name': 'times'
+                                'consequent': {
+                                    'type': NodeType.BlockStatement,
+                                    'body': [
+                                        {
+                                            'type': NodeType.ReturnStatement,
+                                            'argument': null
+                                        }
+                                    ]
+                                },
+                                'alternate': null
                             },
                             },
-                            'prefix': false
-                        },
-                        'body': {
-                            'type': NodeType.BlockStatement,
-                            'body': [
-                                {
-                                    'type': NodeType.IfStatement,
-                                    'test': {
-                                        'type': NodeType.UnaryExpression,
-                                        'operator': '!',
-                                        'argument': {
+                            {
+                                'type': NodeType.ExpressionStatement,
+                                'expression': {
+                                    'type': NodeType.AssignmentExpression,
+                                    'operator': '=',
+                                    'left': {
+                                        'type': NodeType.Identifier,
+                                        'name': 'reverse'
+                                    },
+                                    'right': {
+                                        'type': NodeType.LogicalExpression,
+                                        'operator': '||',
+                                        'left': {
                                             'type': NodeType.Identifier,
                                             'type': NodeType.Identifier,
                                             'name': 'reverse'
                                             'name': 'reverse'
                                         },
                                         },
-                                        'prefix': true
+                                        'right': {
+                                            'type': NodeType.Literal,
+                                            'value': false,
+                                            'raw': 'false'
+                                        }
+                                    }
+                                }
+                            },
+                            {
+                                'type': NodeType.VariableDeclaration,
+                                'declarations': [
+                                    {
+                                        'type': NodeType.VariableDeclarator,
+                                        'id': {
+                                            'type': NodeType.Identifier,
+                                            'name': 'temp'
+                                        },
+                                        'init': null
+                                    }
+                                ],
+                                'kind': 'var'
+                            },
+                            {
+                                'type': NodeType.WhileStatement,
+                                'test': {
+                                    'type': NodeType.UpdateExpression,
+                                    'operator': '--',
+                                    'argument': {
+                                        'type': NodeType.Identifier,
+                                        'name': 'times'
                                     },
                                     },
-                                    'consequent': {
-                                        'type': NodeType.BlockStatement,
-                                        'body': [
-                                            {
-                                                'type': NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType.AssignmentExpression,
-                                                    'operator': '=',
-                                                    'left': {
-                                                        'type': NodeType.Identifier,
-                                                        'name': 'temp'
-                                                    },
-                                                    'right': {
-                                                        'type': NodeType.CallExpression,
-                                                        'callee': {
-                                                            'type': NodeType.MemberExpression,
-                                                            'computed': true,
-                                                            'object': {
+                                    'prefix': false
+                                },
+                                'body': {
+                                    'type': NodeType.BlockStatement,
+                                    'body': [
+                                        {
+                                            'type': NodeType.IfStatement,
+                                            'test': {
+                                                'type': NodeType.UnaryExpression,
+                                                'operator': '!',
+                                                'argument': {
+                                                    'type': NodeType.Identifier,
+                                                    'name': 'reverse'
+                                                },
+                                                'prefix': true
+                                            },
+                                            'consequent': {
+                                                'type': NodeType.BlockStatement,
+                                                'body': [
+                                                    {
+                                                        'type': NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType.AssignmentExpression,
+                                                            'operator': '=',
+                                                            'left': {
                                                                 'type': NodeType.Identifier,
                                                                 'type': NodeType.Identifier,
-                                                                'name': 'array'
+                                                                'name': 'temp'
                                                             },
                                                             },
-                                                            'property': {
-                                                                'type': NodeType.Literal,
-                                                                'name': 'pop',
-                                                                'x-verbatim-property': Utils.stringToUnicode('pop')
+                                                            'right': {
+                                                                'type': NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType.MemberExpression,
+                                                                    'computed': true,
+                                                                    'object': {
+                                                                        'type': NodeType.Identifier,
+                                                                        'name': 'array'
+                                                                    },
+                                                                    'property': {
+                                                                        'type': NodeType.Literal,
+                                                                        'name': 'pop',
+                                                                        'x-verbatim-property': Utils.stringToUnicode('pop')
+                                                                    }
+                                                                },
+                                                                'arguments': []
                                                             }
                                                             }
-                                                        },
-                                                        'arguments': []
-                                                    }
-                                                }
-                                            },
-                                            {
-                                                'type': NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType.CallExpression,
-                                                    'callee': {
-                                                        'type': NodeType.MemberExpression,
-                                                        'computed': true,
-                                                        'object': {
-                                                            'type': NodeType.Identifier,
-                                                            'name': 'array'
-                                                        },
-                                                        'property': {
-                                                            'type': NodeType.Literal,
-                                                            'name': 'unshift',
-                                                            'x-verbatim-property': Utils.stringToUnicode('unshift')
                                                         }
                                                         }
                                                     },
                                                     },
-                                                    'arguments': [
-                                                        {
-                                                            'type': NodeType.Identifier,
-                                                            'name': 'temp'
+                                                    {
+                                                        'type': NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType.CallExpression,
+                                                            'callee': {
+                                                                'type': NodeType.MemberExpression,
+                                                                'computed': true,
+                                                                'object': {
+                                                                    'type': NodeType.Identifier,
+                                                                    'name': 'array'
+                                                                },
+                                                                'property': {
+                                                                    'type': NodeType.Literal,
+                                                                    'name': 'unshift',
+                                                                    'x-verbatim-property': Utils.stringToUnicode('unshift')
+                                                                }
+                                                            },
+                                                            'arguments': [
+                                                                {
+                                                                    'type': NodeType.Identifier,
+                                                                    'name': 'temp'
+                                                                }
+                                                            ]
                                                         }
                                                         }
-                                                    ]
-                                                }
-                                            }
-                                        ]
-                                    },
-                                    'alternate': {
-                                        'type': NodeType.BlockStatement,
-                                        'body': [
-                                            {
-                                                'type': NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType.AssignmentExpression,
-                                                    'operator': '=',
-                                                    'left': {
-                                                        'type': NodeType.Identifier,
-                                                        'name': 'temp'
-                                                    },
-                                                    'right': {
-                                                        'type': NodeType.CallExpression,
-                                                        'callee': {
-                                                            'type': NodeType.MemberExpression,
-                                                            'computed': true,
-                                                            'object': {
+                                                    }
+                                                ]
+                                            },
+                                            'alternate': {
+                                                'type': NodeType.BlockStatement,
+                                                'body': [
+                                                    {
+                                                        'type': NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType.AssignmentExpression,
+                                                            'operator': '=',
+                                                            'left': {
                                                                 'type': NodeType.Identifier,
                                                                 'type': NodeType.Identifier,
-                                                                'name': 'array'
+                                                                'name': 'temp'
                                                             },
                                                             },
-                                                            'property': {
-                                                                'type': NodeType.Literal,
-                                                                'name': 'shift',
-                                                                'x-verbatim-property': Utils.stringToUnicode('shift')
+                                                            'right': {
+                                                                'type': NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType.MemberExpression,
+                                                                    'computed': true,
+                                                                    'object': {
+                                                                        'type': NodeType.Identifier,
+                                                                        'name': 'array'
+                                                                    },
+                                                                    'property': {
+                                                                        'type': NodeType.Literal,
+                                                                        'name': 'shift',
+                                                                        'x-verbatim-property': Utils.stringToUnicode('shift')
+                                                                    }
+                                                                },
+                                                                'arguments': []
                                                             }
                                                             }
-                                                        },
-                                                        'arguments': []
-                                                    }
-                                                }
-                                            },
-                                            {
-                                                'type': NodeType.ExpressionStatement,
-                                                'expression': {
-                                                    'type': NodeType.CallExpression,
-                                                    'callee': {
-                                                        'type': NodeType.MemberExpression,
-                                                        'computed': true,
-                                                        'object': {
-                                                            'type': NodeType.Identifier,
-                                                            'name': 'array'
-                                                        },
-                                                        'property': {
-                                                            'type': NodeType.Literal,
-                                                            'name': 'push',
-                                                            'x-verbatim-property': Utils.stringToUnicode('push')
                                                         }
                                                         }
                                                     },
                                                     },
-                                                    'arguments': [
-                                                        {
-                                                            'type': NodeType.Identifier,
-                                                            'name': 'temp'
+                                                    {
+                                                        'type': NodeType.ExpressionStatement,
+                                                        'expression': {
+                                                            'type': NodeType.CallExpression,
+                                                            'callee': {
+                                                                'type': NodeType.MemberExpression,
+                                                                'computed': true,
+                                                                'object': {
+                                                                    'type': NodeType.Identifier,
+                                                                    'name': 'array'
+                                                                },
+                                                                'property': {
+                                                                    'type': NodeType.Literal,
+                                                                    'name': 'push',
+                                                                    'x-verbatim-property': Utils.stringToUnicode('push')
+                                                                }
+                                                            },
+                                                            'arguments': [
+                                                                {
+                                                                    'type': NodeType.Identifier,
+                                                                    'name': 'temp'
+                                                                }
+                                                            ]
                                                         }
                                                         }
-                                                    ]
-                                                }
+                                                    }
+                                                ]
                                             }
                                             }
-                                        ]
-                                    }
+                                        }
+                                    ]
                                 }
                                 }
-                            ]
-                        }
+                            }
+                        ]
+                    },
+                    'generator': false,
+                    'expression': false
+                },
+                "arguments": [
+                    {
+                        'type': 'Identifier',
+                        'name': this.unicodeArrayName
+                    },
+                    {
+                        'type': 'Literal',
+                        'value': this.unicodeArrayRotateValue,
+                        'raw': `'${this.unicodeArrayRotateValue}'`
+                    },
+                    {
+                        'type': 'Literal',
+                        'value': true,
+                        'raw': 'true'
                     }
                     }
                 ]
                 ]
-            },
-            'generator': false,
-            'expression': false
+            }
         };
         };
     }
     }
 }
 }

+ 0 - 17
src/node-groups/DebugProtectionNodesGroup.js

@@ -1,17 +1,14 @@
 "use strict";
 "use strict";
-const estraverse = require('estraverse');
 const DebugProtectionFunctionCallNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode");
 const DebugProtectionFunctionCallNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode");
 const DebugProtectionFunctionIntervalNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode");
 const DebugProtectionFunctionIntervalNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode");
 const DebugProtectionFunctionNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode");
 const DebugProtectionFunctionNode_1 = require("../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode");
 const NodesGroup_1 = require('./NodesGroup');
 const NodesGroup_1 = require('./NodesGroup');
-const NodeUtils_1 = require("../NodeUtils");
 const Utils_1 = require('../Utils');
 const Utils_1 = require('../Utils');
 class DebugProtectionNodesGroup extends NodesGroup_1.NodesGroup {
 class DebugProtectionNodesGroup extends NodesGroup_1.NodesGroup {
     constructor(options) {
     constructor(options) {
         super();
         super();
         this.debugProtectionFunctionIdentifier = Utils_1.Utils.getRandomVariableName();
         this.debugProtectionFunctionIdentifier = Utils_1.Utils.getRandomVariableName();
         this.options = options;
         this.options = options;
-        this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
         this.nodes = new Map([
         this.nodes = new Map([
             [
             [
                 'debugProtectionFunctionNode',
                 'debugProtectionFunctionNode',
@@ -26,19 +23,5 @@ class DebugProtectionNodesGroup extends NodesGroup_1.NodesGroup {
             this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(this.debugProtectionFunctionIdentifier));
             this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(this.debugProtectionFunctionIdentifier));
         }
         }
     }
     }
-    getDebugProtectionFunctionIndex() {
-        let randomIndex;
-        estraverse.replace(this.astTree, {
-            leave: (node, parent) => {
-                if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
-                    let programBodyLength = node.body.length;
-                    randomIndex = Utils_1.Utils.getRandomInteger(0, programBodyLength);
-                    return estraverse.VisitorOption.Break;
-                }
-                return estraverse.VisitorOption.Skip;
-            }
-        });
-        return randomIndex;
-    }
 }
 }
 exports.DebugProtectionNodesGroup = DebugProtectionNodesGroup;
 exports.DebugProtectionNodesGroup = DebugProtectionNodesGroup;

+ 0 - 30
src/node-groups/DebugProtectionNodesGroup.ts

@@ -18,11 +18,6 @@ export class DebugProtectionNodesGroup extends NodesGroup {
      */
      */
     private astTree: INode;
     private astTree: INode;
 
 
-    /**
-     * @type {number}
-     */
-    private debugProtectionFunctionIndex: number;
-
     /**
     /**
      * @type {string}
      * @type {string}
      */
      */
@@ -41,8 +36,6 @@ export class DebugProtectionNodesGroup extends NodesGroup {
 
 
         this.options = options;
         this.options = options;
 
 
-        this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
-
         this.nodes = new Map <string, ICustomNode> ([
         this.nodes = new Map <string, ICustomNode> ([
             [
             [
                 'debugProtectionFunctionNode',
                 'debugProtectionFunctionNode',
@@ -61,27 +54,4 @@ export class DebugProtectionNodesGroup extends NodesGroup {
             );
             );
         }
         }
     }
     }
-
-    /**
-     * @returns {number}
-     */
-    private getDebugProtectionFunctionIndex (): number {
-        let randomIndex: number;
-
-        estraverse.replace(this.astTree, {
-            leave: (node: INode, parent: INode): any => {
-                if (NodeUtils.isProgramNode(node)) {
-                    let programBodyLength: number = node.body.length;
-
-                    randomIndex = Utils.getRandomInteger(0, programBodyLength);
-
-                    return estraverse.VisitorOption.Break;
-                }
-
-                return estraverse.VisitorOption.Skip;
-            }
-        });
-
-        return randomIndex;
-    }
 }
 }

+ 4 - 9
src/node-groups/UnicodeArrayNodesGroup.js

@@ -1,26 +1,21 @@
 "use strict";
 "use strict";
 const NodesGroup_1 = require('./NodesGroup');
 const NodesGroup_1 = require('./NodesGroup');
 const UnicodeArrayNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayNode');
 const UnicodeArrayNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayNode');
-const UnicodeArrayRotateFunctionCallNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionCallNode');
 const UnicodeArrayRotateFunctionNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode');
 const UnicodeArrayRotateFunctionNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode');
 const Utils_1 = require('../Utils');
 const Utils_1 = require('../Utils');
 class UnicodeArrayNodesGroup extends NodesGroup_1.NodesGroup {
 class UnicodeArrayNodesGroup extends NodesGroup_1.NodesGroup {
     constructor() {
     constructor() {
         super();
         super();
-        this.unicodeArrayRotateFunctionName = Utils_1.Utils.getRandomVariableName();
-        let unicodeArrayName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH), unicodeArrayRotateValue = Utils_1.Utils.getRandomInteger(100, 500);
+        this.unicodeArrayName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH);
+        this.unicodeArrayRotateValue = Utils_1.Utils.getRandomInteger(100, 500);
         this.nodes = new Map([
         this.nodes = new Map([
             [
             [
                 'unicodeArrayNode',
                 'unicodeArrayNode',
-                new UnicodeArrayNode_1.UnicodeArrayNode(unicodeArrayName, unicodeArrayRotateValue)
+                new UnicodeArrayNode_1.UnicodeArrayNode(this.unicodeArrayName, this.unicodeArrayRotateValue)
             ],
             ],
             [
             [
                 'unicodeArrayRotateFunctionNode',
                 'unicodeArrayRotateFunctionNode',
-                new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(this.unicodeArrayRotateFunctionName, unicodeArrayName)
-            ],
-            [
-                'unicodeArrayRotateFunctionCallNode',
-                new UnicodeArrayRotateFunctionCallNode_1.UnicodeArrayRotateFunctionCallNode(this.unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue)
+                new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(this.unicodeArrayName, this.unicodeArrayRotateValue)
             ]
             ]
         ]);
         ]);
     }
     }

+ 10 - 17
src/node-groups/UnicodeArrayNodesGroup.ts

@@ -2,7 +2,6 @@ import { ICustomNode } from '../interfaces/ICustomNode';
 
 
 import { NodesGroup } from './NodesGroup';
 import { NodesGroup } from './NodesGroup';
 import { UnicodeArrayNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayNode';
 import { UnicodeArrayNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayNode';
-import { UnicodeArrayRotateFunctionCallNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionCallNode';
 import { UnicodeArrayRotateFunctionNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode';
 import { UnicodeArrayRotateFunctionNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode';
 import { Utils } from '../Utils';
 import { Utils } from '../Utils';
 
 
@@ -10,35 +9,29 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
     /**
     /**
      * @type {string}
      * @type {string}
      */
      */
-    private unicodeArrayRotateFunctionName: string = Utils.getRandomVariableName();
+    private unicodeArrayName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH);
+
+    /**
+     * @type {number}
+     */
+    private unicodeArrayRotateValue: number = Utils.getRandomInteger(100, 500);
 
 
     constructor () {
     constructor () {
         super();
         super();
 
 
-        let unicodeArrayName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH),
-            unicodeArrayRotateValue: number = Utils.getRandomInteger(100, 500);
-
         this.nodes = new Map <string, ICustomNode> ([
         this.nodes = new Map <string, ICustomNode> ([
             [
             [
                 'unicodeArrayNode',
                 'unicodeArrayNode',
                 new UnicodeArrayNode(
                 new UnicodeArrayNode(
-                    unicodeArrayName,
-                    unicodeArrayRotateValue
+                    this.unicodeArrayName,
+                    this.unicodeArrayRotateValue
                 )
                 )
             ],
             ],
             [
             [
                 'unicodeArrayRotateFunctionNode',
                 'unicodeArrayRotateFunctionNode',
                 new UnicodeArrayRotateFunctionNode(
                 new UnicodeArrayRotateFunctionNode(
-                    this.unicodeArrayRotateFunctionName,
-                    unicodeArrayName
-                )
-            ],
-            [
-                'unicodeArrayRotateFunctionCallNode',
-                new UnicodeArrayRotateFunctionCallNode(
-                    this.unicodeArrayRotateFunctionName,
-                    unicodeArrayName,
-                    unicodeArrayRotateValue
+                    this.unicodeArrayName,
+                    this.unicodeArrayRotateValue
                 )
                 )
             ]
             ]
         ]);
         ]);