2005-02-04 15:39:11 +00:00
|
|
|
/*
|
2007-02-03 10:52:36 +00:00
|
|
|
* $Id: mem.h,v 1.17 2007-02-03 10:51:52 bacon Exp $
|
|
|
|
*
|
|
|
|
* {License}
|
2005-02-04 15:39:11 +00:00
|
|
|
*/
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
#ifndef _ASE_LSP_MEM_H_
|
|
|
|
#define _ASE_LSP_MEM_H_
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-26 08:17:38 +00:00
|
|
|
#ifndef _ASE_LSP_LSP_H_
|
|
|
|
#error Never include this file directly. Include <ase/lsp/lsp.h> instead
|
|
|
|
#endif
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-24 15:31:35 +00:00
|
|
|
typedef struct ase_lsp_mem_t ase_lsp_mem_t;
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_mem_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 15:31:35 +00:00
|
|
|
ase_lsp_t* lsp;
|
|
|
|
|
2006-11-02 06:46:31 +00:00
|
|
|
/* object allocation list */
|
|
|
|
ase_size_t ubound; /* upper bounds of the maximum number of objects */
|
|
|
|
ase_size_t ubound_inc; /* increment of the upper bounds */
|
|
|
|
ase_size_t count; /* the number of objects currently allocated */
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_obj_t* used[ASE_LSP_TYPE_COUNT];
|
|
|
|
ase_lsp_obj_t* free[ASE_LSP_TYPE_COUNT];
|
2006-11-02 10:12:01 +00:00
|
|
|
ase_lsp_obj_t* read;
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-11-02 06:46:31 +00:00
|
|
|
/* commonly accessed objects */
|
|
|
|
ase_lsp_obj_t* nil; /* ase_lsp_obj_nil_t */
|
|
|
|
ase_lsp_obj_t* t; /* ase_lsp_obj_true_t */
|
2006-11-02 10:12:01 +00:00
|
|
|
ase_lsp_obj_t* quote; /* ase_lsp_obj_sym_t */
|
|
|
|
ase_lsp_obj_t* lambda; /* ase_lsp_obj_sym_t */
|
|
|
|
ase_lsp_obj_t* macro; /* ase_lsp_obj_sym_t */
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-11-02 06:46:31 +00:00
|
|
|
/* run-time environment frame */
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_frame_t* frame;
|
2006-11-02 06:46:31 +00:00
|
|
|
/* pointer to a global-level frame */
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_frame_t* root_frame;
|
2006-11-02 06:46:31 +00:00
|
|
|
/* pointer to an interim frame not yet added to "frame" */
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_frame_t* brooding_frame;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-10-24 15:31:35 +00:00
|
|
|
ase_lsp_mem_t* ase_lsp_openmem (
|
|
|
|
ase_lsp_t* lsp, ase_size_t ubound, ase_size_t ubound_inc);
|
|
|
|
void ase_lsp_closemem (ase_lsp_mem_t* mem);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_alloc (ase_lsp_mem_t* mem, int type, ase_size_t size);
|
|
|
|
void ase_lsp_dispose (ase_lsp_mem_t* mem, ase_lsp_obj_t* prev, ase_lsp_obj_t* obj);
|
|
|
|
void ase_lsp_dispose_all (ase_lsp_mem_t* mem);
|
2006-10-24 15:31:35 +00:00
|
|
|
void ase_lsp_collectgarbage (ase_lsp_mem_t* mem);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-25 13:42:31 +00:00
|
|
|
void ase_lsp_lockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
|
|
|
void ase_lsp_unlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
2006-11-02 10:12:01 +00:00
|
|
|
void ase_lsp_deepunlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-29 13:40:33 +00:00
|
|
|
/* object creation of standard types */
|
2006-10-25 13:42:31 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makenil (ase_lsp_mem_t* mem);
|
|
|
|
ase_lsp_obj_t* ase_lsp_maketrue (ase_lsp_mem_t* mem);
|
|
|
|
ase_lsp_obj_t* ase_lsp_makeintobj (ase_lsp_mem_t* mem, ase_long_t value);
|
|
|
|
ase_lsp_obj_t* ase_lsp_makerealobj (ase_lsp_mem_t* mem, ase_real_t value);
|
|
|
|
|
2006-11-02 10:12:01 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makesym (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len);
|
2006-11-02 10:12:01 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makestr (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len);
|
2006-10-25 13:42:31 +00:00
|
|
|
|
|
|
|
ase_lsp_obj_t* ase_lsp_makecons (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, ase_lsp_obj_t* car, ase_lsp_obj_t* cdr);
|
2006-10-25 13:42:31 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makefunc (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body);
|
2006-10-25 13:42:31 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makemacro (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body);
|
|
|
|
|
2006-10-29 13:00:39 +00:00
|
|
|
ase_lsp_obj_t* ase_lsp_makeprim (ase_lsp_mem_t* mem,
|
|
|
|
ase_lsp_prim_t impl, ase_size_t min_args, ase_size_t max_args);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-29 13:40:33 +00:00
|
|
|
/* frame lookup */
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_assoc_t* ase_lsp_lookup (ase_lsp_mem_t* mem, ase_lsp_obj_t* name);
|
2006-10-25 13:42:31 +00:00
|
|
|
ase_lsp_assoc_t* ase_lsp_setvalue (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* value);
|
2006-10-25 13:42:31 +00:00
|
|
|
ase_lsp_assoc_t* ase_lsp_setfunc (
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* func);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-29 13:40:33 +00:00
|
|
|
/* cons operations */
|
2006-10-29 13:00:39 +00:00
|
|
|
ase_size_t ase_lsp_conslen (ase_lsp_mem_t* mem, ase_lsp_obj_t* obj);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|