mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
sorting comment
This commit is contained in:
parent
3750b154ca
commit
e3b3206286
1 changed files with 10 additions and 0 deletions
|
@ -25,6 +25,16 @@ pub fn build_module<'a>(
|
|||
let mut backend = WasmBackend::new();
|
||||
let mut layout_ids = LayoutIds::default();
|
||||
|
||||
// Sort procedures by occurence order
|
||||
//
|
||||
// We sort by the "name", but those are interned strings, and the name that is
|
||||
// interned first will have a lower number.
|
||||
//
|
||||
// But, the name that occurs first is always `main` because it is in the (implicit)
|
||||
// file header. Therefore sorting high to low will put other functions before main
|
||||
//
|
||||
// This means that for now other functions in the file have to be ordered "in reverse": if A
|
||||
// uses B, then the name of A must first occur after the first occurence of the name of B
|
||||
let mut procedures: std::vec::Vec<_> = procedures.into_iter().collect();
|
||||
procedures.sort_by(|a, b| b.0 .0.cmp(&a.0 .0));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue