summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/expr.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-10-05 18:02:51 +0200
committerGitHub <noreply@github.com>2019-10-05 18:02:51 +0200
commit47ccfabe18db3691a09f211fc4aec465ee186c2a (patch)
tree8bd02e8d5e16dee8522e29d21c711ef98282bb52 /src/video_core/shader/expr.cpp
parentMerge pull request #2888 from FernandoS27/decompiler2 (diff)
parentvideo_core/control_flow: Eliminate variable shadowing warnings (diff)
downloadyuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.gz
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.bz2
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.lz
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.xz
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.zst
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.zip
Diffstat (limited to 'src/video_core/shader/expr.cpp')
-rw-r--r--src/video_core/shader/expr.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/video_core/shader/expr.cpp b/src/video_core/shader/expr.cpp
index ca633ffb1..2647865d4 100644
--- a/src/video_core/shader/expr.cpp
+++ b/src/video_core/shader/expr.cpp
@@ -2,40 +2,51 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#pragma once
-
#include <memory>
#include <variant>
#include "video_core/shader/expr.h"
namespace VideoCommon::Shader {
+namespace {
+bool ExprIsBoolean(const Expr& expr) {
+ return std::holds_alternative<ExprBoolean>(*expr);
+}
+
+bool ExprBooleanGet(const Expr& expr) {
+ return std::get_if<ExprBoolean>(expr.get())->value;
+}
+} // Anonymous namespace
bool ExprAnd::operator==(const ExprAnd& b) const {
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
}
+bool ExprAnd::operator!=(const ExprAnd& b) const {
+ return !operator==(b);
+}
+
bool ExprOr::operator==(const ExprOr& b) const {
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
}
-bool ExprNot::operator==(const ExprNot& b) const {
- return (*operand1 == *b.operand1);
+bool ExprOr::operator!=(const ExprOr& b) const {
+ return !operator==(b);
}
-bool ExprIsBoolean(Expr expr) {
- return std::holds_alternative<ExprBoolean>(*expr);
+bool ExprNot::operator==(const ExprNot& b) const {
+ return *operand1 == *b.operand1;
}
-bool ExprBooleanGet(Expr expr) {
- return std::get_if<ExprBoolean>(expr.get())->value;
+bool ExprNot::operator!=(const ExprNot& b) const {
+ return !operator==(b);
}
Expr MakeExprNot(Expr first) {
if (std::holds_alternative<ExprNot>(*first)) {
return std::get_if<ExprNot>(first.get())->operand1;
}
- return MakeExpr<ExprNot>(first);
+ return MakeExpr<ExprNot>(std::move(first));
}
Expr MakeExprAnd(Expr first, Expr second) {
@@ -45,7 +56,7 @@ Expr MakeExprAnd(Expr first, Expr second) {
if (ExprIsBoolean(second)) {
return ExprBooleanGet(second) ? first : second;
}
- return MakeExpr<ExprAnd>(first, second);
+ return MakeExpr<ExprAnd>(std::move(first), std::move(second));
}
Expr MakeExprOr(Expr first, Expr second) {
@@ -55,14 +66,14 @@ Expr MakeExprOr(Expr first, Expr second) {
if (ExprIsBoolean(second)) {
return ExprBooleanGet(second) ? second : first;
}
- return MakeExpr<ExprOr>(first, second);
+ return MakeExpr<ExprOr>(std::move(first), std::move(second));
}
-bool ExprAreEqual(Expr first, Expr second) {
+bool ExprAreEqual(const Expr& first, const Expr& second) {
return (*first) == (*second);
}
-bool ExprAreOpposite(Expr first, Expr second) {
+bool ExprAreOpposite(const Expr& first, const Expr& second) {
if (std::holds_alternative<ExprNot>(*first)) {
return ExprAreEqual(std::get_if<ExprNot>(first.get())->operand1, second);
}
@@ -72,7 +83,7 @@ bool ExprAreOpposite(Expr first, Expr second) {
return false;
}
-bool ExprIsTrue(Expr first) {
+bool ExprIsTrue(const Expr& first) {
if (ExprIsBoolean(first)) {
return ExprBooleanGet(first);
}