MCPcopy
hub / github.com/plasma-umass/browsix / demangle

Function demangle

src/ld.js:1439–1465  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

1437
1438
1439function demangle(func) {
1440 var hasLibcxxabi = !!Module['___cxa_demangle'];
1441 if (hasLibcxxabi) {
1442 try {
1443 var s = func.substr(1);
1444 var len = lengthBytesUTF8(s)+1;
1445 var buf = _malloc(len);
1446 stringToUTF8(s, buf, len);
1447 var status = _malloc(4);
1448 var ret = Module['___cxa_demangle'](buf, 0, 0, status);
1449 if (getValue(status, 'i32') === 0 && ret) {
1450 return Pointer_stringify(ret);
1451 }
1452 // otherwise, libcxxabi failed
1453 } catch(e) {
1454 // ignore problems here
1455 } finally {
1456 if (buf) _free(buf);
1457 if (status) _free(status);
1458 if (ret) _free(ret);
1459 }
1460 // failure when using libcxxabi, don't demangle
1461 return func;
1462 }
1463 Runtime.warnOnce('warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling');
1464 return func;
1465}
1466
1467function demangleAll(text) {
1468 return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });

Callers 1

demangleAllFunction · 0.70

Calls 6

_mallocFunction · 0.85
_freeFunction · 0.85
lengthBytesUTF8Function · 0.70
stringToUTF8Function · 0.70
getValueFunction · 0.70
Pointer_stringifyFunction · 0.70

Tested by

no test coverage detected