remove macro.h
This commit is contained in:
parent
935199ea5e
commit
d965a3da5a
|
@ -274,7 +274,6 @@ int pic_str_hash(pic_state *, struct pic_string *);
|
|||
#include "picrin/state.h"
|
||||
|
||||
#include "picrin/cont.h"
|
||||
#include "picrin/macro.h"
|
||||
|
||||
void *pic_default_allocf(void *, void *, size_t);
|
||||
|
||||
|
@ -294,14 +293,20 @@ void pic_close_port(pic_state *, struct pic_port *port);
|
|||
pic_leave(pic, ai); \
|
||||
} while (0)
|
||||
|
||||
pic_sym *pic_add_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
pic_sym *pic_put_identifier(pic_state *, pic_id *, pic_sym *, struct pic_env *);
|
||||
pic_sym *pic_find_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
|
||||
pic_value pic_read(pic_state *, struct pic_port *);
|
||||
pic_value pic_read_cstr(pic_state *, const char *);
|
||||
|
||||
void pic_load(pic_state *, struct pic_port *);
|
||||
void pic_load_cstr(pic_state *, const char *);
|
||||
pic_value pic_expand(pic_state *, pic_value, struct pic_env *);
|
||||
|
||||
pic_value pic_eval(pic_state *, pic_value, const char *);
|
||||
|
||||
void pic_load(pic_state *, struct pic_port *);
|
||||
void pic_load_cstr(pic_state *, const char *);
|
||||
|
||||
struct pic_proc *pic_make_var(pic_state *, pic_value, struct pic_proc *);
|
||||
|
||||
bool pic_data_type_p(pic_state *, pic_value, const pic_data_type *);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* See Copyright Notice in picrin.h
|
||||
*/
|
||||
|
||||
#ifndef PICRIN_MACRO_H
|
||||
#define PICRIN_MACRO_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
KHASH_DECLARE(env, pic_id *, pic_sym *)
|
||||
|
||||
struct pic_env {
|
||||
PIC_OBJECT_HEADER
|
||||
khash_t(env) map;
|
||||
struct pic_env *up;
|
||||
struct pic_string *lib;
|
||||
};
|
||||
|
||||
#define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ENV)
|
||||
#define pic_env_ptr(v) ((struct pic_env *)pic_obj_ptr(v))
|
||||
|
||||
struct pic_env *pic_make_topenv(pic_state *, struct pic_string *);
|
||||
struct pic_env *pic_make_env(pic_state *, struct pic_env *);
|
||||
|
||||
pic_sym *pic_add_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
pic_sym *pic_put_identifier(pic_state *, pic_id *, pic_sym *, struct pic_env *);
|
||||
pic_sym *pic_find_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
|
||||
pic_value pic_expand(pic_state *, pic_value, struct pic_env *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -203,6 +203,23 @@ struct pic_port {
|
|||
#define pic_port_ptr(v) ((struct pic_port *)pic_obj_ptr(v))
|
||||
|
||||
|
||||
/* environment */
|
||||
|
||||
KHASH_DECLARE(env, pic_id *, pic_sym *)
|
||||
|
||||
struct pic_env {
|
||||
PIC_OBJECT_HEADER
|
||||
khash_t(env) map;
|
||||
struct pic_env *up;
|
||||
struct pic_string *lib;
|
||||
};
|
||||
|
||||
#define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ENV)
|
||||
#define pic_env_ptr(v) ((struct pic_env *)pic_obj_ptr(v))
|
||||
|
||||
struct pic_env *pic_make_env(pic_state *, struct pic_env *);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,10 @@ make_library_env(pic_state *pic, struct pic_string *name)
|
|||
{
|
||||
struct pic_env *env;
|
||||
|
||||
env = pic_make_topenv(pic, name);
|
||||
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TYPE_ENV);
|
||||
env->up = NULL;
|
||||
env->lib = name;
|
||||
kh_init(env, &env->map);
|
||||
|
||||
/* set up default environment */
|
||||
pic_put_identifier(pic, (pic_id *)pic->sDEFINE_LIBRARY, pic->sDEFINE_LIBRARY, env);
|
||||
|
|
|
@ -21,18 +21,6 @@ pic_make_env(pic_state *pic, struct pic_env *up)
|
|||
return env;
|
||||
}
|
||||
|
||||
struct pic_env *
|
||||
pic_make_topenv(pic_state *pic, struct pic_string *lib)
|
||||
{
|
||||
struct pic_env *env;
|
||||
|
||||
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TYPE_ENV);
|
||||
env->up = NULL;
|
||||
env->lib = lib;
|
||||
kh_init(env, &env->map);
|
||||
return env;
|
||||
}
|
||||
|
||||
pic_sym *
|
||||
pic_add_identifier(pic_state *pic, pic_id *id, struct pic_env *env)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue