|
@@ -1,5 +1,8 @@
|
|
|
|
+import { INode } from "../../interfaces/nodes/INode";
|
|
|
|
+
|
|
import { BlockScopeNode } from "../../types/BlockScopeNode";
|
|
import { BlockScopeNode } from "../../types/BlockScopeNode";
|
|
|
|
|
|
|
|
+import { AppendState } from "../../enums/AppendState";
|
|
import { NodeType } from "../../enums/NodeType";
|
|
import { NodeType } from "../../enums/NodeType";
|
|
|
|
|
|
import { Node } from '../Node';
|
|
import { Node } from '../Node';
|
|
@@ -7,6 +10,16 @@ import { NodeUtils } from "../../NodeUtils";
|
|
import { Utils } from '../../Utils';
|
|
import { Utils } from '../../Utils';
|
|
|
|
|
|
export class UnicodeArrayRotateFunctionNode extends Node {
|
|
export class UnicodeArrayRotateFunctionNode extends Node {
|
|
|
|
+ /**
|
|
|
|
+ * @type {AppendState}
|
|
|
|
+ */
|
|
|
|
+ protected appendState: AppendState = AppendState.AfterObfuscation;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @type {string[]}
|
|
|
|
+ */
|
|
|
|
+ private unicodeArray: string[];
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @type {string}
|
|
* @type {string}
|
|
*/
|
|
*/
|
|
@@ -19,15 +32,18 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param unicodeArrayName
|
|
* @param unicodeArrayName
|
|
|
|
+ * @param unicodeArray
|
|
* @param unicodeArrayRotateValue
|
|
* @param unicodeArrayRotateValue
|
|
*/
|
|
*/
|
|
constructor (
|
|
constructor (
|
|
unicodeArrayName: string,
|
|
unicodeArrayName: string,
|
|
|
|
+ unicodeArray: string[],
|
|
unicodeArrayRotateValue
|
|
unicodeArrayRotateValue
|
|
) {
|
|
) {
|
|
super();
|
|
super();
|
|
|
|
|
|
this.unicodeArrayName = unicodeArrayName;
|
|
this.unicodeArrayName = unicodeArrayName;
|
|
|
|
+ this.unicodeArray = unicodeArray;
|
|
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
|
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
|
|
|
|
|
this.node = this.getNodeStructure();
|
|
this.node = this.getNodeStructure();
|
|
@@ -37,7 +53,18 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
|
* @param blockScopeNode
|
|
* @param blockScopeNode
|
|
*/
|
|
*/
|
|
public appendNode (blockScopeNode: BlockScopeNode): void {
|
|
public appendNode (blockScopeNode: BlockScopeNode): void {
|
|
- NodeUtils.prependNode(blockScopeNode.body, this.getNode());
|
|
|
|
|
|
+ NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @returns {INode}
|
|
|
|
+ */
|
|
|
|
+ public getNode (): INode {
|
|
|
|
+ if (!this.unicodeArray.length) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return super.getNode();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -45,9 +72,9 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
|
*/
|
|
*/
|
|
protected getNodeStructure (): any {
|
|
protected getNodeStructure (): any {
|
|
return {
|
|
return {
|
|
- "type": "ExpressionStatement",
|
|
|
|
|
|
+ "type": NodeType.ExpressionStatement,
|
|
"expression": {
|
|
"expression": {
|
|
- "type": "CallExpression",
|
|
|
|
|
|
+ "type": NodeType.CallExpression,
|
|
"callee": {
|
|
"callee": {
|
|
'type': NodeType.FunctionExpression,
|
|
'type': NodeType.FunctionExpression,
|
|
'id': null,
|
|
'id': null,
|
|
@@ -285,16 +312,16 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
|
},
|
|
},
|
|
"arguments": [
|
|
"arguments": [
|
|
{
|
|
{
|
|
- 'type': 'Identifier',
|
|
|
|
|
|
+ 'type': NodeType.Identifier,
|
|
'name': this.unicodeArrayName
|
|
'name': this.unicodeArrayName
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- 'type': 'Literal',
|
|
|
|
|
|
+ 'type': NodeType.Literal,
|
|
'value': this.unicodeArrayRotateValue,
|
|
'value': this.unicodeArrayRotateValue,
|
|
'raw': `'${this.unicodeArrayRotateValue}'`
|
|
'raw': `'${this.unicodeArrayRotateValue}'`
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- 'type': 'Literal',
|
|
|
|
|
|
+ 'type': NodeType.Literal,
|
|
'value': true,
|
|
'value': true,
|
|
'raw': 'true'
|
|
'raw': 'true'
|
|
}
|
|
}
|