sort enum bit fields

This commit is contained in:
water
2021-08-14 13:17:24 -04:00
parent 51dd1bdae8
commit e473ede677
6 changed files with 28 additions and 28 deletions
+11 -2
View File
@@ -1246,11 +1246,20 @@ std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
assert(type_info);
assert(type_info->is_bitfield());
std::vector<std::string> bit_sorted_names;
for (auto& field : type_info->entries()) {
u64 mask = ((u64)1) << field.second;
bit_sorted_names.push_back(field.first);
}
std::sort(bit_sorted_names.begin(), bit_sorted_names.end(),
[&](const std::string& a, const std::string& b) {
return type_info->entries().at(a) < type_info->entries().at(b);
});
for (auto& field_name : bit_sorted_names) {
u64 mask = ((u64)1) << type_info->entries().at(field_name);
if (value & mask) {
reconstructed |= mask;
result.push_back(field.first);
result.push_back(field_name);
}
}
+9 -12
View File
@@ -782,11 +782,8 @@
)
(cond
((= s4-0 'menu)
(let ((s4-1 (new 'debug 'debug-menu arg0 (the-as string s5-1))))
(set!
s5-0
(new 'debug 'debug-menu-item-submenu (the-as string s5-1) s4-1)
)
(let ((s4-1 (new 'debug 'debug-menu arg0 s5-1)))
(set! s5-0 (new 'debug 'debug-menu-item-submenu s5-1 s4-1))
(let* ((gp-1 (cdr (cdr arg1)))
(a1-3 (car gp-1))
)
@@ -803,7 +800,7 @@
)
)
((= s4-0 'main-menu)
(set! s5-0 (new 'debug 'debug-menu arg0 (the-as string s5-1)))
(set! s5-0 (new 'debug 'debug-menu arg0 s5-1))
(let* ((gp-2 (cdr (cdr arg1)))
(a1-6 (car gp-2))
)
@@ -828,7 +825,7 @@
(new
'debug
'debug-menu-item-flag
(the-as string s5-1)
s5-1
(the-as symbol (car (cdr (cdr arg1))))
(debug-menu-func-decode (car (cdr (cdr (cdr arg1)))))
)
@@ -837,7 +834,7 @@
(new
'debug
'debug-menu-item-function
(the-as string s5-1)
s5-1
(the-as int (car (cdr (cdr arg1))))
(debug-menu-func-decode (car (cdr (cdr (cdr arg1)))))
)
@@ -846,7 +843,7 @@
(new
'debug
'debug-menu-item-var
(the-as string s5-1)
s5-1
(the-as int (car (cdr (cdr arg1))))
(the-as int (car (cdr (cdr (cdr arg1)))))
)
@@ -861,7 +858,7 @@
(new
'debug
'debug-menu-item-var
(the-as string s5-1)
s5-1
(the-as int (car (cdr (cdr arg1))))
(the-as int (ref arg1 4))
)
@@ -898,7 +895,7 @@
(new
'debug
'debug-menu-item-var
(the-as string s5-1)
s5-1
(the-as int (car (cdr (cdr arg1))))
(the-as int (ref arg1 4))
)
@@ -933,7 +930,7 @@
(new
'debug
'debug-menu-item-var
(the-as string s5-1)
s5-1
(the-as int (car (cdr (cdr arg1))))
(the-as int (ref arg1 4))
)
+3 -6
View File
@@ -42,12 +42,9 @@
(zero?
(logand (-> *kernel-context* prevent-from-run) (process-mask progress))
)
(let
((v1-18
((method-of-type connection get-process) (the-as connection conn))
)
(a0-22 *progress-process*)
)
(let ((v1-18 (get-process conn))
(a0-22 *progress-process*)
)
(= v1-18 (if a0-22
(-> a0-22 0 self)
)
@@ -93,8 +93,8 @@
(s2-0 (-> s0-0 base))
)
(if (>= s4-0 7)
(generic-init-buf s0-0 1 (the-as gs-zbuf s5-0))
(generic-init-buf s0-0 1 (the-as gs-zbuf gp-0))
(generic-init-buf s0-0 1 s5-0)
(generic-init-buf s0-0 1 gp-0)
)
(generic-dma-foreground-sink-init s1-0)
(let ((a3-0 (-> s0-0 base)))
+2 -5
View File
@@ -557,10 +557,7 @@
)
(set! (-> obj max-spheres) sphere-count)
(set! (-> obj flags) (nav-control-flags bit8 bit13))
(set!
(-> obj mesh)
(nav-mesh-connect (-> shape process) shape (the-as nav-control obj))
)
(set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj))
(let ((ent (-> shape process entity)))
(set!
(-> obj nearest-y-threshold)
@@ -594,7 +591,7 @@
(defmethod should-display? nav-control ((obj nav-control))
(and
*display-nav-marks*
(nonzero? (logand (-> obj flags) (nav-control-flags display-marks bit0)))
(nonzero? (logand (-> obj flags) (nav-control-flags bit0 display-marks)))
)
)
+1 -1
View File
@@ -3759,7 +3759,7 @@ nav-enemy-default-event-handler
)
(logior!
(-> obj nav flags)
(nav-control-flags display-marks bit0 bit3 bit5 bit6 bit7)
(nav-control-flags bit0 display-marks bit3 bit5 bit6 bit7)
)
(set! (-> obj nav gap-event) 'jump)
(dummy-26 (-> obj nav))