-static void call_cmd(char **ptr)
-{
- lispobj thing = parse_lispobj(ptr), function, result = 0, cons, args[3];
- int numargs;
-
- if (LowtagOf(thing) == type_OtherPointer) {
- switch (TypeOf(*(lispobj *)(thing-type_OtherPointer))) {
- case type_SymbolHeader:
- for (cons = SymbolValue(INITIAL_FDEFN_OBJECTS);
- cons != NIL;
- cons = CONS(cons)->cdr) {
- if (FDEFN(CONS(cons)->car)->name == thing) {
- thing = CONS(cons)->car;
- goto fdefn;
- }
- }
- printf("symbol 0x%08lx is undefined.\n", (long unsigned)thing);
- return;
-
- case type_Fdefn:
- fdefn:
- function = FDEFN(thing)->function;
- if (function == NIL) {
- printf("fdefn 0x%08lx is undefined.\n", (long unsigned)thing);
- return;
- }
- break;
- default:
- printf("0x%08lx is not a function pointer, symbol, "
- "or fdefn object.\n",
- (long unsigned)thing);
- return;
- }
- }
- else if (LowtagOf(thing) != type_FunctionPointer) {
- printf("0x%08lx is not a function pointer, symbol, or fdefn object.\n",
- (long unsigned)thing);
- return;
- }
- else
- function = thing;
-
- numargs = 0;
- while (more_p(ptr)) {
- if (numargs >= 3) {
- printf("too many arguments (no more than 3 allowed)\n");
- return;
- }
- args[numargs++] = parse_lispobj(ptr);
- }
-
- switch (numargs) {
- case 0:
- result = funcall0(function);
- break;
- case 1:
- result = funcall1(function, args[0]);
- break;
- case 2:
- result = funcall2(function, args[0], args[1]);
- break;
- case 3:
- result = funcall3(function, args[0], args[1], args[2]);
- break;
- default:
- lose("unsupported argument count");
- }
-
- print(result);
-}