diff options
Diffstat (limited to 'source/slang/slang-mangle.cpp')
| -rw-r--r-- | source/slang/slang-mangle.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index e6c0a8e7f..ca6dcecd7 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -2,6 +2,7 @@ #include "../compiler-core/slang-name.h" #include "slang-syntax.h" +#include "slang-check.h" namespace Slang { @@ -330,6 +331,12 @@ namespace Slang return; } + // TODO: we should special case GenericTypeParamDecl and GenericValueParamDecl nodes + // instead of just dumping their names here to avoid the name of a generic parameter + // to have affect the binary signature. + // For each generic parameter, we should assign it a unique ID (i, j), where i is the + // nesting level of the generic, and j is the sequential order of the parameter within + // its generic parent, and use this 2D ID to refer to such a parameter. emitName(context, declRef.getName()); // Special case: accessors need some way to distinguish themselves @@ -392,26 +399,34 @@ namespace Slang } emit(context, genericParameterCount); - for( auto mm : getMembers(parentGenericDeclRef) ) + + OrderedDictionary<GenericTypeParamDecl*, List<Type*>> genericConstraints; + for (auto mm : getMembers(parentGenericDeclRef)) { - if(auto genericTypeParamDecl = mm.as<GenericTypeParamDecl>()) + if (auto genericTypeParamDecl = mm.as<GenericTypeParamDecl>()) { emitRaw(context, "T"); } - else if(auto genericValueParamDecl = mm.as<GenericValueParamDecl>()) + else if (auto genericValueParamDecl = mm.as<GenericValueParamDecl>()) { emitRaw(context, "v"); emitType(context, getType(context->astBuilder, genericValueParamDecl)); } - else if(mm.as<GenericTypeConstraintDecl>()) - { - emitRaw(context, "C"); - // TODO: actually emit info about the constraint - } else + {} + } + + auto canonicalizedConstraints = getCanonicalGenericConstraints(parentGenericDeclRef); + for (auto& constraint : canonicalizedConstraints) + { + for (auto type : constraint.Value) { + emitRaw(context, "C"); + emitQualifiedName(context, DeclRef<Decl>(constraint.Key, nullptr)); + emitType(context, type); } } + } } |
