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
316
317enum fbflag {
318 fbflag_none = 1 << 0,
319 fbflag_op = 1 << 1,
320 fbflag_unary = 1 << 3,
321 fbflag_postfix = 1 << 4,
322 fbflag_internal = 1 << 5,
323 fbflag_lambda = 1 << 6,
324 fbflag_default = 1 << 7,
325 fbflag_locale = 1 << 8,
326} __attribute__((packed));
327
333
334typedef struct Capture {
336 struct Value_ *temp;
337 uint32_t offset;
338 bool is_ref;
340MK_VECTOR_TYPE(Capture, capture)
341
342
343typedef struct {
345 struct Type_ *owner;
346} Exp_Lambda;
347ANN2(1,2,4) AST_NEW(Exp*, exp_lambda, const Symbol, ArgList*, StmtList*,
348 const loc_t);
349AST_NEW(Exp*, exp_lambda2, const Symbol xid, ArgList *args, Exp* exp,
350 const loc_t);
354 struct Type_ *type;
355 uint16_t depth;
356};
357ANEW AST_NEW(Array_Sub, array_sub, Exp*);
359ANN void free_array_sub(MemPool p, Array_Sub);
360
362typedef struct {
365} Exp_Array;
366ANEW ANN AST_NEW(Exp*, exp_array, Exp*, const Array_Sub,
367 const loc_t);
368
371typedef struct Range_ {
376AST_NEW(Range *, range, Exp*, Exp*);
377
379typedef struct {
382} Exp_Slice;
383ANEW ANN AST_NEW(Exp*, exp_slice, Exp*, Range *, const loc_t);
384
385
391MK_VECTOR_TYPE(Specialized, specialized)
392
393ANN void free_specialized_list(MemPool p, SpecializedList*);
394
395ANN void free_tmplarg_list(MemPool p, TmplArgList *);
396
397ANN void free_arg_list(MemPool p, ArgList*);
398
416
417struct AstString {
418 m_str data;
419 uint16_t delim;
420};
421
437
438typedef struct {
440 struct Type_ *type;
442} Exp_Decl;
443
450
451struct gwint {
452 m_int num;
454};
455#define GWINT(a, b) ((struct gwint){ .num = a, .int_type = b})
456
458struct yyint {
459 long long num;
461};
462
463typedef struct {
464 struct Value_ *value;
465 union prim_data {
466 struct Symbol_ *var;
467 struct gwint gwint;
468 m_float fnum;
469 m_str chr;
470 struct AstString string;
474 } d;
477
478typedef struct Tmpl_ {
479 SpecializedList *list;
480 TmplArgList *call;
482
483ANN ANEW AST_NEW(Tmpl *, tmpl, SpecializedList*);
484ANN ANEW AST_NEW(Tmpl *, tmpl_call, TmplArgList*);
485ANN void free_tmpl(MemPool p, Tmpl *);
486ANN static inline bool is_spread_tmpl(const Tmpl *tmpl) {
487 const Specialized spec = specializedlist_at(tmpl->list, tmpl->list->len - 1);
488 return !strcmp(s_name(spec.tag.sym), "...");
489}
490
491
492static inline bool tmpl_base(const Tmpl *a) {
493 if (a && !a->call) return true;
494 return false;
495}
496
504typedef struct {
507} Exp_Cast;
508typedef struct {
512} Exp_Binary;
513typedef struct {
517typedef struct {
521} Exp_If;
527typedef struct {
529 union {
531 StmtList *code;
532 struct UnaryNew ctor;
533 };
534 CaptureList *captures;
536} Exp_Unary;
537
538typedef struct {
541 bool is_arg;
542} Exp_Named;
543
544AST_NEW(Exp*, exp_named, Exp *exp, const Tag tag, const loc_t loc);
545
547 exp_state_meta, // ae_meta_value
548 exp_state_prot, // ae_meta_protect
551};
552
558
589typedef Exp* E;
591ANN static inline int exp_getuse(const Exp* e) {
592 return (e->emit_var & (1 << exp_state_use)) == (1 << exp_state_use);
593}
594
595ANN static inline void exp_setuse(Exp* e, const bool val) {
596 if (val)
597 e->emit_var |= 1 << exp_state_use;
598 else
599 e->emit_var &= ~(1 << exp_state_use);
600}
601
602ANN static inline int exp_getvar(const Exp* e) {
603 return (e->emit_var & (1 << exp_state_addr)) == (1 << exp_state_addr);
604}
605
606ANN static inline void exp_setvar(Exp* e, const bool val) {
607 if (val)
608 e->emit_var |= 1 << exp_state_addr;
609 else
610 e->emit_var &= ~(1 << exp_state_addr);
611}
612
613ANN static inline int exp_getprot(const Exp* e) {
614 return (e->emit_var & (1 << exp_state_prot)) == (1 << exp_state_prot);
615}
616
617ANN static inline void exp_setprot(Exp* e, const bool val) {
618 if (val)
619 e->emit_var |= 1 << exp_state_prot;
620 else
621 e->emit_var &= ~(1 << exp_state_prot);
622}
623
624ANN static inline int exp_getmeta(const Exp* e) {
625 return (e->emit_var & (1 << exp_state_meta)) == (1 << exp_state_meta);
626}
627
628ANN static inline void exp_setmeta(Exp* e, const bool val) {
629 if (val)
630 e->emit_var |= 1 << exp_state_meta;
631 else
632 e->emit_var &= ~(1 << exp_state_meta);
633}
634
635ANN static inline m_str exp_access(const Exp* e) {
636 if (exp_getmeta(e)) return (m_str) "non-mutable";
637 return !exp_getprot(e) ? NULL : (m_str) "protected";
638}
639
640static inline Exp* exp_self(const void *data) {
641 return container_of((char *)data, Exp, d);
642}
643static inline Exp_Primary *prim_self(const void *data) {
644 return container_of((char *)data, Exp_Primary, d);
645}
646static inline Exp* prim_exp(const void *data) {
647 const Exp_Primary *p = prim_self(data);
648 return exp_self(p);
649}
650static inline loc_t prim_pos(const void *data) {
651 const Exp* e = prim_exp(data);
652 return e->loc;
653}
654
655ANEW ANN AST_NEW(Exp*, prim_id, struct Symbol_ *, const loc_t);
656ANEW ANN2(1) AST_NEW(Exp*, prim_perform, struct Symbol_ *, const loc_t);
657ANEW AST_NEW(Exp*, prim_int, const m_uint, const loc_t);
658ANEW AST_NEW(Exp*, prim_float, const m_float, const loc_t);
659ANEW ANN AST_NEW(Exp*, prim_string, const m_str, const uint16_t delim, const loc_t);
660ANEW ANN AST_NEW(Exp*, prim_array, const Array_Sub, const loc_t);
661ANEW ANN AST_NEW(Exp*, prim_range, Range *, const loc_t);
662ANEW AST_NEW(Exp*, prim_dict, Exp*, const loc_t);
663ANEW AST_NEW(Exp*, prim_hack, Exp*, const loc_t);
664ANEW ANN AST_NEW(Exp*, prim_char, const m_str, const loc_t);
665ANEW AST_NEW(Exp*, prim_nil, const loc_t);
666ANEW ANN AST_NEW(Exp*, prim_interp, Exp* exp, const loc_t);
667ANEW ANN AST_NEW(Exp*, exp_decl, Type_Decl *, const Var_Decl*,
668 const loc_t);
669ANEW ANN AST_NEW(Exp*, exp_binary, Exp*, const Symbol, Exp*,
670 const loc_t);
671ANEW ANN AST_NEW(Exp*, exp_post, Exp*, const Symbol, const loc_t);
672ANN2(1, 2)
673ANEW AST_NEW(Exp*, exp_call, Exp*, Exp* args, const loc_t);
674ANEW ANN AST_NEW(Exp*, exp_cast, Type_Decl *, Exp*, const loc_t);
675ANN2(1, 2, 4)
676ANEW AST_NEW(Exp*, exp_if, Exp*, Exp*, Exp*, const loc_t);
677ANEW ANN AST_NEW(Exp*, exp_dot, Exp*, const Tag tag,
678 const loc_t);
679ANEW ANN AST_NEW(Exp*, exp_unary, const Symbol, Exp*, const loc_t);
680ANEW ANN2(1,2,3) AST_NEW(Exp*, exp_unary2, const Symbol, Type_Decl *,
681 Exp* exp, const loc_t);
682ANEW ANN AST_NEW(Exp*, exp_unary3, const Symbol, StmtList*,
683 const loc_t);
684ANN void free_stmt_list(MemPool, StmtList*);
685ANEW ANN AST_NEW(Exp*, exp_td, Type_Decl *, const loc_t);
686
687static inline uint32_t exp_count(Exp* exp) {
688 uint32_t n = 0;
689 while(exp) {
690 n++;
691 exp = exp->next;
692 }
693 return n;
694}
695
696// TODO: rename to exp_take
697static inline Exp* take_exp(Exp* exp, const uint32_t n) {
698 Exp* e = exp;
699 for (uint32_t i = 1; i < n; i++) CHECK_O((e = e->next));
700 return e;
701}
702
703ANN void free_exp(MemPool p, Exp*);
704
705typedef struct EnumValue {
707 struct gwint gwint;
708 bool set;
710
711MK_VECTOR_TYPE(EnumValue, enumvalue)
712
713typedef struct Enum_Def_ {
715 EnumValueList *list;
716 struct Type_ *type;
717 ae_flag flag;
719ANN2(1, 2)
720ANEW AST_NEW(Enum_Def, enum_def, EnumValueList*, struct Symbol_ *,
721 const loc_t);
722ANN void free_enum_def(MemPool p, Enum_Def);
723
724typedef struct Upvalues {
725 Scope values;
728
729typedef struct Func_Base_ {
732 ArgList *args;
733 struct Func_ * func;
734 struct Type_ * ret_type;
737 struct Vector_ effects;
738 ae_flag flag;
741
742FLAG_FUNC(Func_Base *, fb)
743
744ANN2(1)
745AST_NEW(Func_Base *, func_base, Type_Decl *, const Symbol, ArgList*,
746 const ae_flag flag, const loc_t);
747
752ANEW ANN AST_NEW(Fptr_Def, fptr_def, Func_Base *);
753ANN void free_fptr_def(MemPool p, Fptr_Def);
754
755typedef struct Type_Def_ *Type_Def;
765ANEW ANN AST_NEW(Type_Def, type_def, Type_Decl *, const Symbol, const loc_t);
766ANN void free_type_def(MemPool p, Type_Def);
767
768typedef struct Union_Def_ {
769 VariableList *l;
771 struct Type_ *type;
773 ae_flag flag;
775ANEW ANN AST_NEW(Union_Def, union_def, VariableList*, const loc_t);
776ANN void free_union_def(MemPool p, Union_Def);
777
778struct Func_Def_ {
781 StmtList *code;
783 } d;
784 CaptureList *captures;
785 uint16_t stack_depth;
786 uint16_t vt_index;
788};
789MK_VECTOR_TYPE(Func_Def, funcdef)
790ANEW AST_NEW(Func_Def, func_def, Func_Base *, StmtList*);
791ANN void free_func_base(MemPool p, Func_Base *);
792ANN void free_func_def(MemPool p, Func_Def);
793
794typedef struct Trait_Def_ {
797 TagList *traits;
798 ae_flag flag;
800ANN ANEW Trait_Def new_trait_def(MemPool p, const ae_flag, const Symbol,
801 const Ast, const loc_t);
802ANN void free_trait_def(MemPool p, Trait_Def);
803
804typedef struct Prim_Def_ {
806 m_uint size;
807 ae_flag flag;
809
810AST_NEW(Prim_Def, prim_def, const Symbol name, const m_uint size, const loc_t, const ae_flag flag);
811ANN void free_prim_def(MemPool p, Prim_Def);
812
813static inline bool is_prim(const Exp* e) { return e->exp_type == ae_exp_primary; }
814
815static inline bool is_prim_int(const Exp* e) {
816 return (is_prim(e) && e->d.prim.prim_type == ae_prim_num);
817}
818
819static inline bool is_prim_float(const Exp* e) {
820 return (is_prim(e) && e->d.prim.prim_type == ae_prim_float);
821}
822
823#define MK_SECTION(_type, _target, _data, _loc) (Section){ .section_type = ae_section_##_type, .d = { ._target = _data }, .loc = _loc }
853MK_VECTOR_TYPE(Section, section)
854ANEW ANN AST_NEW(Section *, section_stmt_list, StmtList*);
855ANEW ANN AST_NEW(Section *, section_func_def, const Func_Def);
856ANEW ANN AST_NEW(Section *, section_class_def, const Class_Def);
857ANEW ANN AST_NEW(Section *, section_trait_def, const Trait_Def);
858ANEW ANN AST_NEW(Section *, section_extend_def, const Extend_Def);
859ANEW ANN AST_NEW(Section *, section_enum_def, const Enum_Def);
860ANEW ANN AST_NEW(Section *, section_union_def, const Union_Def);
861ANEW ANN AST_NEW(Section *, section_fptr_def, const Fptr_Def);
862ANEW ANN AST_NEW(Section *, section_type_def, const Type_Def);
863
866 TagList *traits;
867 struct Type_ *type;
868};
869
870ANN2(1)
871ANEW Extend_Def new_extend_def(MemPool p, Type_Decl *const, TagList*const);
872ANN void free_extend_def(MemPool p, Extend_Def);
873
878
882 TagList *traits;
884 ae_flag flag;
885};
886
887ANN static inline int cflag(const Class_Def c, const enum cflag flag) {
888 return (c->cflag & flag) == flag;
889}
890
891ANN2(1)
892ANEW Class_Def new_class_def(MemPool p, const ae_flag, const Tag,
893 Type_Decl *, const Ast);
894ANN void free_class_def(MemPool p, Class_Def);
895
896ANN void free_ast(MemPool p, Ast);
897#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:819
struct Variable_ Variable
variable declaration
struct Stmt_For_ * Stmt_For
Definition absyn.h:180
struct Exp_Call_ Exp_Call
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:650
static ANN int exp_getuse(const Exp *e)
Definition absyn.h:591
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:444
@ gwint_hexa
Definition absyn.h:447
@ gwint_octal
Definition absyn.h:448
@ gwint_binary
Definition absyn.h:446
@ gwint_decimal
Definition absyn.h:445
struct Section_ Section
ANN void free_variablelist(MemPool p, VariableList *)
Type_Decl * TD
Definition absyn.h:288
struct TmplArg TmplArg
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:613
struct Stmt_PP_ * Stmt_PP
Definition absyn.h:184
struct EnumValue EnumValue
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:874
@ cflag_struct
Definition absyn.h:876
@ cflag_none
Definition absyn.h:875
static Exp_Primary * prim_self(const void *data)
Definition absyn.h:643
static Exp * exp_self(const void *data)
Definition absyn.h:640
static ANN int exp_getvar(const Exp *e)
Definition absyn.h:602
ANN void free_ast(MemPool p, Ast)
ANEW Class_Def new_class_def(MemPool p, const ae_flag, const Tag, Type_Decl *, const Ast)
ae_prim_t
Definition absyn.h:422
@ ae_prim_nil
Definition absyn.h:432
@ ae_prim_locale
Definition absyn.h:435
@ ae_prim_array
Definition absyn.h:427
@ ae_prim_id
Definition absyn.h:423
@ ae_prim_float
Definition absyn.h:425
@ ae_prim_hack
Definition absyn.h:430
@ ae_prim_perform
Definition absyn.h:434
@ ae_prim_num
Definition absyn.h:424
@ ae_prim_interp
Definition absyn.h:433
@ ae_prim_char
Definition absyn.h:431
@ ae_prim_str
Definition absyn.h:426
@ ae_prim_range
Definition absyn.h:428
@ ae_prim_dict
Definition absyn.h:429
ae_exp_t
Definition absyn.h:399
@ ae_exp_unary
Definition absyn.h:402
@ ae_exp_binary
Definition absyn.h:401
@ ae_exp_post
Definition absyn.h:405
@ ae_exp_dot
Definition absyn.h:410
@ ae_exp_call
Definition absyn.h:406
@ ae_exp_decl
Definition absyn.h:400
@ ae_exp_primary
Definition absyn.h:403
@ ae_exp_if
Definition absyn.h:409
@ ae_exp_lambda
Definition absyn.h:411
@ ae_exp_td
Definition absyn.h:412
@ ae_exp_cast
Definition absyn.h:404
@ ae_exp_slice
Definition absyn.h:408
@ ae_exp_array
Definition absyn.h:407
@ ae_exp_named
Definition absyn.h:413
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.
struct Capture Capture
ae_Exp_Meta
Definition absyn.h:415
@ ae_meta_var
Definition absyn.h:415
@ ae_meta_value
Definition absyn.h:415
@ ae_meta_protect
Definition absyn.h:415
struct Handler_ Handler
ANN void free_class_def(MemPool p, Class_Def)
Exp * E
Definition absyn.h:589
fbflag_default
Definition absyn.h:6
fbflag_locale
Definition absyn.h:7
ANN void free_union_def(MemPool p, Union_Def)
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:646
fbflag_none
Definition absyn.h:0
struct Stmt_Import_ * Stmt_Import
static bool is_prim_int(const Exp *e)
Definition absyn.h:815
struct Tag Tag
ANEW exp_unary2
Definition absyn.h:680
ANN void free_specialized_list(MemPool p, SpecializedList *)
exp_comptime
Definition absyn.h:553
@ comptime_yes
Definition absyn.h:555
@ comptime_need
Definition absyn.h:556
@ comptime_no
Definition absyn.h:554
exp_lambda
Definition absyn.h:347
typedef __attribute__
struct Func_Def_ * Func_Def
Definition absyn.h:15
struct Upvalues Upvalues
struct SectionList * Ast
Definition absyn.h:23
struct Specialized Specialized
static Exp * take_exp(Exp *exp, const uint32_t n)
Definition absyn.h:697
unary_type
Definition absyn.h:522
@ unary_code
Definition absyn.h:522
@ unary_exp
Definition absyn.h:522
@ unary_td
Definition absyn.h:522
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:755
ANN void free_func_def(MemPool p, Func_Def)
ANN void free_tmplarg_list(MemPool p, TmplArgList *)
ae_section_t
Definition absyn.h:824
@ ae_section_primitive
Definition absyn.h:834
@ ae_section_class
Definition absyn.h:827
@ ae_section_enum
Definition absyn.h:830
@ ae_section_union
Definition absyn.h:831
@ ae_section_fptr
Definition absyn.h:832
@ ae_section_func
Definition absyn.h:826
@ ae_section_type
Definition absyn.h:833
@ ae_section_stmt
Definition absyn.h:825
@ ae_section_extend
Definition absyn.h:829
@ ae_section_trait
Definition absyn.h:828
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:635
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:606
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:813
ANN void free_exp(MemPool p, Exp *)
static ANN void exp_setuse(Exp *e, const bool val)
Definition absyn.h:595
static uint32_t exp_count(Exp *exp)
Definition absyn.h:687
fbflag_internal
Definition absyn.h:4
ANN void free_arg_list(MemPool p, ArgList *)
const Symbol
Definition absyn.h:347
static ANN bool is_spread_tmpl(const Tmpl *tmpl)
Definition absyn.h:486
struct Arg_ Arg
ANN void free_func_base(MemPool p, Func_Base *)
struct ParserHandler ParserHandler
static ANN void exp_setprot(Exp *e, const bool val)
Definition absyn.h:617
struct Stmt_Code_ * Stmt_Code
ANEW const Type_Decl Exp * exp
Definition absyn.h:680
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:628
exp_state
Definition absyn.h:546
@ exp_state_meta
Definition absyn.h:547
@ exp_state_use
Definition absyn.h:550
@ exp_state_addr
Definition absyn.h:549
@ exp_state_prot
Definition absyn.h:548
ANEW prim_perform
Definition absyn.h:656
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:492
fbflag
Definition absyn.h:317
static ANN int exp_getmeta(const Exp *e)
Definition absyn.h:624
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
return NULL
Definition macro.c:41
Definition absyn.h:310
Exp * exp
Definition absyn.h:312
struct Type_ * type
Definition absyn.h:313
Variable var
Definition absyn.h:311
array_subscript.
Definition absyn.h:352
struct Type_ * type
Definition absyn.h:354
uint16_t depth
Definition absyn.h:355
Exp * exp
Definition absyn.h:353
uint16_t delim
Definition absyn.h:419
m_str data
Definition absyn.h:418
Var_Decl var
Definition absyn.h:335
struct Value_ * temp
Definition absyn.h:336
bool is_ref
Definition absyn.h:338
uint32_t offset
Definition absyn.h:337
ae_flag flag
Definition absyn.h:884
Ast body
Definition absyn.h:881
enum cflag cflag
Definition absyn.h:883
TagList * traits
Definition absyn.h:882
struct Type_Def_ base
Definition absyn.h:880
Tag tag
Definition absyn.h:706
bool set
Definition absyn.h:708
ae_flag flag
Definition absyn.h:717
EnumValueList * list
Definition absyn.h:715
struct Type_ * type
Definition absyn.h:716
Tag tag
Definition absyn.h:714
array expression.
Definition absyn.h:362
Exp * base
Definition absyn.h:363
Array_Sub array
Definition absyn.h:364
Symbol op
Definition absyn.h:511
Exp * rhs
Definition absyn.h:510
Exp * lhs
Definition absyn.h:509
Tmpl * tmpl
Definition absyn.h:500
Exp * other
Definition absyn.h:501
Exp * args
Definition absyn.h:499
Exp * func
Definition absyn.h:498
bool checked
Definition absyn.h:502
Exp * exp
Definition absyn.h:506
Type_Decl * td
Definition absyn.h:505
struct Type_ * type
Definition absyn.h:440
Exp * args
Definition absyn.h:441
Variable var
Definition absyn.h:439
a dot expression.
Definition absyn.h:329
Var_Decl var
Definition absyn.h:330
Exp * base
Definition absyn.h:331
Exp * cond
Definition absyn.h:518
Exp * if_exp
Definition absyn.h:519
Exp * else_exp
Definition absyn.h:520
a lambda expression.
Definition absyn.h:343
struct Type_ * owner
Definition absyn.h:345
Func_Def def
Definition absyn.h:344
bool is_arg
Definition absyn.h:541
Tag tag
Definition absyn.h:540
Exp * exp
Definition absyn.h:539
Exp * exp
Definition absyn.h:515
Symbol op
Definition absyn.h:514
ae_prim_t prim_type
Definition absyn.h:475
struct Value_ * value
Definition absyn.h:464
slice.
Definition absyn.h:379
Range * range
Definition absyn.h:381
Exp * base
Definition absyn.h:380
enum unary_type unary_type
Definition absyn.h:535
Exp * exp
Definition absyn.h:530
StmtList * code
Definition absyn.h:531
Symbol op
Definition absyn.h:528
CaptureList * captures
Definition absyn.h:534
Definition absyn.h:559
Exp * ref
Definition absyn.h:579
int16_t emit_var
Definition absyn.h:583
bool poison
Definition absyn.h:585
enum exp_comptime comptime
Definition absyn.h:584
ae_exp_t exp_type
Definition absyn.h:582
struct Type_ * cast_to
Definition absyn.h:577
union Exp::exp_data d
loc_t loc
Definition absyn.h:581
bool paren
Definition absyn.h:586
bool is_call
Definition absyn.h:587
struct Type_ * type
Definition absyn.h:576
Exp * next
Definition absyn.h:578
void * data
Definition absyn.h:580
Type_Decl * td
Definition absyn.h:865
struct Type_ * type
Definition absyn.h:867
TagList * traits
Definition absyn.h:866
Func_Base * base
Definition absyn.h:749
Class_Def cdef
Definition absyn.h:750
Upvalues * values
Definition absyn.h:736
Tag tag
Definition absyn.h:731
struct Type_ * ret_type
Definition absyn.h:734
Tmpl * tmpl
Definition absyn.h:735
struct Vector_ effects
Definition absyn.h:737
ArgList * args
Definition absyn.h:732
Type_Decl * td
Definition absyn.h:730
ae_flag flag
Definition absyn.h:738
struct Func_ * func
Definition absyn.h:733
enum fbflag fbflag
Definition absyn.h:739
bool builtin
Definition absyn.h:787
union Func_Def_::func_def_data d
Func_Base * base
Definition absyn.h:779
CaptureList * captures
Definition absyn.h:784
uint16_t vt_index
Definition absyn.h:786
uint16_t stack_depth
Definition absyn.h:785
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:806
Tag tag
Definition absyn.h:805
ae_flag flag
Definition absyn.h:807
range.
Definition absyn.h:371
bool inclusive
Definition absyn.h:374
Exp * end
end of range expression
Definition absyn.h:373
Exp * start
start of range expression
Definition absyn.h:372
ae_section_t section_type
Definition absyn.h:850
bool poison
Definition absyn.h:851
union Section_::section_data d
loc_t loc
Definition absyn.h:849
Tag tag
Definition absyn.h:387
Type_Decl * td
Definition absyn.h:388
TagList * traits
Definition absyn.h:389
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
Type_Decl * td
Definition absyn.h:136
Tag tag
Definition absyn.h:139
union Stmt_Using_::@2 d
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::@3 d
Type_Decl * td
Definition absyn.h:260
Definition absyn.h:478
SpecializedList * list
Definition absyn.h:479
TmplArgList * call
Definition absyn.h:480
Ast body
Definition absyn.h:796
ae_flag flag
Definition absyn.h:798
Tag tag
Definition absyn.h:795
TagList * traits
Definition absyn.h:797
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:759
Type_Decl * ext
Definition absyn.h:757
Exp * when
Definition absyn.h:761
Func_Def when_def
Definition absyn.h:762
bool distinct
Definition absyn.h:763
Tmpl * tmpl
Definition absyn.h:760
struct Type_ * type
Definition absyn.h:758
Type_Decl * td
Definition absyn.h:524
Exp * exp
Definition absyn.h:525
Tmpl * tmpl
Definition absyn.h:772
struct Type_ * type
Definition absyn.h:771
Tag tag
Definition absyn.h:770
ae_flag flag
Definition absyn.h:773
VariableList * l
Definition absyn.h:769
struct Upvalues * parent
Definition absyn.h:726
Scope values
Definition absyn.h:725
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:451
m_int num
Definition absyn.h:452
enum gwint_type int_type
Definition absyn.h:453
Definition gwlog.h:15
a gwint with a larger int type for parsing
Definition absyn.h:458
enum gwint_type int_type
Definition absyn.h:460
long long num
Definition absyn.h:459
Exp_Lambda exp_lambda
Definition absyn.h:572
Exp_Named exp_named
Definition absyn.h:574
Exp_Decl exp_decl
Definition absyn.h:563
Exp_Array exp_array
Definition absyn.h:570
Exp_Unary exp_unary
Definition absyn.h:564
Exp_Cast exp_cast
Definition absyn.h:566
Exp_Postfix exp_post
Definition absyn.h:561
Exp_Primary prim
Definition absyn.h:562
Exp_Binary exp_binary
Definition absyn.h:565
Exp_Dot exp_dot
Definition absyn.h:569
Exp_Call exp_call
Definition absyn.h:567
Exp_Slice exp_slice
Definition absyn.h:571
Exp_If exp_if
Definition absyn.h:568
Type_Decl * exp_td
Definition absyn.h:573
struct Symbol_ * var
Definition absyn.h:466
StmtList * stmt_list
Definition absyn.h:838
Union_Def union_def
Definition absyn.h:844
Trait_Def trait_def
Definition absyn.h:839
Class_Def class_def
Definition absyn.h:840
Extend_Def extend_def
Definition absyn.h:841
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