Refactor with new name uclisp
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "nihilispm.h"
|
||||
#include "nihilispm_internal.h"
|
||||
#include "nihilispm_utility.h"
|
||||
#include "nihilispm_state.h"
|
||||
#include "uclisp.h"
|
||||
#include "internal.h"
|
||||
#include "utility.h"
|
||||
#include "state.h"
|
||||
|
||||
struct nl_object *nl_evaluate_list(struct nl_state *state, struct nl_object *list) {
|
||||
struct ucl_object *ucl_evaluate_list(struct ucl_state *state, struct ucl_object *list) {
|
||||
// TODO: Recursively eval args
|
||||
struct nl_object *evaluated_list = nl_nil_create();
|
||||
struct ucl_object *evaluated_list = ucl_nil_create();
|
||||
|
||||
FOREACH_LIST(list, iter, item) {
|
||||
struct nl_object *obj = nl_evaluate(state, item);
|
||||
nl_list_append(evaluated_list, obj);
|
||||
struct ucl_object *obj = ucl_evaluate(state, item);
|
||||
ucl_list_append(evaluated_list, obj);
|
||||
};
|
||||
|
||||
struct nl_object *fun = nl_car(evaluated_list);
|
||||
struct nl_object *args = nl_cdr(evaluated_list);
|
||||
struct nl_object *result = NULL;
|
||||
struct ucl_object *fun = ucl_car(evaluated_list);
|
||||
struct ucl_object *args = ucl_cdr(evaluated_list);
|
||||
struct ucl_object *result = NULL;
|
||||
|
||||
assert(fun->type == NL_TYPE_BUILTIN);
|
||||
if (fun->type == NL_TYPE_BUILTIN) {
|
||||
assert(fun->type == UCL_TYPE_BUILTIN);
|
||||
if (fun->type == UCL_TYPE_BUILTIN) {
|
||||
result = fun->builtin(args);
|
||||
}
|
||||
|
||||
@@ -31,20 +31,20 @@ struct nl_object *nl_evaluate_list(struct nl_state *state, struct nl_object *lis
|
||||
return result;
|
||||
}
|
||||
|
||||
struct nl_object *nl_evaluate(struct nl_state *state, struct nl_object *obj) {
|
||||
struct ucl_object *ucl_evaluate(struct ucl_state *state, struct ucl_object *obj) {
|
||||
assert(obj != NULL);
|
||||
|
||||
switch (obj->type) {
|
||||
case NL_TYPE_CELL:
|
||||
return nl_evaluate_list(state, obj);
|
||||
case NL_TYPE_SYMBOL:
|
||||
return nl_state_get(state, obj->symbol);
|
||||
case NL_TYPE_INT:
|
||||
case NL_TYPE_STRING:
|
||||
case NL_TYPE_ERROR:
|
||||
case UCL_TYPE_CELL:
|
||||
return ucl_evaluate_list(state, obj);
|
||||
case UCL_TYPE_SYMBOL:
|
||||
return ucl_state_get(state, obj->symbol);
|
||||
case UCL_TYPE_INT:
|
||||
case UCL_TYPE_STRING:
|
||||
case UCL_TYPE_ERROR:
|
||||
return obj;
|
||||
case NL_TYPE_BUILTIN:
|
||||
case NL_TYPE_COUNT:
|
||||
case UCL_TYPE_BUILTIN:
|
||||
case UCL_TYPE_COUNT:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user