remove symbol.h
This commit is contained in:
parent
665eda1d92
commit
3198e77ac1
|
@ -264,7 +264,6 @@ int pic_str_hash(pic_state *, struct pic_string *);
|
|||
#include "picrin/macro.h"
|
||||
#include "picrin/pair.h"
|
||||
#include "picrin/port.h"
|
||||
#include "picrin/symbol.h"
|
||||
|
||||
void *pic_default_allocf(void *, void *, size_t);
|
||||
|
||||
|
|
|
@ -10,6 +10,32 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/* symbol & identifier */
|
||||
|
||||
struct pic_id {
|
||||
union {
|
||||
struct pic_symbol {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_string *str;
|
||||
} sym;
|
||||
struct {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_id *id;
|
||||
struct pic_env *env;
|
||||
} id;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define pic_sym_ptr(v) ((pic_sym *)pic_obj_ptr(v))
|
||||
|
||||
#define pic_id_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ID || pic_type(pic, v) == PIC_TYPE_SYMBOL)
|
||||
#define pic_id_ptr(v) ((pic_id *)pic_obj_ptr(v))
|
||||
|
||||
pic_id *pic_make_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
|
||||
struct pic_string *pic_id_name(pic_state *, pic_id *);
|
||||
|
||||
|
||||
/* blob */
|
||||
|
||||
struct pic_blob {
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* See Copyright Notice in picrin.h
|
||||
*/
|
||||
|
||||
#ifndef PICRIN_SYMBOL_H
|
||||
#define PICRIN_SYMBOL_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct pic_id {
|
||||
union {
|
||||
struct pic_symbol {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_string *str;
|
||||
} sym;
|
||||
struct {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_id *id;
|
||||
struct pic_env *env;
|
||||
} id;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define pic_sym_ptr(v) ((pic_sym *)pic_obj_ptr(v))
|
||||
|
||||
#define pic_id_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ID || pic_type(pic, v) == PIC_TYPE_SYMBOL)
|
||||
#define pic_id_ptr(v) ((pic_id *)pic_obj_ptr(v))
|
||||
|
||||
pic_id *pic_make_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
|
||||
const char *pic_identifier_name(pic_state *, pic_id *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
#include "picrin.h"
|
||||
#include "picrin/object.h"
|
||||
|
||||
KHASH_DEFINE(ltable, const char *, struct pic_lib, kh_str_hash_func, kh_str_cmp_func)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ pic_add_identifier(pic_state *pic, pic_id *id, struct pic_env *env)
|
|||
pic_sym *uid;
|
||||
struct pic_string *str;
|
||||
|
||||
name = pic_identifier_name(pic, id);
|
||||
name = pic_str(pic, pic_id_name(pic, id));
|
||||
|
||||
if (env->up == NULL && pic_sym_p(pic, pic_obj_value(id))) { /* toplevel & public */
|
||||
str = pic_strf_value(pic, "%s/%s", pic_str(pic, env->lib), name);
|
||||
|
@ -274,7 +274,7 @@ expand_defmacro(pic_state *pic, pic_value expr, struct pic_env *env)
|
|||
|
||||
val = pic_call(pic, pic_compile(pic, pic_expand(pic, pic_list_ref(pic, expr, 2), env)), 0);
|
||||
if (! pic_proc_p(pic, val)) {
|
||||
pic_errorf(pic, "macro definition \"~s\" evaluates to non-procedure object", pic_identifier_name(pic, id));
|
||||
pic_errorf(pic, "macro definition \"%s\" evaluates to non-procedure object", pic_str(pic, pic_id_name(pic, id)));
|
||||
}
|
||||
|
||||
define_macro(pic, uid, pic_proc_ptr(val));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
#include "picrin.h"
|
||||
#include "picrin/object.h"
|
||||
|
||||
#define kh_pic_str_hash(a) (pic_str_hash(pic, (a)))
|
||||
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, (a), (b)) == 0)
|
||||
|
@ -50,14 +51,14 @@ pic_sym_name(pic_state PIC_UNUSED(*pic), pic_sym *sym)
|
|||
return sym->str;
|
||||
}
|
||||
|
||||
const char *
|
||||
pic_identifier_name(pic_state *pic, pic_id *id)
|
||||
struct pic_string *
|
||||
pic_id_name(pic_state *pic, pic_id *id)
|
||||
{
|
||||
while (! pic_sym_p(pic, pic_obj_value(id))) {
|
||||
id = id->u.id.id;
|
||||
}
|
||||
|
||||
return pic_str(pic, pic_sym_name(pic, (pic_sym *)id));
|
||||
return pic_sym_name(pic, (pic_sym *)id);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
|
|
@ -288,7 +288,7 @@ write_core(struct writer_control *p, pic_value obj)
|
|||
xfprintf(pic, file, "#f");
|
||||
break;
|
||||
case PIC_TYPE_ID:
|
||||
xfprintf(pic, file, "#<identifier %s>", pic_identifier_name(pic, pic_id_ptr(obj)));
|
||||
xfprintf(pic, file, "#<identifier %s>", pic_str(pic, pic_id_name(pic, pic_id_ptr(obj))));
|
||||
break;
|
||||
case PIC_TYPE_EOF:
|
||||
xfprintf(pic, file, "#.(eof-object)");
|
||||
|
|
Loading…
Reference in New Issue