From 2cc7d4d11a596798f8271f5c0b8a6e8941c32fb6 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Mon, 13 Oct 2025 13:47:42 +1300 Subject: Include argument count in the signature of a symbol This is done by suffixing the argument count to the symbol name using the ':' separator character, which can't normally be used in a symbol. --- src/stages/compiler.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/stages') diff --git a/src/stages/compiler.rs b/src/stages/compiler.rs index 9d16bf0..87618ff 100644 --- a/src/stages/compiler.rs +++ b/src/stages/compiler.rs @@ -57,8 +57,8 @@ impl SymbolParser { } } - fn record_symbol(&mut self, name: &str, source: &SourceSpan, role: SymbolRole) { - let name = name.to_string(); + fn record_symbol(&mut self, name: &str, arg_count: usize, source: &SourceSpan, role: SymbolRole) { + let name = format!("{name}:{arg_count}"); let namespace = match &self.macro_name { Some(macro_name) => vec![macro_name.to_owned()], None => vec![], @@ -76,6 +76,7 @@ impl SymbolParser { // Record macro definition. self.record_symbol( &definition.name, + definition.arguments.len(), &definition.name.source, Definition(MustPrecedeReference), ); @@ -84,6 +85,7 @@ impl SymbolParser { for argument in &definition.arguments { self.record_symbol( &argument.name, + 0, &argument.source, Definition(MustPrecedeReference), ); @@ -132,6 +134,7 @@ impl SymbolParser { fn parse_invocation(&mut self, invocation: &Invocation, source: &SourceSpan) { self.record_symbol( &invocation.name, + invocation.arguments.len(), &source, Reference, ); @@ -160,6 +163,7 @@ impl SymbolParser { BlockToken::LabelDefinition(name) => { self.record_symbol( &name, + 0, &source, Definition(CanFollowReference), ); @@ -175,6 +179,7 @@ impl SymbolParser { for field in &word_template.fields { self.record_symbol( &field.name.to_string(), + 0, &field.source, Reference, ); -- cgit v1.2.3-70-g09d2