qse/ase/lsp/prim_prog.c

51 lines
1.1 KiB
C
Raw Normal View History

2005-09-19 12:04:00 +00:00
/*
2006-10-22 13:10:46 +00:00
* $Id: prim_prog.c,v 1.2 2006-10-22 13:10:46 bacon Exp $
2005-09-19 12:04:00 +00:00
*/
2006-10-22 13:10:46 +00:00
#include <sse/lsp/prim.h>
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
sse_lsp_obj_t* sse_lsp_prim_prog1 (sse_lsp_t* lsp, sse_lsp_obj_t* args)
2005-09-19 12:04:00 +00:00
{
2006-10-22 13:10:46 +00:00
sse_lsp_obj_t* res = SSE_NULL, * tmp;
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
SSE_LSP_PRIM_CHECK_ARG_COUNT (lsp, args, 1, SSE_LSP_PRIM_MAX_ARG_COUNT);
2005-09-19 12:04:00 +00:00
//while (args != lsp->mem->nil) {
2006-10-22 13:10:46 +00:00
while (SSE_LSP_TYPE(args) == SSE_LSP_OBJ_CONS) {
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
tmp = sse_lsp_eval (lsp, SSE_LSP_CAR(args));
if (tmp == SSE_NULL) return SSE_NULL;
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
if (res == SSE_NULL) {
2005-09-19 12:04:00 +00:00
/*
2006-10-22 13:10:46 +00:00
sse_lsp_array_t* ta = lsp->mem->temp_array;
sse_lsp_array_insert (ta, ta->size, tmp);
2005-09-19 12:04:00 +00:00
*/
res = tmp;
}
2006-10-22 13:10:46 +00:00
args = SSE_LSP_CDR(args);
2005-09-19 12:04:00 +00:00
}
return res;
}
2006-10-22 13:10:46 +00:00
sse_lsp_obj_t* sse_lsp_prim_progn (sse_lsp_t* lsp, sse_lsp_obj_t* args)
2005-09-19 12:04:00 +00:00
{
2006-10-22 13:10:46 +00:00
sse_lsp_obj_t* res, * tmp;
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
SSE_LSP_PRIM_CHECK_ARG_COUNT (lsp, args, 1, SSE_LSP_PRIM_MAX_ARG_COUNT);
2005-09-19 12:04:00 +00:00
res = lsp->mem->nil;
//while (args != lsp->mem->nil) {
2006-10-22 13:10:46 +00:00
while (SSE_LSP_TYPE(args) == SSE_LSP_OBJ_CONS) {
2005-09-19 12:04:00 +00:00
2006-10-22 13:10:46 +00:00
tmp = sse_lsp_eval (lsp, SSE_LSP_CAR(args));
if (tmp == SSE_NULL) return SSE_NULL;
2005-09-19 12:04:00 +00:00
res = tmp;
2006-10-22 13:10:46 +00:00
args = SSE_LSP_CDR(args);
2005-09-19 12:04:00 +00:00
}
return res;
}