gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
scope.h
Go to the documentation of this file.
1
5#ifndef __SCOPE
6#define __SCOPE
7typedef struct Scope_ {
9 struct Map_ map;
11
17
19extern ANN void scope_init(MemPool, Scope);
21extern ANN vtype scope_lookup0(const Scope, const vtype);
22extern ANN vtype scope_lookup1(const Scope, const vtype);
23extern ANN vtype scope_lookup2(const Scope, const vtype);
24extern ANN void scope_add(const Scope, const vtype, const vtype);
25extern ANN void scope_commit(const Scope);
26extern ANN void scope_release(Scope);
27extern ANN void free_scope(MemPool, Scope);
28ANN static inline void scope_push(MemPool p NUSED, const Scope s) {
29 vector_add((Vector)(void *)s, 0);
30 map_init((Map)&VPTR(s, VLEN(s) - 1));
31}
32
33ANN static inline void scope_pop(MemPool p NUSED, const Scope s) {
34 const m_uint back = vector_pop((Vector)(void *)s);
35 map_release((Map)&back);
36}
37
38ANN static inline void _scope_init(const Scope s) {
39 vector_init((Vector)(void *)s);
40}
41ANN bool scope_iter(struct scope_iter *iter, void *ret);
42#endif
#define VLEN(v)
Definition container.h:10
uintptr_t vtype
Definition container.h:14
#define VPTR(v, i)
Definition container.h:12
#define NUSED
Definition defs.h:23
#define ANN
Definition defs.h:19
#define ANEW
Definition defs.h:22
uintptr_t m_uint
Definition gwcommon.h:11
ANN void map_init(const Map a)
Definition map.c:9
ANN void map_release(const Map map)
Definition map.c:61
ANN void scope_add(const Scope, const vtype, const vtype)
Definition scope.c:28
ANN void free_scope(MemPool, Scope)
Definition scope.c:58
static ANN void _scope_init(const Scope s)
Definition scope.h:38
static ANN void scope_pop(MemPool p NUSED, const Scope s)
Definition scope.h:33
ANN Scope new_scope(MemPool)
Definition scope.c:46
struct Scope_ * Scope
static ANN void scope_push(MemPool p NUSED, const Scope s)
Definition scope.h:28
ANN bool scope_iter(struct scope_iter *iter, void *ret)
Definition scope.c:63
ANN vtype scope_lookup1(const Scope, const vtype)
Definition scope.c:14
ANEW ANN Vector scope_get(const Scope)
ANN vtype scope_lookup2(const Scope, const vtype)
Definition scope.c:23
ANN vtype scope_lookup0(const Scope, const vtype)
Definition scope.c:7
ANN void scope_init(MemPool, Scope)
Definition scope.c:40
ANN void scope_commit(const Scope)
Definition scope.c:35
ANN void scope_release(Scope)
Definition scope.c:52
Definition map.h:7
Definition scope.h:7
vtype * ptr
Definition scope.h:8
struct Map_ map
Definition scope.h:9
m_uint vec
Definition scope.h:14
m_uint idx
Definition scope.h:15
const Scope s
Definition scope.h:13
ANN void vector_add(const Vector v, const vtype data)
Definition vector.c:21
ANN vtype vector_pop(const Vector v)
Definition vector.c:61
ANN void vector_init(const Vector v)
Definition vector.c:3