corrections to arithmetic expression compilation

This commit is contained in:
Mark Thom
2025-11-27 21:03:56 -08:00
parent 3b019fca1d
commit b287f0aedb
2 changed files with 6 additions and 9 deletions

View File

@@ -561,11 +561,6 @@ impl CodeGenerator {
self.marker.reset_arg(2); self.marker.reset_arg(2);
let (mut lcode, at_1) = self.compile_arith_expr(&terms[0], term_loc, 1)?; let (mut lcode, at_1) = self.compile_arith_expr(&terms[0], term_loc, 1)?;
if !matches!(terms[0], Term::Var(..)) {
self.marker.advance_arg();
}
let (mut rcode, at_2) = self.compile_arith_expr(&terms[1], term_loc, 2)?; let (mut rcode, at_2) = self.compile_arith_expr(&terms[1], term_loc, 2)?;
code.append(&mut lcode); code.append(&mut lcode);
@@ -855,16 +850,18 @@ impl CodeGenerator {
} }
} }
Term::Literal( Term::Literal(
_, ref cell,
c @ Literal::Integer(_) c @ Literal::Integer(_)
| c @ Literal::F64(..) | c @ Literal::F64(..)
| c @ Literal::Rational(_) | c @ Literal::Rational(_)
| c @ Literal::Fixnum(_), | c @ Literal::Fixnum(_),
) => { ) => {
let v = HeapCellValue::from(c); let v = HeapCellValue::from(c);
code.push_back(instr!("put_constant", Level::Shallow, v, temp_v!(1)));
self.marker.advance_arg(); self.marker
.mark_non_var::<QueryInstruction>(Level::Shallow, term_loc, &cell, code);
code.push_back(instr!("put_constant", Level::Shallow, v, temp_v!(1)));
compile_expr!(self, &terms[1], term_loc, code) compile_expr!(self, &terms[1], term_loc, code)
} }
_ => { _ => {

View File

@@ -59,7 +59,7 @@ get_attrs_var_check(Module) -->
!, !,
'$get_attr_list'(Var, Ls), '$get_attr_list'(Var, Ls),
nonvar(Ls), nonvar(Ls),
atts:'$copy_attr_list'(Ls, Module, Attr))]. atts:'$copy_attr_list'(Ls, Module, Attr))].
put_attrs(Name/Arity, Module) --> put_attrs(Name/Arity, Module) -->
put_attr(Name, Arity, Module), put_attr(Name, Arity, Module),