lisp-take-1/value/user_lambda/prettyprint.c

66 lines
1.1 KiB
C

#include <assert.h>
#include <debug.h>
#include <stringtree/new.h>
#include <stringtree/append.h>
#include <stringtree/free.h>
#include "../struct.h"
#include "../prettyprint.h"
#include "struct.h"
#include "prettyprint.h"
struct stringtree* user_lambda_value_prettyprint(
const struct value* super)
{
ENTER;
assert(super->kind == vk_user_lambda);
const struct user_lambda_value* this = &super->subclass.user_lambda;
struct stringtree* tree = new_stringtree();
stringtree_append_string_const(tree, "(lambda ");
{
struct stringtree* parameters = value_prettyprint(this->parameters);
stringtree_append_stringtree(tree, parameters);
free_stringtree(parameters);
}
stringtree_append_string_const(tree, " ");
{
struct stringtree* body = value_prettyprint(this->body);
stringtree_append_stringtree(tree, body);
free_stringtree(body);
}
stringtree_append_string_const(tree, ")");
EXIT;
return tree;
}