mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Update
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
//! The intermediate representation.
|
||||
|
||||
mod dtype;
|
||||
mod equiv;
|
||||
mod interp;
|
||||
#[allow(clippy::all)]
|
||||
mod parse;
|
||||
mod write_ir;
|
||||
|
||||
@@ -247,11 +250,7 @@ impl HasDtype for Instruction {
|
||||
|
||||
impl Instruction {
|
||||
pub fn is_pure(&self) -> bool {
|
||||
match self {
|
||||
Self::Store { .. } => false,
|
||||
Self::Call { .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self, Self::Store { .. } | Self::Call { .. })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,6 +525,7 @@ impl TryFrom<&ast::Constant> for Constant {
|
||||
ast::IntegerBase::Decimal => Self::DECIMAL,
|
||||
ast::IntegerBase::Octal => Self::OCTAL,
|
||||
ast::IntegerBase::Hexadecimal => Self::HEXADECIMAL,
|
||||
ast::IntegerBase::Binary => Self::BINARY,
|
||||
};
|
||||
|
||||
let value = if integer.suffix.unsigned {
|
||||
@@ -636,14 +636,11 @@ impl Constant {
|
||||
const DECIMAL: u32 = 10;
|
||||
const OCTAL: u32 = 8;
|
||||
const HEXADECIMAL: u32 = 16;
|
||||
const BINARY: u32 = 2;
|
||||
|
||||
#[inline]
|
||||
pub fn is_integer_constant(&self) -> bool {
|
||||
if let Self::Int { .. } = self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(self, Self::Int { .. })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -730,17 +727,13 @@ impl Constant {
|
||||
}
|
||||
_ => panic!(
|
||||
"constant value generated by `Constant::from_ast_expression` \
|
||||
must be `Constant{{Int, Float}}`"
|
||||
must be `Constant(Int, Float)`"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_undef(&self) -> bool {
|
||||
if let Self::Undef { .. } = self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(self, Self::Undef { .. })
|
||||
}
|
||||
|
||||
pub fn typecast(self, target_dtype: Dtype) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user