aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-02 21:10:41 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-02 21:11:56 +0200
commit8cfa2c11ad3354e74d5ba9b50eb6cea222a85463 (patch)
treea6fe32c808bc7909188fbb4c0eaba39bb1ad53ae /qtmips_gui
parent2aa33db8be7397d39080e6ec96a9158e0c1e63e5 (diff)
downloadqtmips-8cfa2c11ad3354e74d5ba9b50eb6cea222a85463.tar.gz
qtmips-8cfa2c11ad3354e74d5ba9b50eb6cea222a85463.tar.bz2
qtmips-8cfa2c11ad3354e74d5ba9b50eb6cea222a85463.zip
Add binary complement operation to the parser.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/fixmatheval.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/qtmips_gui/fixmatheval.cpp b/qtmips_gui/fixmatheval.cpp
index f695e30..c06d892 100644
--- a/qtmips_gui/fixmatheval.cpp
+++ b/qtmips_gui/fixmatheval.cpp
@@ -231,7 +231,11 @@ bool FmeExpression::parse(const QString &expression, QString &error) {
FmeValue (*binary_op)(FmeValue &a, FmeValue &b) = nullptr;
FmeValue (*unary_op)(FmeValue &a) = nullptr;
int prio = base_prio;
- if (ch == '-') {
+
+ if (ch == '~') {
+ prio += 90;
+ unary_op = [](FmeValue &a) -> FmeValue { return ~a; };
+ } else if (ch == '-') {
if (is_unary) {
prio += 90;
unary_op = [](FmeValue &a) -> FmeValue { return -a; };
@@ -256,6 +260,9 @@ bool FmeExpression::parse(const QString &expression, QString &error) {
} else if (ch == '&') {
binary_op = [](FmeValue &a, FmeValue &b) -> FmeValue { return a & b; };
prio += 15;
+ } else if (ch == '^') {
+ binary_op = [](FmeValue &a, FmeValue &b) -> FmeValue { return a ^ b; };
+ prio += 15;
} else if (ch == '(') {
base_prio += 100;
} else if (ch == ')') {