Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/stree.c

    r38aaacc2 r23de644  
    3737#include "stree.h"
    3838
    39 /** Allocate new module.
    40  *
    41  * @return      New module
    42  */
    4339stree_module_t *stree_module_new(void)
    4440{
     
    5551}
    5652
    57 /** Allocate new module member.
    58  *
    59  * @param mc    Module member class
    60  * @return      New module member
    61  */
    6253stree_modm_t *stree_modm_new(modm_class_t mc)
    6354{
     
    7465}
    7566
    76 /** Allocate new CSI.
    77  *
    78  * @param cc    CSI class
    79  * @return      New CSI
    80  */
    8167stree_csi_t *stree_csi_new(csi_class_t cc)
    8268{
     
    9783}
    9884
    99 /** Allocate new CSI member.
    100  *
    101  * @param cc    CSI member class
    102  * @return      New CSI member
    103  */
    10485stree_csimbr_t *stree_csimbr_new(csimbr_class_t cc)
    10586{
     
    11697}
    11798
    118 /** Allocate new member delegate.
    119  *
    120  * @return      New member delegate
    121  */
    122 stree_deleg_t *stree_deleg_new(void)
    123 {
    124         stree_deleg_t *deleg;
    125 
    126         deleg = calloc(1, sizeof(stree_deleg_t));
    127         if (deleg == NULL) {
    128                 printf("Memory allocation failed.\n");
    129                 exit(1);
    130         }
    131 
    132         return deleg;
    133 }
    134 
    135 /** Allocate new member function.
    136  *
    137  * @return      New member function
    138  */
    13999stree_fun_t *stree_fun_new(void)
    140100{
     
    150110}
    151111
    152 /** Allocate new member variable.
    153  *
    154  * @return      New member variable
    155  */
    156112stree_var_t *stree_var_new(void)
    157113{
     
    167123}
    168124
    169 /** Allocate new property.
    170  *
    171  * @return      New property
    172  */
    173125stree_prop_t *stree_prop_new(void)
    174126{
     
    184136}
    185137
    186 /** Allocate new type argument.
    187  *
    188  * @return      New type argument
    189  */
    190 stree_targ_t *stree_targ_new(void)
    191 {
    192         stree_targ_t *targ;
    193 
    194         targ = calloc(1, sizeof(stree_targ_t));
    195         if (targ == NULL) {
    196                 printf("Memory allocation failed.\n");
    197                 exit(1);
    198         }
    199 
    200         return targ;
    201 }
    202 
    203 /** Allocate new symbol attribute.
    204  *
    205  * @param sac   Symbol attribute class
    206  * @return      New symbol attribute
    207  */
    208138stree_symbol_attr_t *stree_symbol_attr_new(symbol_attr_class_t sac)
    209139{
     
    220150}
    221151
    222 /** Allocate new procedure.
    223  *
    224  * @return      New procedure
    225  */
    226152stree_proc_t *stree_proc_new(void)
    227153{
     
    237163}
    238164
    239 /** Allocate new procedure argument.
    240  *
    241  * @return      New procedure argument
    242  */
    243165stree_proc_arg_t *stree_proc_arg_new(void)
    244166{
     
    254176}
    255177
    256 /** Allocate new function signature.
    257  *
    258  * @return      New procedure argument
    259  */
    260 stree_fun_sig_t *stree_fun_sig_new(void)
    261 {
    262         stree_fun_sig_t *fun_sig;
    263 
    264         fun_sig = calloc(1, sizeof(stree_fun_sig_t));
    265         if (fun_sig == NULL) {
    266                 printf("Memory allocation failed.\n");
    267                 exit(1);
    268         }
    269 
    270         return fun_sig;
    271 }
    272 
    273 /** Allocate new procedure argument attribute.
    274  *
    275  * @param       Argument attribute class
    276  * @return      New procedure argument attribute
    277  */
    278178stree_arg_attr_t *stree_arg_attr_new(arg_attr_class_t aac)
    279179{
     
    290190}
    291191
    292 /** Allocate new statement.
    293  *
    294  * @param sc    Statement class
    295  * @return      New statement
    296  */
    297192stree_stat_t *stree_stat_new(stat_class_t sc)
    298193{
     
    309204}
    310205
    311 /** Allocate new local variable declaration.
    312  *
    313  * @return      New local variable declaration
    314  */
    315206stree_vdecl_t *stree_vdecl_new(void)
    316207{
     
    326217}
    327218
    328 /** Allocate new @c if statement.
    329  *
    330  * @return      New @c if statement
    331  */
    332219stree_if_t *stree_if_new(void)
    333220{
     
    343230}
    344231
    345 /** Allocate new @c while statement.
    346  *
    347  * @return      New @c while statement
    348  */
    349232stree_while_t *stree_while_new(void)
    350233{
     
    360243}
    361244
    362 /** Allocate new @c for statement.
    363  *
    364  * @return      New @c for statement
    365  */
    366245stree_for_t *stree_for_new(void)
    367246{
     
    377256}
    378257
    379 /** Allocate new @c raise statement.
    380  *
    381  * @return      New @c raise statement
    382  */
    383258stree_raise_t *stree_raise_new(void)
    384259{
     
    394269}
    395270
    396 /** Allocate new @c return statement.
    397  *
    398  * @return      New @c return statement
    399  */
    400271stree_return_t *stree_return_new(void)
    401272{
     
    411282}
    412283
    413 /** Allocate new with-except-finally statement.
    414  *
    415  * @return      New with-except-finally statement.
    416  */
    417284stree_wef_t *stree_wef_new(void)
    418285{
     
    428295}
    429296
    430 /** Allocate new expression statement.
    431  *
    432  * @return      New expression statement
    433  */
    434297stree_exps_t *stree_exps_new(void)
    435298{
     
    445308}
    446309
    447 /** Allocate new @c except clause.
    448  *
    449  * @return      New @c except clause
    450  */
    451310stree_except_t *stree_except_new(void)
    452311{
     
    462321}
    463322
    464 /** Allocate new statement block.
    465  *
    466  * @return      New statement block
    467  */
    468323stree_block_t *stree_block_new(void)
    469324{
     
    479334}
    480335
    481 /** Allocate new expression.
    482  *
    483  * @param ec    Expression class
    484  * @return      New expression
    485  */
    486336stree_expr_t *stree_expr_new(expr_class_t ec)
    487337{
     
    498348}
    499349
    500 /** Allocate new assignment.
    501  *
    502  * @param ac    Assignment class
    503  * @return      New assignment
    504  */
    505350stree_assign_t *stree_assign_new(assign_class_t ac)
    506351{
     
    517362}
    518363
    519 /** Allocate new binary operation.
    520  *
    521  * @return      New binary operation
    522  */
    523364stree_binop_t *stree_binop_new(binop_class_t bc)
    524365{
     
    535376}
    536377
    537 /** Allocate new unary operation.
    538  *
    539  * @param uc    Unary operation class
    540  * @return      New unary operation
    541  */
    542378stree_unop_t *stree_unop_new(unop_class_t uc)
    543379{
     
    554390}
    555391
    556 /** Allocate new @c new operation.
    557  *
    558  * @return      New @c new operation
    559  */
    560392stree_new_t *stree_new_new(void)
    561393{
     
    571403}
    572404
    573 /** Allocate new .
    574  *
    575  * @return      New
    576  */
    577405stree_access_t *stree_access_new(void)
    578406{
     
    588416}
    589417
    590 /** Allocate new function call operation.
    591  *
    592  * @return      New function call operation
    593  */
    594418stree_call_t *stree_call_new(void)
    595419{
     
    605429}
    606430
    607 /** Allocate new indexing operation.
    608  *
    609  * @return      New indexing operation
    610  */
    611431stree_index_t *stree_index_new(void)
    612432{
     
    622442}
    623443
    624 /** Allocate new as conversion.
    625  *
    626  * @return      New as conversion
    627  */
    628444stree_as_t *stree_as_new(void)
    629445{
     
    639455}
    640456
    641 /** Allocate new boxing operation.
    642  *
    643  * @return      New boxing operation
    644  */
    645 stree_box_t *stree_box_new(void)
    646 {
    647         stree_box_t *box_expr;
    648 
    649         box_expr = calloc(1, sizeof(stree_box_t));
    650         if (box_expr == NULL) {
    651                 printf("Memory allocation failed.\n");
    652                 exit(1);
    653         }
    654 
    655         return box_expr;
    656 }
    657 
    658 /** Allocate new name reference operation.
    659  *
    660  * @return      New name reference operation
    661  */
    662457stree_nameref_t *stree_nameref_new(void)
    663458{
     
    673468}
    674469
    675 /** Allocate new identifier.
    676  *
    677  * @return      New identifier
    678  */
    679470stree_ident_t *stree_ident_new(void)
    680471{
     
    690481}
    691482
    692 /** Allocate new literal.
    693  *
    694  * @param ltc   Literal class
    695  * @return      New literal
    696  */
    697483stree_literal_t *stree_literal_new(literal_class_t ltc)
    698484{
     
    709495}
    710496
    711 /** Allocate new @c self reference.
    712  *
    713  * @return      New @c self reference
    714  */
    715497stree_self_ref_t *stree_self_ref_new(void)
    716498{
     
    726508}
    727509
    728 /** Allocate new type expression
    729  *
    730  * @return      New type expression
    731  */
    732510stree_texpr_t *stree_texpr_new(texpr_class_t tc)
    733511{
     
    744522}
    745523
    746 /** Allocate new type access operation.
    747  *
    748  * @return      New type access operation
    749  */
    750524stree_taccess_t *stree_taccess_new(void)
    751525{
     
    761535}
    762536
    763 /** Allocate new type application operation.
    764  *
    765  * @return      New type application operation
    766  */
    767537stree_tapply_t *stree_tapply_new(void)
    768538{
     
    778548}
    779549
    780 /** Allocate new type indexing operation.
    781  *
    782  * @return      New type indexing operation
    783  */
    784550stree_tindex_t *stree_tindex_new(void)
    785551{
     
    795561}
    796562
    797 /** Allocate new type literal.
    798  *
    799  * @return      New type literal
    800  */
    801563stree_tliteral_t *stree_tliteral_new(tliteral_class_t tlc)
    802564{
     
    813575}
    814576
    815 /** Allocate new type name reference.
    816  *
    817  * @return      New type name reference
    818  */
    819577stree_tnameref_t *stree_tnameref_new(void)
    820578{
     
    830588}
    831589
    832 /** Allocate new symbol.
    833  *
    834  * @return      New symbol
    835  */
    836590stree_symbol_t *stree_symbol_new(symbol_class_t sc)
    837591{
     
    848602}
    849603
    850 /** Allocate new program.
    851  *
    852  * @return      New program
    853  */
    854604stree_program_t *stree_program_new(void)
    855605{
     
    865615}
    866616
    867 /** Determine if @a symbol has attribute of class @a sac.
    868  *
    869  * @param symbol        Symbol
    870  * @param sac           Symbol attribute class
    871  * @return              @c b_true if yes, @c b_false if no.
    872  */
     617/** Determine if @a symbol has attribute of class @a sac. */
    873618bool_t stree_symbol_has_attr(stree_symbol_t *symbol, symbol_attr_class_t sac)
    874619{
     
    888633}
    889634
    890 /** Determine if argument @a arg has attribute of class @a aac.
    891  *
    892  * @param arg           Formal procedure argument
    893  * @param aac           Argument attribute class
    894  * @return              @c b_true if yes, @c b_false if no.
    895  */
     635/** Determine if argument @a arg has attribute of class @a aac. */
    896636bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac)
    897637{
     
    912652
    913653/** Determine wheter @a a is derived (transitively) from @a b.
    914  *
    915  * XXX This does not work right with generics.
    916654 *
    917655 * @param a     Derived CSI.
     
    935673        return b_false;
    936674}
    937 
    938 /** Search for CSI type argument of the given name.
    939  *
    940  * @param csi           CSI to look in.
    941  * @param ident         Identifier of the type argument.
    942  * @return              Type argument definition or @c NULL if not found.
    943  */
    944 stree_targ_t *stree_csi_find_targ(stree_csi_t *csi, stree_ident_t *ident)
    945 {
    946         list_node_t *targ_n;
    947         stree_targ_t *targ;
    948 
    949         targ_n = list_first(&csi->targ);
    950         while (targ_n != NULL) {
    951                 targ = list_node_data(targ_n, stree_targ_t *);
    952                 if (targ->name->sid == ident->sid)
    953                         return targ;
    954 
    955                 targ_n = list_next(&csi->targ, targ_n);
    956         }
    957 
    958         /* No match */
    959         return NULL;
    960 }
Note: See TracChangeset for help on using the changeset viewer.