Browse Source

control flow flattening: update to master

sanex3339 8 năm trước cách đây
mục cha
commit
a6c388d18f

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 335 - 253
dist/index.js


+ 8 - 7
src/ControlFlowStorage.ts

@@ -39,12 +39,13 @@ export class ControlFlowStorage {
      * @returns {string}
      */
     public toString (): string {
-        return `{
-            ${Array.from(this.storage).reduce((string: string, [key, value]: [string, ICustomNode]) => {
-                string += `${key}: ${value.getCode()},`;
-    
-                return string;
-            }, '')}
-        }`;
+        return Array
+            .from(this.storage)
+            .reduce((controlFlowStorageItems: string[], [key, value]: [string, ICustomNode]) => {
+                controlFlowStorageItems.push(`${key}: ${value.getCode()}`);
+
+                return controlFlowStorageItems;
+            }, [])
+            .join(',');
     }
 }

+ 1 - 1
src/templates/custom-nodes/control-flow-storage-nodes/ControlFlowStorageTemplate.ts

@@ -3,6 +3,6 @@
  */
 export function ControlFlowStorageTemplate (): string {
     return `
-        var {controlFlowStorageName} = {controlFlowStorage};
+        var {controlFlowStorageName} = { {controlFlowStorage} };
     `;
 }

+ 2 - 2
test/unit-tests/node-obfuscators/FunctionDeclarationObfuscator.spec.ts

@@ -59,7 +59,7 @@ describe('FunctionDeclarationObfuscator', () => {
                 functionDeclarationNode['parentNode'] = blockStatementNode;
                 expressionStatementNode['parentNode'] = blockStatementNode;
 
-                functionDeclarationObfuscator.obfuscateNode(
+                functionDeclarationObfuscator.transformNode(
                     functionDeclarationNode,
                     blockStatementNode
                 );
@@ -83,7 +83,7 @@ describe('FunctionDeclarationObfuscator', () => {
                 functionDeclarationNode['parentNode'] = programNode;
                 expressionStatementNode['parentNode'] = programNode;
 
-                functionDeclarationObfuscator.obfuscateNode(
+                functionDeclarationObfuscator.transformNode(
                     functionDeclarationNode,
                     programNode
                 );

+ 1 - 1
test/unit-tests/node-obfuscators/FunctionObfuscator.spec.ts

@@ -66,7 +66,7 @@ describe('FunctionObfuscator', () => {
                 new Options(DEFAULT_PRESET)
             );
 
-            functionObfuscator.obfuscateNode(functionDeclarationNode);
+            functionObfuscator.transformNode(functionDeclarationNode);
         });
 
         it('should obfuscate function parameter', () => {

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác