Skip to content

Commit 257fa84

Browse files
committed
[assembler] Ensure that evaluation cannot allocate RC words.
1 parent 9265e13 commit 257fa84

File tree

4 files changed

+113
-113
lines changed

4 files changed

+113
-113
lines changed

assembler/src/asmlib/ast.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub(crate) enum RcWordSource {
3232

3333
pub(crate) trait RcAllocator {
3434
fn allocate(&mut self, source: RcWordSource, value: Unsigned36Bit) -> Address;
35+
}
36+
37+
pub(crate) trait RcUpdater {
3538
fn update(&mut self, address: Address, value: Unsigned36Bit);
3639
}
3740

@@ -161,7 +164,7 @@ impl From<Atom> for SignedAtom {
161164
fn from(magnitude: Atom) -> Self {
162165
Self {
163166
negated: false,
164-
span: magnitude.span(),
167+
span: *magnitude.span(),
165168
magnitude,
166169
}
167170
}
@@ -454,12 +457,11 @@ impl From<SymbolOrLiteral> for Atom {
454457
}
455458

456459
impl Atom {
457-
fn span(&self) -> Span {
458-
// TODO: return &Span instead?
460+
fn span(&self) -> &Span {
459461
match self {
460-
Atom::SymbolOrLiteral(value) => *value.span(),
461-
Atom::Parens(span, _script, _bae) => *span,
462-
Atom::RcRef(span, _) => *span,
462+
Atom::SymbolOrLiteral(value) => value.span(),
463+
Atom::Parens(span, _script, _bae) => span,
464+
Atom::RcRef(span, _) => span,
463465
}
464466
}
465467

@@ -602,8 +604,6 @@ pub(crate) enum InstructionFragment {
602604
rc_word_value: RegisterContaining,
603605
},
604606
Null,
605-
// TODO: subscript/superscript atom (if the `Arithmetic` variant
606-
// disallows subscript/superscript).
607607
}
608608

609609
impl InstructionFragment {

assembler/src/asmlib/driver.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ impl RcAllocator for NoRcBlock {
445445
fn allocate(&mut self, _source: RcWordSource, _value: Unsigned36Bit) -> Address {
446446
panic!("Cannot allocate an RC-word before we know the address of the RC block");
447447
}
448+
}
448449

450+
impl RcUpdater for NoRcBlock {
449451
fn update(&mut self, _address: Address, _value: Unsigned36Bit) {
450452
panic!("Cannot update an RC-word in an RC-block which cannot allocate words");
451453
}

0 commit comments

Comments
 (0)