abouttreesummaryrefslogcommitdiff
path: root/src/generic.h
diff options
context:
space:
mode:
authorPatrick Schönberger2021-08-12 10:32:51 +0200
committerPatrick Schönberger2021-08-12 10:32:51 +0200
commit66a27d2fc7c1ad4e97de76d4982168a0fed9920a (patch)
treeca3f0e5d740214bc7ecd85949a278e64e49898b7 /src/generic.h
parentc4231c6faf4e1b4650b075c641b0bb8c053739e4 (diff)
downloadtoc-66a27d2fc7c1ad4e97de76d4982168a0fed9920a.tar.gz
toc-66a27d2fc7c1ad4e97de76d4982168a0fed9920a.zip
comments
Diffstat (limited to 'src/generic.h')
-rw-r--r--src/generic.h8
1 files changed, 7 insertions, 1 deletions
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<std::vector<Type>> & insts,
const std::vector<Type> & 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<Context> 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<Context> 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<Type> & ts)
{
std::stringstream sstr;