80 lines
1.3 KiB
C
80 lines
1.3 KiB
C
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <booleans/struct.h>
|
|
|
|
/*#include <number/new.h>*/
|
|
#include <number/compare.h>
|
|
/*#include <number/set_int.h>*/
|
|
/*#include <number/free.h>*/
|
|
|
|
#include <value/number/struct.h>
|
|
/*#include <value/number/new.h>*/
|
|
|
|
#include <value/lazy/unlazy.h>
|
|
|
|
#include <value/inc.h>
|
|
#include <value/free.h>
|
|
|
|
#include <value/builtin_lambda/struct.h>
|
|
|
|
#include "lte.h"
|
|
|
|
struct value* builtin_compare_lte(
|
|
struct booleans* booleans,
|
|
struct builtin_lambda_value* prev,
|
|
struct value* tail)
|
|
{
|
|
ENTER;
|
|
|
|
struct value* left = lazy_value_unlazy(prev->value, booleans);
|
|
|
|
struct value* right = lazy_value_unlazy(tail, booleans);
|
|
|
|
dpvp(left);
|
|
dpvp(right);
|
|
|
|
assert(left);
|
|
assert(right);
|
|
|
|
if (left->kind != vk_number || right->kind != vk_number)
|
|
{
|
|
TODO;
|
|
exit(1);
|
|
}
|
|
|
|
int cmp = compare_number(
|
|
/* left: */ ((struct number_value*) left)->value,
|
|
/* right: */ ((struct number_value*) right)->value);
|
|
|
|
struct value* result = inc_value(
|
|
cmp <= 0
|
|
? booleans->true_value
|
|
: booleans->false_value);
|
|
|
|
free_value(left);
|
|
|
|
free_value(right);
|
|
|
|
EXIT;
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|