Input & Output then just Output

This commit is contained in:
n1073645 2019-12-03 09:19:28 +00:00
parent 40c7e63046
commit a35e3348d8

View file

@ -279,6 +279,11 @@ class Magic {
}); });
const prevOp = recipeConfig[recipeConfig.length - 1]; const prevOp = recipeConfig[recipeConfig.length - 1];
/**
*
* @param flag
* @param sensible
*/
async function regexesTests(flag, sensible) { async function regexesTests(flag, sensible) {
// Execute each of the matching operations, then recursively call the speculativeExecution() // Execute each of the matching operations, then recursively call the speculativeExecution()
@ -299,14 +304,14 @@ class Magic {
if (_buffersEqual(output, new ArrayBuffer())) { if (_buffersEqual(output, new ArrayBuffer())) {
return; return;
} }
if(flag) { if (flag) {
const outputRegexes = OperationConfig[op.op].outputRegexes; const outputRegexes = OperationConfig[op.op].outputRegexes;
if (outputRegexes) if (outputRegexes)
for (const pattern of outputRegexes) for (const pattern of outputRegexes)
if (!(new RegExp(pattern.match, pattern.flags).test(Utils.arrayBufferToStr(output)))) if (!(new RegExp(pattern.match, pattern.flags).test(Utils.arrayBufferToStr(output))))
return; return;
} else { } else {
if (!(op.match.test(output))){ if (!(op.match.test(output))) {
return; return;
} }
} }
@ -317,11 +322,11 @@ class Magic {
results = results.concat(speculativeResults); results = results.concat(speculativeResults);
})); }));
} }
regexesTests(1, matchingOps); regexesTests(1, matchingOps);
regexesTests(0, this.opPatterns.getOutputRegexes()); // regexesTests(0, this.opPatterns.getOutputRegexes());
//console.log("haha",this.opPatterns.getOutputRegexes()); // console.log("haha", results);
if (intensive) { if (intensive) {
// Run brute forcing of various types on the data and create a new branch for each option // Run brute forcing of various types on the data and create a new branch for each option
const bfEncodings = await this.bruteForce(); const bfEncodings = await this.bruteForce();
@ -348,7 +353,7 @@ class Magic {
) )
); );
// console.log(prunedResults); console.log("important", prunedResults);
// Return a sorted list of possible recipes along with their properties // Return a sorted list of possible recipes along with their properties
return prunedResults.sort((a, b) => { return prunedResults.sort((a, b) => {