MCPcopy
hub / github.com/jvilk/BrowserFS / demangle

Function demangle

test/tests/emscripten/readdir_empty.js:981–1154  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

979Module["lengthBytesUTF32"] = lengthBytesUTF32;
980
981function demangle(func) {
982 var hasLibcxxabi = !!Module['___cxa_demangle'];
983 if (hasLibcxxabi) {
984 try {
985 var buf = _malloc(func.length);
986 writeStringToMemory(func.substr(1), buf);
987 var status = _malloc(4);
988 var ret = Module['___cxa_demangle'](buf, 0, 0, status);
989 if (getValue(status, 'i32') === 0 && ret) {
990 return Pointer_stringify(ret);
991 }
992 // otherwise, libcxxabi failed, we can try ours which may return a partial result
993 } catch(e) {
994 // failure when using libcxxabi, we can try ours which may return a partial result
995 } finally {
996 if (buf) _free(buf);
997 if (status) _free(status);
998 if (ret) _free(ret);
999 }
1000 }
1001 var i = 3;
1002 // params, etc.
1003 var basicTypes = {
1004 'v': 'void',
1005 'b': 'bool',
1006 'c': 'char',
1007 's': 'short',
1008 'i': 'int',
1009 'l': 'long',
1010 'f': 'float',
1011 'd': 'double',
1012 'w': 'wchar_t',
1013 'a': 'signed char',
1014 'h': 'unsigned char',
1015 't': 'unsigned short',
1016 'j': 'unsigned int',
1017 'm': 'unsigned long',
1018 'x': 'long long',
1019 'y': 'unsigned long long',
1020 'z': '...'
1021 };
1022 var subs = [];
1023 var first = true;
1024 function dump(x) {
1025 //return;
1026 if (x) Module.print(x);
1027 Module.print(func);
1028 var pre = '';
1029 for (var a = 0; a < i; a++) pre += ' ';
1030 Module.print (pre + '^');
1031 }
1032 function parseNested() {
1033 i++;
1034 if (func[i] === 'K') i++; // ignore const
1035 var parts = [];
1036 while (func[i] !== 'E') {
1037 if (func[i] === 'S') { // substitution
1038 i++;

Callers 1

demangleAllFunction · 0.70

Calls 6

_mallocFunction · 0.70
writeStringToMemoryFunction · 0.70
getValueFunction · 0.70
Pointer_stringifyFunction · 0.70
_freeFunction · 0.70
parseFunction · 0.70

Tested by

no test coverage detected