X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/c4231c6faf4e1b4650b075c641b0bb8c053739e4..66a27d2fc7c1ad4e97de76d4982168a0fed9920a:/src/generic.h diff --git a/src/generic.h b/src/generic.h index df203b3..33323e4 100644 --- a/src/generic.h +++ b/src/generic.h @@ -4,6 +4,7 @@ #include "typeInfo.h" #include "visit.h" +// add a generic instantiation if its not in the vector already void addGenericInstantiation( std::vector> & insts, const std::vector & newInst) @@ -32,6 +33,8 @@ Program instantiateGenerics(const Program & p) // Find generic instantiations + // visit expressions (only function calls are considered) and types, + // find the function/struct by pointer and add an instantiation Visitor findGenericInstantiations; findGenericInstantiations.onExpr = [&](const Expr & e, const std::shared_ptr ctx) @@ -48,7 +51,6 @@ Program instantiateGenerics(const Program & p) addGenericInstantiation(std::get<0>(*f)->genericInstantiations, e._func.genericInstantiation); } } - // TODO: generic methods }; findGenericInstantiations.onType = [&](const Type & t, const std::shared_ptr ctx) @@ -72,6 +74,10 @@ Program instantiateGenerics(const Program & p) return result; } +// generate the appendix for C struct/function names +// including array/pointer indicators because +// there might be distinct instantiations +// for int and int* for example std::string genericAppendix(const std::vector & ts) { std::stringstream sstr;