mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
fixed empty controlFlowStorageCustomNode append
This commit is contained in:
Vendored
+808
-802
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -20,7 +20,6 @@ import { ControlFlowStorageNode } from '../../custom-nodes/control-flow-storage-
|
||||
import { Node } from '../../node/Node';
|
||||
import { NodeAppender } from '../../node/NodeAppender';
|
||||
import { Utils } from '../../Utils';
|
||||
import { NodeUtils } from '../../node/NodeUtils';
|
||||
|
||||
@injectable()
|
||||
export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
||||
@@ -60,8 +59,6 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
||||
const controlFlowStorage: IStorage <ICustomNode> = new ControlFlowStorage();
|
||||
const controlFlowStorageCustomNodeName: string = Utils.getRandomVariableName(6);
|
||||
|
||||
console.log(NodeUtils.getNodeBlockScopeDepth(functionNode.body));
|
||||
|
||||
estraverse.replace(functionNode.body, {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
|
||||
const controlFlowReplacer: TControlFlowReplacer | undefined = FunctionControlFlowTransformer
|
||||
@@ -94,6 +91,10 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
||||
}
|
||||
});
|
||||
|
||||
if (!controlFlowStorage.getLength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controlFlowStorageCustomNode: ICustomNode = new ControlFlowStorageNode(
|
||||
controlFlowStorage,
|
||||
controlFlowStorageCustomNodeName,
|
||||
|
||||
@@ -59,6 +59,10 @@ export class IdentifierReplacer extends AbstractReplacer {
|
||||
* @param nodeName
|
||||
*/
|
||||
public storeNames (nodeName: string): void {
|
||||
if (!this.uniquePrefix) {
|
||||
throw new Error('`uniquePrefix` is `undefined`. Set it before `storeNames`');
|
||||
}
|
||||
|
||||
if (!this.isReservedName(nodeName)) {
|
||||
this.namesMap.set(`${nodeName}-${this.uniquePrefix}`, Utils.getRandomVariableName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user