-
Notifications
You must be signed in to change notification settings - Fork 43
/
specialid.h
32 lines (26 loc) · 1010 Bytes
/
specialid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef __SPECIALID
#define __SPECIALID
ANN struct SpecialId_ *specialid_get(const Gwion, const Symbol);
#ifndef __NO_EMIT
typedef Type (*idck)(const Env, const Exp_Primary *);
typedef bool (*idem)(const Emitter, const Exp_Primary *);
struct SpecialId_ {
Type type;
idck ck;
f_instr exec;
idem em;
bool is_const;
};
#define ID_CHECK(a) \
ANN Type a(const Env env NUSED, const Exp_Primary *prim NUSED)
#define ID_EMIT(a) \
ANN bool a(const Emitter emit NUSED, const Exp_Primary *prim NUSED)
ANN static inline Type specialid_type(const Env env, struct SpecialId_ *spid,
const Exp_Primary *prim) {
exp_self(prim)->type = spid->type;
if (spid->is_const) exp_setmeta(exp_self(prim), 1);
return spid->ck ? spid->ck(env, prim) : spid->type;
}
ANN struct SpecialId_ *specialid_get(const Gwion, const Symbol);
#endif
#endif