2005-02-04 15:39:11 +00:00
|
|
|
/*
|
2006-10-24 04:22:40 +00:00
|
|
|
* $Id: obj.h,v 1.7 2006-10-24 04:22:39 bacon Exp $
|
2005-02-04 15:39:11 +00:00
|
|
|
*/
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
#ifndef _ASE_LSP_OBJ_H_
|
|
|
|
#define _ASE_LSP_OBJ_H_
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
#include <ase/lsp/types.h>
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2005-09-21 15:53:55 +00:00
|
|
|
/* object types */
|
2005-02-04 15:39:11 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ASE_LSP_OBJ_NIL = 0,
|
|
|
|
ASE_LSP_OBJ_TRUE,
|
|
|
|
ASE_LSP_OBJ_INT,
|
|
|
|
ASE_LSP_OBJ_REAL,
|
|
|
|
ASE_LSP_OBJ_SYMBOL,
|
|
|
|
ASE_LSP_OBJ_STRING,
|
|
|
|
ASE_LSP_OBJ_CONS,
|
|
|
|
ASE_LSP_OBJ_FUNC,
|
|
|
|
ASE_LSP_OBJ_MACRO,
|
|
|
|
ASE_LSP_OBJ_PRIM,
|
|
|
|
|
|
|
|
ASE_LSP_TYPE_COUNT // the number of lsp object types
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
typedef struct ase_lsp_objhdr_t ase_lsp_objhdr_t;
|
|
|
|
typedef struct ase_lsp_obj_t ase_lsp_obj_t;
|
|
|
|
typedef struct ase_lsp_obj_nil_t ase_lsp_obj_nil_t;
|
|
|
|
typedef struct ase_lsp_obj_true_t ase_lsp_obj_true_t;
|
|
|
|
typedef struct ase_lsp_obj_int_t ase_lsp_obj_int_t;
|
|
|
|
typedef struct ase_lsp_obj_real_t ase_lsp_obj_real_t;
|
|
|
|
typedef struct ase_lsp_obj_symbol_t ase_lsp_obj_symbol_t;
|
|
|
|
typedef struct ase_lsp_obj_string_t ase_lsp_obj_string_t;
|
|
|
|
typedef struct ase_lsp_obj_cons_t ase_lsp_obj_cons_t;
|
|
|
|
typedef struct ase_lsp_obj_func_t ase_lsp_obj_func_t;
|
|
|
|
typedef struct ase_lsp_obj_macro_t ase_lsp_obj_macro_t;
|
|
|
|
typedef struct ase_lsp_obj_prim_t ase_lsp_obj_prim_t;
|
|
|
|
|
|
|
|
struct ase_lsp_objhdr_t
|
2005-09-21 15:53:55 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_uint32_t type: 24;
|
|
|
|
ase_uint32_t mark: 4;
|
|
|
|
ase_uint32_t lock: 4;
|
|
|
|
ase_size_t size;
|
|
|
|
ase_lsp_obj_t* link;
|
2005-09-21 15:53:55 +00:00
|
|
|
};
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_nil_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_true_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_int_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
ase_lsp_int_t value;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_real_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
ase_lsp_real_t value;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_symbol_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
2006-10-23 14:44:43 +00:00
|
|
|
#if defined(__BORLANDC__) || defined(_MSC_VER)
|
2005-02-04 15:39:11 +00:00
|
|
|
#else
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_char_t buffer[0];
|
2005-02-04 15:39:11 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_string_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
2006-10-23 14:44:43 +00:00
|
|
|
#if defined(__BORLANDC__) || defined(_MSC_VER)
|
2005-02-04 15:39:11 +00:00
|
|
|
#else
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_char_t buffer[0];
|
2005-02-04 15:39:11 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_cons_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
struct ase_lsp_obj_t* car;
|
|
|
|
struct ase_lsp_obj_t* cdr;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_func_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
struct ase_lsp_obj_t* formal;
|
|
|
|
struct ase_lsp_obj_t* body;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_macro_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
struct ase_lsp_obj_t* formal;
|
|
|
|
struct ase_lsp_obj_t* body;
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 04:22:40 +00:00
|
|
|
struct ase_lsp_obj_prim_t
|
2005-02-04 15:39:11 +00:00
|
|
|
{
|
2006-10-24 04:22:40 +00:00
|
|
|
ase_lsp_objhdr_t hdr;
|
|
|
|
void* impl; /* ase_lsp_prim_t */
|
2005-02-04 15:39:11 +00:00
|
|
|
};
|
|
|
|
|
2005-09-21 15:53:55 +00:00
|
|
|
/* header access */
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_TYPE(x) (((ase_lsp_obj_t*)x)->hdr.type)
|
|
|
|
#define ASE_LSP_SIZE(x) (((ase_lsp_obj_t*)x)->hdr.size)
|
|
|
|
#define ASE_LSP_MARK(x) (((ase_lsp_obj_t*)x)->hdr.mark)
|
|
|
|
#define ASE_LSP_LOCK(x) (((ase_lsp_obj_t*)x)->hdr.lock)
|
|
|
|
#define ASE_LSP_LINK(x) (((ase_lsp_obj_t*)x)->hdr.link)
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2005-09-21 15:53:55 +00:00
|
|
|
/* value access */
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_IVALUE(x) (((ase_lsp_obj_int_t*)x)->value)
|
|
|
|
#define ASE_LSP_RVALUE(x) (((ase_lsp_obj_real_t*)x)->value)
|
2005-02-04 15:39:11 +00:00
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_SYMVALUE(x) ((ase_char_t*)(((ase_lsp_obj_symbol_t*)x) + 1))
|
2005-02-04 15:39:11 +00:00
|
|
|
#else
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_SYMVALUE(x) (((ase_lsp_obj_symbol_t*)x)->buffer)
|
2005-02-04 15:39:11 +00:00
|
|
|
#endif
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_SYMLEN(x) ((((ase_lsp_obj_symbol_t*)x)->hdr.size - sizeof(ase_lsp_obj_t)) / sizeof(ase_char_t) - 1)
|
2005-02-04 15:39:11 +00:00
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_STRVALUE(x) ((ase_char_t*)(((ase_lsp_obj_string_t*)x) + 1))
|
2005-02-04 15:39:11 +00:00
|
|
|
#else
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_STRVALUE(x) (((ase_lsp_obj_string_t*)x)->buffer)
|
2005-02-04 15:39:11 +00:00
|
|
|
#endif
|
2006-10-24 04:22:40 +00:00
|
|
|
#define ASE_LSP_STRLEN(x) ((((ase_lsp_obj_string_t*)x)->hdr.size - sizeof(ase_lsp_obj_t)) / sizeof(ase_char_t) - 1)
|
|
|
|
|
|
|
|
#define ASE_LSP_CAR(x) (((ase_lsp_obj_cons_t*)x)->car)
|
|
|
|
#define ASE_LSP_CDR(x) (((ase_lsp_obj_cons_t*)x)->cdr)
|
|
|
|
#define ASE_LSP_FFORMAL(x) (((ase_lsp_obj_func_t*)x)->formal)
|
|
|
|
#define ASE_LSP_FBODY(x) (((ase_lsp_obj_func_t*)x)->body)
|
|
|
|
#define ASE_LSP_MFORMAL(x) (((ase_lsp_obj_macro_t*)x)->formal)
|
|
|
|
#define ASE_LSP_MBODY(x) (((ase_lsp_obj_macro_t*)x)->body)
|
|
|
|
#define ASE_LSP_PRIM(x) ((ase_lsp_prim_t)(((ase_lsp_obj_prim_t*)x)->impl))
|
2005-02-04 15:39:11 +00:00
|
|
|
|
|
|
|
#endif
|