spec: Option<OpDesc>,
op_dir: &OpDir,
) -> Option<OpDesc> {
- fetch_op_spec_from_existing(name, 1, spec, op_dir)
- .or_else(|| fetch_op_spec_from_existing(name, 2, spec, op_dir))
+ fetch_op_spec_from_existing(name, 2, spec, op_dir)
+ .or_else(|| fetch_op_spec_from_existing(name, 1, spec, op_dir))
}
pub(crate) fn fetch_op_spec_from_existing(
}
})
}
+ 0 => {
+ fetch_atom_op_spec(name, None, op_dir)
+ }
_ => None,
}
}
true
} else if (is_postfix!(spec) || is_infix!(spec)) && !is_postfix!(child_desc.get_spec())
{
- *cell == child_desc && child_desc.get_prec() == priority
+ *cell != child_desc && child_desc.get_prec() == priority
} else {
false
}
}
impl NumberFocus {
- fn is_positive(&self) -> bool {
+ fn is_negative(&self) -> bool {
match self {
- NumberFocus::Unfocused(n) => n.is_positive(),
- NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r > 0,
+ NumberFocus::Unfocused(n) => n.is_negative(),
+ NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r < 0,
}
}
}
fn print_number(&mut self, n: NumberFocus, op: &Option<DirectedOp>) {
let add_brackets = if let Some(op) = op {
- op.is_negative_sign() && n.is_positive()
+ op.is_negative_sign() && !n.is_negative()
} else {
false
};
match n {
NumberFocus::Unfocused(n) => match n {
Number::Float(fl) => {
- if &fl == &OrderedFloat(0f64) {
- push_space_if_amb!(self, "0.0", {
- append_str!(self, "0.0");
- });
- } else {
- let OrderedFloat(fl) = fl;
- let output_str = format!("{0:<20?}", fl);
+ let OrderedFloat(fl) = fl;
+ let output_str = format!("{0:<20?}", fl);
- push_space_if_amb!(self, &output_str, {
- append_str!(self, &output_str.trim());
- });
- }
+ push_space_if_amb!(self, &output_str, {
+ append_str!(self, &output_str.trim());
+ });
}
Number::Rational(r) => {
self.print_rational(r, add_brackets);
return;
}
+ Number::Fixnum(n) => {
+ append_str!(self, &format!("{}", n.get_num()));
+ }
n => {
let output_str = format!("{}", n);
}
}
(HeapCellValueTag::Fixnum, n) => {
- append_str!(self, &format!("{}", n.get_num()));
+ self.print_number(NumberFocus::Unfocused(Number::Fixnum(n)), &op);
}
(HeapCellValueTag::F64, f) => {
self.print_number(NumberFocus::Unfocused(Number::Float(**f)), &op);