mangleof (signature) question
Ary Borenszweig
ary at esperanto.org.ar
Wed Jan 2 07:09:49 PST 2008
Hi all,
In Descent I'm using the mangleof, or signature, of a class or function
to search it in the project, for "go to definition" and other
functionalities.
The problem I'm facing is that the mangled representation is sometimes
ambiguous for symbols defined in functions. For example:
---
module main;
class X {
}
X foo(X x) {
class Bla {
static class Foo {
}
}
return null;
}
---
The mangleof of Foo is: C4main3fooFC4main1XZC4main1X3Bla3Foo
Decomposing the signature, we can deduce that:
- the function is 4main3foo = main.foo
- the first and only parameter is C4main1X = main.X
- the return type is C4main1X3Bla3Foo
The problem with the last point is I can't tell the return type is
main.X, and then, nested in the function, there's Bla.Foo. It could
perfectly be that the return type is main.X.Bla, and nested in the
function there's Foo. In fact, this code compiles:
---
module main;
class X {
static class Foo {
}
static class Bla {
static class Foo {
}
}
}
static assert(X.Bla.Foo.mangleof == "C4main1X3Bla3Foo");
X foo(X x) {
class Bla {
static class Foo {
static assert(Foo.mangleof ==
"C4main3fooFC4main1XZC4main1X3Bla3Foo"); // 1
}
}
return null;
}
X.Bla foo(X x) {
class Foo {
static assert(Foo.mangleof ==
"C4main3fooFC4main1XZC4main1X3Bla3Foo"); // 2
}
return null;
}
// 1 and 2 are the same
---
My questions are: is there any reason for the signature to be ambigous?
If so, how can I tell how to search a symbol from that signature? Or
maybe I should create my own signatures just for searching symbols...
Thanks,
Ary
More information about the Digitalmars-d-learn
mailing list