feat!(core): Change Signal to be a sumtype
We want to be able to reason about if a signal is empty, constant, or sampled at compile time without using any trait objects. Moreover, the core Argus library shouldn't care about how it deals with interfacing with other languages like Python. Thus, we remove the need for having an `AnySignal` type and what not.
This commit is contained in:
parent
a6a3805107
commit
4431b79bcd
10 changed files with 442 additions and 966 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::signals::utils::{apply1, apply2, apply2_const};
|
||||
use crate::signals::{ConstantSignal, Signal};
|
||||
use crate::signals::utils::{apply1, apply2};
|
||||
use crate::signals::Signal;
|
||||
|
||||
impl core::ops::Not for &Signal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
|
@ -17,14 +17,6 @@ impl core::ops::BitAnd<Self> for &Signal<bool> {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitAnd<&ConstantSignal<bool>> for &Signal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
fn bitand(self, other: &ConstantSignal<bool>) -> Self::Output {
|
||||
apply2_const(self, other, |lhs, rhs| lhs && rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitOr<Self> for &Signal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
|
|
@ -32,50 +24,3 @@ impl core::ops::BitOr<Self> for &Signal<bool> {
|
|||
apply2(self, other, |lhs, rhs| lhs || rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitOr<&ConstantSignal<bool>> for &Signal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
fn bitor(self, other: &ConstantSignal<bool>) -> Self::Output {
|
||||
apply2_const(self, other, |lhs, rhs| lhs || rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::Not for &ConstantSignal<bool> {
|
||||
type Output = ConstantSignal<bool>;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
ConstantSignal::<bool>::new(!self.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitAnd<Self> for &ConstantSignal<bool> {
|
||||
type Output = ConstantSignal<bool>;
|
||||
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
ConstantSignal::<bool>::new(self.value && rhs.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitAnd<&Signal<bool>> for &ConstantSignal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
fn bitand(self, rhs: &Signal<bool>) -> Self::Output {
|
||||
rhs & self
|
||||
}
|
||||
}
|
||||
impl core::ops::BitOr<Self> for &ConstantSignal<bool> {
|
||||
type Output = ConstantSignal<bool>;
|
||||
|
||||
fn bitor(self, rhs: Self) -> Self::Output {
|
||||
ConstantSignal::<bool>::new(self.value || rhs.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl core::ops::BitOr<&Signal<bool>> for &ConstantSignal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
fn bitor(self, rhs: &Signal<bool>) -> Self::Output {
|
||||
rhs | self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue