summaryrefslogtreecommitdiff
path: root/src/assembler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/assembler.rs')
-rw-r--r--src/assembler.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/assembler.rs b/src/assembler.rs
index cb6b6f1..692eb14 100644
--- a/src/assembler.rs
+++ b/src/assembler.rs
@@ -78,9 +78,13 @@ impl Assembler {
pub fn resolve_references(&mut self) {
let syntactic_tokens = take(&mut self.syntactic_tokens);
let syntactic_token_count = syntactic_tokens.len();
+ let mut parent_label = None;
for (index, syntactic_token) in syntactic_tokens.into_iter().enumerate() {
- let semantic_token = self.convert_syn_token_to_sem_token(syntactic_token, index);
+ if let SyntacticTokenType::LabelDefinition(name) = &syntactic_token.r#type {
+ parent_label = Some(name.to_owned());
+ }
+ let semantic_token = self.convert_syn_token_to_sem_token(syntactic_token, index, parent_label.clone());
self.semantic_tokens.push(semantic_token);
}
assert_eq!(syntactic_token_count, self.semantic_tokens.len());
@@ -199,7 +203,7 @@ impl Assembler {
(bytecode, semantic_tokens)
}
- fn convert_syn_token_to_sem_token(&mut self, mut syn_token: SyntacticToken, index: usize) -> SemanticToken {
+ fn convert_syn_token_to_sem_token(&mut self, mut syn_token: SyntacticToken, index: usize, parent_label: Option<String>) -> SemanticToken {
SemanticToken {
r#type: {
if let Some(err) = syn_token.error {
@@ -221,7 +225,7 @@ impl Assembler {
if syn_body_token.is_macro_terminator() {
syn_token.source_location.end = syn_body_token.source_location.start;
}
- let sem_body_token = self.convert_syn_token_to_sem_token(syn_body_token, 0);
+ let sem_body_token = self.convert_syn_token_to_sem_token(syn_body_token, 0, parent_label.clone());
sem_body_tokens.push(sem_body_token);
}
self.semantic_macro_bodies.insert(index, sem_body_tokens);
@@ -238,6 +242,7 @@ impl Assembler {
},
source_location: syn_token.source_location,
bytecode_location: BytecodeLocation::zero(),
+ parent_label,
}
}