@@ -132,9 +132,9 @@ impl Closure {
132
132
}
133
133
134
134
/// Eliminate a closure.
135
- pub fn elim ( & self , globals : & Globals , argument : Arc < Value > ) -> Arc < Value > {
135
+ pub fn elim ( & self , globals : & Globals , input : Arc < Value > ) -> Arc < Value > {
136
136
let mut values = self . values . clone ( ) ;
137
- values. push ( argument ) ;
137
+ values. push ( input ) ;
138
138
eval_term ( globals, self . universe_offset , & mut values, & self . term )
139
139
}
140
140
}
@@ -232,8 +232,8 @@ impl LazyValue {
232
232
Some ( LazyInit :: ApplyElim ( head, Elim :: Record ( label) ) ) => {
233
233
apply_record_elim ( head. force ( globals) , & label)
234
234
}
235
- Some ( LazyInit :: ApplyElim ( head, Elim :: Function ( argument ) ) ) => {
236
- apply_function_elim ( globals, head. force ( globals) , argument )
235
+ Some ( LazyInit :: ApplyElim ( head, Elim :: Function ( input ) ) ) => {
236
+ apply_function_elim ( globals, head. force ( globals) , input )
237
237
}
238
238
None => panic ! ( "Lazy instance has previously been poisoned" ) ,
239
239
} )
@@ -312,21 +312,21 @@ pub fn eval_term(
312
312
let head = eval_term ( globals, universe_offset, values, head) ;
313
313
apply_record_elim ( & head, label)
314
314
}
315
- Term :: FunctionType ( param_name_hint , param_type , body_type ) => {
316
- let param_name_hint = param_name_hint . clone ( ) ;
317
- let param_type = eval_term ( globals , universe_offset , values , param_type ) ;
318
- let body_type = Closure :: new ( universe_offset, values. clone ( ) , body_type . clone ( ) ) ;
319
-
320
- Arc :: new ( Value :: FunctionType ( param_name_hint , param_type , body_type ) )
315
+ Term :: FunctionType ( input_name_hint , input_type , output_type ) => {
316
+ Arc :: new ( Value :: FunctionType (
317
+ input_name_hint . clone ( ) ,
318
+ eval_term ( globals , universe_offset, values, input_type ) ,
319
+ Closure :: new ( universe_offset , values . clone ( ) , output_type . clone ( ) ) ,
320
+ ) )
321
321
}
322
- Term :: FunctionTerm ( param_name , body ) => Arc :: new ( Value :: FunctionTerm (
323
- param_name . clone ( ) ,
324
- Closure :: new ( universe_offset, values. clone ( ) , body . clone ( ) ) ,
322
+ Term :: FunctionTerm ( input_name , output_term ) => Arc :: new ( Value :: FunctionTerm (
323
+ input_name . clone ( ) ,
324
+ Closure :: new ( universe_offset, values. clone ( ) , output_term . clone ( ) ) ,
325
325
) ) ,
326
- Term :: FunctionElim ( head, argument ) => {
326
+ Term :: FunctionElim ( head, input ) => {
327
327
let head = eval_term ( globals, universe_offset, values, head) ;
328
- let argument = LazyValue :: eval_term ( universe_offset, values. clone ( ) , argument . clone ( ) ) ;
329
- apply_function_elim ( globals, & head, Arc :: new ( argument ) )
328
+ let input = LazyValue :: eval_term ( universe_offset, values. clone ( ) , input . clone ( ) ) ;
329
+ apply_function_elim ( globals, & head, Arc :: new ( input ) )
330
330
}
331
331
Term :: Lift ( term, offset) => {
332
332
let universe_offset = ( universe_offset + * offset) . unwrap ( ) ; // FIXME: Handle overflow
@@ -379,26 +379,22 @@ fn apply_record_elim(head_value: &Value, label: &str) -> Arc<Value> {
379
379
}
380
380
381
381
/// Apply a function term elimination.
382
- fn apply_function_elim (
383
- globals : & Globals ,
384
- head_value : & Value ,
385
- argument : Arc < LazyValue > ,
386
- ) -> Arc < Value > {
382
+ fn apply_function_elim ( globals : & Globals , head_value : & Value , input : Arc < LazyValue > ) -> Arc < Value > {
387
383
match head_value {
388
384
Value :: Stuck ( head, spine) => {
389
385
let mut spine = spine. clone ( ) ; // FIXME: Avoid clone of spine?
390
- spine. push ( Elim :: Function ( argument ) ) ;
386
+ spine. push ( Elim :: Function ( input ) ) ;
391
387
Arc :: new ( Value :: Stuck ( head. clone ( ) , spine) )
392
388
}
393
389
Value :: Unstuck ( head, spine, value) => {
394
390
let mut spine = spine. clone ( ) ; // FIXME: Avoid clone of spine?
395
- spine. push ( Elim :: Function ( argument . clone ( ) ) ) ;
396
- let value = LazyValue :: apply_elim ( value. clone ( ) , Elim :: Function ( argument ) ) ;
391
+ spine. push ( Elim :: Function ( input . clone ( ) ) ) ;
392
+ let value = LazyValue :: apply_elim ( value. clone ( ) , Elim :: Function ( input ) ) ;
397
393
Arc :: new ( Value :: Unstuck ( head. clone ( ) , spine, Arc :: new ( value) ) )
398
394
}
399
395
400
- Value :: FunctionTerm ( _, body_closure ) => {
401
- body_closure . elim ( globals, argument . force ( globals) . clone ( ) )
396
+ Value :: FunctionTerm ( _, output_closure ) => {
397
+ output_closure . elim ( globals, input . force ( globals) . clone ( ) )
402
398
}
403
399
404
400
_ => Arc :: new ( Value :: Error ) ,
@@ -430,9 +426,9 @@ fn read_back_spine(
430
426
431
427
spine. iter ( ) . fold ( head, |head, elim| match elim {
432
428
Elim :: Record ( label) => Term :: RecordElim ( Arc :: new ( head) , label. clone ( ) ) ,
433
- Elim :: Function ( argument ) => {
434
- let argument = read_back_value ( globals, local_size, unfold, argument . force ( globals) ) ;
435
- Term :: FunctionElim ( Arc :: new ( head) , Arc :: new ( argument ) )
429
+ Elim :: Function ( input ) => {
430
+ let input = read_back_value ( globals, local_size, unfold, input . force ( globals) ) ;
431
+ Term :: FunctionElim ( Arc :: new ( head) , Arc :: new ( input ) )
436
432
}
437
433
} )
438
434
}
@@ -490,20 +486,22 @@ pub fn read_back_value(
490
486
491
487
Term :: RecordTerm ( term_entries)
492
488
}
493
- Value :: FunctionType ( param_name_hint , param_type , body_closure ) => {
489
+ Value :: FunctionType ( input_name_hint , input_type , output_closure ) => {
494
490
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) ) ) ;
495
- let param_type = Arc :: new ( read_back_value ( globals, local_size, unfold, param_type) ) ;
496
- let body_type = body_closure. elim ( globals, local) ;
497
- let body_type = read_back_value ( globals, local_size. increment ( ) , unfold, & body_type) ;
491
+ let input_type = Arc :: new ( read_back_value ( globals, local_size, unfold, input_type) ) ;
492
+ let output_type = output_closure. elim ( globals, local) ;
493
+ let output_type =
494
+ read_back_value ( globals, local_size. increment ( ) , unfold, & output_type) ;
498
495
499
- Term :: FunctionType ( param_name_hint . clone ( ) , param_type , Arc :: new ( body_type ) )
496
+ Term :: FunctionType ( input_name_hint . clone ( ) , input_type , Arc :: new ( output_type ) )
500
497
}
501
- Value :: FunctionTerm ( param_name_hint , body_closure ) => {
498
+ Value :: FunctionTerm ( input_name_hint , output_closure ) => {
502
499
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) ) ) ;
503
- let body = body_closure. elim ( globals, local) ;
504
- let body = read_back_value ( globals, local_size. increment ( ) , unfold, & body) ;
500
+ let output_term = output_closure. elim ( globals, local) ;
501
+ let output_term =
502
+ read_back_value ( globals, local_size. increment ( ) , unfold, & output_term) ;
505
503
506
- Term :: FunctionTerm ( param_name_hint . clone ( ) , Arc :: new ( body ) )
504
+ Term :: FunctionTerm ( input_name_hint . clone ( ) , Arc :: new ( output_term ) )
507
505
}
508
506
509
507
Value :: Error => Term :: Error ,
@@ -523,11 +521,11 @@ pub fn is_equal_spine(
523
521
524
522
for ( elim0, elim1) in Iterator :: zip ( spine0. iter ( ) , spine1. iter ( ) ) {
525
523
match ( elim0, elim1) {
526
- ( Elim :: Function ( argument0 ) , Elim :: Function ( argument1 ) ) => {
527
- let argument0 = argument0 . force ( globals) ;
528
- let argument1 = argument1 . force ( globals) ;
524
+ ( Elim :: Function ( input0 ) , Elim :: Function ( input1 ) ) => {
525
+ let input0 = input0 . force ( globals) ;
526
+ let input1 = input1 . force ( globals) ;
529
527
530
- if !is_equal ( globals, local_size, argument0 , argument1 ) {
528
+ if !is_equal ( globals, local_size, input0 , input1 ) {
531
529
return false ;
532
530
}
533
531
}
@@ -620,25 +618,29 @@ fn is_equal(globals: &Globals, local_size: LocalSize, value0: &Value, value1: &V
620
618
)
621
619
}
622
620
(
623
- Value :: FunctionType ( _, param_type0 , body_closure0 ) ,
624
- Value :: FunctionType ( _, param_type1 , body_closure1 ) ,
621
+ Value :: FunctionType ( _, input_type0 , output_closure0 ) ,
622
+ Value :: FunctionType ( _, input_type1 , output_closure1 ) ,
625
623
) => {
626
- if !is_equal ( globals, local_size, param_type1 , param_type0 ) {
624
+ if !is_equal ( globals, local_size, input_type1 , input_type0 ) {
627
625
return false ;
628
626
}
629
627
630
628
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) ) ) ;
631
- let body_term0 = body_closure0. elim ( globals, local. clone ( ) ) ;
632
- let body_term1 = body_closure1. elim ( globals, local) ;
633
-
634
- is_equal ( globals, local_size. increment ( ) , & body_term0, & body_term1)
629
+ is_equal (
630
+ globals,
631
+ local_size. increment ( ) ,
632
+ & output_closure0. elim ( globals, local. clone ( ) ) ,
633
+ & output_closure1. elim ( globals, local) ,
634
+ )
635
635
}
636
- ( Value :: FunctionTerm ( _, body_closure0 ) , Value :: FunctionTerm ( _, body_closure1 ) ) => {
636
+ ( Value :: FunctionTerm ( _, output_closure0 ) , Value :: FunctionTerm ( _, output_closure1 ) ) => {
637
637
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) ) ) ;
638
- let body_value0 = body_closure0. elim ( globals, local. clone ( ) ) ;
639
- let body_value1 = body_closure1. elim ( globals, local) ;
640
-
641
- is_equal ( globals, local_size. increment ( ) , & body_value0, & body_value1)
638
+ is_equal (
639
+ globals,
640
+ local_size. increment ( ) ,
641
+ & output_closure0. elim ( globals, local. clone ( ) ) ,
642
+ & output_closure1. elim ( globals, local) ,
643
+ )
642
644
}
643
645
644
646
// Errors are always treated as subtypes, regardless of what they are compared with.
@@ -711,18 +713,23 @@ pub fn is_subtype(
711
713
true
712
714
}
713
715
(
714
- Value :: FunctionType ( _, param_type0 , body_closure0 ) ,
715
- Value :: FunctionType ( _, param_type1 , body_closure1 ) ,
716
+ Value :: FunctionType ( _, input_type0 , output_closure0 ) ,
717
+ Value :: FunctionType ( _, input_type1 , output_closure1 ) ,
716
718
) => {
717
- if !is_subtype ( globals, local_size, param_type1 , param_type0 ) {
719
+ if !is_subtype ( globals, local_size, input_type1 , input_type0 ) {
718
720
return false ;
719
721
}
720
722
721
723
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) ) ) ;
722
- let body_term0 = body_closure0. elim ( globals, local. clone ( ) ) ;
723
- let body_term1 = body_closure1. elim ( globals, local) ;
724
-
725
- is_subtype ( globals, local_size. increment ( ) , & body_term0, & body_term1)
724
+ let output_term0 = output_closure0. elim ( globals, local. clone ( ) ) ;
725
+ let output_term1 = output_closure1. elim ( globals, local) ;
726
+
727
+ is_subtype (
728
+ globals,
729
+ local_size. increment ( ) ,
730
+ & output_term0,
731
+ & output_term1,
732
+ )
726
733
}
727
734
728
735
// Errors are always treated as subtypes, regardless of what they are compared with.
0 commit comments