Renamed fields of IStringArrayScopeCallsWrapperParameterIndexesData interface

This commit is contained in:
sanex
2020-11-16 21:04:21 +03:00
parent 80e54a4307
commit 002e068be2
7 changed files with 37 additions and 15 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -125,11 +125,15 @@ export class StringArrayCallNode extends AbstractStringArrayCallNode {
() => this.getFakeStringArrayIndexNode(resultIndex)
);
callExpressionArgs.splice(this.stringArrayCallsWrapperParameterIndexesData?.index ?? 0, 1, indexNode);
callExpressionArgs.splice(
this.stringArrayCallsWrapperParameterIndexesData?.valueIndexParameterIndex ?? 0,
1,
indexNode
);
if (this.stringArrayCallsWrapperParameterIndexesData) {
callExpressionArgs.splice(
this.stringArrayCallsWrapperParameterIndexesData.decodeKey,
this.stringArrayCallsWrapperParameterIndexesData.decodeKeyParameterIndex,
1,
// use rc4 key literal node if exists or a node with fake string array wrapper index
rc4KeyLiteralNode ?? this.getFakeStringArrayIndexNode(resultIndex)
@@ -129,8 +129,16 @@ export class StringArrayScopeCallsWrapperFunctionNode extends AbstractStringArra
: this.options.stringArrayWrappersParametersMaxCount,
() => this.getFakeParameterNode()
);
parameters.splice(this.stringArrayScopeCallsWrapperParameterIndexesData?.index ?? 0, 1, stringArrayCallIdentifierNode);
parameters.splice(this.stringArrayScopeCallsWrapperParameterIndexesData?.decodeKey ?? 1, 1, decodeKeyIdentifierNode);
parameters.splice(
this.stringArrayScopeCallsWrapperParameterIndexesData?.valueIndexParameterIndex ?? 0,
1,
stringArrayCallIdentifierNode
);
parameters.splice(
this.stringArrayScopeCallsWrapperParameterIndexesData?.decodeKeyParameterIndex ?? 1,
1,
decodeKeyIdentifierNode
);
// stage 2: upper string array call expression arguments
// filling all call expression arguments with a fake string array calls
@@ -146,8 +154,16 @@ export class StringArrayScopeCallsWrapperFunctionNode extends AbstractStringArra
)
);
callExpressionArgs.splice(this.upperStringArrayCallsWrapperParameterIndexesData?.index ?? 0, 1, stringArrayCallNode);
callExpressionArgs.splice(this.upperStringArrayCallsWrapperParameterIndexesData?.decodeKey ?? 1, 1, decodeKeyIdentifierNode);
callExpressionArgs.splice(
this.upperStringArrayCallsWrapperParameterIndexesData?.valueIndexParameterIndex ?? 0,
1,
stringArrayCallNode
);
callExpressionArgs.splice(
this.upperStringArrayCallsWrapperParameterIndexesData?.decodeKeyParameterIndex ?? 1,
1,
decodeKeyIdentifierNode
);
// stage 3: function expression node
const functionExpressionNode: ESTree.FunctionExpression = NodeFactory.functionExpressionNode(
@@ -2,10 +2,10 @@ export interface IStringArrayScopeCallsWrapperParameterIndexesData {
/**
* @type {number}
*/
index: number;
valueIndexParameterIndex: number;
/**
* @type {number}
*/
decodeKey: number;
decodeKeyParameterIndex: number;
}
@@ -407,12 +407,14 @@ export class StringArrayTransformer extends AbstractNodeTransformer {
const minIndexValue: number = 0;
const maxIndexValue: number = this.options.stringArrayWrappersParametersMaxCount - 1;
const index: number = this.randomGenerator.getRandomInteger(minIndexValue, maxIndexValue);
const decodeKey: number = this.randomGenerator.getRandomIntegerExcluding(minIndexValue, maxIndexValue, [index]);
const valueIndexParameterIndex: number = this.randomGenerator
.getRandomInteger(minIndexValue, maxIndexValue);
const decodeKeyParameterIndex: number = this.randomGenerator
.getRandomIntegerExcluding(minIndexValue, maxIndexValue, [valueIndexParameterIndex]);
return {
index,
decodeKey
valueIndexParameterIndex,
decodeKeyParameterIndex
};
}
}