Skip to content

Commit 8e398c6

Browse files
committed
[assembler] Eliminate lookup_with_op and final_lookup_helper_body.
We fold those helper functions into symbol_name_lookup. The symbol_name_lookup function is still poorly-named as it also performs evaluation on the result of the lookup.
1 parent d6026f6 commit 8e398c6

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

assembler/src/asmlib/driver/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::super::ast::{
55
InstructionSequence, LiteralValue, TaggedProgramInstruction, UntaggedProgramInstruction,
66
};
77
use super::super::collections::OneOrMore;
8-
use super::super::eval::{lookup_with_op, make_empty_rc_block_for_test, EvaluationContext};
8+
use super::super::eval::{make_empty_rc_block_for_test, symbol_name_lookup, EvaluationContext};
99
use super::super::manuscript::{ManuscriptBlock, PunchCommand, SourceFile};
1010
use super::super::memorymap::LocatedBlock;
1111
use super::super::source::Source;
@@ -52,7 +52,7 @@ fn assemble_check_symbols(
5252
lookup_operation: Default::default(),
5353
};
5454

55-
match lookup_with_op(&mut ctx, &sym, span) {
55+
match symbol_name_lookup(&sym, Script::Normal, span, &mut ctx) {
5656
Ok(got) => {
5757
if got != *expected_value {
5858
panic!(

assembler/src/asmlib/eval.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,11 @@ pub(crate) fn make_empty_rc_block_for_test(location: Address) -> RcBlock {
368368
}
369369
}
370370

371-
fn final_lookup_helper_body<R: RcUpdater>(
372-
ctx: &mut EvaluationContext<R>,
371+
pub(crate) fn symbol_name_lookup<R: RcUpdater>(
373372
name: &SymbolName,
373+
elevation: Script,
374374
span: Span,
375-
) -> Result<Unsigned36Bit, SymbolLookupFailure> {
376-
if let Some(def) = ctx.explicit_symtab.get(name) {
377-
let what: (&Span, &SymbolName, &ExplicitDefinition) = (&span, name, def);
378-
what.evaluate(ctx)
379-
} else {
380-
ctx.fetch_or_assign_default(name)
381-
}
382-
}
383-
384-
pub(super) fn lookup_with_op<R: RcUpdater>(
385375
ctx: &mut EvaluationContext<R>,
386-
name: &SymbolName,
387-
span: Span,
388376
) -> Result<Unsigned36Bit, SymbolLookupFailure> {
389377
ctx.lookup_operation.deps_in_order.push(name.clone());
390378
if !ctx.lookup_operation.depends_on.insert(name.clone()) {
@@ -402,21 +390,20 @@ pub(super) fn lookup_with_op<R: RcUpdater>(
402390
}
403391
}
404392
}
405-
let result = final_lookup_helper_body(ctx, name, span);
393+
394+
let result = if let Some(def) = ctx.explicit_symtab.get(name) {
395+
let what: (&Span, &SymbolName, &ExplicitDefinition) = (&span, name, def);
396+
what.evaluate(ctx)
397+
} else {
398+
ctx.fetch_or_assign_default(name)
399+
}
400+
.map(|value| value.shl(elevation.shift()));
401+
406402
ctx.lookup_operation.deps_in_order.pop();
407403
ctx.lookup_operation.depends_on.remove(name);
408404
result
409405
}
410406

411-
pub(crate) fn symbol_name_lookup<R: RcUpdater>(
412-
name: &SymbolName,
413-
elevation: Script,
414-
span: Span,
415-
ctx: &mut EvaluationContext<R>,
416-
) -> Result<Unsigned36Bit, SymbolLookupFailure> {
417-
lookup_with_op(ctx, name, span).map(|value| value.shl(elevation.shift()))
418-
}
419-
420407
#[allow(clippy::too_many_arguments)]
421408
pub(super) fn extract_final_equalities<R: RcUpdater>(
422409
equalities: &[Equality],

0 commit comments

Comments
 (0)