MCPcopy Create free account
hub / github.com/crosire/reshade / parse_expression_multary

Method parse_expression_multary

source/effect_parser_exp.cpp:1488–1757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486}
1487
1488bool reshadefx::parser::parse_expression_multary(expression &lhs_exp, unsigned int left_precedence)
1489{
1490 const bool precise = lhs_exp.type.has(type::q_precise);
1491
1492 // Parse left hand side of the expression
1493 if (!parse_expression_unary(lhs_exp))
1494 return false;
1495
1496 // Check if an operator exists so that this is a binary or ternary expression
1497 unsigned int right_precedence;
1498
1499 while (peek_multary_op(right_precedence))
1500 {
1501 // Only process this operator if it has a lower precedence than the current operation, otherwise leave it for later and abort
1502 if (right_precedence <= left_precedence)
1503 break;
1504
1505 // Finally consume the operator token
1506 consume();
1507
1508 const tokenid op = _token.id;
1509
1510 // Check if this is a binary or ternary operation
1511 if (op != tokenid::question)
1512 {
1513#if RESHADEFX_SHORT_CIRCUIT
1514 codegen::id lhs_block = 0;
1515 codegen::id rhs_block = 0;
1516 codegen::id merge_block = 0;
1517
1518 // Switch block to a new one before parsing right-hand side value in case it needs to be skipped during short-circuiting
1519 if (op == tokenid::ampersand_ampersand || op == tokenid::pipe_pipe)
1520 {
1521 lhs_block = _codegen->set_block(0);
1522 rhs_block = _codegen->create_block();
1523 merge_block = _codegen->create_block();
1524
1525 _codegen->enter_block(rhs_block);
1526 }
1527#endif
1528 expression rhs_exp;
1529 // Propagate precise qualifier to the right hand side
1530 if (precise)
1531 rhs_exp.type.qualifiers |= type::q_precise;
1532
1533 // Parse the right hand side of the binary operation
1534 if (!parse_expression_multary(rhs_exp, right_precedence))
1535 return false;
1536
1537 // Deduce the result base type based on implicit conversion rules
1538 type type = type::merge(lhs_exp.type, rhs_exp.type);
1539 bool is_bool_result = false;
1540
1541 // Do some error checking depending on the operator
1542 if (op == tokenid::equal_equal || op == tokenid::exclaim_equal)
1543 {
1544 // Equality checks return a boolean value
1545 is_bool_result = true;

Callers

nothing calls this directly

Calls 15

mergeFunction · 0.85
create_blockMethod · 0.80
is_arrayMethod · 0.80
is_booleanMethod · 0.80
is_integralMethod · 0.80
is_scalarMethod · 0.80
is_vectorMethod · 0.80
is_matrixMethod · 0.80
componentsMethod · 0.80
add_cast_operationMethod · 0.80
reset_to_rvalueMethod · 0.80

Tested by

no test coverage detected