I'm afraid the code if t in TT: has no simple equivalent in free pascal.
Yes, it has, but it involves a bit of library code to be written. If you have seen my examples, you will find it is pretty easy to do.
So yes, can be done in FPC, but that particular library code is at the moment missing in the rtl or any of the standard packages.
OTOH, I just wrote it for you, so you can re-use it if needed by putting it in a separate library unit.