Skip to content

Commit ba8c48c

Browse files
committed
Simplify operations in elaborator using MachineRep
1 parent 95ec25d commit ba8c48c

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

experiments/analytic-engine/src/elaborator.rs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub(crate) struct TypedCast<TypeRep> {
184184
pub(crate) mod inference {
185185
use std::collections::HashSet;
186186

187-
use crate::core::{Bounds, Expr, NumRep};
187+
use crate::core::{Bounds, Expr, MachineRep, NumRep};
188188

189189
use super::{IntType, PrimInt};
190190

@@ -253,13 +253,6 @@ pub(crate) mod inference {
253253
}
254254
}
255255

256-
// pub fn as_backref(&self) -> Option<usize> {
257-
// match self {
258-
// Alias::Ground | Alias::Canonical(_) => None,
259-
// Alias::BackRef(ix) => Some(*ix),
260-
// }
261-
// }
262-
263256
pub fn add_forward_ref(&mut self, tgt: usize) {
264257
match self {
265258
Alias::Ground => {
@@ -327,7 +320,7 @@ pub(crate) mod inference {
327320
}
328321

329322
impl Constraint {
330-
/// Speculatively checks if this constraint is definiitely satisfiable (as-is) by a given type-assignment.
323+
/// Speculatively checks if this constraint is definitely satisfiable (as-is) by a given type-assignment.
331324
///
332325
/// If this is not statically deterministic, returns `None`.
333326
/// Returns `Some(true)` if the constraint is satisfiable by the assignment, and `Some(false)` otherwise.
@@ -341,30 +334,13 @@ pub(crate) mod inference {
341334
let IntType::Prim(candidate) = candidate;
342335
Some(
343336
bounds.is_encompassed_by(
344-
&<PrimInt as Into<NumRep>>::into(candidate)
345-
.as_bounds()
346-
.unwrap(),
337+
&<PrimInt as Into<MachineRep>>::into(candidate).as_bounds()
347338
),
348339
)
349340
}
350341
}
351342
}
352343

353-
// pub(crate) fn has_unique_assignment(&self) -> bool {
354-
// // REVIEW - there are smarter ways of calculating this
355-
// let mut solutions = 0;
356-
// for prim_int in super::PRIM_INTS.iter() {
357-
// match self.is_satisfied_by(IntType::Prim(*prim_int)) {
358-
// Some(true) => {
359-
// solutions += 1;
360-
// }
361-
// Some(false) => (),
362-
// None => return false,
363-
// }
364-
// }
365-
// solutions == 1
366-
// }
367-
368344
// NOTE - should only be called on Encompasses
369345
pub(crate) fn get_unique_solution(&self) -> InferenceResult<IntType> {
370346
// REVIEW - there are smarter ways of calculating this
@@ -759,9 +735,8 @@ pub(crate) mod inference {
759735
UType::Int(int_type) => {
760736
let IntType::Prim(candidate) = int_type;
761737
let soluble = bounds.is_encompassed_by(
762-
&<PrimInt as Into<NumRep>>::into(candidate)
763-
.as_bounds()
764-
.unwrap(),
738+
&<PrimInt as Into<MachineRep>>::into(candidate)
739+
.as_bounds(),
765740
);
766741
if soluble {
767742
Ok(Constraint::Equiv(utype))

0 commit comments

Comments
 (0)