stree.c

00001 /*
00002  * Copyright (c) 2011 Jiri Svoboda
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <assert.h>
00034 #include "list.h"
00035 #include "mytypes.h"
00036 
00037 #include "stree.h"
00038 
00043 stree_module_t *stree_module_new(void)
00044 {
00045         stree_module_t *module;
00046 
00047         module = calloc(1, sizeof(stree_module_t));
00048         if (module == NULL) {
00049                 printf("Memory allocation failed.\n");
00050                 exit(1);
00051         }
00052 
00053         list_init(&module->members);
00054         return module;
00055 }
00056 
00062 stree_modm_t *stree_modm_new(modm_class_t mc)
00063 {
00064         stree_modm_t *modm;
00065 
00066         modm = calloc(1, sizeof(stree_modm_t));
00067         if (modm == NULL) {
00068                 printf("Memory allocation failed.\n");
00069                 exit(1);
00070         }
00071 
00072         modm->mc = mc;
00073         return modm;
00074 }
00075 
00081 stree_csi_t *stree_csi_new(csi_class_t cc)
00082 {
00083         stree_csi_t *csi;
00084 
00085         csi = calloc(1, sizeof(stree_csi_t));
00086         if (csi == NULL) {
00087                 printf("Memory allocation failed.\n");
00088                 exit(1);
00089         }
00090 
00091         csi->cc = cc;
00092         csi->ancr_state = ws_unvisited;
00093         csi->name = NULL;
00094         csi->base_csi = NULL;
00095         list_init(&csi->inherit);
00096         list_init(&csi->impl_if_ti);
00097         list_init(&csi->members);
00098 
00099         return csi;
00100 }
00101 
00107 stree_csimbr_t *stree_csimbr_new(csimbr_class_t cc)
00108 {
00109         stree_csimbr_t *csimbr;
00110 
00111         csimbr = calloc(1, sizeof(stree_csimbr_t));
00112         if (csimbr == NULL) {
00113                 printf("Memory allocation failed.\n");
00114                 exit(1);
00115         }
00116 
00117         csimbr->cc = cc;
00118         return csimbr;
00119 }
00120 
00125 stree_ctor_t *stree_ctor_new(void)
00126 {
00127         stree_ctor_t *ctor;
00128 
00129         ctor = calloc(1, sizeof(stree_ctor_t));
00130         if (ctor == NULL) {
00131                 printf("Memory allocation failed.\n");
00132                 exit(1);
00133         }
00134 
00135         return ctor;
00136 }
00137 
00142 stree_deleg_t *stree_deleg_new(void)
00143 {
00144         stree_deleg_t *deleg;
00145 
00146         deleg = calloc(1, sizeof(stree_deleg_t));
00147         if (deleg == NULL) {
00148                 printf("Memory allocation failed.\n");
00149                 exit(1);
00150         }
00151 
00152         return deleg;
00153 }
00154 
00159 stree_enum_t *stree_enum_new(void)
00160 {
00161         stree_enum_t *enum_d;
00162 
00163         enum_d = calloc(1, sizeof(stree_enum_t));
00164         if (enum_d == NULL) {
00165                 printf("Memory allocation failed.\n");
00166                 exit(1);
00167         }
00168 
00169         return enum_d;
00170 }
00171 
00176 stree_embr_t *stree_embr_new(void)
00177 {
00178         stree_embr_t *embr;
00179 
00180         embr = calloc(1, sizeof(stree_embr_t));
00181         if (embr == NULL) {
00182                 printf("Memory allocation failed.\n");
00183                 exit(1);
00184         }
00185 
00186         return embr;
00187 }
00188 
00193 stree_fun_t *stree_fun_new(void)
00194 {
00195         stree_fun_t *fun;
00196 
00197         fun = calloc(1, sizeof(stree_fun_t));
00198         if (fun == NULL) {
00199                 printf("Memory allocation failed.\n");
00200                 exit(1);
00201         }
00202 
00203         return fun;
00204 }
00205 
00210 stree_var_t *stree_var_new(void)
00211 {
00212         stree_var_t *var;
00213 
00214         var = calloc(1, sizeof(stree_var_t));
00215         if (var == NULL) {
00216                 printf("Memory allocation failed.\n");
00217                 exit(1);
00218         }
00219 
00220         return var;
00221 }
00222 
00227 stree_prop_t *stree_prop_new(void)
00228 {
00229         stree_prop_t *prop;
00230 
00231         prop = calloc(1, sizeof(stree_prop_t));
00232         if (prop == NULL) {
00233                 printf("Memory allocation failed.\n");
00234                 exit(1);
00235         }
00236 
00237         return prop;
00238 }
00239 
00244 stree_targ_t *stree_targ_new(void)
00245 {
00246         stree_targ_t *targ;
00247 
00248         targ = calloc(1, sizeof(stree_targ_t));
00249         if (targ == NULL) {
00250                 printf("Memory allocation failed.\n");
00251                 exit(1);
00252         }
00253 
00254         return targ;
00255 }
00256 
00262 stree_symbol_attr_t *stree_symbol_attr_new(symbol_attr_class_t sac)
00263 {
00264         stree_symbol_attr_t *symbol_attr;
00265 
00266         symbol_attr = calloc(1, sizeof(stree_symbol_attr_t));
00267         if (symbol_attr == NULL) {
00268                 printf("Memory allocation failed.\n");
00269                 exit(1);
00270         }
00271 
00272         symbol_attr->sac = sac;
00273         return symbol_attr;
00274 }
00275 
00280 stree_proc_t *stree_proc_new(void)
00281 {
00282         stree_proc_t *proc;
00283 
00284         proc = calloc(1, sizeof(stree_proc_t));
00285         if (proc == NULL) {
00286                 printf("Memory allocation failed.\n");
00287                 exit(1);
00288         }
00289 
00290         return proc;
00291 }
00292 
00297 stree_proc_arg_t *stree_proc_arg_new(void)
00298 {
00299         stree_proc_arg_t *proc_arg;
00300 
00301         proc_arg = calloc(1, sizeof(stree_proc_arg_t));
00302         if (proc_arg == NULL) {
00303                 printf("Memory allocation failed.\n");
00304                 exit(1);
00305         }
00306 
00307         return proc_arg;
00308 }
00309 
00314 stree_fun_sig_t *stree_fun_sig_new(void)
00315 {
00316         stree_fun_sig_t *fun_sig;
00317 
00318         fun_sig = calloc(1, sizeof(stree_fun_sig_t));
00319         if (fun_sig == NULL) {
00320                 printf("Memory allocation failed.\n");
00321                 exit(1);
00322         }
00323 
00324         return fun_sig;
00325 }
00326 
00332 stree_arg_attr_t *stree_arg_attr_new(arg_attr_class_t aac)
00333 {
00334         stree_arg_attr_t *arg_attr;
00335 
00336         arg_attr = calloc(1, sizeof(stree_arg_attr_t));
00337         if (arg_attr == NULL) {
00338                 printf("Memory allocation failed.\n");
00339                 exit(1);
00340         }
00341 
00342         arg_attr->aac = aac;
00343         return arg_attr;
00344 }
00345 
00351 stree_stat_t *stree_stat_new(stat_class_t sc)
00352 {
00353         stree_stat_t *stat;
00354 
00355         stat = calloc(1, sizeof(stree_stat_t));
00356         if (stat == NULL) {
00357                 printf("Memory allocation failed.\n");
00358                 exit(1);
00359         }
00360 
00361         stat->sc = sc;
00362         return stat;
00363 }
00364 
00369 stree_vdecl_t *stree_vdecl_new(void)
00370 {
00371         stree_vdecl_t *vdecl_s;
00372 
00373         vdecl_s = calloc(1, sizeof(stree_vdecl_t));
00374         if (vdecl_s == NULL) {
00375                 printf("Memory allocation failed.\n");
00376                 exit(1);
00377         }
00378 
00379         return vdecl_s;
00380 }
00381 
00386 stree_if_t *stree_if_new(void)
00387 {
00388         stree_if_t *if_s;
00389 
00390         if_s = calloc(1, sizeof(stree_if_t));
00391         if (if_s == NULL) {
00392                 printf("Memory allocation failed.\n");
00393                 exit(1);
00394         }
00395 
00396         return if_s;
00397 }
00398 
00403 stree_switch_t *stree_switch_new(void)
00404 {
00405         stree_switch_t *switch_s;
00406 
00407         switch_s = calloc(1, sizeof(stree_switch_t));
00408         if (switch_s == NULL) {
00409                 printf("Memory allocation failed.\n");
00410                 exit(1);
00411         }
00412 
00413         return switch_s;
00414 }
00415 
00420 stree_while_t *stree_while_new(void)
00421 {
00422         stree_while_t *while_s;
00423 
00424         while_s = calloc(1, sizeof(stree_while_t));
00425         if (while_s == NULL) {
00426                 printf("Memory allocation failed.\n");
00427                 exit(1);
00428         }
00429 
00430         return while_s;
00431 }
00432 
00437 stree_for_t *stree_for_new(void)
00438 {
00439         stree_for_t *for_s;
00440 
00441         for_s = calloc(1, sizeof(stree_for_t));
00442         if (for_s == NULL) {
00443                 printf("Memory allocation failed.\n");
00444                 exit(1);
00445         }
00446 
00447         return for_s;
00448 }
00449 
00454 stree_raise_t *stree_raise_new(void)
00455 {
00456         stree_raise_t *raise_s;
00457 
00458         raise_s = calloc(1, sizeof(stree_raise_t));
00459         if (raise_s == NULL) {
00460                 printf("Memory allocation failed.\n");
00461                 exit(1);
00462         }
00463 
00464         return raise_s;
00465 }
00466 
00471 stree_break_t *stree_break_new(void)
00472 {
00473         stree_break_t *break_s;
00474 
00475         break_s = calloc(1, sizeof(stree_break_t));
00476         if (break_s == NULL) {
00477                 printf("Memory allocation failed.\n");
00478                 exit(1);
00479         }
00480 
00481         return break_s;
00482 }
00483 
00488 stree_return_t *stree_return_new(void)
00489 {
00490         stree_return_t *return_s;
00491 
00492         return_s = calloc(1, sizeof(stree_return_t));
00493         if (return_s == NULL) {
00494                 printf("Memory allocation failed.\n");
00495                 exit(1);
00496         }
00497 
00498         return return_s;
00499 }
00500 
00505 stree_wef_t *stree_wef_new(void)
00506 {
00507         stree_wef_t *wef_s;
00508 
00509         wef_s = calloc(1, sizeof(stree_wef_t));
00510         if (wef_s == NULL) {
00511                 printf("Memory allocation failed.\n");
00512                 exit(1);
00513         }
00514 
00515         return wef_s;
00516 }
00517 
00522 stree_exps_t *stree_exps_new(void)
00523 {
00524         stree_exps_t *exp_s;
00525 
00526         exp_s = calloc(1, sizeof(stree_exps_t));
00527         if (exp_s == NULL) {
00528                 printf("Memory allocation failed.\n");
00529                 exit(1);
00530         }
00531 
00532         return exp_s;
00533 }
00534 
00539 stree_except_t *stree_except_new(void)
00540 {
00541         stree_except_t *except_c;
00542 
00543         except_c = calloc(1, sizeof(stree_except_t));
00544         if (except_c == NULL) {
00545                 printf("Memory allocation failed.\n");
00546                 exit(1);
00547         }
00548 
00549         return except_c;
00550 }
00551 
00556 stree_if_clause_t *stree_if_clause_new(void)
00557 {
00558         stree_if_clause_t *if_clause;
00559 
00560         if_clause = calloc(1, sizeof(stree_if_clause_t));
00561         if (if_clause == NULL) {
00562                 printf("Memory allocation failed.\n");
00563                 exit(1);
00564         }
00565 
00566         return if_clause;
00567 }
00568 
00573 stree_when_t *stree_when_new(void)
00574 {
00575         stree_when_t *when_c;
00576 
00577         when_c = calloc(1, sizeof(stree_when_t));
00578         if (when_c == NULL) {
00579                 printf("Memory allocation failed.\n");
00580                 exit(1);
00581         }
00582 
00583         return when_c;
00584 }
00585 
00590 stree_block_t *stree_block_new(void)
00591 {
00592         stree_block_t *block;
00593 
00594         block = calloc(1, sizeof(stree_block_t));
00595         if (block == NULL) {
00596                 printf("Memory allocation failed.\n");
00597                 exit(1);
00598         }
00599 
00600         return block;
00601 }
00602 
00608 stree_expr_t *stree_expr_new(expr_class_t ec)
00609 {
00610         stree_expr_t *expr;
00611 
00612         expr = calloc(1, sizeof(stree_expr_t));
00613         if (expr == NULL) {
00614                 printf("Memory allocation failed.\n");
00615                 exit(1);
00616         }
00617 
00618         expr->ec = ec;
00619         return expr;
00620 }
00621 
00627 stree_assign_t *stree_assign_new(assign_class_t ac)
00628 {
00629         stree_assign_t *assign;
00630 
00631         assign = calloc(1, sizeof(stree_assign_t));
00632         if (assign == NULL) {
00633                 printf("Memory allocation failed.\n");
00634                 exit(1);
00635         }
00636 
00637         assign->ac = ac;
00638         return assign;
00639 }
00640 
00645 stree_binop_t *stree_binop_new(binop_class_t bc)
00646 {
00647         stree_binop_t *binop;
00648 
00649         binop = calloc(1, sizeof(stree_binop_t));
00650         if (binop == NULL) {
00651                 printf("Memory allocation failed.\n");
00652                 exit(1);
00653         }
00654 
00655         binop->bc = bc;
00656         return binop;
00657 }
00658 
00664 stree_unop_t *stree_unop_new(unop_class_t uc)
00665 {
00666         stree_unop_t *unop;
00667 
00668         unop = calloc(1, sizeof(stree_unop_t));
00669         if (unop == NULL) {
00670                 printf("Memory allocation failed.\n");
00671                 exit(1);
00672         }
00673 
00674         unop->uc = uc;
00675         return unop;
00676 }
00677 
00682 stree_new_t *stree_new_new(void)
00683 {
00684         stree_new_t *new_op;
00685 
00686         new_op = calloc(1, sizeof(stree_new_t));
00687         if (new_op == NULL) {
00688                 printf("Memory allocation failed.\n");
00689                 exit(1);
00690         }
00691 
00692         return new_op;
00693 }
00694 
00699 stree_access_t *stree_access_new(void)
00700 {
00701         stree_access_t *access;
00702 
00703         access = calloc(1, sizeof(stree_access_t));
00704         if (access == NULL) {
00705                 printf("Memory allocation failed.\n");
00706                 exit(1);
00707         }
00708 
00709         return access;
00710 }
00711 
00716 stree_call_t *stree_call_new(void)
00717 {
00718         stree_call_t *call;
00719 
00720         call = calloc(1, sizeof(stree_call_t));
00721         if (call == NULL) {
00722                 printf("Memory allocation failed.\n");
00723                 exit(1);
00724         }
00725 
00726         return call;
00727 }
00728 
00733 stree_index_t *stree_index_new(void)
00734 {
00735         stree_index_t *index;
00736 
00737         index = calloc(1, sizeof(stree_index_t));
00738         if (index == NULL) {
00739                 printf("Memory allocation failed.\n");
00740                 exit(1);
00741         }
00742 
00743         return index;
00744 }
00745 
00750 stree_as_t *stree_as_new(void)
00751 {
00752         stree_as_t *as_expr;
00753 
00754         as_expr = calloc(1, sizeof(stree_as_t));
00755         if (as_expr == NULL) {
00756                 printf("Memory allocation failed.\n");
00757                 exit(1);
00758         }
00759 
00760         return as_expr;
00761 }
00762 
00767 stree_box_t *stree_box_new(void)
00768 {
00769         stree_box_t *box_expr;
00770 
00771         box_expr = calloc(1, sizeof(stree_box_t));
00772         if (box_expr == NULL) {
00773                 printf("Memory allocation failed.\n");
00774                 exit(1);
00775         }
00776 
00777         return box_expr;
00778 }
00779 
00784 stree_nameref_t *stree_nameref_new(void)
00785 {
00786         stree_nameref_t *nameref;
00787 
00788         nameref = calloc(1, sizeof(stree_nameref_t));
00789         if (nameref == NULL) {
00790                 printf("Memory allocation failed.\n");
00791                 exit(1);
00792         }
00793 
00794         return nameref;
00795 }
00796 
00801 stree_ident_t *stree_ident_new(void)
00802 {
00803         stree_ident_t *ident;
00804 
00805         ident = calloc(1, sizeof(stree_ident_t));
00806         if (ident == NULL) {
00807                 printf("Memory allocation failed.\n");
00808                 exit(1);
00809         }
00810 
00811         return ident;
00812 }
00813 
00819 stree_literal_t *stree_literal_new(literal_class_t ltc)
00820 {
00821         stree_literal_t *literal;
00822 
00823         literal = calloc(1, sizeof(stree_literal_t));
00824         if (literal == NULL) {
00825                 printf("Memory allocation failed.\n");
00826                 exit(1);
00827         }
00828 
00829         literal->ltc = ltc;
00830         return literal;
00831 }
00832 
00837 stree_self_ref_t *stree_self_ref_new(void)
00838 {
00839         stree_self_ref_t *self_ref;
00840 
00841         self_ref = calloc(1, sizeof(stree_self_ref_t));
00842         if (self_ref == NULL) {
00843                 printf("Memory allocation failed.\n");
00844                 exit(1);
00845         }
00846 
00847         return self_ref;
00848 }
00849 
00854 stree_texpr_t *stree_texpr_new(texpr_class_t tc)
00855 {
00856         stree_texpr_t *texpr;
00857 
00858         texpr = calloc(1, sizeof(stree_texpr_t));
00859         if (texpr == NULL) {
00860                 printf("Memory allocation failed.\n");
00861                 exit(1);
00862         }
00863 
00864         texpr->tc = tc;
00865         return texpr;
00866 }
00867 
00872 stree_taccess_t *stree_taccess_new(void)
00873 {
00874         stree_taccess_t *taccess;
00875 
00876         taccess = calloc(1, sizeof(stree_taccess_t));
00877         if (taccess == NULL) {
00878                 printf("Memory allocation failed.\n");
00879                 exit(1);
00880         }
00881 
00882         return taccess;
00883 }
00884 
00889 stree_tapply_t *stree_tapply_new(void)
00890 {
00891         stree_tapply_t *tapply;
00892 
00893         tapply = calloc(1, sizeof(stree_tapply_t));
00894         if (tapply == NULL) {
00895                 printf("Memory allocation failed.\n");
00896                 exit(1);
00897         }
00898 
00899         return tapply;
00900 }
00901 
00906 stree_tindex_t *stree_tindex_new(void)
00907 {
00908         stree_tindex_t *tindex;
00909 
00910         tindex = calloc(1, sizeof(stree_tindex_t));
00911         if (tindex == NULL) {
00912                 printf("Memory allocation failed.\n");
00913                 exit(1);
00914         }
00915 
00916         return tindex;
00917 }
00918 
00923 stree_tliteral_t *stree_tliteral_new(tliteral_class_t tlc)
00924 {
00925         stree_tliteral_t *tliteral;
00926 
00927         tliteral = calloc(1, sizeof(stree_tliteral_t));
00928         if (tliteral == NULL) {
00929                 printf("Memory allocation failed.\n");
00930                 exit(1);
00931         }
00932 
00933         tliteral->tlc = tlc;
00934         return tliteral;
00935 }
00936 
00941 stree_tnameref_t *stree_tnameref_new(void)
00942 {
00943         stree_tnameref_t *tnameref;
00944 
00945         tnameref = calloc(1, sizeof(stree_tnameref_t));
00946         if (tnameref == NULL) {
00947                 printf("Memory allocation failed.\n");
00948                 exit(1);
00949         }
00950 
00951         return tnameref;
00952 }
00953 
00958 stree_symbol_t *stree_symbol_new(symbol_class_t sc)
00959 {
00960         stree_symbol_t *symbol;
00961 
00962         symbol = calloc(1, sizeof(stree_symbol_t));
00963         if (symbol == NULL) {
00964                 printf("Memory allocation failed.\n");
00965                 exit(1);
00966         }
00967 
00968         symbol->sc = sc;
00969         list_init(&symbol->attr);
00970 
00971         return symbol;
00972 }
00973 
00978 stree_program_t *stree_program_new(void)
00979 {
00980         stree_program_t *program;
00981 
00982         program = calloc(1, sizeof(stree_program_t));
00983         if (program == NULL) {
00984                 printf("Memory allocation failed.\n");
00985                 exit(1);
00986         }
00987 
00988         return program;
00989 }
00990 
00997 bool_t stree_symbol_has_attr(stree_symbol_t *symbol, symbol_attr_class_t sac)
00998 {
00999         list_node_t *node;
01000         stree_symbol_attr_t *attr;
01001 
01002         node = list_first(&symbol->attr);
01003         while (node != NULL) {
01004                 attr = list_node_data(node, stree_symbol_attr_t *);
01005                 if (attr->sac == sac)
01006                         return b_true;
01007 
01008                 node = list_next(&symbol->attr, node);
01009         }
01010 
01011         return b_false;
01012 }
01013 
01020 bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac)
01021 {
01022         list_node_t *node;
01023         stree_arg_attr_t *attr;
01024 
01025         node = list_first(&arg->attr);
01026         while (node != NULL) {
01027                 attr = list_node_data(node, stree_arg_attr_t *);
01028                 if (attr->aac == aac)
01029                         return b_true;
01030 
01031                 node = list_next(&arg->attr, node);
01032         }
01033 
01034         return b_false;
01035 }
01036 
01046 bool_t stree_is_csi_derived_from_csi(stree_csi_t *a, stree_csi_t *b)
01047 {
01048         stree_csi_t *csi;
01049 
01050         csi = a;
01051         while (csi != NULL) {
01052                 if (csi == b)
01053                         return b_true;
01054 
01055                 csi = csi->base_csi;
01056         }
01057 
01058         /* We went all the way to the root and did not find b. */
01059         return b_false;
01060 }
01061 
01067 bool_t stree_symbol_is_static(stree_symbol_t *symbol)
01068 {
01069         /* Module-wide symbols are static. */
01070         if (symbol->outer_csi == NULL)
01071                 return b_true;
01072 
01073         /* Symbols with @c static attribute are static. */
01074         if (stree_symbol_has_attr(symbol, sac_static))
01075                 return b_true;
01076 
01077         switch (symbol->sc) {
01078         case sc_csi:
01079         case sc_deleg:
01080         case sc_enum:
01081                 return b_true;
01082         case sc_ctor:
01083         case sc_fun:
01084         case sc_var:
01085         case sc_prop:
01086                 break;
01087         }
01088 
01089         return b_false;
01090 }
01091 
01098 stree_targ_t *stree_csi_find_targ(stree_csi_t *csi, stree_ident_t *ident)
01099 {
01100         list_node_t *targ_n;
01101         stree_targ_t *targ;
01102 
01103         targ_n = list_first(&csi->targ);
01104         while (targ_n != NULL) {
01105                 targ = list_node_data(targ_n, stree_targ_t *);
01106                 if (targ->name->sid == ident->sid)
01107                         return targ;
01108 
01109                 targ_n = list_next(&csi->targ, targ_n);
01110         }
01111 
01112         /* No match */
01113         return NULL;
01114 }
01115 
01122 stree_embr_t *stree_enum_find_mbr(stree_enum_t *enum_d, stree_ident_t *ident)
01123 {
01124         list_node_t *embr_n;
01125         stree_embr_t *embr;
01126 
01127         embr_n = list_first(&enum_d->members);
01128         while (embr_n != NULL) {
01129                 embr = list_node_data(embr_n, stree_embr_t *);
01130                 if (embr->name->sid == ident->sid)
01131                         return embr;
01132 
01133                 embr_n = list_next(&enum_d->members, embr_n);
01134         }
01135 
01136         /* No match */
01137         return NULL;
01138 }
01139 
01145 stree_ident_t *stree_csimbr_get_name(stree_csimbr_t *csimbr)
01146 {
01147         stree_ident_t *mbr_name;
01148 
01149         /* Keep compiler happy. */
01150         mbr_name = NULL;
01151 
01152         switch (csimbr->cc) {
01153         case csimbr_csi: mbr_name = csimbr->u.csi->name; break;
01154         case csimbr_ctor: mbr_name = csimbr->u.ctor->name; break;
01155         case csimbr_deleg: mbr_name = csimbr->u.deleg->name; break;
01156         case csimbr_enum: mbr_name = csimbr->u.enum_d->name; break;
01157         case csimbr_fun: mbr_name = csimbr->u.fun->name; break;
01158         case csimbr_var: mbr_name = csimbr->u.var->name; break;
01159         case csimbr_prop: mbr_name = csimbr->u.prop->name; break;
01160         }
01161 
01162         return mbr_name;
01163 }

Generated on Thu Jun 2 07:45:42 2011 for HelenOS/USB by  doxygen 1.4.7