My Project
Loading...
Searching...
No Matches
absyn.h
Go to the documentation of this file.
5#ifndef __ABSYN
6#define __ABSYN
8#include <inttypes.h>
9#define AST_NEW(type, name, ...) type new_##name(MemPool p, __VA_ARGS__)
10
11#define AST_FREE(type, name) void free_##name(MemPool p NUSED, type a NUSED)
12
13typedef struct Class_Def_ * Class_Def;
14typedef struct Extend_Def_ * Extend_Def;
15typedef struct Func_Def_ * Func_Def;
16typedef struct Exp Exp;
17typedef struct Stmt Stmt;
18typedef struct Array_Sub_ * Array_Sub;
19typedef struct Fptr_Def_ * Fptr_Def;
20typedef struct Type_Decl_ Type_Decl;
21
22
23typedef struct SectionList* Ast;
24
25typedef struct Tag {
29#define MK_TAG(a, b) (Tag){ .sym = (a), .loc = (b) }
30
32
33typedef struct Var_Decl_ {
35 struct Value_ * value;
37
38
39typedef struct Stmt_Exp_ {
42
43typedef struct Stmt_Index_ {
44 m_int idx;
46
47typedef struct Stmt_Flow_ {
50 bool is_do;
52
53typedef struct Match {
55 struct StmtList *list;
56 union {
59 };
61
62typedef struct Stmt_Code_ {
63 struct StmtList *stmt_list;
65
72
80
86
92
93typedef struct Handler_ {
97MK_VECTOR_TYPE(Handler, handler)
98
99typedef struct ParserHandler {
100 HandlerList *handlers;
103
104typedef struct Stmt_Try_ {
106 HandlerList *handler;
108
121
122
129
132};
133
134typedef struct Stmt_Using_ {
135 union {
138 } d;
141typedef struct Stmt_Using_ UsingStmt;
143MK_VECTOR_TYPE(UsingStmt, usingstmt)
144MK_VECTOR_TYPE(Using, using)
145
146typedef struct Stmt_Import_ {
148 UsingStmtList *selection;
150
151typedef struct Spread_Def_ {
153 TagList *list;
154 m_str data;
156
157
179
180typedef struct Stmt_For_ * Stmt_For;
181typedef struct Stmt_Each_ * Stmt_Each;
182typedef struct Stmt_Loop_ * Stmt_Loop;
183typedef struct Stmt_If_ * Stmt_If;
184typedef struct Stmt_PP_ * Stmt_PP;
185typedef struct Stmt_Defer_ * Stmt_Defer;
186
209
210MK_VECTOR_TYPE(Stmt, stmt)
211
212#define MK_STMT(_type, _loc, ...) (Stmt){ .stmt_type = _type, \
213 .d = { __VA_ARGS__ }, .loc = _loc }
214#define MK_STMT_PP(_type, _pos, ...) MK_STMT(ae_stmt_pp, _pos, .stmt_pp = { .pp_type = ae_pp_##_type, __VA_ARGS__ })
215#define MK_STMT_EXP(_pos, _exp) MK_STMT(ae_stmt_exp, _pos, .stmt_exp = { .val = _exp })
216#define MK_STMT_RETURN(_pos, _exp) MK_STMT(ae_stmt_return, _pos, .stmt_exp = { .val = _exp })
217
218static inline Stmt* stmt_self(const void *data) {
219 return container_of((char *)data, Stmt, d);
220}
221
222ANEW AST_NEW(Stmt*, stmt, const ae_stmt_t, const loc_t);
223ANN ANEW AST_NEW(Stmt*, stmt_exp, const ae_stmt_t, Exp*,
224 const loc_t);
225ANN ANEW AST_NEW(Stmt*, stmt_code, StmtList*, const loc_t);
226ANN ANEW AST_NEW(Stmt*, stmt_if, Exp*, Stmt*, const loc_t);
227ANEW ANN AST_NEW(Stmt*, stmt_flow, const ae_stmt_t, Exp*, Stmt*,
228 const bool, const loc_t);
229ANN2(1, 2, 3, 5)
230ANEW AST_NEW(Stmt*, stmt_for, Stmt*, Stmt*, Exp*, Stmt*,
231 const loc_t);
232ANEW ANN AST_NEW(Stmt*, stmt_each, struct Symbol_ *, Exp*, Stmt*,
233 const loc_t);
234ANEW ANN AST_NEW(Stmt*, stmt_loop, Exp*, Stmt*, const loc_t);
235ANEW ANN2(1, 3) AST_NEW(Stmt*, stmt_pp, const enum ae_pp_type type, const m_str,
236 const loc_t);
237ANEW ANN AST_NEW(Stmt*, stmt_defer, Stmt*, const loc_t);
238ANEW ANN AST_NEW(Stmt*, stmt_try, Stmt*, HandlerList*);
239
240ANN void free_stmt(MemPool p, Stmt*);
241
242
248#define MK_VAR(a, b) (Variable){ .td = (a), .vd = (b) }
249MK_VECTOR_TYPE(Variable, variable)
250
251ANN void free_variablelist(MemPool p, VariableList*);
252
257
258typedef struct TmplArg {
259 union {
262 } d;
265MK_VECTOR_TYPE(TmplArg, tmplarg)
266#define MK_TMPLARG_TD(a) \
267 (TmplArg) { \
268 .type = tmplarg_td, \
269 .d = { .td = (a) }, \
270 }
271#define MK_TMPLARG_EXP(a) \
272 (TmplArg) { \
273 .type = tmplarg_exp, \
274 .d = { .exp = (a) }, \
275 }
276
277
288typedef Type_Decl* TD;
290ANEW ANN AST_NEW(Type_Decl *, type_decl, const Symbol, const loc_t);
291ANN void free_type_decl(MemPool p, Type_Decl *);
292
293ANN static inline uint32_t tmplarg_has_const(const TmplArgList *tl) {
294 for(uint32_t i = 0; i < tl->len; i++) {
295 const TmplArg ta = tmplarglist_at(tl, i);
296 if(ta.type == tmplarg_exp) return true;
297 }
298 return false;
299}
300
301ANN static inline uint32_t tmplarg_ntypes(const TmplArgList *tl) {
302 uint32_t ret = 0;
303 for(uint32_t i = 0; i < tl->len; i++) {
304 const TmplArg ta = tmplarglist_at(tl, i);
305 if(ta.type == tmplarg_td) ret++;
306 }
307 return ret;
308}
309
310typedef struct Arg_ {
313 struct Type_ *type; // can be removed by using var_decl.value->type
317
318enum fbflag {
319 fbflag_none = 1 << 0,
320 fbflag_op = 1 << 1,
321 fbflag_unary = 1 << 3,
322 fbflag_postfix = 1 << 4,
323 fbflag_internal = 1 << 5,
324 fbflag_lambda = 1 << 6,
325 fbflag_default = 1 << 7,
326 fbflag_locale = 1 << 8,
327} __attribute__((packed));
328
334
335typedef struct Capture {
337 struct Value_ *temp;
338 uint32_t offset;
339 bool is_ref;
341MK_VECTOR_TYPE(Capture, capture)
342
343
344typedef struct {
346 struct Type_ *owner;
347} Exp_Lambda;
348ANN2(1,2,4) AST_NEW(Exp*, exp_lambda, const Symbol, ArgList*, StmtList*,
349 const loc_t);
350AST_NEW(Exp*, exp_lambda2, const Symbol xid, ArgList *args, Exp* exp,
351 const loc_t);
355 struct Type_ *type;
356 uint16_t depth;
357};
358ANEW AST_NEW(Array_Sub, array_sub, Exp*);
360ANN void free_array_sub(MemPool p, Array_Sub);
361
363typedef struct {
366} Exp_Array;
367ANEW ANN AST_NEW(Exp*, exp_array, Exp*, const Array_Sub,
368 const loc_t);
369
372typedef struct Range_ {
377AST_NEW(Range *, range, Exp*, Exp*);
378
380typedef struct {
383} Exp_Slice;
384ANEW ANN AST_NEW(Exp*, exp_slice, Exp*, Range *, const loc_t);
385
386
392MK_VECTOR_TYPE(Specialized, specialized)
393
394ANN void free_specialized_list(MemPool p, SpecializedList*);
395
396ANN void free_tmplarg_list(MemPool p, TmplArgList *);
397
398ANN void free_arg_list(MemPool p, ArgList*);
399
417
418struct AstString {
419 m_str data;
420 uint16_t delim;
421};
422
438
439typedef struct {
441 struct Type_ *type;
443} Exp_Decl;
444
451
452struct gwint {
453 m_int num;
455};
456#define GWINT(a, b) ((struct gwint){ .num = a, .int_type = b})
457
459struct yyint {
460 long long num;
462};
463
464typedef struct {
465 struct Value_ *value;
466 union prim_data {
467 struct Symbol_ *var;
468 struct gwint gwint;
469 m_float fnum;
470 m_str chr;
475 } d;
478
479typedef struct Tmpl_ {
480 SpecializedList *list;
481 TmplArgList *call;
483
484ANN ANEW AST_NEW(Tmpl *, tmpl, SpecializedList*);
485ANN ANEW AST_NEW(Tmpl *, tmpl_call, TmplArgList*);
486ANN void free_tmpl(MemPool p, Tmpl *);
487ANN static inline bool is_spread_tmpl(const Tmpl *tmpl) {
488 const Specialized spec = specializedlist_at(tmpl->list, tmpl->list->len - 1);
489 return !strcmp(s_name(spec.tag.sym), "...");
490}
491
492
493static inline bool tmpl_base(const Tmpl *a) {
494 if (a && !a->call) return true;
495 return false;
496}
497
505typedef struct {
508} Exp_Cast;
509typedef struct {
513} Exp_Binary;
514typedef struct {
518typedef struct {
522} Exp_If;
528typedef struct {
530 union {
532 StmtList *code;
534 };
535 CaptureList *captures;
537} Exp_Unary;
538
539typedef struct {
542 bool is_arg;
543} Exp_Named;
544
545AST_NEW(Exp*, exp_named, Exp *exp, const Tag tag, const loc_t loc);
546
548 exp_state_meta, // ae_meta_value
549 exp_state_prot, // ae_meta_protect
552};
553
559
590typedef Exp* E;
592ANN static inline int exp_getuse(const Exp* e) {
593 return (e->emit_var & (1 << exp_state_use)) == (1 << exp_state_use);
594}
595
596ANN static inline void exp_setuse(Exp* e, const bool val) {
597 if (val)
598 e->emit_var |= 1 << exp_state_use;
599 else
600 e->emit_var &= ~(1 << exp_state_use);
601}
602
603ANN static inline int exp_getvar(const Exp* e) {
604 return (e->emit_var & (1 << exp_state_addr)) == (1 << exp_state_addr);
605}
606
607ANN static inline void exp_setvar(Exp* e, const bool val) {
608 if (val)
609 e->emit_var |= 1 << exp_state_addr;
610 else
611 e->emit_var &= ~(1 << exp_state_addr);
612}
613
614ANN static inline int exp_getprot(const Exp* e) {
615 return (e->emit_var & (1 << exp_state_prot)) == (1 << exp_state_prot);
616}
617
618ANN static inline void exp_setprot(Exp* e, const bool val) {
619 if (val)
620 e->emit_var |= 1 << exp_state_prot;
621 else
622 e->emit_var &= ~(1 << exp_state_prot);
623}
624
625ANN static inline int exp_getmeta(const Exp* e) {
626 return (e->emit_var & (1 << exp_state_meta)) == (1 << exp_state_meta);
627}
628
629ANN static inline void exp_setmeta(Exp* e, const bool val) {
630 if (val)
631 e->emit_var |= 1 << exp_state_meta;
632 else
633 e->emit_var &= ~(1 << exp_state_meta);
634}
635
636ANN static inline m_str exp_access(const Exp* e) {
637 if (exp_getmeta(e)) return (m_str) "non-mutable";
638 return !exp_getprot(e) ? NULL : (m_str) "protected";
639}
640
641static inline Exp* exp_self(const void *data) {
642 return container_of((char *)data, Exp, d);
643}
644static inline Exp_Primary *prim_self(const void *data) {
645 return container_of((char *)data, Exp_Primary, d);
646}
647static inline Exp* prim_exp(const void *data) {
648 const Exp_Primary *p = prim_self(data);
649 return exp_self(p);
650}
651static inline loc_t prim_pos(const void *data) {
652 const Exp* e = prim_exp(data);
653 return e->loc;
654}
655
656ANEW ANN AST_NEW(Exp*, prim_id, struct Symbol_ *, const loc_t);
657ANEW ANN2(1) AST_NEW(Exp*, prim_perform, struct Symbol_ *, const loc_t);
658ANEW AST_NEW(Exp*, prim_int, const m_uint, const loc_t);
659ANEW AST_NEW(Exp*, prim_float, const m_float, const loc_t);
660ANEW ANN AST_NEW(Exp*, prim_string, const m_str, const uint16_t delim, const loc_t);
661ANEW ANN AST_NEW(Exp*, prim_array, const Array_Sub, const loc_t);
662ANEW ANN AST_NEW(Exp*, prim_range, Range *, const loc_t);
663ANEW AST_NEW(Exp*, prim_dict, Exp*, const loc_t);
664ANEW AST_NEW(Exp*, prim_hack, Exp*, const loc_t);
665ANEW ANN AST_NEW(Exp*, prim_char, const m_str, const loc_t);
666ANEW AST_NEW(Exp*, prim_nil, const loc_t);
667ANEW ANN AST_NEW(Exp*, prim_interp, Exp* exp, const loc_t);
668ANEW ANN AST_NEW(Exp*, exp_decl, Type_Decl *, const Var_Decl*,
669 const loc_t);
670ANEW ANN AST_NEW(Exp*, exp_binary, Exp*, const Symbol, Exp*,
671 const loc_t);
672ANEW ANN AST_NEW(Exp*, exp_post, Exp*, const Symbol, const loc_t);
673ANN2(1, 2)
674ANEW AST_NEW(Exp*, exp_call, Exp*, Exp* args, const loc_t);
675ANEW ANN AST_NEW(Exp*, exp_cast, Type_Decl *, Exp*, const loc_t);
676ANN2(1, 2, 4)
677ANEW AST_NEW(Exp*, exp_if, Exp*, Exp*, Exp*, const loc_t);
678ANEW ANN AST_NEW(Exp*, exp_dot, Exp*, const Tag tag,
679 const loc_t);
680ANEW ANN AST_NEW(Exp*, exp_unary, const Symbol, Exp*, const loc_t);
681ANEW ANN2(1,2,3) AST_NEW(Exp*, exp_unary2, const Symbol, Type_Decl *,
682 Exp* exp, const loc_t);
683ANEW ANN AST_NEW(Exp*, exp_unary3, const Symbol, StmtList*,
684 const loc_t);
685ANN void free_stmt_list(MemPool, StmtList*);
686ANEW ANN AST_NEW(Exp*, exp_td, Type_Decl *, const loc_t);
687
688static inline uint32_t exp_count(Exp* exp) {
689 uint32_t n = 0;
690 while(exp) {
691 n++;
692 exp = exp->next;
693 }
694 return n;
695}
696
697// TODO: rename to exp_take
698static inline Exp* take_exp(Exp* exp, const uint32_t n) {
699 Exp* e = exp;
700 for (uint32_t i = 1; i < n; i++) CHECK_O((e = e->next));
701 return e;
702}
703
704ANN void free_exp(MemPool p, Exp*);
705
706typedef struct EnumValue {
708 struct gwint gwint;
709 bool set;
711
712MK_VECTOR_TYPE(EnumValue, enumvalue)
713
714typedef struct Enum_Def_ {
716 EnumValueList *list;
717 struct Type_ *type;
718 ae_flag flag;
720ANN2(1, 2)
721ANEW AST_NEW(Enum_Def, enum_def, EnumValueList*, struct Symbol_ *,
722 const loc_t);
723ANN void free_enum_def(MemPool p, Enum_Def);
724
725typedef struct Upvalues {
726 Scope values;
729
730typedef struct Func_Base_ {
733 ArgList *args;
734 struct Func_ * func;
735 struct Type_ * ret_type;
738 struct Vector_ effects;
739 ae_flag flag;
742
743FLAG_FUNC(Func_Base *, fb)
744
745ANN2(1)
746AST_NEW(Func_Base *, func_base, Type_Decl *, const Symbol, ArgList*,
747 const ae_flag flag, const loc_t);
748
753ANEW ANN AST_NEW(Fptr_Def, fptr_def, Func_Base *);
754ANN void free_fptr_def(MemPool p, Fptr_Def);
755
756typedef struct Type_Def_ *Type_Def;
766ANEW ANN AST_NEW(Type_Def, type_def, Type_Decl *, const Symbol, const loc_t);
767ANN void free_type_def(MemPool p, Type_Def);
768
769typedef struct Union_Def_ {
770 VariableList *l;
772 struct Type_ *type;
774 ae_flag flag;
776ANEW ANN AST_NEW(Union_Def, union_def, VariableList*, const loc_t);
777ANN void free_union_def(MemPool p, Union_Def);
778
779struct Func_Def_ {
782 StmtList *code;
784 } d;
785 CaptureList *captures;
786 uint16_t stack_depth;
787 uint16_t vt_index;
789};
790MK_VECTOR_TYPE(Func_Def, funcdef)
791ANEW AST_NEW(Func_Def, func_def, Func_Base *, StmtList*);
792ANN void free_func_base(MemPool p, Func_Base *);
793ANN void free_func_def(MemPool p, Func_Def);
794
795typedef struct Trait_Def_ {
798 TagList *traits;
799 ae_flag flag;
801ANN ANEW Trait_Def new_trait_def(MemPool p, const ae_flag, const Symbol,
802 const Ast, const loc_t);
803ANN void free_trait_def(MemPool p, Trait_Def);
804
805typedef struct Prim_Def_ {
807 m_uint size;
808 ae_flag flag;
810
811AST_NEW(Prim_Def, prim_def, const Symbol name, const m_uint size, const loc_t, const ae_flag flag);
812ANN void free_prim_def(MemPool p, Prim_Def);
813
814static inline bool is_prim(const Exp* e) { return e->exp_type == ae_exp_primary; }
815
816static inline bool is_prim_int(const Exp* e) {
817 return (is_prim(e) && e->d.prim.prim_type == ae_prim_num);
818}
819
820static inline bool is_prim_float(const Exp* e) {
821 return (is_prim(e) && e->d.prim.prim_type == ae_prim_float);
822}
823
824#define MK_SECTION(_type, _target, _data, _loc) (Section){ .section_type = ae_section_##_type, .d = { ._target = _data }, .loc = _loc }
854MK_VECTOR_TYPE(Section, section)
855ANEW ANN AST_NEW(Section *, section_stmt_list, StmtList*);
856ANEW ANN AST_NEW(Section *, section_func_def, const Func_Def);
857ANEW ANN AST_NEW(Section *, section_class_def, const Class_Def);
858ANEW ANN AST_NEW(Section *, section_trait_def, const Trait_Def);
859ANEW ANN AST_NEW(Section *, section_extend_def, const Extend_Def);
860ANEW ANN AST_NEW(Section *, section_enum_def, const Enum_Def);
861ANEW ANN AST_NEW(Section *, section_union_def, const Union_Def);
862ANEW ANN AST_NEW(Section *, section_fptr_def, const Fptr_Def);
863ANEW ANN AST_NEW(Section *, section_type_def, const Type_Def);
864
867 TagList *traits;
868 struct Type_ *type;
869};
870
871ANN2(1)
872ANEW Extend_Def new_extend_def(MemPool p, Type_Decl *const, TagList*const);
873ANN void free_extend_def(MemPool p, Extend_Def);
874
879
883 TagList *traits;
885 ae_flag flag;
886};
887
888ANN static inline int cflag(const Class_Def c, const enum cflag flag) {
889 return (c->cflag & flag) == flag;
890}
891
892ANN2(1)
893ANEW Class_Def new_class_def(MemPool p, const ae_flag, const Tag,
894 Type_Decl *, const Ast);
895ANN void free_class_def(MemPool p, Class_Def);
896
897ANN void free_ast(MemPool p, Ast);
898#endif
struct Stmt_Flow_ * Stmt_Flow
ae_stmt_t
Definition absyn.h:158
@ ae_stmt_exp
Definition absyn.h:159
@ ae_stmt_continue
Definition absyn.h:168
@ ae_stmt_spread
Definition absyn.h:175
@ ae_stmt_loop
Definition absyn.h:164
@ ae_stmt_return
Definition absyn.h:169
@ ae_stmt_while
Definition absyn.h:160
@ ae_stmt_pp
Definition absyn.h:173
@ ae_stmt_code
Definition absyn.h:166
@ ae_stmt_match
Definition absyn.h:172
@ ae_stmt_for
Definition absyn.h:162
@ ae_stmt_if
Definition absyn.h:165
@ ae_stmt_until
Definition absyn.h:161
@ ae_stmt_import
Definition absyn.h:177
@ ae_stmt_each
Definition absyn.h:163
@ ae_stmt_break
Definition absyn.h:167
@ ae_stmt_try
Definition absyn.h:170
@ ae_stmt_defer
Definition absyn.h:174
@ ae_stmt_retry
Definition absyn.h:171
@ ae_stmt_using
Definition absyn.h:176
ANN ANEW Trait_Def new_trait_def(MemPool p, const ae_flag, const Symbol, const Ast, const loc_t)
static bool is_prim_float(const Exp *e)
Definition absyn.h:820
struct Variable_ Variable
variable declaration
struct Stmt_For_ * Stmt_For
Definition absyn.h:180
struct Exp_Call_ Exp_Call
struct Type_Decl_ Type_Decl
Definition absyn.h:20
struct Extend_Def_ * Extend_Def
Definition absyn.h:14
struct Class_Def_ * Class_Def
Definition absyn.h:13
struct Stmt_Exp_ * Stmt_Exp
struct Stmt_Each_ * Stmt_Each
Definition absyn.h:181
static loc_t prim_pos(const void *data)
Definition absyn.h:651
static ANN int exp_getuse(const Exp *e)
Definition absyn.h:592
ae_pp_type
Definition absyn.h:109
@ ae_pp_pragma
Definition absyn.h:112
@ ae_pp_ifdef
Definition absyn.h:114
@ ae_pp_endif
Definition absyn.h:117
@ ae_pp_else
Definition absyn.h:116
@ ae_pp_include
Definition absyn.h:110
@ ae_pp_define
Definition absyn.h:111
@ ae_pp_locale
Definition absyn.h:118
@ ae_pp_ifndef
Definition absyn.h:115
@ ae_pp_undef
Definition absyn.h:113
@ ae_pp_nl
Definition absyn.h:119
gwint_type
Definition absyn.h:445
@ gwint_hexa
Definition absyn.h:448
@ gwint_octal
Definition absyn.h:449
@ gwint_binary
Definition absyn.h:447
@ gwint_decimal
Definition absyn.h:446
struct Section_ Section
ANN void free_variablelist(MemPool p, VariableList *)
Type_Decl * TD
Definition absyn.h:288
static ANN uint32_t tmplarg_has_const(const TmplArgList *tl)
Definition absyn.h:293
static ANN int exp_getprot(const Exp *e)
Definition absyn.h:614
struct Stmt_PP_ * Stmt_PP
Definition absyn.h:184
struct Enum_Def_ * Enum_Def
#define AST_NEW(type, name,...)
Definition absyn.h:9
ANN void free_tmpl(MemPool p, Tmpl *)
ANN void free_stmt_list(MemPool, StmtList *)
struct Prim_Def_ * Prim_Def
MK_VECTOR_TYPE(Tag, tag)
static Stmt * stmt_self(const void *data)
Definition absyn.h:218
cflag
Definition absyn.h:875
@ cflag_struct
Definition absyn.h:877
@ cflag_none
Definition absyn.h:876
static Exp_Primary * prim_self(const void *data)
Definition absyn.h:644
static Exp * exp_self(const void *data)
Definition absyn.h:641
static ANN int exp_getvar(const Exp *e)
Definition absyn.h:603
ANN void free_ast(MemPool p, Ast)
ANEW Class_Def new_class_def(MemPool p, const ae_flag, const Tag, Type_Decl *, const Ast)
struct Stmt_Using_ UsingStmt
Definition absyn.h:141
ae_prim_t
Definition absyn.h:423
@ ae_prim_nil
Definition absyn.h:433
@ ae_prim_locale
Definition absyn.h:436
@ ae_prim_array
Definition absyn.h:428
@ ae_prim_id
Definition absyn.h:424
@ ae_prim_float
Definition absyn.h:426
@ ae_prim_hack
Definition absyn.h:431
@ ae_prim_perform
Definition absyn.h:435
@ ae_prim_num
Definition absyn.h:425
@ ae_prim_interp
Definition absyn.h:434
@ ae_prim_char
Definition absyn.h:432
@ ae_prim_str
Definition absyn.h:427
@ ae_prim_range
Definition absyn.h:429
@ ae_prim_dict
Definition absyn.h:430
ae_exp_t
Definition absyn.h:400
@ ae_exp_unary
Definition absyn.h:403
@ ae_exp_binary
Definition absyn.h:402
@ ae_exp_post
Definition absyn.h:406
@ ae_exp_dot
Definition absyn.h:411
@ ae_exp_call
Definition absyn.h:407
@ ae_exp_decl
Definition absyn.h:401
@ ae_exp_primary
Definition absyn.h:404
@ ae_exp_if
Definition absyn.h:410
@ ae_exp_lambda
Definition absyn.h:412
@ ae_exp_td
Definition absyn.h:413
@ ae_exp_cast
Definition absyn.h:405
@ ae_exp_slice
Definition absyn.h:409
@ ae_exp_array
Definition absyn.h:408
@ ae_exp_named
Definition absyn.h:414
ANN void free_trait_def(MemPool p, Trait_Def)
ANEW stmt_pp
Definition absyn.h:235
ANN void free_stmt(MemPool p, Stmt *)
struct Range_ Range
range.
ae_Exp_Meta
Definition absyn.h:416
@ ae_meta_var
Definition absyn.h:416
@ ae_meta_value
Definition absyn.h:416
@ ae_meta_protect
Definition absyn.h:416
struct Handler_ Handler
ANN void free_class_def(MemPool p, Class_Def)
Exp * E
Definition absyn.h:590
fbflag_default
Definition absyn.h:6
fbflag_locale
Definition absyn.h:7
ANN void free_union_def(MemPool p, Union_Def)
ANEW enum ae_pp_type type const m_str const loc_t
Definition absyn.h:235
fbflag_op
Definition absyn.h:1
struct Array_Sub_ * Array_Sub
Definition absyn.h:18
struct Stmt_Loop_ * Stmt_Loop
Definition absyn.h:182
ANEW Extend_Def new_extend_def(MemPool p, Type_Decl *const, TagList *const)
ANN void free_type_decl(MemPool p, Type_Decl *)
struct Stmt_Defer_ * Stmt_Defer
Definition absyn.h:185
struct Match * Stmt_Match
static Exp * prim_exp(const void *data)
Definition absyn.h:647
fbflag_none
Definition absyn.h:0
struct Stmt_Import_ * Stmt_Import
static bool is_prim_int(const Exp *e)
Definition absyn.h:816
ANEW exp_unary2
Definition absyn.h:681
ANN void free_specialized_list(MemPool p, SpecializedList *)
exp_comptime
Definition absyn.h:554
@ comptime_yes
Definition absyn.h:556
@ comptime_need
Definition absyn.h:557
@ comptime_no
Definition absyn.h:555
exp_lambda
Definition absyn.h:348
typedef __attribute__
struct Func_Def_ * Func_Def
Definition absyn.h:15
struct SectionList * Ast
Definition absyn.h:23
static Exp * take_exp(Exp *exp, const uint32_t n)
Definition absyn.h:698
unary_type
Definition absyn.h:523
@ unary_code
Definition absyn.h:523
@ unary_exp
Definition absyn.h:523
@ unary_td
Definition absyn.h:523
ANN void free_fptr_def(MemPool p, Fptr_Def)
struct Fptr_Def_ * Fptr_Def
Definition absyn.h:19
struct Trait_Def_ * Trait_Def
struct Func_Base_ Func_Base
struct Var_Decl_ Var_Decl
ANN void free_type_def(MemPool p, Type_Def)
tmplarg_t
Definition absyn.h:253
@ tmplarg_td
Definition absyn.h:254
@ tmplarg_exp
Definition absyn.h:255
struct Type_Def_ * Type_Def
Definition absyn.h:756
ANN void free_func_def(MemPool p, Func_Def)
ANN void free_tmplarg_list(MemPool p, TmplArgList *)
ae_section_t
Definition absyn.h:825
@ ae_section_primitive
Definition absyn.h:835
@ ae_section_class
Definition absyn.h:828
@ ae_section_enum
Definition absyn.h:831
@ ae_section_union
Definition absyn.h:832
@ ae_section_fptr
Definition absyn.h:833
@ ae_section_func
Definition absyn.h:827
@ ae_section_type
Definition absyn.h:834
@ ae_section_stmt
Definition absyn.h:826
@ ae_section_extend
Definition absyn.h:830
@ ae_section_trait
Definition absyn.h:829
Stmt_Using Using
Definition absyn.h:142
ANEW ANN2(1, 3) AST_NEW(Stmt *
fbflag_postfix
Definition absyn.h:3
static ANN m_str exp_access(const Exp *e)
Definition absyn.h:636
ANN void free_enum_def(MemPool p, Enum_Def)
struct Stmt_Try_ * Stmt_Try
struct Tmpl_ Tmpl
static ANN void exp_setvar(Exp *e, const bool val)
Definition absyn.h:607
fbflag_lambda
Definition absyn.h:5
struct Spread_Def_ * Spread_Def
Exp *ANN void free_array_sub(MemPool p, Array_Sub)
static bool is_prim(const Exp *e)
Definition absyn.h:814
ANN void free_exp(MemPool p, Exp *)
static ANN void exp_setuse(Exp *e, const bool val)
Definition absyn.h:596
static uint32_t exp_count(Exp *exp)
Definition absyn.h:688
fbflag_internal
Definition absyn.h:4
ANN void free_arg_list(MemPool p, ArgList *)
const Symbol
Definition absyn.h:348
static ANN bool is_spread_tmpl(const Tmpl *tmpl)
Definition absyn.h:487
struct Arg_ Arg
ANN void free_func_base(MemPool p, Func_Base *)
static ANN void exp_setprot(Exp *e, const bool val)
Definition absyn.h:618
struct Stmt_Code_ * Stmt_Code
ANEW const Type_Decl Exp * exp
Definition absyn.h:681
ANN void free_extend_def(MemPool p, Extend_Def)
struct Stmt_If_ * Stmt_If
Definition absyn.h:183
static ANN void exp_setmeta(Exp *e, const bool val)
Definition absyn.h:629
exp_state
Definition absyn.h:547
@ exp_state_meta
Definition absyn.h:548
@ exp_state_use
Definition absyn.h:551
@ exp_state_addr
Definition absyn.h:550
@ exp_state_prot
Definition absyn.h:549
ANEW prim_perform
Definition absyn.h:657
static ANN uint32_t tmplarg_ntypes(const TmplArgList *tl)
Definition absyn.h:301
fbflag_unary
Definition absyn.h:2
struct Stmt_Index_ * Stmt_Index
ANN void free_prim_def(MemPool p, Prim_Def)
static bool tmpl_base(const Tmpl *a)
Definition absyn.h:493
fbflag
Definition absyn.h:318
static ANN int exp_getmeta(const Exp *e)
Definition absyn.h:625
struct Union_Def_ * Union_Def
struct Stmt_Using_ * Stmt_Using
Array_Sub prepend_array_sub(const Array_Sub a, Exp *exp)
Definition ast_new.c:24
#define FLAG_FUNC(A, a)
Definition flags.h:41
struct loc_t_ loc_t
Definition absyn.h:348
return NULL
Definition macro.c:41
ANN2(1)
Definition pparg.c:46
Definition absyn.h:310
loc_t loc
Definition absyn.h:314
Exp * exp
Definition absyn.h:312
struct Type_ * type
Definition absyn.h:313
Variable var
Definition absyn.h:311
array_subscript.
Definition absyn.h:353
struct Type_ * type
Definition absyn.h:355
uint16_t depth
Definition absyn.h:356
Exp * exp
Definition absyn.h:354
uint16_t delim
Definition absyn.h:420
m_str data
Definition absyn.h:419
Var_Decl var
Definition absyn.h:336
struct Value_ * temp
Definition absyn.h:337
bool is_ref
Definition absyn.h:339
uint32_t offset
Definition absyn.h:338
ae_flag flag
Definition absyn.h:885
Ast body
Definition absyn.h:882
enum cflag cflag
Definition absyn.h:884
TagList * traits
Definition absyn.h:883
struct Type_Def_ base
Definition absyn.h:881
struct gwint gwint
Definition absyn.h:708
Tag tag
Definition absyn.h:707
bool set
Definition absyn.h:709
ae_flag flag
Definition absyn.h:718
EnumValueList * list
Definition absyn.h:716
struct Type_ * type
Definition absyn.h:717
Tag tag
Definition absyn.h:715
array expression.
Definition absyn.h:363
Exp * base
Definition absyn.h:364
Array_Sub array
Definition absyn.h:365
Symbol op
Definition absyn.h:512
Exp * rhs
Definition absyn.h:511
Exp * lhs
Definition absyn.h:510
Tmpl * tmpl
Definition absyn.h:501
Exp * other
Definition absyn.h:502
Exp * args
Definition absyn.h:500
Exp * func
Definition absyn.h:499
bool checked
Definition absyn.h:503
Exp * exp
Definition absyn.h:507
Type_Decl * td
Definition absyn.h:506
struct Type_ * type
Definition absyn.h:441
Exp * args
Definition absyn.h:442
Variable var
Definition absyn.h:440
a dot expression.
Definition absyn.h:330
Var_Decl var
Definition absyn.h:331
Exp * base
Definition absyn.h:332
Exp * cond
Definition absyn.h:519
Exp * if_exp
Definition absyn.h:520
Exp * else_exp
Definition absyn.h:521
a lambda expression.
Definition absyn.h:344
struct Type_ * owner
Definition absyn.h:346
Func_Def def
Definition absyn.h:345
bool is_arg
Definition absyn.h:542
Tag tag
Definition absyn.h:541
Exp * exp
Definition absyn.h:540
Exp * exp
Definition absyn.h:516
Symbol op
Definition absyn.h:515
ae_prim_t prim_type
Definition absyn.h:476
struct Value_ * value
Definition absyn.h:465
slice.
Definition absyn.h:380
Range * range
Definition absyn.h:382
Exp * base
Definition absyn.h:381
enum unary_type unary_type
Definition absyn.h:536
Exp * exp
Definition absyn.h:531
StmtList * code
Definition absyn.h:532
struct UnaryNew ctor
Definition absyn.h:533
Symbol op
Definition absyn.h:529
CaptureList * captures
Definition absyn.h:535
Definition absyn.h:560
Exp * ref
Definition absyn.h:580
int16_t emit_var
Definition absyn.h:584
bool poison
Definition absyn.h:586
enum exp_comptime comptime
Definition absyn.h:585
ae_exp_t exp_type
Definition absyn.h:583
struct Type_ * cast_to
Definition absyn.h:578
union Exp::exp_data d
loc_t loc
Definition absyn.h:582
bool paren
Definition absyn.h:587
bool is_call
Definition absyn.h:588
struct Type_ * type
Definition absyn.h:577
Exp * next
Definition absyn.h:579
void * data
Definition absyn.h:581
Type_Decl * td
Definition absyn.h:866
struct Type_ * type
Definition absyn.h:868
TagList * traits
Definition absyn.h:867
Func_Base * base
Definition absyn.h:750
Class_Def cdef
Definition absyn.h:751
Upvalues * values
Definition absyn.h:737
Tag tag
Definition absyn.h:732
struct Type_ * ret_type
Definition absyn.h:735
Tmpl * tmpl
Definition absyn.h:736
struct Vector_ effects
Definition absyn.h:738
ArgList * args
Definition absyn.h:733
Type_Decl * td
Definition absyn.h:731
ae_flag flag
Definition absyn.h:739
struct Func_ * func
Definition absyn.h:734
enum fbflag fbflag
Definition absyn.h:740
bool builtin
Definition absyn.h:788
union Func_Def_::func_def_data d
Func_Base * base
Definition absyn.h:780
CaptureList * captures
Definition absyn.h:785
uint16_t vt_index
Definition absyn.h:787
uint16_t stack_depth
Definition absyn.h:786
Stmt * stmt
Definition absyn.h:95
Tag tag
Definition absyn.h:94
Definition absyn.h:53
Exp * when
Definition absyn.h:58
Exp * cond
Definition absyn.h:54
Stmt * where
Definition absyn.h:57
struct StmtList * list
Definition absyn.h:55
HandlerList * handlers
Definition absyn.h:100
bool has_xid
Definition absyn.h:101
m_uint size
Definition absyn.h:807
Tag tag
Definition absyn.h:806
ae_flag flag
Definition absyn.h:808
range.
Definition absyn.h:372
bool inclusive
Definition absyn.h:375
Exp * end
end of range expression
Definition absyn.h:374
Exp * start
start of range expression
Definition absyn.h:373
ae_section_t section_type
Definition absyn.h:851
bool poison
Definition absyn.h:852
union Section_::section_data d
loc_t loc
Definition absyn.h:850
Tag tag
Definition absyn.h:388
Type_Decl * td
Definition absyn.h:389
TagList * traits
Definition absyn.h:390
Tag tag
Definition absyn.h:152
TagList * list
Definition absyn.h:153
m_str data
Definition absyn.h:154
struct StmtList * stmt_list
Definition absyn.h:63
Stmt * stmt
Definition absyn.h:131
Var_Decl idx
Definition absyn.h:77
Var_Decl var
Definition absyn.h:74
Exp * exp
Definition absyn.h:75
bool is_ref
Definition absyn.h:78
Stmt * body
Definition absyn.h:76
Exp * val
Definition absyn.h:40
bool is_do
Definition absyn.h:50
Stmt * body
Definition absyn.h:49
Exp * cond
Definition absyn.h:48
Stmt * body
Definition absyn.h:70
Stmt * c2
Definition absyn.h:68
Stmt * c1
Definition absyn.h:67
Exp * c3
Definition absyn.h:69
Stmt * else_body
Definition absyn.h:90
Stmt * if_body
Definition absyn.h:89
Exp * cond
Definition absyn.h:88
UsingStmtList * selection
Definition absyn.h:148
m_int idx
Definition absyn.h:44
Exp * cond
Definition absyn.h:82
Var_Decl idx
Definition absyn.h:84
Stmt * body
Definition absyn.h:83
m_str data
Definition absyn.h:124
Exp * exp
Definition absyn.h:125
Symbol xid
Definition absyn.h:126
enum ae_pp_type pp_type
Definition absyn.h:127
HandlerList * handler
Definition absyn.h:106
Stmt * stmt
Definition absyn.h:105
Exp * exp
Definition absyn.h:137
union Stmt_Using_::@110350002355252166347271066036333112332376164252 d
Type_Decl * td
Definition absyn.h:136
Tag tag
Definition absyn.h:139
Definition absyn.h:187
loc_t loc
position
Definition absyn.h:205
ae_stmt_t stmt_type
Definition absyn.h:206
bool poison
Definition absyn.h:207
union Stmt::stmt_data d
Definition absyn.h:25
Symbol sym
Definition absyn.h:26
loc_t loc
Definition absyn.h:27
Exp * exp
Definition absyn.h:261
enum tmplarg_t type
Definition absyn.h:263
union TmplArg::@050373127370005100317310121124014227123135177154 d
Type_Decl * td
Definition absyn.h:260
Definition absyn.h:479
SpecializedList * list
Definition absyn.h:480
TmplArgList * call
Definition absyn.h:481
Ast body
Definition absyn.h:797
ae_flag flag
Definition absyn.h:799
Tag tag
Definition absyn.h:796
TagList * traits
Definition absyn.h:798
Tag tag
Definition absyn.h:279
Type_Decl * next
Definition absyn.h:282
ae_flag flag
Definition absyn.h:285
TmplArgList * types
Definition absyn.h:281
Array_Sub array
Definition absyn.h:280
bool ref
Definition absyn.h:286
uint8_t option
Definition absyn.h:284
Fptr_Def fptr
Definition absyn.h:283
Tag tag
Definition absyn.h:760
Type_Decl * ext
Definition absyn.h:758
Exp * when
Definition absyn.h:762
Func_Def when_def
Definition absyn.h:763
bool distinct
Definition absyn.h:764
Tmpl * tmpl
Definition absyn.h:761
struct Type_ * type
Definition absyn.h:759
Type_Decl * td
Definition absyn.h:525
Exp * exp
Definition absyn.h:526
Tmpl * tmpl
Definition absyn.h:773
struct Type_ * type
Definition absyn.h:772
Tag tag
Definition absyn.h:771
ae_flag flag
Definition absyn.h:774
VariableList * l
Definition absyn.h:770
struct Upvalues * parent
Definition absyn.h:727
Scope values
Definition absyn.h:726
struct Value_ * value
corresponding value
Definition absyn.h:35
Tag tag
Definition absyn.h:34
variable declaration
Definition absyn.h:244
Var_Decl vd
Definition absyn.h:246
Type_Decl * td
Definition absyn.h:245
Definition absyn.h:452
m_int num
Definition absyn.h:453
enum gwint_type int_type
Definition absyn.h:454
a gwint with a larger int type for parsing
Definition absyn.h:459
enum gwint_type int_type
Definition absyn.h:461
long long num
Definition absyn.h:460
Exp_Lambda exp_lambda
Definition absyn.h:573
Exp_Named exp_named
Definition absyn.h:575
Exp_Decl exp_decl
Definition absyn.h:564
Exp_Array exp_array
Definition absyn.h:571
Exp_Unary exp_unary
Definition absyn.h:565
Exp_Cast exp_cast
Definition absyn.h:567
Exp_Postfix exp_post
Definition absyn.h:562
Exp_Primary prim
Definition absyn.h:563
Exp_Binary exp_binary
Definition absyn.h:566
Exp_Dot exp_dot
Definition absyn.h:570
Exp_Call exp_call
Definition absyn.h:568
Exp_Slice exp_slice
Definition absyn.h:572
Exp_If exp_if
Definition absyn.h:569
Type_Decl * exp_td
Definition absyn.h:574
struct gwint gwint
Definition absyn.h:468
struct Symbol_ * var
Definition absyn.h:467
struct AstString string
Definition absyn.h:471
StmtList * stmt_list
Definition absyn.h:839
Union_Def union_def
Definition absyn.h:845
Trait_Def trait_def
Definition absyn.h:840
Class_Def class_def
Definition absyn.h:841
Extend_Def extend_def
Definition absyn.h:842
struct Stmt_Loop_ stmt_loop
Definition absyn.h:192
struct Spread_Def_ stmt_spread
Definition absyn.h:201
struct Stmt_Defer_ stmt_defer
Definition absyn.h:200
struct Stmt_Import_ stmt_import
Definition absyn.h:203
struct Stmt_Try_ stmt_try
Definition absyn.h:196
struct Stmt_Each_ stmt_each
Definition absyn.h:194
struct Stmt_Code_ stmt_code
Definition absyn.h:190
struct Stmt_Index_ stmt_index
Definition absyn.h:198
struct Stmt_Using_ stmt_using
Definition absyn.h:202
struct Stmt_For_ stmt_for
Definition absyn.h:193
struct Match stmt_match
Definition absyn.h:197
struct Stmt_Flow_ stmt_flow
Definition absyn.h:191
struct Stmt_Exp_ stmt_exp
Definition absyn.h:189
struct Stmt_PP_ stmt_pp
Definition absyn.h:199
struct Stmt_If_ stmt_if
Definition absyn.h:195