MCPcopy Create free account
hub / github.com/nodejs/node / parse

Function parse

deps/v8/test/mjsunit/asm/embenchen/copy.js:957–1027  ·  view source on GitHub ↗
(rawList, limit, allowVoid)

Source from the content-addressed store, hash-verified

955 return parts;
956 }
957 function parse(rawList, limit, allowVoid) { // main parser
958 limit = limit || Infinity;
959 var ret = '', list = [];
960 function flushList() {
961 return '(' + list.join(', ') + ')';
962 }
963 var name;
964 if (func[i] === 'N') {
965 // namespaced N-E
966 name = parseNested().join('::');
967 limit--;
968 if (limit === 0) return rawList ? [name] : name;
969 } else {
970 // not namespaced
971 if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
972 var size = parseInt(func.substr(i));
973 if (size) {
974 var pre = size.toString().length;
975 name = func.substr(i + pre, size);
976 i += pre + size;
977 }
978 }
979 first = false;
980 if (func[i] === 'I') {
981 i++;
982 var iList = parse(true);
983 var iRet = parse(true, 1, true);
984 ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
985 } else {
986 ret = name;
987 }
988 paramLoop: while (i < func.length && limit-- > 0) {
989 //dump('paramLoop');
990 var c = func[i++];
991 if (c in basicTypes) {
992 list.push(basicTypes[c]);
993 } else {
994 switch (c) {
995 case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
996 case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
997 case 'L': { // literal
998 i++; // skip basic type
999 var end = func.indexOf('E', i);
1000 var size = end - i;
1001 list.push(func.substr(i, size));
1002 i += size + 2; // size + 'EE'
1003 break;
1004 }
1005 case 'A': { // array
1006 var size = parseInt(func.substr(i));
1007 i += size.toString().length;
1008 if (func[i] !== '_') throw '?';
1009 i++; // skip _
1010 list.push(parse(true, 1, true)[0] + ' [' + size + ']');
1011 break;
1012 }
1013 case 'E': break paramLoop;
1014 default: ret += '?' + c; break paramLoop;

Callers 2

demangleFunction · 0.70

Calls 6

parseNestedFunction · 0.70
flushListFunction · 0.70
joinMethod · 0.45
toStringMethod · 0.45
pushMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected