Introduce true and false conditions #21
Manually merged
MightyPork
merged 2 commits from User_4574/crsn:master
into master
4 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'User_4574/crsn:master'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I learned just enough Rust to do something simple and possibly (maybe) just a little bit useful.
I added True and False conditions that are always true and false.
The most useful thing is that it allows you to have an
(else? ...)
final branch that is always taken.I did my best in terms of responsible PR, feel free to send it back for changes if you don't like something (or don't outright reject it, which is also fine :p)
Cool,
else
is useful. The compiler could emit a warning if else is not the last branch, since in that case it won't work (or will - depends how you look at it).No problem with
never
, but I also see no use for it...Idk about
always
, it's not very useful, and seems to evoke something like "finally" - to run always. Which it obviously does not, since there is no fall-through between the branches.What I don't like is
true
andfalse
- because there are instructions that write a truthy value as 0 or 1 to the output register (e.g.sc-mbtn
,sc-key
, maybe others). Logically true should be an alias of "not zero" and false of "zero"?Okay, that all makes sense. I started out wanting
else
, but when I saw how the others were implemented it made more sense to me to do it like this because it needs an opposite for not.Is there a more sensible way to do this rather than it being a cond?
Oh, you're right.
I'd do it like this then:
Cond::True
... parsed from "else", and only documented as "else"Cond::False
... not parsed and not documented (or called "never"), only to satisfy Notthe negation is used only in this one spot, I think: https://git.ondrovo.com/MightyPork/crsn/src/branch/master/crsn/src/asm/instr/flatten.rs#L70
This is also the place where you can add a warning about else not being the final branch, if you want to do that. It's fine either way with me
Okay, I've made those changes. This does feel much cleaner.
Thanks, it's merged!
54ff5fbce9
.