lambda-calc-1/statement/expression/execute.c

66 lines
1.2 KiB
C

#include <stddef.h>
#include <debug.h>
#include <stringtree/new.h>
#include <stringtree/println.h>
#include <stringtree/free.h>
#include <value/prettyprint.h>
#include <value/lazy/unlazy.h>
#include <value/free.h>
#include <expression/evaluate.h>
#include "struct.h"
#include "execute.h"
void expression_statement_execute(
struct statement* super,
struct environment** environment,
struct booleans* booleans,
struct wcostream* ostream,
bool print_value,
bool print_with_color)
{
ENTER;
struct expression_statement* this = (void*) super;
struct value* value = expression_evaluate(
/* expression: */ this->expression,
/* environment: */ *environment,
/* booleans: */ booleans);
struct value* vvalue = lazy_value_unlazy(value, booleans);
if (print_value)
{
struct stringtree* tree = value_prettyprint(
/* outgoing chosen color: */ NULL,
/* value: */ vvalue,
/* print with color? */ print_with_color);
stringtree_println(tree, ostream);
free_stringtree(tree);
}
free_value(vvalue);
free_value(value);
EXIT;
}