Commit 85d85d1d authored by Ronny Wichers Schreur's avatar Ronny Wichers Schreur

johnvg: add SortByM macro instead of importing StdOrdOverloadedList

parent 2db3abfc
implementation module mach_o_linker2;
import StdInt,StdBool,StdString,StdChar,StdArray,StdFile,StdClass,StdMisc;
import StdStrictLists,StdOverloadedList,StdOrdOverloadedList;
import StdStrictLists,StdOverloadedList;
swap_bytes i :== i;
//swap_bytes i = ((i>>24) bitand 0xff) bitor ((i>>8) bitand 0xff00) bitor ((i<<8) bitand 0xff0000) bitor (i<<24);
......@@ -529,6 +529,29 @@ N_SECT:==0xe;
sort_module_offsets module_offsets = SortByM (\ {module_offset=x} {module_offset=y} -> x<y) module_offsets;
SortByM less_f l
:== HdM (msort (pair l));
pair [|x1,x2:xs]
| less_f x2 x1
= [[|x2,x1]:pair xs];
= [[|x1,x2]:pair xs];
pair x = [|x];
msort [|x1,x2:xs] = msort (merge_stage [|x1,x2:xs]);
msort x = x;
merge_stage [|xs1,xs2:xxs] = [mergeBy less_f xs1 xs2 : merge_stage xxs];
merge_stage x = x;
mergeBy less_f [|] y = y;
mergeBy less_f f=:[|x:xs] [|] = f;
mergeBy less_f f=:[|x:xs] s=:[|y:ys]
| less_f y x
= [|y:mergeBy less_f f ys];
= [|x:mergeBy less_f xs s];
:: SymbolNumberAndOffset = { symbol_n::!Int, module_offset::!Int};
define_symbols :: Int Int Int String String {!Section} String Int NamesTable -> (!NamesTable,!SymbolTable);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment