summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-10-13 13:47:42 +1300
committerBen Bridle <ben@derelict.engineering>2025-10-14 16:54:44 +1300
commit2cc7d4d11a596798f8271f5c0b8a6e8941c32fb6 (patch)
treec3bee41735ae6d990a89940017d1d834899263c6 /src
parenta494bebe0adea18567548e1f8b43f679be2669b5 (diff)
downloadtorque-asm-2cc7d4d11a596798f8271f5c0b8a6e8941c32fb6.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/stages/compiler.rs9
1 files changed, 7 insertions, 2 deletions
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,
);