My Project
Loading...
Searching...
No Matches
pp.c File Reference
#include "gwion_util.h"
#include "gwion_ast.h"
#include "bison_compat.h"

Go to the source code of this file.

Functions

ANN PPStatenew_ppstate (MemPool p, const char *filename)
 
ANEW PPnew_pp (MemPool p, const uint size, const char *name)
 
static void pp_post (PP *pp, void *data)
 
ANN void free_pp (MemPool p, PP *pp, void *data)
 

Function Documentation

◆ free_pp()

ANN void free_pp ( MemPool p,
PP * pp,
void * data )

Definition at line 38 of file pp.c.

38 {
39 pp_post(pp, data);
40 vector_release(&pp->state);
41 vector_release(&pp->global_undef);
42 hend(pp->macros);
43 mp_free(p, Hash, pp->macros);
44 vector_release(&pp->data);
45 mp_free(p, PP, pp);
46}
static void pp_post(PP *pp, void *data)
Definition pp.c:26
Definition pp.h:26
struct Hash_ * macros
Definition pp.h:28
struct Vector_ global_undef
Definition pp.h:29
struct Vector_ state
Definition pp.h:27
struct Vector_ data
Definition pp.h:31

◆ new_pp()

ANEW PP * new_pp ( MemPool p,
const uint size,
const char * name )

Definition at line 11 of file pp.c.

11 {
12 PP *pp = (PP *)mp_calloc(p, PP);
13 vector_init(&pp->data);
14 pp->macros = (Hash)mp_calloc(p, Hash);
15 hini(pp->macros, size);
16 pp->macros->p = p; // in ctor ?
17 vector_init(&pp->state);
18 vector_init(&pp->global_undef);
19 PPState *pps = new_ppstate(p, name);
20 pos_ini(&pps->loc.first);
21 pos_ini(&pps->loc.last);
22 vector_add(&pp->state, (vtype)pps);
23 return pp;
24}
ANN void pos_ini(pos_t *pos)
Definition gwlog.c:11
ANN PPState * new_ppstate(MemPool p, const char *filename)
Definition pp.c:5
Definition pp.h:14
loc_t loc
Definition pp.h:22
struct pos_t last
Definition gwlog.h:17
struct pos_t first
Definition gwlog.h:16

◆ new_ppstate()

ANN PPState * new_ppstate ( MemPool p,
const char * filename )

Definition at line 5 of file pp.c.

5 {
6 PPState *ppstate = mp_calloc(p, PPState);
7 ppstate->filename = filename;
8 return ppstate;
9};
char * filename
Definition pp.h:21

◆ pp_post()

static void pp_post ( PP * pp,
void * data )
static

Definition at line 26 of file pp.c.

26 {
27 for (m_uint i = 1; i < vector_size(&pp->state); ++i) {
28 void *ppstate = (void *)vector_at(&pp->state, i);
29 clear_buffer(ppstate, data);
30 }
31 mp_free(pp->macros->p, PPState, (PPState*)vector_front(&pp->state));
32 pp->entry = NULL;
33 vector_clear(&pp->state);
34 vector_clear(&pp->global_undef);
35 macro_del(pp->macros);
36}
ANN void clear_buffer(void *state, void *scan)
return NULL
Definition macro.c:41
void macro_del(const Hash)
struct Macro_ * entry
Definition pp.h:30