aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/context.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-05 13:39:16 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:55:55 +0100
commitf0624b8929e6ead3f2d8b1939dc7f094c539bee1 (patch)
tree649391e261e7d023ade940a1d25f1974143250fd /lib/xixanta/src/context.rs
parentb768b2c6749986b0efe8610c023b42eb0d9e2ce6 (diff)
downloadtools.nes-f0624b8929e6ead3f2d8b1939dc7f094c539bee1.tar.gz
tools.nes-f0624b8929e6ead3f2d8b1939dc7f094c539bee1.zip
Re-work the handling of segments in the assembler
There were a lot of assumptions on the assembler that stemmed from a fundamental missunderstanding from my side on how segments are laid out on the final file. This commit is the first step to address this. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/context.rs')
-rw-r--r--lib/xixanta/src/context.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/xixanta/src/context.rs b/lib/xixanta/src/context.rs
index 683d750..000c959 100644
--- a/lib/xixanta/src/context.rs
+++ b/lib/xixanta/src/context.rs
@@ -124,6 +124,8 @@ impl Context {
let scope_name = self.name().to_string();
let scope = self.labels.get_mut(&scope_name).unwrap();
+ // println!("PUSHING: {:#?}", bundle);
+
scope.push(bundle.clone());
}
@@ -274,7 +276,7 @@ impl Context {
Ok(())
}
- // Returns the name of the current context.
+ /// Returns the name of the current context.
pub fn name(&self) -> &str {
match self.stack.last() {
Some(name) => name,
@@ -282,6 +284,11 @@ impl Context {
}
}
+ /// Returns true if we are in the global scope.
+ pub fn is_global(&self) -> bool {
+ self.stack.is_empty()
+ }
+
// Returns a human-readable string representing the current context.
fn to_human(&self) -> String {
match self.stack.last() {