Changeset c5cb943d in mainline for uspace/app/sbi/src/run.c


Ignore:
Timestamp:
2010-06-09T19:01:08Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1113c9e
Parents:
051bc69a
Message:

Update SBI to rev. 291.

File:
1 edited

Legend:

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

    r051bc69a rc5cb943d  
    9999        stree_symbol_t *main_fun_sym;
    100100        stree_fun_t *main_fun;
     101        rdata_var_t *main_obj;
    101102        stree_ident_t *fake_ident;
    102103        list_t main_args;
     
    111112        list_init(&run->thread_ar->proc_ar);
    112113        run->thread_ar->bo_mode = bm_none;
     114
     115        /* Initialize global data structure. */
     116        run_gdata_init(run);
    113117
    114118        /*
     
    126130        assert(main_fun != NULL);
    127131
     132        main_obj = run_fun_sobject_find(run, main_fun);
     133
    128134#ifdef DEBUG_RUN_TRACE
    129135        printf("Found function '"); symbol_print_fqn(main_fun_sym);
     
    133139        /* Run function @c main. */
    134140        list_init(&main_args);
    135         run_proc_ar_create(run, NULL, main_fun->proc, &proc_ar);
     141        run_proc_ar_create(run, main_obj, main_fun->proc, &proc_ar);
    136142        run_proc_ar_set_args(run, proc_ar, &main_args);
    137143        run_proc(run, proc_ar, &res);
    138144
    139145        run_exc_check_unhandled(run);
     146}
     147
     148/** Initialize global data.
     149 *
     150 * @param run           Runner object
     151 */
     152void run_gdata_init(run_t *run)
     153{
     154        rdata_object_t *gobject;
     155
     156        run->gdata = rdata_var_new(vc_object);
     157        gobject = rdata_object_new();
     158        run->gdata->u.object_v = gobject;
     159
     160        gobject->class_sym = NULL;
     161        gobject->static_obj = sn_static;
     162        intmap_init(&gobject->fields);
    140163}
    141164
     
    787810        proc_ar = run_get_current_proc_ar(run);
    788811        return proc_ar->proc->outer_symbol->outer_csi;
     812}
     813
     814/** Get static object (i.e. class object).
     815 *
     816 * Looks for a child static object named @a name in static object @a pobject.
     817 * If the child does not exist yet, it is created.
     818 *
     819 * @param run           Runner object
     820 * @param csi           CSI of the static object named @a name
     821 * @param pobject       Parent static object
     822 * @param name          Static object name
     823 *
     824 * @return              Static (class) object of the given name
     825 */
     826rdata_var_t *run_sobject_get(run_t *run, stree_csi_t *csi,
     827    rdata_var_t *pobj_var, sid_t name)
     828{
     829        rdata_object_t *pobject;
     830        rdata_var_t *mbr_var;
     831        rdata_var_t *rvar;
     832        stree_ident_t *ident;
     833
     834        assert(pobj_var->vc == vc_object);
     835        pobject = pobj_var->u.object_v;
     836#ifdef DEBUG_RUN_TRACE
     837        printf("Get static object '%s' in '", strtab_get_str(name));
     838        if (pobject->class_sym != NULL)
     839                symbol_print_fqn(pobject->class_sym);
     840        else
     841                printf("global");
     842#endif
     843
     844        assert(pobject->static_obj == sn_static);
     845
     846        mbr_var = intmap_get(&pobject->fields, name);
     847        if (mbr_var != NULL) {
     848#ifdef DEBUG_RUN_TRACE
     849                printf("Return exising static object (mbr_var=%p).\n", mbr_var);
     850#endif
     851                /* Return existing object. */
     852                return mbr_var;
     853        }
     854
     855        /* Construct new object. */
     856#ifdef DEBUG_RUN_TRACE
     857        printf("Construct new static object.\n");
     858#endif
     859        ident = stree_ident_new();
     860        ident->sid = name;
     861
     862        run_new_csi_inst(run, csi, sn_static, &rvar);
     863
     864        /* Store static object reference for future use. */
     865        intmap_set(&pobject->fields, name, rvar);
     866
     867        return rvar;
     868}
     869
     870/** Get static object for CSI.
     871 *
     872 * In situations where we do not have the parent static object and need
     873 * to find static object for a CSI from the gdata root we use this.
     874 *
     875 * This is only used in special cases such as when invoking the entry
     876 * point. This is too slow to use during normal execution.
     877 *
     878 * @param run           Runner object
     879 * @param csi           CSI to get static object of
     880 *
     881 * @return              Static (class) object
     882 */
     883rdata_var_t *run_sobject_find(run_t *run, stree_csi_t *csi)
     884{
     885        rdata_var_t *pobj_var;
     886
     887        if (csi == NULL)
     888                return run->gdata;
     889
     890        assert(csi->ancr_state == ws_visited);
     891        pobj_var = run_sobject_find(run, csi_to_symbol(csi)->outer_csi);
     892
     893        return run_sobject_get(run, csi, pobj_var, csi->name->sid);
     894}
     895
     896/** Get static object for CSI containing function.
     897 *
     898 * This is used to obtain active object for invoking static function
     899 * @a fun. Only used in cases where we don't already have the object such
     900 * as when running the entry point. Otherwise this would be slow.
     901 *
     902 * @param run           Runner object
     903 * @param fun           Function to get static class object of
     904 *
     905 * @return              Static (class) object
     906 */
     907rdata_var_t *run_fun_sobject_find(run_t *run, stree_fun_t *fun)
     908{
     909        return run_sobject_find(run, fun_to_symbol(fun)->outer_csi);
    789910}
    790911
     
    15121633
    15131634        /* Create exception object. */
    1514         run_new_csi_inst(run, csi, &exc_vi);
     1635        run_new_csi_inst_ref(run, csi, sn_nonstatic, &exc_vi);
    15151636        assert(exc_vi->ic == ic_value);
    15161637
Note: See TracChangeset for help on using the changeset viewer.