Compare commits

...

4 Commits

Author SHA1 Message Date
Jordan Woyak
04e3deb9ef
Merge 5078a63084 into 2c92e5b5b3 2024-11-12 13:28:59 -06:00
OatmealDome
2c92e5b5b3
Merge pull request #13160 from cpba/flatpak-6.8-runtime
Flatpak: Upgrade kde runtime to 6.8
2024-11-12 00:30:46 -05:00
Carles Pastor
fe96bf4108 Flatpak: Upgrade kde runtime to 6.8
this version bundles SDL2-2.30.6, the temporary measure of building the
vendored version from exports is no longer necessary.
2024-11-10 12:06:06 +01:00
Jordan Woyak
5078a63084 InputCommon: Add ternary conditional operator to input expressions. 2024-11-07 08:31:25 -06:00
5 changed files with 53 additions and 39 deletions

View File

@ -1,22 +0,0 @@
{
"name": "SDL2",
"buildsystem": "autotools",
"config-opts": ["--disable-static"],
"sources": [
{
"type": "dir",
"path": "../../Externals/SDL/SDL"
}
],
"cleanup": [ "/bin/sdl2-config",
"/include",
"/lib/libSDL2.la",
"/lib/libSDL2main.a",
"/lib/libSDL2main.la",
"/lib/libSDL2_test.a",
"/lib/libSDL2_test.la",
"/lib/cmake",
"/share/aclocal",
"/lib/pkgconfig"]
}

View File

@ -1,6 +1,6 @@
app-id: org.DolphinEmu.dolphin-emu app-id: org.DolphinEmu.dolphin-emu
runtime: org.kde.Platform runtime: org.kde.Platform
runtime-version: '6.7' runtime-version: '6.8'
sdk: org.kde.Sdk sdk: org.kde.Sdk
command: dolphin-emu-wrapper command: dolphin-emu-wrapper
rename-desktop-file: dolphin-emu.desktop rename-desktop-file: dolphin-emu.desktop
@ -47,9 +47,6 @@ modules:
url: https://github.com/Unrud/xdg-screensaver-shim/archive/0.0.2.tar.gz url: https://github.com/Unrud/xdg-screensaver-shim/archive/0.0.2.tar.gz
sha256: 0ed2a69fe6ee6cbffd2fe16f85116db737f17fb1e79bfb812d893cf15c728399 sha256: 0ed2a69fe6ee6cbffd2fe16f85116db737f17fb1e79bfb812d893cf15c728399
# build the vendored SDL2 from Externals until the runtime gets 2.30.6
- SDL2/SDL2.json
- name: dolphin-emu - name: dolphin-emu
buildsystem: cmake-ninja buildsystem: cmake-ninja
config-opts: config-opts:

View File

@ -160,6 +160,8 @@ void ControlExpressionSyntaxHighlighter::highlightBlock(const QString&)
case TokenType::TOK_LPAREN: case TokenType::TOK_LPAREN:
case TokenType::TOK_RPAREN: case TokenType::TOK_RPAREN:
case TokenType::TOK_COMMA: case TokenType::TOK_COMMA:
case TokenType::TOK_QUESTION:
case TokenType::TOK_COLON:
char_format = GetSpecialCharFormat(); char_format = GetSpecialCharFormat();
break; break;
case TokenType::TOK_LITERAL: case TokenType::TOK_LITERAL:
@ -290,6 +292,7 @@ void IOWindow::CreateMainLayout()
m_operators_combo->addItem(tr("< Less-than")); m_operators_combo->addItem(tr("< Less-than"));
m_operators_combo->addItem(tr("& And")); m_operators_combo->addItem(tr("& And"));
m_operators_combo->addItem(tr("^ Xor")); m_operators_combo->addItem(tr("^ Xor"));
m_operators_combo->addItem(tr("? Conditional"));
} }
m_operators_combo->addItem(tr("| Or")); m_operators_combo->addItem(tr("| Or"));
m_operators_combo->addItem(tr("$ User Variable")); m_operators_combo->addItem(tr("$ User Variable"));

View File

@ -168,6 +168,10 @@ Token Lexer::NextToken()
return Token(TOK_RPAREN); return Token(TOK_RPAREN);
case '@': case '@':
return Token(TOK_HOTKEY); return Token(TOK_HOTKEY);
case '?':
return Token(TOK_QUESTION);
case ':':
return Token(TOK_COLON);
case '&': case '&':
return Token(TOK_AND); return Token(TOK_AND);
case '|': case '|':
@ -745,7 +749,7 @@ private:
{ {
// Read one argument. // Read one argument.
// Grab an expression, but stop at comma. // Grab an expression, but stop at comma.
auto arg = ParseBinary(BinaryOperatorPrecedence(TOK_COMMA)); auto arg = ParseInfixOperations(OperatorPrecedence(TOK_COMMA));
if (ParseStatus::Successful != arg.status) if (ParseStatus::Successful != arg.status)
return arg; return arg;
@ -844,7 +848,7 @@ private:
} }
} }
static int BinaryOperatorPrecedence(TokenType type) static constexpr int OperatorPrecedence(TokenType type = TOK_EOF)
{ {
switch (type) switch (type)
{ {
@ -865,16 +869,16 @@ private:
case TOK_OR: case TOK_OR:
return 6; return 6;
case TOK_ASSIGN: case TOK_ASSIGN:
case TOK_QUESTION:
return 7; return 7;
case TOK_COMMA: case TOK_COMMA:
return 8; return 8;
default: default:
ASSERT(false); return 999;
return 0;
} }
} }
ParseResult ParseBinary(int precedence = 999) ParseResult ParseInfixOperations(int precedence = OperatorPrecedence())
{ {
ParseResult lhs = ParseAtom(Chew()); ParseResult lhs = ParseAtom(Chew());
@ -884,18 +888,48 @@ private:
std::unique_ptr<Expression> expr = std::move(lhs.expr); std::unique_ptr<Expression> expr = std::move(lhs.expr);
// TODO: handle LTR/RTL associativity? // TODO: handle LTR/RTL associativity?
while (Peek().IsBinaryOperator() && BinaryOperatorPrecedence(Peek().type) < precedence) while (true)
{ {
const Token tok = Chew(); const Token op = Peek();
ParseResult rhs = ParseBinary(BinaryOperatorPrecedence(tok.type)); if (op.IsBinaryOperator() && OperatorPrecedence(op.type) < precedence)
if (rhs.status == ParseStatus::SyntaxError)
{ {
return rhs; Chew();
ParseResult rhs = ParseInfixOperations(OperatorPrecedence(op.type));
if (rhs.status == ParseStatus::SyntaxError)
return rhs;
expr = std::make_unique<BinaryExpression>(op.type, std::move(expr), std::move(rhs.expr));
} }
else if (op.type == TOK_QUESTION && OperatorPrecedence(TOK_QUESTION) <= precedence)
{
// Handle conditional operator: (a ? b : c)
Chew();
auto true_result = ParseInfixOperations(OperatorPrecedence(op.type));
if (true_result.status != ParseStatus::Successful)
return true_result;
expr = std::make_unique<BinaryExpression>(tok.type, std::move(expr), std::move(rhs.expr)); const Token should_be_colon = Chew();
if (should_be_colon.type != TOK_COLON)
return ParseResult::MakeErrorResult(should_be_colon,
Common::GetStringT("Expected colon."));
auto false_result = ParseInfixOperations(OperatorPrecedence(op.type));
if (false_result.status != ParseStatus::Successful)
return false_result;
auto conditional = MakeFunctionExpression("if");
std::vector<std::unique_ptr<Expression>> args;
args.emplace_back(std::move(expr));
args.emplace_back(std::move(true_result.expr));
args.emplace_back(std::move(false_result.expr));
conditional->SetArguments(std::move(args));
expr = std::move(conditional);
}
else
{
break;
}
} }
return ParseResult::MakeSuccessfulResult(std::move(expr)); return ParseResult::MakeSuccessfulResult(std::move(expr));
} }
@ -948,7 +982,7 @@ private:
return ParseResult::MakeSuccessfulResult(std::make_unique<HotkeyExpression>(std::move(inputs))); return ParseResult::MakeSuccessfulResult(std::make_unique<HotkeyExpression>(std::move(inputs)));
} }
ParseResult ParseToplevel() { return ParseBinary(); } ParseResult ParseToplevel() { return ParseInfixOperations(); }
}; // namespace ExpressionParser }; // namespace ExpressionParser
ParseResult ParseTokens(const std::vector<Token>& tokens) ParseResult ParseTokens(const std::vector<Token>& tokens)

View File

@ -26,6 +26,8 @@ enum TokenType
TOK_BAREWORD, TOK_BAREWORD,
TOK_COMMENT, TOK_COMMENT,
TOK_HOTKEY, TOK_HOTKEY,
TOK_QUESTION,
TOK_COLON,
// Binary Ops: // Binary Ops:
TOK_BINARY_OPS_BEGIN, TOK_BINARY_OPS_BEGIN,
TOK_AND = TOK_BINARY_OPS_BEGIN, TOK_AND = TOK_BINARY_OPS_BEGIN,