Skip to content

Commit

Permalink
Print object fields in lexographical order.
Browse files Browse the repository at this point in the history
  • Loading branch information
kondziu committed Mar 14, 2022
1 parent ea6bbda commit 50869fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ then
fi

# No custom processors specified: run the underlying command without changes
if $(not $parser_defined) && $(not $compiler_defined) && $(not interpreter_defined)
if $(not $parser_defined) && $(not $compiler_defined) && $(not $interpreter_defined)
then
$CMD $@
fi
Expand Down
7 changes: 6 additions & 1 deletion src/bytecode/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use indexmap::IndexMap;

use crate::bytecode::state::OperandStack;
use crate::bytecode::program::{ProgramObject, ConstantPoolIndex, AddressRange, Arity, Size};

use std::path::PathBuf;
use std::fs::{File, create_dir_all};
use std::time::SystemTime;
Expand Down Expand Up @@ -251,7 +252,11 @@ impl ObjectInstance {
parent => Some(parent.evaluate_as_string(heap)?),
};

let fields = self.fields.iter()
// Sort fields in lexographical order
let mut sorted_fields: Vec<(&String, &Pointer)> = self.fields.iter().collect();
sorted_fields.sort_by_key(|(name, _)| *name);

let fields = sorted_fields.into_iter()
.map(|(name, value)| {
value.evaluate_as_string(heap).map(|value| format!("{}={}", name, value))
})
Expand Down

0 comments on commit 50869fb

Please sign in to comment.