aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-25 22:57:57 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-25 22:57:57 +0200
commit5d4116881f2cc4d053fad66c1a6d00d2dcbead90 (patch)
treefe8703aecd3476b4c2b6b41dd41c3b4d0dc20432
parentee9d61f078b04406c5b264d4e0e5bd1ea287e6e2 (diff)
downloadtools.nes-5d4116881f2cc4d053fad66c1a6d00d2dcbead90.tar.gz
tools.nes-5d4116881f2cc4d053fad66c1a6d00d2dcbead90.zip
Add the context's name into memory ranges
This is applied whenever a given memory range name is not under the global context. The end result is that scopes will be shown into the memory.txt file when using '--write-info'. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--lib/xixanta/src/assembler.rs10
-rw-r--r--lib/xixanta/src/object.rs2
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index a25ba41..7e5ff90 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -3,7 +3,7 @@ use crate::node::{
is_asan_friendly_name, CommentType, ControlType, EchoKind, NodeType, OperationType, PNode,
PString,
};
-use crate::object::{Bundle, Context, Object, ObjectType};
+use crate::object::{Bundle, Context, Object, ObjectType, GLOBAL_CONTEXT};
use crate::opcodes::{AddressingMode, INSTRUCTIONS};
use crate::parser::Parser;
use crate::SourceInfo;
@@ -1160,7 +1160,7 @@ impl<'a> Assembler<'a> {
fn asan(&mut self, memory: &mut MemoryResult) -> Result<(), Vec<Error>> {
let mut errors = vec![];
- for (_context, map) in self.context.map.iter() {
+ for (context_name, map) in self.context.map.iter() {
for (name, bundle) in map {
// Ignore this bundle if the user explicitely told us to do so.
if bundle.asan_ignore {
@@ -1177,7 +1177,11 @@ impl<'a> Assembler<'a> {
let val = bundle.bundle.value() as usize;
let range = MemoryRange {
range: (val..val + bundle.asan_reserve),
- name: name.clone(),
+ name: if context_name == GLOBAL_CONTEXT {
+ name.clone()
+ } else {
+ format!("{context_name}::{name}")
+ },
};
// Check if this variable was ever accessed and warn about
diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs
index 5b4b235..cd1db1f 100644
--- a/lib/xixanta/src/object.rs
+++ b/lib/xixanta/src/object.rs
@@ -4,7 +4,7 @@ use crate::opcodes::CONTROL_FUNCTIONS;
use std::collections::HashMap;
/// The name of the global context as used internally.
-const GLOBAL_CONTEXT: &str = "__internal_nasm_global_scope";
+pub const GLOBAL_CONTEXT: &str = "__internal_nasm_global_scope";
/// A Bundle represents a set of bytes that can be encoded as binary data.
#[derive(Debug, Default, Clone, Eq, Ord, PartialEq, PartialOrd)]