- macros work in the new way (the "right" way?) - added test.py script, with basic test cases. Need to fill out new test builtins.
86 lines
1.4 KiB
C
86 lines
1.4 KiB
C
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <evaluate.h>
|
|
|
|
#include <value/struct.h>
|
|
#include <value/environment/define.h>
|
|
#include <value/null/new.h>
|
|
|
|
#include <gc/dec_external_refcount.h>
|
|
|
|
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"
|
|
#include "../defines/BUILTIN_PARAMETER_PASS_EVALUATE.h"
|
|
|
|
#include "define.h"
|
|
|
|
struct value* builtin_define(
|
|
BUILTIN_PARAMETER_DECLARATION)
|
|
{
|
|
ENTER;
|
|
|
|
if (arguments->kind != vk_list)
|
|
{
|
|
TODO;
|
|
|
|
exit(1);
|
|
}
|
|
|
|
struct list_value* arguments_lv = &arguments->subclass.list;
|
|
|
|
struct value* first = arguments_lv->first;
|
|
|
|
if (first->kind != vk_identifier)
|
|
{
|
|
TODO;
|
|
exit(1);
|
|
}
|
|
|
|
struct value* rest = arguments_lv->rest;
|
|
|
|
if (rest->kind != vk_list)
|
|
{
|
|
TODO;
|
|
exit(1);
|
|
}
|
|
|
|
struct value* second = rest->subclass.list.first;
|
|
|
|
if (rest->subclass.list.rest->kind != vk_null)
|
|
{
|
|
TODO;
|
|
exit(1);
|
|
}
|
|
|
|
struct value* result = evaluate(second, environment, BUILTIN_PARAMETER_PASS_EVALUATE);
|
|
|
|
environment_value_define(
|
|
/* environment: */ environment,
|
|
/* name: */ first->subclass.identifier.name,
|
|
/* value: */ result);
|
|
|
|
gc_dec_external_refcount(gc, result);
|
|
|
|
struct value* retval = new_null_value(gc);
|
|
|
|
EXIT;
|
|
return retval;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|