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

Go to the source code of this file.

Functions

MacroArg new_macroarg (MemPool p, const m_str name)
 
void clean_macroarg (const MacroArg a)
 
static void free_args (MemPool p, const MacroArg a)
 
void free_entry (MemPool p, void *data)
 
static Macro mkentry (MemPool p, const m_str name, const Macro next)
 
 hstraction (Macro, Macro, has,, return sym;,, return NULL) hstraction(Macro
 
 hstraction (Macro, bool, rem, Macro prev=NULL;, if(prev) prev->next=s->next;else h->table[idx]=NULL;s->next=NULL;free_entry(h->p, s);return false;, prev=s;, return true;) ANN void macro_del(const Hash h)
 

Variables

 Macro
 
 add
 
return NULL
 
return h table [idx] = mkentry(h->p, arg, sym)
 

Function Documentation

◆ clean_macroarg()

void clean_macroarg ( const MacroArg a)

Definition at line 11 of file macro.c.

11 {
12 if (a->next) clean_macroarg(a->next);
13 text_release(&a->text);
14}
void clean_macroarg(const MacroArg a)
Definition macro.c:11
MacroArg next
Definition macro.h:14
GwText text
Definition macro.h:13

◆ free_args()

static void free_args ( MemPool p,
const MacroArg a )
static

Definition at line 16 of file macro.c.

16 {
17 if (a->next) free_args(p, a->next);
18 text_release(&a->text);
19 free_mstr(p, a->name);
20 mp_free(p, MacroArg, a);
21}
static void free_args(MemPool p, const MacroArg a)
Definition macro.c:16
char * name
Definition macro.h:12

◆ free_entry()

void free_entry ( MemPool p,
void * data )

Definition at line 23 of file macro.c.

23 {
24 const Macro s = (Macro)data;
25 if (s->next) free_entry(p, s->next);
26 free_mstr(p, s->name);
27 free_text(s->text);
28 if (s->base) free_args(p, s->base);
29 mp_free(p, Macro, s);
30}
void free_entry(MemPool p, void *data)
Definition macro.c:23
Macro
Definition macro.c:41
Definition macro.h:22
MacroArg base
Definition macro.h:25
Macro next
Definition macro.h:27
GwText * text
Definition macro.h:24
char * name
Definition macro.h:23

◆ hstraction() [1/2]

hstraction ( Macro ,
bool ,
rem ,
Macro prev = NULL;,
if(prev) prev-> next = s->next; else h->table[idx] = NULL; s->next = NULLfree_entry(h->p, s); return false;,
prev = s;,
return true;  ) const

Definition at line 43 of file macro.c.

48 {
49 hdel(h, free_entry);
50}

◆ hstraction() [2/2]

hstraction ( Macro ,
Macro ,
has ,
return sym; ,
return NULL )

◆ mkentry()

static Macro mkentry ( MemPool p,
const m_str name,
const Macro next )
inlinestatic

Definition at line 32 of file macro.c.

32 {
33 const Macro s = mp_calloc(p, Macro);
34 s->name = mstrdup(p, name);
35 s->next = next;
36 s->text = new_text(p);
37 return s;
38}

◆ new_macroarg()

MacroArg new_macroarg ( MemPool p,
const m_str name )

Definition at line 4 of file macro.c.

4 {
5 const MacroArg a = mp_calloc(p, MacroArg);
6 a->name = mstrdup(p, name);
7 text_init(&a->text, p);
8 return a;
9}

Variable Documentation

◆ add

add

Definition at line 41 of file macro.c.

◆ Macro

Definition at line 41 of file macro.c.

◆ NULL

return NULL

Definition at line 41 of file macro.c.

◆ table

return h table[idx] = mkentry(h->p, arg, sym)

Definition at line 42 of file macro.c.