Work on dynamic variable
This commit is contained in:
+7
-79
@@ -10,18 +10,21 @@ static void construct_manual_symbols(void) {
|
||||
// IMPORTANT: the symbols listed here need to also be set as special in
|
||||
// gen-init-globals.awk
|
||||
Qnil = Fmake_symbol(LISP_LITSTR("nil"));
|
||||
((LispSymbol *) Qnil)->value = Qnil;
|
||||
((LispSymbol *) Qnil)->flags = SYMBOL_CONST_VALUE | SYMBOL_CONST_FUNCTION;
|
||||
((LispSymbol *) Qnil)->value.normal = Qnil;
|
||||
((LispSymbol *) Qnil)->function = Qnil;
|
||||
((LispSymbol *) Qnil)->plist = Qnil;
|
||||
lisp_gc_register_static_object(Qnil);
|
||||
Qt = Fmake_symbol(LISP_LITSTR("t"));
|
||||
((LispSymbol *) Qt)->value = Qt;
|
||||
((LispSymbol *) Qt)->flags = SYMBOL_CONST_VALUE | SYMBOL_CONST_FUNCTION;
|
||||
((LispSymbol *) Qt)->value.normal = Qt;
|
||||
lisp_gc_register_static_object(Qt);
|
||||
Qunbound = Fmake_symbol(LISP_LITSTR("unbound"));
|
||||
((LispSymbol *) Qunbound)->value = Qunbound;
|
||||
((LispSymbol *) Qunbound)->value.normal = Qunbound;
|
||||
lisp_gc_register_static_object(Qunbound);
|
||||
Qlexical_environment = Fmake_symbol(LISP_LITSTR("lexical-environment"));
|
||||
((LispSymbol *) Qlexical_environment)->value = Qnil;
|
||||
((LispSymbol *) Qlexical_environment)->value_type = SYMBOL_NATIVE;
|
||||
((LispSymbol *) Qlexical_environment)->value.native = &Vlexical_environment;
|
||||
lisp_gc_register_static_object(Qlexical_environment);
|
||||
|
||||
Qhash_string = Fmake_symbol(LISP_LITSTR("hash-string"));
|
||||
@@ -184,78 +187,3 @@ DEFSPECIAL(or, "or", (LispVal * forms), "(&rest forms)", "") {
|
||||
DEFUN(null, "null", (LispVal * datum), "(datum)", "") {
|
||||
return NILP(datum) ? Qt : Qnil;
|
||||
}
|
||||
|
||||
void debug_print(FILE *file, LispVal *obj) {
|
||||
switch (TYPE_OF(obj)) {
|
||||
case TYPE_FIXNUM:
|
||||
fprintf(file, "%jd", (intmax_t) XFIXNUM(obj));
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
fprintf(file, "%f", (double) XLISP_FLOAT(obj));
|
||||
break;
|
||||
case TYPE_STRING: {
|
||||
LispString *s = obj;
|
||||
fputc('"', file);
|
||||
fwrite(s->data, 1, s->length, file);
|
||||
fputc('"', file);
|
||||
break;
|
||||
}
|
||||
case TYPE_SYMBOL: {
|
||||
LispString *name = ((LispSymbol *) obj)->name;
|
||||
fwrite(name->data, 1, name->length, file);
|
||||
break;
|
||||
}
|
||||
case TYPE_HASH_TABLE: {
|
||||
fprintf(file, "<hash-table count=%zu at 0x%jx>",
|
||||
((LispHashTable *) obj)->count, (uintmax_t) obj);
|
||||
break;
|
||||
}
|
||||
case TYPE_FUNCTION: {
|
||||
LispFunction *fobj = obj;
|
||||
if (NILP(fobj->name)) {
|
||||
fprintf(file, "<lambda at 0x%jx>", (uintmax_t) obj);
|
||||
} else {
|
||||
fprintf(file, "<function ");
|
||||
debug_print(file, fobj->name);
|
||||
fprintf(file, " at 0x%jx>", (uintmax_t) obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_CONS: {
|
||||
fputc('(', file);
|
||||
DOTAILS(tail, obj) {
|
||||
if (CONSP(tail)) {
|
||||
debug_print(file, XCAR(tail));
|
||||
if (!NILP(XCDR(tail))) {
|
||||
fputc(' ', file);
|
||||
}
|
||||
} else {
|
||||
fwrite(". ", 1, 2, file);
|
||||
debug_print(file, tail);
|
||||
}
|
||||
}
|
||||
fputc(')', file);
|
||||
break;
|
||||
}
|
||||
case TYPE_VECTOR: {
|
||||
LispVector *v = obj;
|
||||
fputc('[', file);
|
||||
for (size_t i = 0; i < v->length; ++i) {
|
||||
debug_print(file, v->data[i]);
|
||||
if (i < v->length - 1) {
|
||||
fputc(' ', file);
|
||||
}
|
||||
}
|
||||
fputc(']', file);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void debug_obj_info(FILE *file, LispVal *obj) {
|
||||
fprintf(file, "%s -> ", LISP_TYPE_NAMES[TYPE_OF(obj)]);
|
||||
debug_print(file, obj);
|
||||
fputc('\n', file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user