@@ -54,31 +54,35 @@ pub fn eval_term(
54
54
Term :: Ann ( term, _) => eval_term ( globals, universe_offset, values, term) ,
55
55
Term :: RecordType ( type_entries) => match type_entries. split_first ( ) {
56
56
None => Arc :: new ( Value :: RecordTypeEmpty ) ,
57
- Some ( ( ( name , r#type ) , rest_type) ) => {
58
- let r#type = eval_term ( globals, universe_offset, values, r#type ) ;
57
+ Some ( ( ( entry_name , entry_type ) , rest_type) ) => {
58
+ let entry_type = eval_term ( globals, universe_offset, values, entry_type ) ;
59
59
let rest_types = Closure :: new (
60
60
universe_offset,
61
61
values. clone ( ) ,
62
62
Arc :: new ( Term :: RecordType ( rest_type. to_owned ( ) ) ) , // FIXME: expensive to_owned?
63
63
) ;
64
64
65
- Arc :: new ( Value :: RecordTypeExtend ( name. clone ( ) , r#type, rest_types) )
65
+ Arc :: new ( Value :: RecordTypeExtend (
66
+ entry_name. clone ( ) ,
67
+ entry_type,
68
+ rest_types,
69
+ ) )
66
70
}
67
71
} ,
68
72
Term :: RecordTerm ( term_entries) => {
69
73
let value_entries = term_entries
70
74
. iter ( )
71
- . map ( |( name , term ) | {
72
- let term = eval_term ( globals, universe_offset, values, term ) ;
73
- ( name . clone ( ) , term )
75
+ . map ( |( entry_name , entry_term ) | {
76
+ let entry_term = eval_term ( globals, universe_offset, values, entry_term ) ;
77
+ ( entry_name . clone ( ) , entry_term )
74
78
} )
75
79
. collect ( ) ;
76
80
77
81
Arc :: new ( Value :: RecordTerm ( value_entries) )
78
82
}
79
- Term :: RecordElim ( head, field_name ) => {
83
+ Term :: RecordElim ( head, name ) => {
80
84
let head = eval_term ( globals, universe_offset, values, head) ;
81
- eval_record_elim ( globals, & head, field_name )
85
+ eval_record_elim ( globals, & head, name )
82
86
}
83
87
Term :: FunctionType ( param_type, body_type) => {
84
88
let param_type = eval_term ( globals, universe_offset, values, param_type) ;
@@ -131,10 +135,10 @@ pub fn eval_record_elim(globals: &Globals, head_value: &Value, name: &str) -> Ar
131
135
Value :: Elim ( head, elims, r#type) => {
132
136
let mut current_type = r#type. clone ( ) ;
133
137
134
- while let Value :: RecordTypeExtend ( current_name , entry_type, rest_type) =
138
+ while let Value :: RecordTypeExtend ( entry_name , entry_type, rest_type) =
135
139
current_type. as_ref ( )
136
140
{
137
- if name == current_name {
141
+ if name == entry_name {
138
142
let mut elims = elims. clone ( ) ; // TODO: Avoid clone?
139
143
elims. push ( Elim :: Record ( name. to_owned ( ) ) ) ;
140
144
return Arc :: new ( Value :: Elim ( head. clone ( ) , elims, entry_type. clone ( ) ) ) ;
@@ -220,18 +224,18 @@ pub fn read_back_nf(
220
224
_ => Term :: Error , // TODO: Report error
221
225
}
222
226
}
223
- ( Value :: RecordTerm ( _) , Value :: RecordTypeExtend ( name , entry_type, rest_type) ) => {
227
+ ( Value :: RecordTerm ( _) , Value :: RecordTypeExtend ( entry_name , entry_type, rest_type) ) => {
224
228
let mut term_entries = BTreeMap :: new ( ) ;
225
229
226
- let entry_value = eval_record_elim ( globals, value, name ) ;
230
+ let entry_value = eval_record_elim ( globals, value, entry_name ) ;
227
231
let entry_term = read_back_nf ( globals, local_size, & entry_value, entry_type) ;
228
- term_entries. insert ( name . clone ( ) , Arc :: new ( entry_term) ) ;
232
+ term_entries. insert ( entry_name . clone ( ) , Arc :: new ( entry_term) ) ;
229
233
let mut r#type = eval_closure_elim ( globals, rest_type, entry_value) ;
230
234
231
- while let Value :: RecordTypeExtend ( name , entry_type, rest_type) = r#type. as_ref ( ) {
232
- let entry_value = eval_record_elim ( globals, value, name ) ;
235
+ while let Value :: RecordTypeExtend ( entry_name , entry_type, rest_type) = r#type. as_ref ( ) {
236
+ let entry_value = eval_record_elim ( globals, value, entry_name ) ;
233
237
let entry_term = read_back_nf ( globals, local_size, & entry_value, entry_type) ;
234
- term_entries. insert ( name . clone ( ) , Arc :: new ( entry_term) ) ;
238
+ term_entries. insert ( entry_name . clone ( ) , Arc :: new ( entry_term) ) ;
235
239
r#type = eval_closure_elim ( globals, rest_type, entry_value) ;
236
240
}
237
241
@@ -263,20 +267,20 @@ pub fn read_back_type(globals: &Globals, local_size: LocalSize, r#type: &Value)
263
267
match r#type {
264
268
Value :: Universe ( level) => Term :: Universe ( * level) ,
265
269
Value :: Elim ( head, spine, _) => read_back_elim ( globals, local_size, head, spine) ,
266
- Value :: RecordTypeExtend ( name , entry_type, rest_type) => {
270
+ Value :: RecordTypeExtend ( entry_name , entry_type, rest_type) => {
267
271
let mut local_size = local_size;
268
272
let mut type_entries = Vec :: new ( ) ;
269
273
270
274
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) , entry_type. clone ( ) ) ) ;
271
275
let entry_type = Arc :: new ( read_back_type ( globals, local_size, entry_type) ) ;
272
- type_entries. push ( ( name . clone ( ) , entry_type) ) ;
276
+ type_entries. push ( ( entry_name . clone ( ) , entry_type) ) ;
273
277
local_size = local_size. increment ( ) ;
274
278
let mut r#type = eval_closure_elim ( globals, rest_type, local) ;
275
279
276
- while let Value :: RecordTypeExtend ( name , entry_type, rest_type) = r#type. as_ref ( ) {
280
+ while let Value :: RecordTypeExtend ( entry_name , entry_type, rest_type) = r#type. as_ref ( ) {
277
281
let local = Arc :: new ( Value :: local ( local_size. next_level ( ) , entry_type. clone ( ) ) ) ;
278
282
let entry_type = Arc :: new ( read_back_type ( globals, local_size, entry_type) ) ;
279
- type_entries. push ( ( name . clone ( ) , entry_type) ) ;
283
+ type_entries. push ( ( entry_name . clone ( ) , entry_type) ) ;
280
284
local_size = local_size. increment ( ) ;
281
285
r#type = eval_closure_elim ( globals, rest_type, local) ;
282
286
}
@@ -344,14 +348,14 @@ fn compare_types(
344
348
is_equal_elim ( globals, local_size, ( head0, spine0) , ( head1, spine1) )
345
349
}
346
350
(
347
- Value :: RecordTypeExtend ( name0 , entry_type0, rest_type0) ,
348
- Value :: RecordTypeExtend ( name1 , entry_type1, rest_type1) ,
351
+ Value :: RecordTypeExtend ( entry_name0 , entry_type0, rest_type0) ,
352
+ Value :: RecordTypeExtend ( entry_name1 , entry_type1, rest_type1) ,
349
353
) => {
350
- name0 == name1
354
+ entry_name0 == entry_name1
351
355
&& compare_types ( globals, local_size, entry_type0, entry_type1, compare)
352
356
&& {
353
- let local =
354
- Arc :: new ( Value :: local ( local_size . next_level ( ) , entry_type0. clone ( ) ) ) ;
357
+ let level = local_size . next_level ( ) ;
358
+ let local = Arc :: new ( Value :: local ( level , entry_type0. clone ( ) ) ) ;
355
359
356
360
compare_types (
357
361
globals,
0 commit comments