Skip to content

Commit

Permalink
Improve function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanzab committed Oct 10, 2020
1 parent 129adc3 commit cdd94c1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pikelet/src/lang/core/semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ pub enum Unfold {
}

/// Read-back a spine of eliminators into the term syntax.
fn read_back_spine(
fn read_back_stuck_value(
globals: &Globals,
local_size: LocalSize,
unfold: Unfold,
Expand Down Expand Up @@ -505,9 +505,11 @@ pub fn read_back_value(
value: &Value,
) -> Term {
match value {
Value::Stuck(head, spine) => read_back_spine(globals, local_size, unfold, head, spine),
Value::Stuck(head, spine) => {
read_back_stuck_value(globals, local_size, unfold, head, spine)
}
Value::Unstuck(head, spine, value) => match unfold {
Unfold::Never => read_back_spine(globals, local_size, unfold, head, spine),
Unfold::Never => read_back_stuck_value(globals, local_size, unfold, head, spine),
Unfold::Always => read_back_value(globals, local_size, unfold, value.force(globals)),
},

Expand Down Expand Up @@ -588,8 +590,8 @@ pub fn read_back_value(
}
}

/// Check that one suspended elimination is equal to another suspended elimination.
fn is_equal_stuck_elim(
/// Check that one stuck value is equal to another stuck value.
fn is_equal_stuck_value(
globals: &Globals,
local_size: LocalSize,
(head0, spine0): (&Head, &[Elim]),
Expand Down Expand Up @@ -623,11 +625,11 @@ fn is_equal_stuck_elim(
fn is_equal(globals: &Globals, local_size: LocalSize, value0: &Value, value1: &Value) -> bool {
match (value0, value1) {
(Value::Stuck(head0, spine0), Value::Stuck(head1, spine1)) => {
is_equal_stuck_elim(globals, local_size, (head0, spine0), (head1, spine1))
is_equal_stuck_value(globals, local_size, (head0, spine0), (head1, spine1))
}
(Value::Unstuck(head0, spine0, value0), Value::Unstuck(head1, spine1, value1)) => {
if is_equal_stuck_elim(globals, local_size, (head0, spine0), (head1, spine1)) {
// No need to force computation if the spines are the same!
if is_equal_stuck_value(globals, local_size, (head0, spine0), (head1, spine1)) {
// No need to force computation if the stuck values are the same!
return true;
}

Expand Down Expand Up @@ -771,10 +773,10 @@ pub fn is_subtype(
) -> bool {
match (value0, value1) {
(Value::Stuck(head0, spine0), Value::Stuck(head1, spine1)) => {
is_equal_stuck_elim(globals, local_size, (head0, spine0), (head1, spine1))
is_equal_stuck_value(globals, local_size, (head0, spine0), (head1, spine1))
}
(Value::Unstuck(head0, spine0, value0), Value::Unstuck(head1, spine1, value1)) => {
if is_equal_stuck_elim(globals, local_size, (head0, spine0), (head1, spine1)) {
if is_equal_stuck_value(globals, local_size, (head0, spine0), (head1, spine1)) {
// No need to force computation if the spines are the same!
return true;
}
Expand Down

0 comments on commit cdd94c1

Please sign in to comment.