jdeans289 / icg2

Interface Code Generator 2: Electric Boogaloo
Other
0 stars 2 forks source link

Typdef Support #28

Closed jdeans289 closed 10 months ago

jdeans289 commented 11 months ago

We need to support typedefs.

typedef MyInt int;
typedef ObjList std::vector<MyObj>;
typedef ObjMap std::map<std::string, ObjList>;

MyInt a;
memoryManager.declare_var("MyInt a_ptr", &a);
ObjMap * ptr = memoryManager.declare_var("ObjMap o");

We need to support all the above.

I think this should be pretty straightforward. We need to add another data structure to the DataTypeInator - something like TypedefDictionary. This will be just a simple map <string, string> that maps a typedef'ed name to the declared type, which can then be looked up in the TypeDictionary. The DataTypeInator should take care of all of this.

ICG Changes: We need to have some intermediate representation for typedefs, which can be simple. Need a visitor for typedefs, which only needs to scrape the names. Get the canonical name of the RHS type to avoid dealing with typedefs of other typedefs. Add something to the template engine to represent them. Should just be dealing with string representations.

DataTypes Changes: The changes here should be limited to within the DataTypeInator only. We'll have to add some tracking structure, add a way register a typedef, and include a lookup in the typedef dictionary before the normal type dictionary.

jdeans289 commented 10 months ago

Closed by #46