@@ -42,38 +42,42 @@ pub(super) fn bootstrapping_compile(
42
42
Ok ( ( ) )
43
43
}
44
44
45
- fn lower_bound_of_target_clause ( skeleton : & mut PredicateSkeleton , target_pos : usize ) -> usize {
45
+ fn lower_bound_of_target_clause ( skeleton : & PredicateSkeleton , target_pos : usize ) -> usize {
46
46
if target_pos == 0 {
47
47
return 0 ;
48
48
}
49
49
50
- let index = target_pos - 1 ;
51
- let arg_num = skeleton. clauses [ index] . opt_arg_index_key . arg_num ( ) ;
50
+ let arg_num = skeleton. clauses [ target_pos - 1 ] . opt_arg_index_key . arg_num ( ) ;
52
51
53
52
if arg_num == 0 {
54
- return index ;
53
+ return target_pos - 1 ;
55
54
}
56
55
57
- skeleton
58
- . clauses [ target_pos]
59
- . opt_arg_index_key
60
- . switch_on_term_loc ( )
61
- . map ( |index_loc| {
62
- let search_result = skeleton. clauses . make_contiguous ( )
63
- [ 0 .. skeleton. core . clause_assert_margin ]
64
- . partition_point ( |clause_index_info| {
65
- clause_index_info. clause_start > index_loc
66
- } ) ;
67
-
68
- if search_result < skeleton. core . clause_assert_margin {
69
- search_result
70
- } else {
71
- skeleton. clauses . make_contiguous ( ) [ skeleton. core . clause_assert_margin ..]
72
- . partition_point ( |clause_index_info| {
73
- clause_index_info. clause_start < index_loc
74
- } ) + skeleton. core . clause_assert_margin
56
+ let mut index_loc_opt = None ;
57
+
58
+ for index in ( 0 ..target_pos) . rev ( ) {
59
+ let current_arg_num = skeleton. clauses [ index] . opt_arg_index_key . arg_num ( ) ;
60
+
61
+ if current_arg_num == 0 || current_arg_num != arg_num {
62
+ return index + 1 ;
63
+ }
64
+
65
+ if let Some ( index_loc) = index_loc_opt {
66
+ let current_index_loc = skeleton. clauses [ index]
67
+ . opt_arg_index_key
68
+ . switch_on_term_loc ( ) ;
69
+
70
+ if Some ( index_loc) != current_index_loc {
71
+ return index + 1 ;
75
72
}
76
- } ) . unwrap_or ( index)
73
+ } else {
74
+ index_loc_opt = skeleton. clauses [ index]
75
+ . opt_arg_index_key
76
+ . switch_on_term_loc ( ) ;
77
+ }
78
+ }
79
+
80
+ 0
77
81
}
78
82
79
83
fn derelictize_try_me_else (
0 commit comments