source: mainline/uspace/app/sbi/src/stree_t.h

Last change on this file was 051b3db8, checked in by Jiri Svoboda <jiri@…>, 14 years ago

Update SBI to rev. 344 from upstream. What's new:

  • Builtin.WriteLine() renamed to Console.WriteLine()
  • Implemented 'switch' statement
  • Significantly reduced memory consumption (also increases execution speed in some cases)
  • Properties can be accessed via unqualified names
  • Exceptions raised during property accesses are now handled correctly
  • Some missing checks against expressions returning no value added
  • Property mode set to 100644
File size: 16.2 KB
RevLine 
[09ababb7]1/*
[051b3db8]2 * Copyright (c) 2011 Jiri Svoboda
[09ababb7]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef STREE_T_H_
30#define STREE_T_H_
31
[23de644]32#include "bigint_t.h"
[09ababb7]33#include "list_t.h"
[37f527b]34#include "builtin_t.h"
[09ababb7]35
36/*
37 * Arithmetic expressions
38 */
39
40struct stree_expr;
41
42/** Identifier */
43typedef struct {
44 int sid;
[051bc69a]45 struct cspan *cspan;
[09ababb7]46} stree_ident_t;
47
48/** Name reference */
49typedef struct {
[051bc69a]50 /** Expression backlink */
51 struct stree_expr *expr;
52
[09ababb7]53 stree_ident_t *name;
54} stree_nameref_t;
55
[074444f]56/** Boolean literal */
57typedef struct {
58 bool_t value;
59} stree_lit_bool_t;
60
61/** Character literal */
62typedef struct {
63 bigint_t value;
64} stree_lit_char_t;
65
66/** Integer literal */
[09ababb7]67typedef struct {
[23de644]68 bigint_t value;
[09ababb7]69} stree_lit_int_t;
70
[fa36f29]71/** Reference literal (there is only one: @c nil). */
72typedef struct {
73} stree_lit_ref_t;
74
[074444f]75/** String literal */
[09ababb7]76typedef struct {
77 char *value;
78} stree_lit_string_t;
79
80typedef enum {
[074444f]81 ltc_bool,
82 ltc_char,
[09ababb7]83 ltc_int,
[fa36f29]84 ltc_ref,
[09ababb7]85 ltc_string
86} literal_class_t;
87
88/** Literal */
89typedef struct {
[051bc69a]90 /** Expression backlink */
91 struct stree_expr *expr;
92
[09ababb7]93 literal_class_t ltc;
94 union {
[074444f]95 stree_lit_bool_t lit_bool;
96 stree_lit_char_t lit_char;
[09ababb7]97 stree_lit_int_t lit_int;
[fa36f29]98 stree_lit_ref_t lit_ref;
[09ababb7]99 stree_lit_string_t lit_string;
100 } u;
101} stree_literal_t;
102
[051bc69a]103/** Reference to currently active object. */
104typedef struct {
105 /** Expression backlink */
106 struct stree_expr *expr;
107} stree_self_ref_t;
108
[09ababb7]109/** Binary operation class */
110typedef enum {
111 bo_equal,
112 bo_notequal,
113 bo_lt,
114 bo_gt,
115 bo_lt_equal,
116 bo_gt_equal,
[23de644]117 bo_plus,
118 bo_minus,
[051bc69a]119 bo_mult,
120 bo_and,
121 bo_or
[09ababb7]122} binop_class_t;
123
124/** Unary operation class */
125typedef enum {
[23de644]126 uo_plus,
127 uo_minus,
[051bc69a]128 uo_not
[09ababb7]129} unop_class_t;
130
131/** Binary operation */
132typedef struct {
[051bc69a]133 /** Expression backlink */
134 struct stree_expr *expr;
135
[09ababb7]136 /** Binary operation class */
137 binop_class_t bc;
138
139 /** Arguments */
140 struct stree_expr *arg1, *arg2;
141} stree_binop_t;
142
143/** Unary operation */
144typedef struct {
[051bc69a]145 /** Expression backlink */
146 struct stree_expr *expr;
147
[09ababb7]148 /** Operation class */
[23de644]149 unop_class_t uc;
[09ababb7]150
151 /** Argument */
152 struct stree_expr *arg;
153} stree_unop_t;
154
[fa36f29]155/** New operation */
156typedef struct {
[051bc69a]157 /** Expression backlink */
158 struct stree_expr *expr;
159
[fa36f29]160 /** Type of object to construct. */
161 struct stree_texpr *texpr;
[051bc69a]162
163 /** Constructor arguments */
164 list_t ctor_args; /* of stree_expr_t */
[fa36f29]165} stree_new_t;
166
[09ababb7]167/** Member access operation */
168typedef struct {
[051bc69a]169 /** Expression backlink */
170 struct stree_expr *expr;
171
[09ababb7]172 /** Argument */
173 struct stree_expr *arg;
174 /** Name of member being accessed. */
175 stree_ident_t *member_name;
176} stree_access_t;
177
178/** Function call operation */
179typedef struct {
[051bc69a]180 /** Expression backlink */
181 struct stree_expr *expr;
182
[09ababb7]183 /** Function */
184 struct stree_expr *fun;
185
186 /** Arguments */
187 list_t args; /* of stree_expr_t */
188} stree_call_t;
189
190typedef enum {
191 ac_set,
192 ac_increase
193} assign_class_t;
194
195/** Assignment */
196typedef struct {
[051bc69a]197 /** Expression backlink */
198 struct stree_expr *expr;
199
[09ababb7]200 assign_class_t ac;
201 struct stree_expr *dest, *src;
202} stree_assign_t;
203
[94d484a]204/** Indexing operation */
205typedef struct {
[051bc69a]206 /** Expression backlink */
207 struct stree_expr *expr;
208
[94d484a]209 /** Base */
210 struct stree_expr *base;
211
212 /** Arguments (indices) */
213 list_t args; /* of stree_expr_t */
214} stree_index_t;
215
[37f527b]216/** @c as conversion operation */
217typedef struct {
[051bc69a]218 /** Expression backlink */
219 struct stree_expr *expr;
220
[37f527b]221 /** Expression to convert */
222 struct stree_expr *arg;
[051bc69a]223
[37f527b]224 /** Destination type of conversion. */
225 struct stree_texpr *dtype;
226} stree_as_t;
227
[38aaacc2]228/** Boxing of primitive type (pseudo)
229 *
230 * This pseudo-node is used internally to box a value of primitive type.
231 * It is implicitly inserted by stype_convert(). It does not correspond
232 * to a an explicit program construct.
233 */
234typedef struct {
[051bc69a]235 /** Expression backlink */
236 struct stree_expr *expr;
237
[38aaacc2]238 /* Primitive type expression */
239 struct stree_expr *arg;
240} stree_box_t;
241
[09ababb7]242/** Arithmetic expression class */
243typedef enum {
244 ec_nameref,
245 ec_literal,
[fa36f29]246 ec_self_ref,
[09ababb7]247 ec_binop,
248 ec_unop,
[fa36f29]249 ec_new,
[09ababb7]250 ec_access,
251 ec_call,
[94d484a]252 ec_assign,
[37f527b]253 ec_index,
[38aaacc2]254 ec_as,
255 ec_box
[09ababb7]256} expr_class_t;
257
258/** Arithmetic expression */
259typedef struct stree_expr {
260 expr_class_t ec;
261
[051bc69a]262 /** Type of this expression or @c NULL if not typed yet */
[39e8406]263 struct tdata_item *titem;
264
[051bc69a]265 /** Coordinate span */
266 struct cspan *cspan;
267
[09ababb7]268 union {
269 stree_nameref_t *nameref;
270 stree_literal_t *literal;
[fa36f29]271 stree_self_ref_t *self_ref;
[09ababb7]272 stree_binop_t *binop;
273 stree_unop_t *unop;
[fa36f29]274 stree_new_t *new_op;
[09ababb7]275 stree_access_t *access;
276 stree_call_t *call;
[94d484a]277 stree_index_t *index;
[09ababb7]278 stree_assign_t *assign;
[37f527b]279 stree_as_t *as_op;
[38aaacc2]280 stree_box_t *box;
[09ababb7]281 } u;
282} stree_expr_t;
283
284/*
285 * Type expressions
286 */
287
288struct stree_texpr;
289
[fa36f29]290/** Type literal class */
291typedef enum {
[074444f]292 tlc_bool,
293 tlc_char,
[fa36f29]294 tlc_int,
[37f527b]295 tlc_resource,
[fa36f29]296 tlc_string
297} tliteral_class_t;
298
299/** Type literal */
300typedef struct {
[051bc69a]301 /** Type expression backlink */
302 struct stree_texpr *texpr;
303
[fa36f29]304 tliteral_class_t tlc;
305} stree_tliteral_t;
306
[09ababb7]307/** Type name reference */
308typedef struct {
[051bc69a]309 /** Type expression backlink */
310 struct stree_texpr *texpr;
311
[09ababb7]312 stree_ident_t *name;
313} stree_tnameref_t;
314
315/** Type member access operation */
316typedef struct {
[051bc69a]317 /** Type expression backlink */
318 struct stree_texpr *texpr;
319
[09ababb7]320 /** Argument */
321 struct stree_texpr *arg;
[051bc69a]322
[09ababb7]323 /** Name of member being accessed. */
324 stree_ident_t *member_name;
325} stree_taccess_t;
326
327/** Type application operation */
328typedef struct {
[051bc69a]329 /** Type expression backlink */
330 struct stree_texpr *texpr;
331
[074444f]332 /* Base type */
333 struct stree_texpr *gtype;
334
335 /** (Formal) type arguments */
336 list_t targs; /* of stree_texpr_t */
[09ababb7]337} stree_tapply_t;
338
[94d484a]339/** Type index operation */
340typedef struct {
[051bc69a]341 /** Type expression backlink */
342 struct stree_texpr *texpr;
343
[94d484a]344 /** Base type */
345 struct stree_texpr *base_type;
346
347 /**
348 * Number of arguments (rank). Needed when only rank is specified
349 * and @c args are not used.
350 */
351 int n_args;
352
353 /** Arguments (extents) */
354 list_t args; /* of stree_expr_t */
355} stree_tindex_t;
356
[09ababb7]357/** Type expression class */
358typedef enum {
[fa36f29]359 tc_tliteral,
[09ababb7]360 tc_tnameref,
361 tc_taccess,
[94d484a]362 tc_tapply,
363 tc_tindex
[09ababb7]364} texpr_class_t;
365
[051b3db8]366/** Type expression */
[09ababb7]367typedef struct stree_texpr {
368 texpr_class_t tc;
369
[051bc69a]370 /** Coordinate span */
371 struct cspan *cspan;
372
[09ababb7]373 union {
[fa36f29]374 stree_tliteral_t *tliteral;
[09ababb7]375 stree_tnameref_t *tnameref;
376 stree_taccess_t *taccess;
377 stree_tapply_t *tapply;
[94d484a]378 stree_tindex_t *tindex;
[09ababb7]379 } u;
380} stree_texpr_t;
381
382/*
383 * Statements, class members and module members.
384 */
385
386/** Statement block */
[d0febca]387typedef struct stree_block {
[09ababb7]388 /** List of statements in the block */
389 list_t stats; /* of stree_stat_t */
390} stree_block_t;
391
392/** Variable declaration */
393typedef struct {
394 stree_ident_t *name;
395 stree_texpr_t *type;
[051b3db8]396
397 /** Type of this variable or @c NULL if not typed yet */
398 struct tdata_item *titem;
[09ababb7]399} stree_vdecl_t;
400
[94d484a]401/** @c except clause */
402typedef struct {
403 stree_ident_t *evar;
404 stree_texpr_t *etype;
405 stree_block_t *block;
[051b3db8]406
407 /** Evaluated etype or @c NULL if not typed yet */
408 struct tdata_item *titem;
[94d484a]409} stree_except_t;
410
[051bc69a]411/** @c if or @c elif clause */
[09ababb7]412typedef struct {
413 stree_expr_t *cond;
[051bc69a]414 stree_block_t *block;
415} stree_if_clause_t;
416
417/** If statement */
418typedef struct {
419 /** If and elif clauses */
420 list_t if_clauses; /* of stree_if_clause_t */
421
422 /** Else block */
[09ababb7]423 stree_block_t *else_block;
424} stree_if_t;
425
[051b3db8]426/** @c when clause */
427typedef struct {
428 /** List of expressions -- cases -- for this clause */
429 list_t exprs; /* of stree_expr_t */
430 stree_block_t *block;
431} stree_when_t;
432
433/** Switch statement */
434typedef struct {
435 /** Switch expression */
436 stree_expr_t *expr;
437
438 /** When clauses */
439 list_t when_clauses; /* of stree_when_t */
440
441 /** Else block */
442 stree_block_t *else_block;
443} stree_switch_t;
444
[09ababb7]445/** While statement */
446typedef struct {
447 stree_expr_t *cond;
448 stree_block_t *body;
449} stree_while_t;
450
451/** For statement */
452typedef struct {
453 stree_block_t *body;
454} stree_for_t;
455
456/** Raise statement */
457typedef struct {
[94d484a]458 stree_expr_t *expr;
[09ababb7]459} stree_raise_t;
460
[051bc69a]461/** Break statement */
462typedef struct {
463} stree_break_t;
464
[fa36f29]465/** Return statement */
466typedef struct {
467 stree_expr_t *expr;
468} stree_return_t;
469
[09ababb7]470/** Expression statement */
471typedef struct {
472 stree_expr_t *expr;
473} stree_exps_t;
474
[051b3db8]475/** With-try-except-finally (WEF) statement */
[09ababb7]476typedef struct {
477 stree_block_t *with_block;
[94d484a]478 list_t except_clauses; /* of stree_except_t */
[09ababb7]479 stree_block_t *finally_block;
480} stree_wef_t;
481
482/** Statement class */
483typedef enum {
484 st_vdecl,
485 st_if,
[051b3db8]486 st_switch,
[09ababb7]487 st_while,
488 st_for,
489 st_raise,
[051bc69a]490 st_break,
[fa36f29]491 st_return,
[09ababb7]492 st_exps,
493 st_wef
494} stat_class_t;
495
496/** Statement */
497typedef struct {
498 stat_class_t sc;
499
500 union {
501 stree_vdecl_t *vdecl_s;
502 stree_if_t *if_s;
[051b3db8]503 stree_switch_t *switch_s;
[09ababb7]504 stree_while_t *while_s;
505 stree_for_t *for_s;
506 stree_raise_t *raise_s;
[051bc69a]507 stree_break_t *break_s;
[fa36f29]508 stree_return_t *return_s;
[09ababb7]509 stree_exps_t *exp_s;
510 stree_wef_t *wef_s;
511 } u;
512} stree_stat_t;
513
[94d484a]514/** Argument attribute class */
515typedef enum {
516 /** Packed argument (for variadic functions) */
517 aac_packed
518} arg_attr_class_t;
519
520/** Argument atribute */
521typedef struct {
522 arg_attr_class_t aac;
523} stree_arg_attr_t;
524
[09ababb7]525/** Formal function parameter */
526typedef struct {
527 /* Argument name */
528 stree_ident_t *name;
529
530 /* Argument type */
531 stree_texpr_t *type;
[94d484a]532
533 /* Attributes */
534 list_t attr; /* of stree_arg_attr_t */
[d0febca]535} stree_proc_arg_t;
[09ababb7]536
[38aaacc2]537/** Function signature.
538 *
[051b3db8]539 * Formal parameters and return type. This is common to function and delegate
[38aaacc2]540 * delcarations.
541 */
542typedef struct {
543 /** Formal parameters */
544 list_t args; /* of stree_proc_arg_t */
545
546 /** Variadic argument or @c NULL if none. */
547 stree_proc_arg_t *varg;
548
549 /** Return type */
550 stree_texpr_t *rtype;
551} stree_fun_sig_t;
552
[39e8406]553/** Procedure
554 *
555 * Procedure is the common term for a getter, setter or function body.
556 * A procedure can be invoked. However, the arguments are specified by
557 * the containing symbol.
558 */
559typedef struct stree_proc {
560 /** Symbol (function or property) containing the procedure */
561 struct stree_symbol *outer_symbol;
562
[37f527b]563 /** Main block for regular procedures */
[39e8406]564 stree_block_t *body;
[37f527b]565
566 /** Builtin handler for builtin procedures */
567 builtin_proc_t bi_handler;
[39e8406]568} stree_proc_t;
569
[051bc69a]570/** Constructor declaration */
571typedef struct stree_ctor {
572 /** Constructor 'name'. Points to the @c new keyword. */
573 stree_ident_t *name;
574
575 /** Symbol */
576 struct stree_symbol *symbol;
577
578 /** Signature (arguments, return type is always none) */
579 stree_fun_sig_t *sig;
580
581 /** Constructor implementation */
582 stree_proc_t *proc;
583
584 /** Type item describing the constructor */
585 struct tdata_item *titem;
586} stree_ctor_t;
587
[38aaacc2]588/** Delegate declaration */
589typedef struct stree_deleg {
590 /** Delegate name */
591 stree_ident_t *name;
592
593 /** Symbol */
594 struct stree_symbol *symbol;
595
596 /** Signature (arguments and return type) */
597 stree_fun_sig_t *sig;
598
599 /** Type item describing the delegate */
600 struct tdata_item *titem;
601} stree_deleg_t;
602
[051bc69a]603/** Enum member */
604typedef struct stree_embr {
605 /** Enum containing this declaration */
606 struct stree_enum *outer_enum;
607
608 /** Enum member name */
609 stree_ident_t *name;
610} stree_embr_t;
611
612/** Enum declaration */
613typedef struct stree_enum {
614 /** Enum name */
615 stree_ident_t *name;
616
617 /** Symbol */
618 struct stree_symbol *symbol;
619
620 /** List of enum members */
621 list_t members; /* of stree_embr_t */
622
623 /** Type item describing the enum */
624 struct tdata_item *titem;
625} stree_enum_t;
626
[09ababb7]627/** Member function declaration */
[39e8406]628typedef struct stree_fun {
[09ababb7]629 /** Function name */
630 stree_ident_t *name;
631
632 /** Symbol */
633 struct stree_symbol *symbol;
634
[38aaacc2]635 /** Signature (arguments and return type) */
636 stree_fun_sig_t *sig;
[09ababb7]637
[39e8406]638 /** Function implementation */
639 stree_proc_t *proc;
[38aaacc2]640
641 /** Type item describing the function */
642 struct tdata_item *titem;
[09ababb7]643} stree_fun_t;
644
645/** Member variable declaration */
[39e8406]646typedef struct stree_var {
[09ababb7]647 stree_ident_t *name;
648 struct stree_symbol *symbol;
649 stree_texpr_t *type;
650} stree_var_t;
651
652/** Member property declaration */
[39e8406]653typedef struct stree_prop {
[09ababb7]654 stree_ident_t *name;
655 struct stree_symbol *symbol;
656 stree_texpr_t *type;
[d0febca]657
[39e8406]658 stree_proc_t *getter;
659
660 stree_proc_t *setter;
661 stree_proc_arg_t *setter_arg;
[d0febca]662
663 /** Formal parameters (for indexed properties) */
664 list_t args; /* of stree_proc_arg_t */
665
666 /** Variadic argument or @c NULL if none. */
667 stree_proc_arg_t *varg;
[c5cb943d]668
669 /** Type of the property */
670 struct tdata_item *titem;
[09ababb7]671} stree_prop_t;
672
[d0febca]673/**
[39e8406]674 * Fake identifiers used with symbols that do not really have one.
[d0febca]675 */
[051bc69a]676#define CTOR_IDENT "$ctor"
[d0febca]677#define INDEXER_IDENT "$indexer"
678
[09ababb7]679typedef enum {
680 csimbr_csi,
[051bc69a]681 csimbr_ctor,
[38aaacc2]682 csimbr_deleg,
[051bc69a]683 csimbr_enum,
[09ababb7]684 csimbr_fun,
685 csimbr_var,
686 csimbr_prop
687} csimbr_class_t;
688
689/** Class, struct or interface member */
690typedef struct {
691 csimbr_class_t cc;
692
693 union {
694 struct stree_csi *csi;
[051bc69a]695 stree_ctor_t *ctor;
[38aaacc2]696 stree_deleg_t *deleg;
[051bc69a]697 stree_enum_t *enum_d;
[09ababb7]698 stree_fun_t *fun;
699 stree_var_t *var;
700 stree_prop_t *prop;
701 } u;
702} stree_csimbr_t;
703
704typedef enum {
705 csi_class,
706 csi_struct,
707 csi_interface
708} csi_class_t;
709
[38aaacc2]710/** CSI formal type argument */
711typedef struct stree_targ {
712 stree_ident_t *name;
713 struct stree_symbol *symbol;
714} stree_targ_t;
715
[09ababb7]716/** Class, struct or interface declaration */
717typedef struct stree_csi {
718 /** Which of class, struct or interface */
719 csi_class_t cc;
720
721 /** Name of this CSI */
722 stree_ident_t *name;
723
[38aaacc2]724 /** List of type arguments */
725 list_t targ; /* of stree_targ_t */
[074444f]726
[09ababb7]727 /** Symbol for this CSI */
728 struct stree_symbol *symbol;
729
[c5cb943d]730 /** Type expressions referencing inherited CSIs. */
731 list_t inherit; /* of stree_texpr_t */
[09ababb7]732
[94d484a]733 /** Base CSI. Only available when ancr_state == ws_visited. */
734 struct stree_csi *base_csi;
735
[c5cb943d]736 /** Types of implemented or accumulated interfaces. */
737 list_t impl_if_ti; /* of tdata_item_t */
738
[09ababb7]739 /** Node state for ancr walks. */
740 walk_state_t ancr_state;
741
742 /** List of CSI members */
743 list_t members; /* of stree_csimbr_t */
744} stree_csi_t;
745
746typedef enum {
747 /* Class, struct or interface declaration */
[051bc69a]748 mc_csi,
749 /* Enum declaration */
750 mc_enum
[09ababb7]751} modm_class_t;
752
753/** Module member */
754typedef struct {
755 modm_class_t mc;
756 union {
757 stree_csi_t *csi;
[051bc69a]758 stree_enum_t *enum_d;
[09ababb7]759 } u;
760} stree_modm_t;
761
762/** Module */
763typedef struct stree_module {
764 /** List of module members */
765 list_t members; /* of stree_modm_t */
766} stree_module_t;
767
[37f527b]768/** Symbol attribute class */
769typedef enum {
770 /** Builtin symbol (interpreter hook) */
[c5cb943d]771 sac_builtin,
772
773 /** Static symbol */
774 sac_static
[37f527b]775} symbol_attr_class_t;
776
777/** Symbol atribute */
778typedef struct {
779 symbol_attr_class_t sac;
780} stree_symbol_attr_t;
781
[09ababb7]782typedef enum {
[38aaacc2]783 /** CSI (class, struct or interface) */
[09ababb7]784 sc_csi,
[051bc69a]785 /** Constructor */
786 sc_ctor,
[38aaacc2]787 /** Member delegate */
788 sc_deleg,
[051bc69a]789 /** Enum */
790 sc_enum,
[38aaacc2]791 /** Member function */
[09ababb7]792 sc_fun,
[38aaacc2]793 /** Member variable */
[09ababb7]794 sc_var,
[38aaacc2]795 /** Member property */
[09ababb7]796 sc_prop
797} symbol_class_t;
798
[39e8406]799/** Symbol
800 *
801 * A symbol is a common superclass of different program elements that
802 * allow us to refer to them, print their fully qualified names, etc.
803 */
[09ababb7]804typedef struct stree_symbol {
805 symbol_class_t sc;
806
807 union {
808 struct stree_csi *csi;
[051bc69a]809 stree_ctor_t *ctor;
[38aaacc2]810 stree_deleg_t *deleg;
[051bc69a]811 stree_enum_t *enum_d;
[09ababb7]812 stree_fun_t *fun;
813 stree_var_t *var;
814 stree_prop_t *prop;
815 } u;
816
[051b3db8]817 /** Containing CSI */
[09ababb7]818 stree_csi_t *outer_csi;
819
[051b3db8]820 /** Symbol attributes */
[37f527b]821 list_t attr; /* of stree_symbol_attr_t */
[09ababb7]822} stree_symbol_t;
823
824/** Program */
825typedef struct stree_program {
826 /** The one and only module in the program */
827 stree_module_t *module;
[37f527b]828
829 /** Builtin symbols binding. */
830 struct builtin *builtin;
[09ababb7]831} stree_program_t;
832
833#endif
Note: See TracBrowser for help on using the repository browser.