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

Go to the source code of this file.

Macros

#define mk_section(Type, name, sec_type)
 

Functions

 AST_NEW (Type_Decl *, type_decl, const Symbol xid, const loc_t loc)
 
 AST_NEW (Array_Sub, array_sub, Exp *exp)
 
 AST_NEW (Range *, range, Exp *start, Exp *end)
 
Array_Sub prepend_array_sub (const Array_Sub a, Exp *exp)
 
static ANN AST_NEW (Exp *, exp, const ae_exp_t type, const loc_t loc)
 
 AST_NEW (Exp *, exp_lambda, const Symbol xid, ArgList *args, StmtList *code, const loc_t loc)
 
 AST_NEW (Exp *, exp_lambda2, const Symbol xid, ArgList *args, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, exp_array, Exp *base, const Array_Sub array, const loc_t loc)
 
 AST_NEW (Exp *, exp_slice, Exp *base, Range *range, const loc_t loc)
 
 AST_NEW (Exp *, exp_decl, Type_Decl *td, const Var_Decl *vd, const loc_t loc)
 
 AST_NEW (Exp *, exp_binary, Exp *lhs, const Symbol op, Exp *rhs, const loc_t loc)
 
 AST_NEW (Exp *, exp_cast, Type_Decl *td, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, exp_post, Exp *exp, const Symbol op, const loc_t loc)
 
 AST_NEW (Exp *, exp_td, Type_Decl *td, const loc_t loc)
 
 AST_NEW (Exp *, exp_named, Exp *exp, const Tag tag, const loc_t loc)
 
static AST_NEW (Exp *, prim, const loc_t loc)
 
 AST_NEW (Exp *, prim_int, const m_uint i, const loc_t loc)
 
 AST_NEW (Exp *, prim_float, const m_float num, const loc_t loc)
 
 AST_NEW (Exp *, prim_string, const m_str s, const uint16_t delim, const loc_t loc)
 
 AST_NEW (Exp *, prim_nil, const loc_t loc)
 
 AST_NEW (Exp *, prim_id, struct Symbol_ *xid, const loc_t loc)
 
 AST_NEW (Exp *, prim_perform, struct Symbol_ *xid, const loc_t loc)
 
 AST_NEW (Exp *, prim_hack, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, prim_interp, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, prim_char, const m_str chr, const loc_t loc)
 
 AST_NEW (Exp *, prim_array, const Array_Sub exp, const loc_t loc)
 
 AST_NEW (Exp *, prim_range, Range *range, const loc_t loc)
 
 AST_NEW (Exp *, prim_dict, Exp *exp, const loc_t loc)
 
static AST_NEW (Exp *, exp_unary_base, const Symbol oper, const loc_t loc)
 
 AST_NEW (Exp *, exp_unary, const Symbol oper, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, exp_unary2, const Symbol oper, Type_Decl *td, Exp *exp, const loc_t loc)
 
 AST_NEW (Exp *, exp_unary3, const Symbol oper, StmtList *code, const loc_t loc)
 
 AST_NEW (Exp *, exp_if, Exp *cond, Exp *if_exp, Exp *else_exp, const loc_t loc)
 
 AST_NEW (Tmpl *, tmpl, SpecializedList *list)
 
Func_Def new_func_def (MemPool p, Func_Base *base, StmtList *code)
 
 AST_NEW (Func_Base *, func_base, Type_Decl *td, const Symbol xid, ArgList *args, const ae_flag flag, const loc_t loc)
 
 AST_NEW (Fptr_Def, fptr_def, Func_Base *base)
 
 AST_NEW (Type_Def, type_def, Type_Decl *ext, const Symbol xid, const loc_t loc)
 
 AST_NEW (Tmpl *, tmpl_call, TmplArgList *tl)
 
 AST_NEW (Exp *, exp_call, Exp *base, Exp *args, const loc_t loc)
 
 AST_NEW (Exp *, exp_dot, Exp *base, const Tag tag, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_exp, const ae_stmt_t type, Exp *exp, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_code, StmtList *list, const loc_t loc)
 
 AST_NEW (Stmt *, stmt, const ae_stmt_t type, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_flow, const ae_stmt_t type, Exp *cond, Stmt *body, const bool is_do, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_for, Stmt *c1, Stmt *c2, Exp *c3, Stmt *body, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_each, struct Symbol_ *sym, Exp *exp, Stmt *body, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_loop, Exp *cond, Stmt *body, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_try, Stmt *stmt, HandlerList *handler)
 
 AST_NEW (Stmt *, stmt_if, Exp *cond, Stmt *if_body, const loc_t loc)
 
 AST_NEW (Enum_Def, enum_def, EnumValueList *list, struct Symbol_ *xid, const loc_t loc)
 
 AST_NEW (Union_Def, union_def, VariableList *l, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_pp, const enum ae_pp_type type, const m_str data, const loc_t loc)
 
 AST_NEW (Stmt *, stmt_defer, Stmt *stmt, const loc_t loc)
 
 mk_section (StmtList *, stmt_list, stmt)
 
 mk_section (Func_Def, func_def, func)
 
 mk_section (Class_Def, class_def, class)
 
 mk_section (Trait_Def, trait_def, trait)
 
 mk_section (Extend_Def, extend_def, extend)
 
 mk_section (Enum_Def, enum_def, enum)
 
 mk_section (Union_Def, union_def, union)
 
 mk_section (Fptr_Def, fptr_def, fptr)
 
 mk_section (Type_Def, type_def, type)
 
 AST_NEW (Extend_Def, extend_def, Type_Decl *const td, TagList *const trait)
 
 AST_NEW (Class_Def, class_def, const ae_flag class_decl, const Tag tag, Type_Decl *ext, const Ast body)
 
 AST_NEW (Trait_Def, trait_def, const ae_flag class_decl, const Symbol xid, const Ast body, const loc_t loc)
 
 AST_NEW (Prim_Def, prim_def, const Symbol name, const m_uint size, const loc_t loc, const ae_flag flag)
 

Macro Definition Documentation

◆ mk_section

#define mk_section ( Type,
name,
sec_type )
Value:
AST_NEW(Section *, section_##name, Type name) { \
Section *a = mp_calloc(p, Section); \
a->section_type = ae_section_##sec_type; \
a->d.name = name; \
return a; \
}
#define AST_NEW(type, name,...)
Definition absyn.h:9
ae_section_t section_type
Definition absyn.h:850
union Section_::section_data d

Definition at line 430 of file ast_new.c.

430#define mk_section(Type, name, sec_type) \
431 AST_NEW(Section *, section_##name, Type name) { \
432 Section *a = mp_calloc(p, Section); \
433 a->section_type = ae_section_##sec_type; \
434 a->d.name = name; \
435 return a; \
436 }

Function Documentation

◆ AST_NEW() [1/56]

AST_NEW ( Array_Sub ,
array_sub ,
Exp * exp )

Definition at line 10 of file ast_new.c.

10 {
11 Array_Sub a = mp_calloc(p, Array_Sub);
12 a->exp = exp;
13 a->depth = 1;
14 return a;
15}
ANEW const Type_Decl Exp * exp
Definition absyn.h:680
array_subscript.
Definition absyn.h:352
uint16_t depth
Definition absyn.h:355
Exp * exp
Definition absyn.h:353

◆ AST_NEW() [2/56]

AST_NEW ( Class_Def ,
class_def ,
const ae_flag class_decl,
const Tag tag,
Type_Decl * ext,
const Ast body )

Definition at line 454 of file ast_new.c.

455 {
456 Class_Def a = mp_calloc(p, Class_Def);
457 a->flag = class_decl;
458 a->base.tag = tag;
459 a->base.ext = ext;
460 a->body = body;
461 return a;
462}
ae_flag flag
Definition absyn.h:884
Ast body
Definition absyn.h:881
struct Type_Def_ base
Definition absyn.h:880
Tag tag
Definition absyn.h:759
Type_Decl * ext
Definition absyn.h:757

◆ AST_NEW() [3/56]

AST_NEW ( Enum_Def ,
enum_def ,
EnumValueList * list,
struct Symbol_ * xid,
const loc_t loc )

Definition at line 401 of file ast_new.c.

402 {
403 Enum_Def a = mp_calloc(p, Enum_Def);
404 a->tag = MK_TAG(xid, loc);
405 a->list = list;
406 return a;
407}
#define MK_TAG(a, b)
Definition absyn.h:29
EnumValueList * list
Definition absyn.h:715
Tag tag
Definition absyn.h:714

◆ AST_NEW() [4/56]

static ANN AST_NEW ( Exp * ,
exp ,
const ae_exp_t type,
const loc_t loc )
static

Definition at line 33 of file ast_new.c.

33 {
34 Exp* a = mp_calloc2(p, sizeof(Exp));
35 a->exp_type = type;
36 a->loc = loc;
37 return a;
38}
Definition absyn.h:559
ae_exp_t exp_type
Definition absyn.h:582
loc_t loc
Definition absyn.h:581

◆ AST_NEW() [5/56]

AST_NEW ( Exp * ,
exp_array ,
Exp * base,
const Array_Sub array,
const loc_t loc )

Definition at line 61 of file ast_new.c.

62 {
63 Exp* a = new_exp(p, ae_exp_array, loc);
64 a->d.exp_array.base = base;
65 a->d.exp_array.array = array;
66 return a;
67}
@ ae_exp_array
Definition absyn.h:407
Exp * base
Definition absyn.h:363
Array_Sub array
Definition absyn.h:364
union Exp::exp_data d
Exp_Array exp_array
Definition absyn.h:570

◆ AST_NEW() [6/56]

AST_NEW ( Exp * ,
exp_binary ,
Exp * lhs,
const Symbol op,
Exp * rhs,
const loc_t loc )

Definition at line 83 of file ast_new.c.

84 {
85 Exp* a = new_exp(p, ae_exp_binary, loc);
86 exp_setmeta(a, 1);
87 a->d.exp_binary.lhs = lhs;
88 a->d.exp_binary.op = op;
89 a->d.exp_binary.rhs = rhs;
90 return a;
91}
@ ae_exp_binary
Definition absyn.h:401
static ANN void exp_setmeta(Exp *e, const bool val)
Definition absyn.h:628
Symbol op
Definition absyn.h:511
Exp * rhs
Definition absyn.h:510
Exp * lhs
Definition absyn.h:509
Exp_Binary exp_binary
Definition absyn.h:565

◆ AST_NEW() [7/56]

AST_NEW ( Exp * ,
exp_call ,
Exp * base,
Exp * args,
const loc_t loc )

Definition at line 304 of file ast_new.c.

305 {
306 Exp* a = new_exp(p, ae_exp_call, loc);
307 exp_setmeta(a, 1);
308 a->d.exp_call.func = base;
309 a->d.exp_call.args = args;
310 return a;
311}
@ ae_exp_call
Definition absyn.h:406
Exp * args
Definition absyn.h:499
Exp * func
Definition absyn.h:498
Exp_Call exp_call
Definition absyn.h:567

◆ AST_NEW() [8/56]

AST_NEW ( Exp * ,
exp_cast ,
Type_Decl * td,
Exp * exp,
const loc_t loc )

Definition at line 93 of file ast_new.c.

93 {
94 Exp* a = new_exp(p, ae_exp_cast, loc);
95 exp_setmeta(a, 1);
96 a->d.exp_cast.td = td;
97 a->d.exp_cast.exp = exp;
98 return a;
99}
@ ae_exp_cast
Definition absyn.h:404
Exp * exp
Definition absyn.h:506
Type_Decl * td
Definition absyn.h:505
Exp_Cast exp_cast
Definition absyn.h:566

◆ AST_NEW() [9/56]

AST_NEW ( Exp * ,
exp_decl ,
Type_Decl * td,
const Var_Decl * vd,
const loc_t loc )

Definition at line 76 of file ast_new.c.

77 {
78 Exp* a = new_exp(p, ae_exp_decl, loc);
79 a->d.exp_decl.var = MK_VAR(td, *vd);
80 return a;
81}
#define MK_VAR(a, b)
Definition absyn.h:248
@ ae_exp_decl
Definition absyn.h:400
Variable var
Definition absyn.h:439
Exp_Decl exp_decl
Definition absyn.h:563

◆ AST_NEW() [10/56]

AST_NEW ( Exp * ,
exp_dot ,
Exp * base,
const Tag tag,
const loc_t loc )

Definition at line 313 of file ast_new.c.

314 {
315 Exp* a = new_exp(p, ae_exp_dot, loc);
316 a->d.exp_dot.base = base;
317 a->d.exp_dot.var.tag = tag;
318 return a;
319}
@ ae_exp_dot
Definition absyn.h:410
Var_Decl var
Definition absyn.h:330
Exp * base
Definition absyn.h:331
Tag tag
Definition absyn.h:34
Exp_Dot exp_dot
Definition absyn.h:569

◆ AST_NEW() [11/56]

AST_NEW ( Exp * ,
exp_if ,
Exp * cond,
Exp * if_exp,
Exp * else_exp,
const loc_t loc )

Definition at line 250 of file ast_new.c.

251 {
252 Exp* a = new_exp(p, ae_exp_if, loc);
253 enum exp_state state =
254 (!(!exp_getmeta(if_exp ?: cond)) && !exp_getmeta(else_exp)) ? 0 : 1;
255 exp_setmeta(a, state);
256 a->d.exp_if.cond = cond;
257 a->d.exp_if.if_exp = if_exp;
258 a->d.exp_if.else_exp = else_exp;
259 return a;
260}
@ ae_exp_if
Definition absyn.h:409
exp_state
Definition absyn.h:546
static ANN int exp_getmeta(const Exp *e)
Definition absyn.h:624
Exp * cond
Definition absyn.h:518
Exp * if_exp
Definition absyn.h:519
Exp * else_exp
Definition absyn.h:520
Exp_If exp_if
Definition absyn.h:568

◆ AST_NEW() [12/56]

AST_NEW ( Exp * ,
exp_lambda ,
const Symbol xid,
ArgList * args,
StmtList * code,
const loc_t loc )

Definition at line 40 of file ast_new.c.

41 {
42 Exp* a = new_exp(p, ae_exp_lambda, loc);
43 Func_Base *base = new_func_base(p, NULL, xid, args, ae_flag_none, loc);
44 base->fbflag |= fbflag_lambda;
45 a->d.exp_lambda.def = new_func_def(p, base, code);
46 return a;
47}
@ ae_exp_lambda
Definition absyn.h:411
fbflag_lambda
Definition absyn.h:5
Func_Def new_func_def(MemPool p, Func_Base *base, StmtList *code)
Definition ast_new.c:268
@ ae_flag_none
Definition flags.h:21
return NULL
Definition macro.c:41
Func_Def def
Definition absyn.h:344
enum fbflag fbflag
Definition absyn.h:739
Exp_Lambda exp_lambda
Definition absyn.h:572

◆ AST_NEW() [13/56]

AST_NEW ( Exp * ,
exp_lambda2 ,
const Symbol xid,
ArgList * args,
Exp * exp,
const loc_t loc )

Definition at line 49 of file ast_new.c.

50 {
51 Exp* a = new_exp(p, ae_exp_lambda, loc);
52 Func_Base *base = new_func_base(p, NULL, xid, args, ae_flag_none, loc);
53 base->fbflag |= fbflag_lambda;
54 StmtList *code = new_stmtlist(p, 1);
55 Stmt stmt = MK_STMT_RETURN(loc, exp);
56 stmtlist_set(code, 0, stmt);
57 a->d.exp_lambda.def = new_func_def(p, base, code);
58 return a;
59}
#define MK_STMT_RETURN(_pos, _exp)
Definition absyn.h:216
Definition absyn.h:187

◆ AST_NEW() [14/56]

AST_NEW ( Exp * ,
exp_named ,
Exp * exp,
const Tag tag,
const loc_t loc )

Definition at line 115 of file ast_new.c.

115 {
116 Exp* a = new_exp(p, ae_exp_named, loc);
117 a->d.exp_named.exp = exp;
118 a->d.exp_named.tag = tag;
119 return a;
120}
@ ae_exp_named
Definition absyn.h:413
Tag tag
Definition absyn.h:540
Exp * exp
Definition absyn.h:539
Exp_Named exp_named
Definition absyn.h:574

◆ AST_NEW() [15/56]

AST_NEW ( Exp * ,
exp_post ,
Exp * exp,
const Symbol op,
const loc_t loc )

Definition at line 101 of file ast_new.c.

102 {
103 Exp* a = new_exp(p, ae_exp_post, loc);
104 a->d.exp_post.exp = exp;
105 a->d.exp_post.op = op;
106 return a;
107}
@ ae_exp_post
Definition absyn.h:405
Exp * exp
Definition absyn.h:515
Symbol op
Definition absyn.h:514
Exp_Postfix exp_post
Definition absyn.h:561

◆ AST_NEW() [16/56]

AST_NEW ( Exp * ,
exp_slice ,
Exp * base,
Range * range,
const loc_t loc )

Definition at line 69 of file ast_new.c.

69 {
70 Exp* a = new_exp(p, ae_exp_slice, loc);
71 a->d.exp_slice.base = base;
72 a->d.exp_slice.range = range;
73 return a;
74}
@ ae_exp_slice
Definition absyn.h:408
Range * range
Definition absyn.h:381
Exp * base
Definition absyn.h:380
Exp_Slice exp_slice
Definition absyn.h:571

◆ AST_NEW() [17/56]

AST_NEW ( Exp * ,
exp_td ,
Type_Decl * td,
const loc_t loc )

Definition at line 109 of file ast_new.c.

109 {
110 Exp* a = new_exp(p, ae_exp_td, loc);
111 a->d.exp_td = td;
112 return a;
113}
@ ae_exp_td
Definition absyn.h:412
Type_Decl * exp_td
Definition absyn.h:573

◆ AST_NEW() [18/56]

AST_NEW ( Exp * ,
exp_unary ,
const Symbol oper,
Exp * exp,
const loc_t loc )

Definition at line 222 of file ast_new.c.

223 {
224 Exp* a = new_exp_unary_base(p, oper, loc);
226 a->d.exp_unary.exp = exp;
228 return a;
229}
@ unary_exp
Definition absyn.h:522
enum unary_type unary_type
Definition absyn.h:535
Exp * exp
Definition absyn.h:530
Exp_Unary exp_unary
Definition absyn.h:564

◆ AST_NEW() [19/56]

AST_NEW ( Exp * ,
exp_unary2 ,
const Symbol oper,
Type_Decl * td,
Exp * exp,
const loc_t loc )

Definition at line 231 of file ast_new.c.

232 {
233 Exp* a = new_exp_unary_base(p, oper, loc);
234 exp_setmeta(a, 1);
235 a->d.exp_unary.ctor.td = td;
236 a->d.exp_unary.ctor.exp = exp;
238 return a;
239}
@ unary_td
Definition absyn.h:522
struct UnaryNew ctor
Definition absyn.h:532
Type_Decl * td
Definition absyn.h:524
Exp * exp
Definition absyn.h:525

◆ AST_NEW() [20/56]

AST_NEW ( Exp * ,
exp_unary3 ,
const Symbol oper,
StmtList * code,
const loc_t loc )

Definition at line 241 of file ast_new.c.

242 {
243 Exp* a = new_exp_unary_base(p, oper, loc);
244 exp_setmeta(a, 1);
245 a->d.exp_unary.code = code;
247 return a;
248}
@ unary_code
Definition absyn.h:522
StmtList * code
Definition absyn.h:531

◆ AST_NEW() [21/56]

static AST_NEW ( Exp * ,
exp_unary_base ,
const Symbol oper,
const loc_t loc )
inlinestatic

Definition at line 215 of file ast_new.c.

216 {
217 Exp* a = new_exp(p, ae_exp_unary, loc);
218 a->d.exp_unary.op = oper;
219 return a;
220}
@ ae_exp_unary
Definition absyn.h:402
Symbol op
Definition absyn.h:528

◆ AST_NEW() [22/56]

static AST_NEW ( Exp * ,
prim ,
const loc_t loc )
static

Definition at line 123 of file ast_new.c.

123 {
124 Exp* a = new_exp(p, ae_exp_primary, loc);
125 exp_setmeta(a, 1);
126 return a;
127}
@ ae_exp_primary
Definition absyn.h:403

◆ AST_NEW() [23/56]

AST_NEW ( Exp * ,
prim_array ,
const Array_Sub exp,
const loc_t loc )

Definition at line 194 of file ast_new.c.

194 {
195 Exp* a = new_prim(p, loc);
197 a->d.prim.d.array = exp;
198 return a;
199}
@ ae_prim_array
Definition absyn.h:427
union Exp_Primary::prim_data d
ae_prim_t prim_type
Definition absyn.h:475
Exp_Primary prim
Definition absyn.h:562

◆ AST_NEW() [24/56]

AST_NEW ( Exp * ,
prim_char ,
const m_str chr,
const loc_t loc )

Definition at line 187 of file ast_new.c.

187 {
188 Exp* a = new_prim(p, loc);
190 a->d.prim.d.chr = chr;
191 return a;
192}
@ ae_prim_char
Definition absyn.h:431

◆ AST_NEW() [25/56]

AST_NEW ( Exp * ,
prim_dict ,
Exp * exp,
const loc_t loc )

Definition at line 208 of file ast_new.c.

208 {
209 Exp* a = new_prim(p, loc);
211 a->d.prim.d.exp = exp;
212 return a;
213}
@ ae_prim_dict
Definition absyn.h:429

◆ AST_NEW() [26/56]

AST_NEW ( Exp * ,
prim_float ,
const m_float num,
const loc_t loc )

Definition at line 136 of file ast_new.c.

136 {
137 Exp* a = new_prim(p, loc);
139 a->d.prim.d.fnum = num;
140 return a;
141}
@ ae_prim_float
Definition absyn.h:425

◆ AST_NEW() [27/56]

AST_NEW ( Exp * ,
prim_hack ,
Exp * exp,
const loc_t loc )

Definition at line 173 of file ast_new.c.

173 {
174 Exp* a = new_prim(p, loc);
176 a->d.prim.d.exp = exp;
177 return a;
178}
@ ae_prim_hack
Definition absyn.h:430

◆ AST_NEW() [28/56]

AST_NEW ( Exp * ,
prim_id ,
struct Symbol_ * xid,
const loc_t loc )

Definition at line 157 of file ast_new.c.

157 {
158 Exp* a = new_prim(p, loc);
159 exp_setmeta(a, 0);
161 a->d.prim.d.var = xid;
162 return a;
163}
@ ae_prim_id
Definition absyn.h:423
struct Symbol_ * var
Definition absyn.h:466

◆ AST_NEW() [29/56]

AST_NEW ( Exp * ,
prim_int ,
const m_uint i,
const loc_t loc )

Definition at line 129 of file ast_new.c.

129 {
130 Exp* a = new_prim(p, loc);
132 a->d.prim.d.gwint.num = i;
133 return a;
134}
@ ae_prim_num
Definition absyn.h:424
m_int num
Definition absyn.h:452
struct gwint gwint
Definition absyn.h:467

◆ AST_NEW() [30/56]

AST_NEW ( Exp * ,
prim_interp ,
Exp * exp,
const loc_t loc )

Definition at line 180 of file ast_new.c.

180 {
181 Exp* a = new_prim(p, loc);
183 a->d.prim.d.exp = exp;
184 return a;
185}
@ ae_prim_interp
Definition absyn.h:433

◆ AST_NEW() [31/56]

AST_NEW ( Exp * ,
prim_nil ,
const loc_t loc )

Definition at line 151 of file ast_new.c.

151 {
152 Exp* a = new_prim(p, loc);
154 return a;
155}
@ ae_prim_nil
Definition absyn.h:432

◆ AST_NEW() [32/56]

AST_NEW ( Exp * ,
prim_perform ,
struct Symbol_ * xid,
const loc_t loc )

Definition at line 165 of file ast_new.c.

165 {
166 Exp* a = new_prim(p, loc);
167 exp_setmeta(a, 0);
169 a->d.prim.d.var = xid;
170 return a;
171}
@ ae_prim_perform
Definition absyn.h:434

◆ AST_NEW() [33/56]

AST_NEW ( Exp * ,
prim_range ,
Range * range,
const loc_t loc )

Definition at line 201 of file ast_new.c.

201 {
202 Exp* a = new_prim(p, loc);
204 a->d.prim.d.range = range;
205 return a;
206}
@ ae_prim_range
Definition absyn.h:428

◆ AST_NEW() [34/56]

AST_NEW ( Exp * ,
prim_string ,
const m_str s,
const uint16_t delim,
const loc_t loc )

Definition at line 143 of file ast_new.c.

143 {
144 Exp* a = new_prim(p, loc);
146 a->d.prim.d.string.data = s;
147 a->d.prim.d.string.delim = delim;
148 return a;
149}
@ ae_prim_str
Definition absyn.h:426
uint16_t delim
Definition absyn.h:419
m_str data
Definition absyn.h:418
struct AstString string
Definition absyn.h:470

◆ AST_NEW() [35/56]

AST_NEW ( Extend_Def ,
extend_def ,
Type_Decl *const td,
TagList *const trait )

Definition at line 447 of file ast_new.c.

447 {
448 Extend_Def a = mp_calloc(p, Class_Def);
449 a->td = td;
450 a->traits = trait;
451 return a;
452}
Type_Decl * td
Definition absyn.h:865
TagList * traits
Definition absyn.h:866

◆ AST_NEW() [36/56]

AST_NEW ( Fptr_Def ,
fptr_def ,
Func_Base * base )

Definition at line 285 of file ast_new.c.

285 {
286 Fptr_Def a = mp_calloc(p, Fptr_Def);
287 a->base = base;
288 return a;
289}
Func_Base * base
Definition absyn.h:749

◆ AST_NEW() [37/56]

AST_NEW ( Func_Base * ,
func_base ,
Type_Decl * td,
const Symbol xid,
ArgList * args,
const ae_flag flag,
const loc_t loc )

Definition at line 275 of file ast_new.c.

276 {
277 Func_Base *a = (Func_Base *)mp_calloc(p, Func_Base);
278 a->td = td;
279 a->tag = MK_TAG(xid, loc);
280 a->args = args;
281 a->flag = flag;
282 return a;
283}
Tag tag
Definition absyn.h:731
ArgList * args
Definition absyn.h:732
Type_Decl * td
Definition absyn.h:730
ae_flag flag
Definition absyn.h:738

◆ AST_NEW() [38/56]

AST_NEW ( Prim_Def ,
prim_def ,
const Symbol name,
const m_uint size,
const loc_t loc,
const ae_flag flag )

Definition at line 473 of file ast_new.c.

473 {
474 Prim_Def a = mp_calloc(p, Prim_Def);
475 a->tag = MK_TAG(name, loc);
476 a->size = size;
477 a->flag = flag;
478 return a;
479}
m_uint size
Definition absyn.h:806
Tag tag
Definition absyn.h:805
ae_flag flag
Definition absyn.h:807

◆ AST_NEW() [39/56]

AST_NEW ( Range * ,
range ,
Exp * start,
Exp * end )

Definition at line 17 of file ast_new.c.

17 {
18 Range *a = mp_calloc(p, Array_Sub);
19 a->start = start;
20 a->end = end;
21 return a;
22}
range.
Definition absyn.h:371
Exp * end
end of range expression
Definition absyn.h:373
Exp * start
start of range expression
Definition absyn.h:372

◆ AST_NEW() [40/56]

AST_NEW ( Stmt * ,
stmt ,
const ae_stmt_t type,
const loc_t loc )

Definition at line 343 of file ast_new.c.

343 {
344 Stmt* a = mp_calloc2(p, sizeof(Stmt));
345 a->stmt_type = type;
346 a->loc = loc;
347 return a;
348}
loc_t loc
position
Definition absyn.h:205
ae_stmt_t stmt_type
Definition absyn.h:206

◆ AST_NEW() [41/56]

AST_NEW ( Stmt * ,
stmt_code ,
StmtList * list,
const loc_t loc )

Definition at line 337 of file ast_new.c.

337 {
338 Stmt* a = new_stmt(p, ae_stmt_code, loc);
339 a->d.stmt_code.stmt_list = list;
340 return a;
341}
@ ae_stmt_code
Definition absyn.h:166
struct StmtList * stmt_list
Definition absyn.h:63
union Stmt::stmt_data d
struct Stmt_Code_ stmt_code
Definition absyn.h:190

◆ AST_NEW() [42/56]

AST_NEW ( Stmt * ,
stmt_defer ,
Stmt * stmt,
const loc_t loc )

Definition at line 424 of file ast_new.c.

424 {
425 Stmt* a = new_stmt(p, ae_stmt_defer, loc);
426 a->d.stmt_defer.stmt = stmt;
427 return a;
428}
@ ae_stmt_defer
Definition absyn.h:174
Stmt * stmt
Definition absyn.h:131
struct Stmt_Defer_ stmt_defer
Definition absyn.h:200

◆ AST_NEW() [43/56]

AST_NEW ( Stmt * ,
stmt_each ,
struct Symbol_ * sym,
Exp * exp,
Stmt * body,
const loc_t loc )

Definition at line 369 of file ast_new.c.

370 {
371 Stmt* a = new_stmt(p, ae_stmt_each, loc);
372 a->d.stmt_each.var = (Var_Decl) { .tag = MK_TAG(sym, loc) };
373 a->d.stmt_each.exp = exp;
374 a->d.stmt_each.body = body;
375 return a;
376}
@ ae_stmt_each
Definition absyn.h:163
struct Var_Decl_ Var_Decl
Var_Decl var
Definition absyn.h:74
Exp * exp
Definition absyn.h:75
Stmt * body
Definition absyn.h:76
struct Stmt_Each_ stmt_each
Definition absyn.h:194

◆ AST_NEW() [44/56]

AST_NEW ( Stmt * ,
stmt_exp ,
const ae_stmt_t type,
Exp * exp,
const loc_t loc )

Definition at line 330 of file ast_new.c.

331 {
332 Stmt* a = new_stmt(p, type, loc);
333 a->d.stmt_exp.val = exp;
334 return a;
335}
Exp * val
Definition absyn.h:40
struct Stmt_Exp_ stmt_exp
Definition absyn.h:189

◆ AST_NEW() [45/56]

AST_NEW ( Stmt * ,
stmt_flow ,
const ae_stmt_t type,
Exp * cond,
Stmt * body,
const bool is_do,
const loc_t loc )

Definition at line 350 of file ast_new.c.

351 {
352 Stmt* a = new_stmt(p, type, loc);
353 a->d.stmt_flow.is_do = !!is_do;
354 a->d.stmt_flow.cond = cond;
355 a->d.stmt_flow.body = body;
356 return a;
357}
bool is_do
Definition absyn.h:50
Stmt * body
Definition absyn.h:49
Exp * cond
Definition absyn.h:48
struct Stmt_Flow_ stmt_flow
Definition absyn.h:191

◆ AST_NEW() [46/56]

AST_NEW ( Stmt * ,
stmt_for ,
Stmt * c1,
Stmt * c2,
Exp * c3,
Stmt * body,
const loc_t loc )

Definition at line 359 of file ast_new.c.

360 {
361 Stmt* a = new_stmt(p, ae_stmt_for, loc);
362 a->d.stmt_for.c1 = c1;
363 a->d.stmt_for.c2 = c2;
364 a->d.stmt_for.c3 = c3;
365 a->d.stmt_for.body = body;
366 return a;
367}
@ ae_stmt_for
Definition absyn.h:162
Stmt * body
Definition absyn.h:70
Stmt * c2
Definition absyn.h:68
Stmt * c1
Definition absyn.h:67
Exp * c3
Definition absyn.h:69
struct Stmt_For_ stmt_for
Definition absyn.h:193

◆ AST_NEW() [47/56]

AST_NEW ( Stmt * ,
stmt_if ,
Exp * cond,
Stmt * if_body,
const loc_t loc )

Definition at line 393 of file ast_new.c.

394 {
395 Stmt* a = new_stmt(p, ae_stmt_if, loc);
396 a->d.stmt_if.cond = cond;
397 a->d.stmt_if.if_body = cpy_stmt3(p, if_body);
398 return a;
399}
@ ae_stmt_if
Definition absyn.h:165
ANN Stmt * cpy_stmt3(MemPool p, const Stmt *src)
Definition ast_cpy.c:440
Stmt * if_body
Definition absyn.h:89
Exp * cond
Definition absyn.h:88
struct Stmt_If_ stmt_if
Definition absyn.h:195

◆ AST_NEW() [48/56]

AST_NEW ( Stmt * ,
stmt_loop ,
Exp * cond,
Stmt * body,
const loc_t loc )

Definition at line 378 of file ast_new.c.

379 {
380 Stmt* a = new_stmt(p, ae_stmt_loop, loc);
381 a->d.stmt_loop.cond = cond;
382 a->d.stmt_loop.body = body;
383 return a;
384}
@ ae_stmt_loop
Definition absyn.h:164
Exp * cond
Definition absyn.h:82
Stmt * body
Definition absyn.h:83
struct Stmt_Loop_ stmt_loop
Definition absyn.h:192

◆ AST_NEW() [49/56]

AST_NEW ( Stmt * ,
stmt_pp ,
const enum ae_pp_type type,
const m_str data,
const loc_t loc )

Definition at line 416 of file ast_new.c.

417 {
418 Stmt* a = new_stmt(p, ae_stmt_pp, loc);
419 a->d.stmt_pp.pp_type = type;
420 a->d.stmt_pp.data = data;
421 return a;
422}
@ ae_stmt_pp
Definition absyn.h:173
m_str data
Definition absyn.h:124
enum ae_pp_type pp_type
Definition absyn.h:127
struct Stmt_PP_ stmt_pp
Definition absyn.h:199

◆ AST_NEW() [50/56]

AST_NEW ( Stmt * ,
stmt_try ,
Stmt * stmt,
HandlerList * handler )

Definition at line 386 of file ast_new.c.

386 {
387 Stmt* a = new_stmt(p, ae_stmt_try, stmt->loc);
388 a->d.stmt_try.stmt = cpy_stmt3(p, stmt);
389 a->d.stmt_try.handler = handler;
390 return a;
391}
@ ae_stmt_try
Definition absyn.h:170
HandlerList * handler
Definition absyn.h:106
Stmt * stmt
Definition absyn.h:105
struct Stmt_Try_ stmt_try
Definition absyn.h:196

◆ AST_NEW() [51/56]

AST_NEW ( Tmpl * ,
tmpl ,
SpecializedList * list )

Definition at line 262 of file ast_new.c.

262 {
263 Tmpl *a = mp_calloc(p, Tmpl);
264 a->list = list;
265 return a;
266}
Definition absyn.h:478
SpecializedList * list
Definition absyn.h:479

◆ AST_NEW() [52/56]

AST_NEW ( Tmpl * ,
tmpl_call ,
TmplArgList * tl )

Definition at line 298 of file ast_new.c.

298 {
299 Tmpl *a = mp_calloc(p, Tmpl);
300 a->call = tl;
301 return a;
302}
TmplArgList * call
Definition absyn.h:480

◆ AST_NEW() [53/56]

AST_NEW ( Trait_Def ,
trait_def ,
const ae_flag class_decl,
const Symbol xid,
const Ast body,
const loc_t loc )

Definition at line 464 of file ast_new.c.

465 {
466 Trait_Def a = mp_calloc(p, Trait_Def);
467 a->tag = MK_TAG(xid, loc);
468 a->flag = class_decl;
469 a->body = body;
470 return a;
471}
Ast body
Definition absyn.h:796
ae_flag flag
Definition absyn.h:798
Tag tag
Definition absyn.h:795

◆ AST_NEW() [54/56]

AST_NEW ( Type_Decl * ,
type_decl ,
const Symbol xid,
const loc_t loc )

Definition at line 4 of file ast_new.c.

4 {
5 Type_Decl *a = mp_calloc(p, Type_Decl);
6 a->tag = MK_TAG(xid, loc);
7 return a;
8}
Tag tag
Definition absyn.h:279

◆ AST_NEW() [55/56]

AST_NEW ( Type_Def ,
type_def ,
Type_Decl * ext,
const Symbol xid,
const loc_t loc )

Definition at line 291 of file ast_new.c.

291 {
292 Type_Def a = mp_calloc(p, Type_Def);
293 a->ext = ext;
294 a->tag = MK_TAG(xid, loc);
295 return a;
296}

◆ AST_NEW() [56/56]

AST_NEW ( Union_Def ,
union_def ,
VariableList * l,
const loc_t loc )

Definition at line 409 of file ast_new.c.

409 {
410 Union_Def a = mp_calloc(p, Union_Def);
411 a->l = l;
412 a->tag.loc = loc; // change ctor
413 return a;
414}
loc_t loc
Definition absyn.h:27
Tag tag
Definition absyn.h:770
VariableList * l
Definition absyn.h:769

◆ mk_section() [1/9]

mk_section ( Class_Def ,
class_def ,
class  )

◆ mk_section() [2/9]

mk_section ( Enum_Def ,
enum_def ,
enum  )

◆ mk_section() [3/9]

mk_section ( Extend_Def ,
extend_def ,
extend  )

◆ mk_section() [4/9]

mk_section ( Fptr_Def ,
fptr_def ,
fptr  )

◆ mk_section() [5/9]

mk_section ( Func_Def ,
func_def ,
func  )

◆ mk_section() [6/9]

mk_section ( StmtList * ,
stmt_list ,
stmt  )

◆ mk_section() [7/9]

mk_section ( Trait_Def ,
trait_def ,
trait  )

◆ mk_section() [8/9]

mk_section ( Type_Def ,
type_def ,
type  )

◆ mk_section() [9/9]

mk_section ( Union_Def ,
union_def ,
union  )

◆ new_func_def()

Func_Def new_func_def ( MemPool p,
Func_Base * base,
StmtList * code )

Definition at line 268 of file ast_new.c.

268 {
269 Func_Def a = mp_calloc(p, Func_Def);
270 a->base = base;
271 a->d.code = code;
272 return a;
273}
union Func_Def_::func_def_data d
Func_Base * base
Definition absyn.h:779

◆ prepend_array_sub()

Array_Sub prepend_array_sub ( const Array_Sub a,
Exp * exp )

Definition at line 24 of file ast_new.c.

24 {
25 if (exp) {
26 exp->next = a->exp;
27 a->exp = exp;
28 }
29 ++a->depth;
30 return a;
31}
Type_Decl * next
Definition absyn.h:282