1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-29 03:19:54 +00:00

Update pretty printer to remove values

from seen table.
This commit is contained in:
Calvin Rose 2018-11-19 09:57:24 -05:00
parent 8520d3f6cb
commit a7860f1dd1
3 changed files with 11 additions and 1 deletions

View File

@ -541,6 +541,10 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
x = janet_get(s, janet_csymbolv("vararg"));
if (janet_truthy(x)) def->flags |= JANET_FUNCDEF_FLAG_VARARG;
/* Check strict arity */
x = janet_get(s, janet_csymbolv("fix-arity"));
if (janet_truthy(x)) def->flags |= JANET_FUNCDEF_FLAG_FIXARITY;
/* Check source */
x = janet_get(s, janet_csymbolv("source"));
if (janet_checktype(x, JANET_STRING)) def->source = janet_unwrap_string(x);
@ -836,6 +840,9 @@ Janet janet_disasm(JanetFuncDef *def) {
if (def->flags & JANET_FUNCDEF_FLAG_VARARG) {
janet_table_put(ret, janet_csymbolv("vararg"), janet_wrap_true());
}
if (def->flags & JANET_FUNCDEF_FLAG_FIXARITY) {
janet_table_put(ret, janet_csymbolv("fix-arity"), janet_wrap_true());
}
if (NULL != def->name) {
janet_table_put(ret, janet_csymbolv("name"), janet_wrap_string(def->name));
}

View File

@ -518,7 +518,7 @@ static void janet_pretty_one(struct pretty *S, Janet x) {
switch (janet_type(x)) {
default:
janet_description_b(S->buffer, x);
return;
break;
case JANET_ARRAY:
case JANET_TUPLE:
{
@ -579,6 +579,8 @@ static void janet_pretty_one(struct pretty *S, Janet x) {
break;
}
}
/* Remove from seen */
janet_table_remove(&S->seen, x);
return;
}

View File

@ -1094,6 +1094,7 @@ JANET_API int janet_equals(Janet x, Janet y);
JANET_API int32_t janet_hash(Janet x);
JANET_API int janet_compare(Janet x, Janet y);
JANET_API int janet_cstrcmp(const uint8_t *str, const char *other);
JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, Janet x);
/* VM functions */
JANET_API int janet_init(void);