Changeset 38aaacc2 in mainline for uspace/app/sbi/src/stree.c


Ignore:
Timestamp:
2010-04-23T21:41:10Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4f866c
Parents:
074444f
Message:

Update SBI to rev. 207.

File:
1 edited

Legend:

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

    r074444f r38aaacc2  
    3737#include "stree.h"
    3838
     39/** Allocate new module.
     40 *
     41 * @return      New module
     42 */
    3943stree_module_t *stree_module_new(void)
    4044{
     
    5155}
    5256
     57/** Allocate new module member.
     58 *
     59 * @param mc    Module member class
     60 * @return      New module member
     61 */
    5362stree_modm_t *stree_modm_new(modm_class_t mc)
    5463{
     
    6574}
    6675
     76/** Allocate new CSI.
     77 *
     78 * @param cc    CSI class
     79 * @return      New CSI
     80 */
    6781stree_csi_t *stree_csi_new(csi_class_t cc)
    6882{
     
    8397}
    8498
     99/** Allocate new CSI member.
     100 *
     101 * @param cc    CSI member class
     102 * @return      New CSI member
     103 */
    85104stree_csimbr_t *stree_csimbr_new(csimbr_class_t cc)
    86105{
     
    97116}
    98117
     118/** Allocate new member delegate.
     119 *
     120 * @return      New member delegate
     121 */
     122stree_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 */
    99139stree_fun_t *stree_fun_new(void)
    100140{
     
    110150}
    111151
     152/** Allocate new member variable.
     153 *
     154 * @return      New member variable
     155 */
    112156stree_var_t *stree_var_new(void)
    113157{
     
    123167}
    124168
     169/** Allocate new property.
     170 *
     171 * @return      New property
     172 */
    125173stree_prop_t *stree_prop_new(void)
    126174{
     
    136184}
    137185
     186/** Allocate new type argument.
     187 *
     188 * @return      New type argument
     189 */
     190stree_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 */
    138208stree_symbol_attr_t *stree_symbol_attr_new(symbol_attr_class_t sac)
    139209{
     
    150220}
    151221
     222/** Allocate new procedure.
     223 *
     224 * @return      New procedure
     225 */
    152226stree_proc_t *stree_proc_new(void)
    153227{
     
    163237}
    164238
     239/** Allocate new procedure argument.
     240 *
     241 * @return      New procedure argument
     242 */
    165243stree_proc_arg_t *stree_proc_arg_new(void)
    166244{
     
    176254}
    177255
     256/** Allocate new function signature.
     257 *
     258 * @return      New procedure argument
     259 */
     260stree_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 */
    178278stree_arg_attr_t *stree_arg_attr_new(arg_attr_class_t aac)
    179279{
     
    190290}
    191291
     292/** Allocate new statement.
     293 *
     294 * @param sc    Statement class
     295 * @return      New statement
     296 */
    192297stree_stat_t *stree_stat_new(stat_class_t sc)
    193298{
     
    204309}
    205310
     311/** Allocate new local variable declaration.
     312 *
     313 * @return      New local variable declaration
     314 */
    206315stree_vdecl_t *stree_vdecl_new(void)
    207316{
     
    217326}
    218327
     328/** Allocate new @c if statement.
     329 *
     330 * @return      New @c if statement
     331 */
    219332stree_if_t *stree_if_new(void)
    220333{
     
    230343}
    231344
     345/** Allocate new @c while statement.
     346 *
     347 * @return      New @c while statement
     348 */
    232349stree_while_t *stree_while_new(void)
    233350{
     
    243360}
    244361
     362/** Allocate new @c for statement.
     363 *
     364 * @return      New @c for statement
     365 */
    245366stree_for_t *stree_for_new(void)
    246367{
     
    256377}
    257378
     379/** Allocate new @c raise statement.
     380 *
     381 * @return      New @c raise statement
     382 */
    258383stree_raise_t *stree_raise_new(void)
    259384{
     
    269394}
    270395
     396/** Allocate new @c return statement.
     397 *
     398 * @return      New @c return statement
     399 */
    271400stree_return_t *stree_return_new(void)
    272401{
     
    282411}
    283412
     413/** Allocate new with-except-finally statement.
     414 *
     415 * @return      New with-except-finally statement.
     416 */
    284417stree_wef_t *stree_wef_new(void)
    285418{
     
    295428}
    296429
     430/** Allocate new expression statement.
     431 *
     432 * @return      New expression statement
     433 */
    297434stree_exps_t *stree_exps_new(void)
    298435{
     
    308445}
    309446
     447/** Allocate new @c except clause.
     448 *
     449 * @return      New @c except clause
     450 */
    310451stree_except_t *stree_except_new(void)
    311452{
     
    321462}
    322463
     464/** Allocate new statement block.
     465 *
     466 * @return      New statement block
     467 */
    323468stree_block_t *stree_block_new(void)
    324469{
     
    334479}
    335480
     481/** Allocate new expression.
     482 *
     483 * @param ec    Expression class
     484 * @return      New expression
     485 */
    336486stree_expr_t *stree_expr_new(expr_class_t ec)
    337487{
     
    348498}
    349499
     500/** Allocate new assignment.
     501 *
     502 * @param ac    Assignment class
     503 * @return      New assignment
     504 */
    350505stree_assign_t *stree_assign_new(assign_class_t ac)
    351506{
     
    362517}
    363518
     519/** Allocate new binary operation.
     520 *
     521 * @return      New binary operation
     522 */
    364523stree_binop_t *stree_binop_new(binop_class_t bc)
    365524{
     
    376535}
    377536
     537/** Allocate new unary operation.
     538 *
     539 * @param uc    Unary operation class
     540 * @return      New unary operation
     541 */
    378542stree_unop_t *stree_unop_new(unop_class_t uc)
    379543{
     
    390554}
    391555
     556/** Allocate new @c new operation.
     557 *
     558 * @return      New @c new operation
     559 */
    392560stree_new_t *stree_new_new(void)
    393561{
     
    403571}
    404572
     573/** Allocate new .
     574 *
     575 * @return      New
     576 */
    405577stree_access_t *stree_access_new(void)
    406578{
     
    416588}
    417589
     590/** Allocate new function call operation.
     591 *
     592 * @return      New function call operation
     593 */
    418594stree_call_t *stree_call_new(void)
    419595{
     
    429605}
    430606
     607/** Allocate new indexing operation.
     608 *
     609 * @return      New indexing operation
     610 */
    431611stree_index_t *stree_index_new(void)
    432612{
     
    442622}
    443623
     624/** Allocate new as conversion.
     625 *
     626 * @return      New as conversion
     627 */
    444628stree_as_t *stree_as_new(void)
    445629{
     
    455639}
    456640
     641/** Allocate new boxing operation.
     642 *
     643 * @return      New boxing operation
     644 */
     645stree_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 */
    457662stree_nameref_t *stree_nameref_new(void)
    458663{
     
    468673}
    469674
     675/** Allocate new identifier.
     676 *
     677 * @return      New identifier
     678 */
    470679stree_ident_t *stree_ident_new(void)
    471680{
     
    481690}
    482691
     692/** Allocate new literal.
     693 *
     694 * @param ltc   Literal class
     695 * @return      New literal
     696 */
    483697stree_literal_t *stree_literal_new(literal_class_t ltc)
    484698{
     
    495709}
    496710
     711/** Allocate new @c self reference.
     712 *
     713 * @return      New @c self reference
     714 */
    497715stree_self_ref_t *stree_self_ref_new(void)
    498716{
     
    508726}
    509727
     728/** Allocate new type expression
     729 *
     730 * @return      New type expression
     731 */
    510732stree_texpr_t *stree_texpr_new(texpr_class_t tc)
    511733{
     
    522744}
    523745
     746/** Allocate new type access operation.
     747 *
     748 * @return      New type access operation
     749 */
    524750stree_taccess_t *stree_taccess_new(void)
    525751{
     
    535761}
    536762
     763/** Allocate new type application operation.
     764 *
     765 * @return      New type application operation
     766 */
    537767stree_tapply_t *stree_tapply_new(void)
    538768{
     
    548778}
    549779
     780/** Allocate new type indexing operation.
     781 *
     782 * @return      New type indexing operation
     783 */
    550784stree_tindex_t *stree_tindex_new(void)
    551785{
     
    561795}
    562796
     797/** Allocate new type literal.
     798 *
     799 * @return      New type literal
     800 */
    563801stree_tliteral_t *stree_tliteral_new(tliteral_class_t tlc)
    564802{
     
    575813}
    576814
     815/** Allocate new type name reference.
     816 *
     817 * @return      New type name reference
     818 */
    577819stree_tnameref_t *stree_tnameref_new(void)
    578820{
     
    588830}
    589831
     832/** Allocate new symbol.
     833 *
     834 * @return      New symbol
     835 */
    590836stree_symbol_t *stree_symbol_new(symbol_class_t sc)
    591837{
     
    602848}
    603849
     850/** Allocate new program.
     851 *
     852 * @return      New program
     853 */
    604854stree_program_t *stree_program_new(void)
    605855{
     
    615865}
    616866
    617 /** Determine if @a symbol has attribute of class @a sac. */
     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 */
    618873bool_t stree_symbol_has_attr(stree_symbol_t *symbol, symbol_attr_class_t sac)
    619874{
     
    633888}
    634889
    635 /** Determine if argument @a arg has attribute of class @a aac. */
     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 */
    636896bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac)
    637897{
     
    653913/** Determine wheter @a a is derived (transitively) from @a b.
    654914 *
     915 * XXX This does not work right with generics.
     916 *
    655917 * @param a     Derived CSI.
    656918 * @param b     Base CSI.
     
    673935        return b_false;
    674936}
     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 */
     944stree_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.