54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/*
|
|
User Extensions
|
|
*/
|
|
|
|
// Definitions
|
|
object *fn_sym_def (object *args, object *env) {
|
|
(void) env;
|
|
object *obj = first(args);
|
|
pfun_t pfun = pstreamfun(cdr(args));
|
|
#if defined(gfxsupport)
|
|
if (pfun == gfxwrite) ppwidth = GFXPPWIDTH;
|
|
#endif
|
|
object *pair = findvalue(obj, env);
|
|
object *var = car(pair);
|
|
object *val = cdr(pair);
|
|
pln(pfun);
|
|
if (consp(val) && symbolp(car(val)) && builtin(car(val)->name) == LAMBDA) {
|
|
superprint(cons(bsymbol(DEFUN), cons(var, cdr(val))), 0, false, pfun);
|
|
} else {
|
|
superprint(cons(bsymbol(DEFVAR), cons(var, cons(quote(val), NULL))), 0, false, pfun);
|
|
}
|
|
pln(pfun);
|
|
ppwidth = PPWIDTH;
|
|
return bsymbol(NOTHING);
|
|
}
|
|
|
|
// Symbol names
|
|
const char string_sym_def[] PROGMEM = "symbol-def";
|
|
|
|
|
|
// Documentation strings
|
|
const char doc_sym_def[] PROGMEM = "(symbol-def symbol [str])\n"
|
|
"Prints the definition of a symbol (variable or function) defined in ulisp using the pretty printer."
|
|
"If str is specified it prints to the specified stream. It returns no value.";
|
|
|
|
|
|
// Symbol lookup table
|
|
const tbl_entry_t lookup_table2[] PROGMEM = {
|
|
|
|
{ string_sym_def, fn_sym_def, 0212, doc_sym_def }
|
|
};
|
|
|
|
// Table cross-reference functions
|
|
|
|
tbl_entry_t *tables[] = {lookup_table, lookup_table2};
|
|
const unsigned int tablesizes[] = { arraysize(lookup_table), arraysize(lookup_table2) };
|
|
|
|
const tbl_entry_t *table (int n) {
|
|
return tables[n];
|
|
}
|
|
|
|
unsigned int tablesize (int n) {
|
|
return tablesizes[n];
|
|
} |