2018-05-23 19:59:57 +02:00
|
|
|
/**
|
|
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2016
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2019-07-09 13:23:59 +02:00
|
|
|
import Operation from "../Operation.mjs";
|
|
|
|
import Utils from "../Utils.mjs";
|
|
|
|
import { bitOp, and, BITWISE_OP_DELIMS } from "../lib/BitwiseOp.mjs";
|
2018-05-23 19:59:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AND operation
|
|
|
|
*/
|
|
|
|
class AND extends Operation {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AND constructor
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "AND";
|
|
|
|
this.module = "Default";
|
|
|
|
this.description = "AND the input with the given key.<br>e.g. <code>fe023da5</code>";
|
2018-08-21 20:07:13 +02:00
|
|
|
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#AND";
|
2018-05-23 19:59:57 +02:00
|
|
|
this.inputType = "byteArray";
|
|
|
|
this.outputType = "byteArray";
|
|
|
|
this.args = [
|
|
|
|
{
|
|
|
|
"name": "Key",
|
|
|
|
"type": "toggleString",
|
|
|
|
"value": "",
|
2018-11-09 16:25:16 +01:00
|
|
|
"toggleValues": BITWISE_OP_DELIMS
|
2018-05-23 19:59:57 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {byteArray} input
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {byteArray}
|
|
|
|
*/
|
|
|
|
run(input, args) {
|
|
|
|
const key = Utils.convertToByteArray(args[0].string || "", args[0].option);
|
|
|
|
|
|
|
|
return bitOp(input, key, and);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight AND
|
|
|
|
*
|
|
|
|
* @param {Object[]} pos
|
|
|
|
* @param {number} pos[].start
|
|
|
|
* @param {number} pos[].end
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {Object[]} pos
|
|
|
|
*/
|
|
|
|
highlight(pos, args) {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight AND in reverse
|
|
|
|
*
|
|
|
|
* @param {Object[]} pos
|
|
|
|
* @param {number} pos[].start
|
|
|
|
* @param {number} pos[].end
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {Object[]} pos
|
|
|
|
*/
|
|
|
|
highlightReverse(pos, args) {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AND;
|