count single character atoms as characters when generating first argument indices

This commit is contained in:
Mark Thom
2020-03-06 21:19:53 -07:00
parent 9852e30b39
commit 6ddfef6383
2 changed files with 10 additions and 1 deletions

View File

@@ -74,6 +74,15 @@ impl CodeOffsets {
code.push(Self::add_index(is_initial_index, index));
}
&Term::Constant(_, ref constant) => {
if let Constant::Atom(ref name, _) = constant {
if !name.as_str().is_empty() && name.as_str().chars().skip(1).next().is_none() {
let c = name.as_str().chars().next().unwrap();
let code = self.constants.entry(Constant::Char(c)).or_insert(vec![]);
code.push(Self::add_index(code.is_empty(), index));
}
}
let code = self.constants.entry(constant.clone()).or_insert(Vec::new());
let is_initial_index = code.is_empty();

View File

@@ -1806,7 +1806,7 @@ impl MachineState {
let a1 = self.registers[1].clone();
let addr = self.store(self.deref(a1));
let offset = match addr {
let offset = match addr {
Addr::Con(constant) => match hm.get(&constant) {
Some(offset) => *offset,
_ => 0,