mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Implement logical operators && ||
Unary logical NOT was already implemented earlier. Logical AND OR are expressed via conditional expression: * a && b -> a ? (b != 0) : 0 * a || b -> a ? 1 : (b != 0) They work as expected in any expressions. For instance, having `cond && f()`, f is called only if cond is true. For primitive cases, like `a > 0 && b > 0`, Fift code is not optimal, it could potentially be without IFs. These are moments of future optimizations. For now, it's more than enough.
This commit is contained in:
parent
16824fcfe3
commit
d110022731
4 changed files with 204 additions and 46 deletions
|
@ -67,8 +67,8 @@ private:
|
|||
public:
|
||||
|
||||
static constexpr sym_idx_t not_found = 0;
|
||||
sym_idx_t lookup(std::string_view str, int mode = 0) {
|
||||
return gen_lookup(str, mode);
|
||||
sym_idx_t lookup(std::string_view str) {
|
||||
return gen_lookup(str, 0);
|
||||
}
|
||||
sym_idx_t lookup_add(std::string_view str) {
|
||||
return gen_lookup(str, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue