Compare commits

..

10 Commits

Author SHA1 Message Date
David Mak 847d19077e core: Implement elementwise comparison operators 2024-04-02 16:56:27 +08:00
David Mak a1310570d1 core: Implement elementwise unary operators 2024-04-02 16:56:27 +08:00
David Mak 7ba5bfa33d core: Implement elementwise binary operators
Including immediate variants of these operators.
2024-04-02 16:56:27 +08:00
David Mak 08ee380512 core/magic_methods: Add typeof_*op
Used to determine the expected type of the binary operator with
primitive operands.
2024-04-02 16:56:22 +08:00
David Mak 90d95efd5c core/toplevel/numpy: Split ndarray type var utilities 2024-04-02 16:49:12 +08:00
David Mak 08f1a1c8b7 core: Implement calculations for broadcasting ndarrays 2024-04-02 16:49:12 +08:00
David Mak f50a5f0345 core/type_inferencer: Allow both int32 and isize when indexing ndarray 2024-04-02 16:49:12 +08:00
David Mak a77fd213e0 core/magic_methods: Allow unknown return types
These types can be later inferred by the type inferencer.
2024-04-02 16:49:12 +08:00
David Mak 8f1497df83 core/helper: Add PrimitiveDefinitionIds::iter 2024-04-02 16:49:12 +08:00
David Mak 5ca2dbeec8 core/typedef: Add Type::obj_id to replace get_obj_id 2024-04-02 16:49:10 +08:00
2 changed files with 5 additions and 8 deletions

View File

@ -233,10 +233,11 @@ impl Display for SymbolValue {
impl TryFrom<SymbolValue> for u64 {
type Error = ();
/// TODO
/// Tries to convert a [`SymbolValue`] into a [`u64`], returning [`Err`] if the value is not
/// numeric or if the value cannot be converted into a `u64` without overflow.
fn try_from(value: SymbolValue) -> Result<Self, Self::Error> {
match value {
SymbolValue::I32(v) => Ok(v as u64),
SymbolValue::I32(v) => u64::try_from(v).map_err(|_| ()),
SymbolValue::I64(v) => u64::try_from(v).map_err(|_| ()),
SymbolValue::U32(v) => Ok(v as u64),
SymbolValue::U64(v) => Ok(v),
@ -248,7 +249,8 @@ impl TryFrom<SymbolValue> for u64 {
impl TryFrom<SymbolValue> for i128 {
type Error = ();
/// TODO
/// Tries to convert a [`SymbolValue`] into a [`i128`], returning [`Err`] if the value is not
/// numeric.
fn try_from(value: SymbolValue) -> Result<Self, Self::Error> {
match value {
SymbolValue::I32(v) => Ok(v as i128),

View File

@ -71,11 +71,6 @@ impl Type {
None
}
}
#[deprecated = "Prefer using `Type::obj_id` instead to handle non-TObj cases."]
pub fn get_obj_id(self, unifier: &Unifier) -> DefinitionId {
self.obj_id(unifier).expect("expect a object type")
}
}
impl From<&RecordKey> for StrRef {