in src/debugger/TextBuilder.cpp [388:431]
void TextBuilder::buildFunction(SEXP func, bool withBody) {
if (functionReplacement.count(func)) {
text << functionReplacement[func];
return;
}
SHIELD(func);
switch (TYPEOF(func)) {
case CLOSXP: {
buildFunctionHeader(FORMALS(func));
if (withBody) {
text << " ";
SEXP body = BODY_EXPR(func);
if (TYPEOF(body) == LANGSXP && Rf_getAttrib(body, RI->generatedBlockFlag) != R_NilValue && Rf_length(body) == 2) {
body = CADR(body);
}
build(body);
}
break;
}
case SPECIALSXP:
case BUILTINSXP: {
int offset = getPrimOffset(func);
int arity = getFunTabArity(offset);
const char* name = getFunTabName(offset);
text << "function(";
if (arity == -1) {
text << "...";
} else {
for (int i = 1; i <= arity; ++i) {
if (i > 1) {
text << ", ";
}
text << "e" << i;
}
}
text << ")";
if (withBody) {
text << " ";
text << ".Primitive(\"" << name << "\")";
}
break;
}
}
}