Here’s version 0.1.0 of the creatively named cr-source-typer
project:
It works on my machine, but buyer beware and all that :) If you try it and find issues, please let me know so I can improve it!
And another mini brain dump along the lines of the one that started this thread:
- Running the
semantic
process has acleanup
property; setting this totrue
will cause it to expand the returned ASTNode to contain all required files and expanded macros. Setting it tofalse
doesn’t. - After
semantic
has run, theprogram
object has atypes
variable that’s a hash of the type name =>Type
instance representing that class / struct / whatever. - The
types
hash only contains the top level types - to get to ones within “namespaces” (or subclasses, etc.), a breadth-first-search expansion can be done, using each types’ owntypes
variable to get the subtypes under it. - Similarly, the previously described
defs
anddef_instances
on theprogram
object only contain the top level methods and its typed definitions. Use theType#defs
andType#def_instances
to get the methods for individual types (keeping in mind not everyType
actually has or supports methods) - Static / class methods don’t exist on the
Type
directly (which contains instance level variables and methods), but instead on the*MetaclassType
, which is a type specific to capturing class level information. Usetype#metaclass
to get a metaclass of a given type. This is the difference betweenString
andString.class
*MetaclassType
also use thedefs
anddef_instances
to store the class level methods (likenew
andallocate
, by default).