Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

Add support for visiting type references

Open PathogenDavid opened this issue 3 years ago • 2 comments

Right now there's no good way to visit type references. You can make a type transformation, but that's relatively clunky. There should be a subclass of DeclarationVisitor which also visits type references.

Part of the reason this doesn't exist yet is there's no generalized way to enumerate type references in the first place. They're special-cased in RawTypeTransformationBase and that has to be able to handle ICustomTranslatedDeclaration to function properly.

This would greatly help with https://github.com/InfectedLibraries/Biohazrd/issues/188 and https://github.com/InfectedLibraries/Biohazrd/issues/55

This might also be a reasonable time to investigate merging Biohazrd.Transformation into the main Biohazrd assembly. The division makes stuff like this annoying, and I'm not sure if the separate is really all that valuable. (The intent when I did it originally is that someone could in theory use just the core as a library for doing static analysis of a C++ API, but they could just as easily do that while ignoring everything transformation-related.)

Alternatively, we could make this part of Biohazrd.Transformation, although that'd be slightly odd.

PathogenDavid avatar May 03 '21 20:05 PathogenDavid

A prototype of this was added as Biohazrd.Transformation.__TypeReferenceVisitor as part of https://github.com/InfectedLibraries/Biohazrd/issues/188

It's not 100% there and is missing extensibility points, but it accomplishes the needs of https://github.com/InfectedLibraries/Biohazrd/issues/188 for now.

PathogenDavid avatar May 09 '21 03:05 PathogenDavid

Reminder for the future since it's kinda burried above:

The main issue is that TypeReferenceVisitor can't use the same logic for enumerating type references as DeclarationVisitor does.

I think the better solution is going to be to add a IEnumerateTypeReferences interface in Biohazrd which is a parent of both ICustomTranslatedDeclaration and ICustomTypeReference.

PathogenDavid avatar Jun 30 '22 16:06 PathogenDavid