use slightly better names in indexing functions

This commit is contained in:
Mark Thom
2020-04-30 18:20:42 -06:00
parent b6df5a4b7f
commit efd5d6efab
3 changed files with 5 additions and 5 deletions

View File

@@ -54,7 +54,7 @@ impl CodeOffsets {
} }
} }
fn intercept_constant(&mut self, constant: &Constant, index: usize) { fn intercept_overlapping_constant(&mut self, constant: &Constant, index: usize) {
match constant { match constant {
&Constant::Atom(ref name, ref op) if name.is_char() => { &Constant::Atom(ref name, ref op) if name.is_char() => {
let c = name.as_str().chars().next().unwrap(); let c = name.as_str().chars().next().unwrap();
@@ -162,7 +162,7 @@ impl CodeOffsets {
self.lists.push(Self::add_index(is_initial_index, index)); self.lists.push(Self::add_index(is_initial_index, index));
} }
&Term::Constant(_, ref constant) => { &Term::Constant(_, ref constant) => {
self.intercept_constant(constant, index); self.intercept_overlapping_constant(constant, index);
let code = self.constants let code = self.constants
.entry(constant.clone()) .entry(constant.clone())

View File

@@ -238,7 +238,7 @@ impl Addr {
} }
} }
pub fn as_constant(&self, machine_st: &MachineState) -> Option<Constant> { pub fn as_constant_index(&self, machine_st: &MachineState) -> Option<Constant> {
match self { match self {
&Addr::Char(c) => { &Addr::Char(c) => {
Some(Constant::Char(c)) Some(Constant::Char(c))
@@ -249,7 +249,7 @@ impl Addr {
&Addr::Con(h) => { &Addr::Con(h) => {
match &machine_st.heap[h] { match &machine_st.heap[h] {
&HeapCellValue::Atom(ref name, ref op) => { &HeapCellValue::Atom(ref name, ref op) => {
Some(Constant::Atom(name.clone(), op.clone())) Some(Constant::Atom(name.clone(), None))
} }
&HeapCellValue::Integer(ref n) => { &HeapCellValue::Integer(ref n) => {
Some(Constant::Integer(n.clone())) Some(Constant::Integer(n.clone()))

View File

@@ -1433,7 +1433,7 @@ impl MachineState {
let addr = self.store(self.deref(addr)); let addr = self.store(self.deref(addr));
let offset = let offset =
match addr.as_constant(&self) { match addr.as_constant_index(&self) {
Some(c) => { Some(c) => {
match hm.get(&c) { match hm.get(&c) {
Some(offset) => *offset, Some(offset) => *offset,