src: Template Argument Handling

* improved handling of template arguments
This commit is contained in:
malte_langkabel
2015-11-19 16:30:59 +01:00
parent 4e6fdaf79c
commit bbf9c43909
7 changed files with 163 additions and 253 deletions
+24 -4
View File
@@ -516,7 +516,7 @@ Id Storage::onTypeUsageParsed(const ParseTypeUsage& typeUsage, const ParseVariab
return edgeId;
}
Id Storage::onTemplateArgumentTypeParsed(
Id Storage::onTemplateArgumentTypeOfTemplateRecordParsed(
const ParseLocation& location, const NameHierarchy& argumentNameHierarchy,
const NameHierarchy& templateNameHierarchy)
{
@@ -536,20 +536,40 @@ Id Storage::onTemplateArgumentTypeParsed(
return argumentNodeId;
}
Id Storage::onTemplateArgumentTypeOfTemplateFunctionParsed(
const ParseLocation& location, const NameHierarchy& argumentNameHierarchy,
const ParseFunction& templateFunction)
{
log(
"template argument type",
argumentNameHierarchy.getFullName() + " -> " + templateFunction.getFullName(),
location
);
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, argumentNameHierarchy, false);
// does not need a source location because this type that is already defined (and therefore has a location).
Id templateNodeId = addNodeHierarchyWithDistinctSignature(Node::NODE_FUNCTION, templateFunction, false);
addEdge(templateNodeId, argumentNodeId, Edge::EDGE_TEMPLATE_ARGUMENT, location);
return argumentNodeId;
}
Id Storage::onTemplateDefaultArgumentTypeParsed(
const ParseTypeUsage& defaultArgumentTypeUsage,
const NameHierarchy& templateArgumentTypeNameHierarchy // actually this is the template parameter???
const NameHierarchy& templateParameterNameHierarchy // actually this is the template parameter???
){
log(
"template default argument",
defaultArgumentTypeUsage.dataType->getTypeNameHierarchy().getFullName() + " -> " + templateArgumentTypeNameHierarchy.getFullName(),
defaultArgumentTypeUsage.dataType->getTypeNameHierarchy().getFullName() + " -> " + templateParameterNameHierarchy.getFullName(),
defaultArgumentTypeUsage.location
);
Id defaultArgumentNodeId = addNodeHierarchy(Node::NODE_TYPE, defaultArgumentTypeUsage.dataType->getTypeNameHierarchy(), false);
// does not need a source location because this type that is already defined (and therefore has a location).
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, templateArgumentTypeNameHierarchy, false);
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, templateParameterNameHierarchy, false);
addEdge(argumentNodeId, defaultArgumentNodeId, Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, defaultArgumentTypeUsage.location);