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