From c3a27c0e5a5b36b5a14566394d1694419632b76c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 18 Apr 2018 14:14:26 -0700 Subject: Fix up name mangling/unmangling for extensions (#493) * Fix up name mangling/unmangling for extensions This is required for the unmangling we do on some builtin function names. The work here is mostly just a band-aid, and a more comprehensive pass over the name mangling/unmangling code is required to make any of this robust. * fixup: UNREACHABLE_RETURN argument --- source/slang/emit.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index e86a6d1e4..008ddb270 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2355,6 +2355,28 @@ struct EmitVisitor } } + + UnownedStringSlice readRawStringSegment() + { + // Read the length part + UInt count = readCount(); + if(count > UInt(end_ - cursor_)) + { + SLANG_UNEXPECTED("bad name mangling"); + UNREACHABLE_RETURN(UnownedStringSlice()); + } + + auto result = UnownedStringSlice(cursor_, cursor_ + count); + cursor_ += count; + return result; + } + + void readNamedType() + { + // TODO: handle types with more complicated names + readRawStringSegment(); + } + void readType() { int c = peek(); @@ -2378,16 +2400,30 @@ struct EmitVisitor break; default: - // TODO: need to read a named type - // here... + readNamedType(); break; } } void readVal() { - // TODO: handle other cases here - readType(); + switch(peek()) + { + case 'k': + get(); + readCount(); + break; + + case 'K': + get(); + readRawStringSegment(); + break; + + default: + readType(); + break; + } + } void readGenericArg() @@ -2405,6 +2441,12 @@ struct EmitVisitor } } + void readExtensionSpec() + { + expect("X"); + readType(); + } + UnownedStringSlice readSimpleName() { UnownedStringSlice result; @@ -2422,6 +2464,11 @@ struct EmitVisitor readGenericArgs(); continue; } + else if(c == 'X') + { + readExtensionSpec(); + continue; + } if(!isDigit((char)c)) return result; -- cgit v1.2.3