Changes in uspace/app/sbi/src/run.c [c5cb943d:051bc69a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/run.c
rc5cb943d r051bc69a 99 99 stree_symbol_t *main_fun_sym; 100 100 stree_fun_t *main_fun; 101 rdata_var_t *main_obj;102 101 stree_ident_t *fake_ident; 103 102 list_t main_args; … … 112 111 list_init(&run->thread_ar->proc_ar); 113 112 run->thread_ar->bo_mode = bm_none; 114 115 /* Initialize global data structure. */116 run_gdata_init(run);117 113 118 114 /* … … 130 126 assert(main_fun != NULL); 131 127 132 main_obj = run_fun_sobject_find(run, main_fun);133 134 128 #ifdef DEBUG_RUN_TRACE 135 129 printf("Found function '"); symbol_print_fqn(main_fun_sym); … … 139 133 /* Run function @c main. */ 140 134 list_init(&main_args); 141 run_proc_ar_create(run, main_obj, main_fun->proc, &proc_ar);135 run_proc_ar_create(run, NULL, main_fun->proc, &proc_ar); 142 136 run_proc_ar_set_args(run, proc_ar, &main_args); 143 137 run_proc(run, proc_ar, &res); 144 138 145 139 run_exc_check_unhandled(run); 146 }147 148 /** Initialize global data.149 *150 * @param run Runner object151 */152 void 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);163 140 } 164 141 … … 810 787 proc_ar = run_get_current_proc_ar(run); 811 788 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 object820 * @param csi CSI of the static object named @a name821 * @param pobject Parent static object822 * @param name Static object name823 *824 * @return Static (class) object of the given name825 */826 rdata_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_TRACE837 printf("Get static object '%s' in '", strtab_get_str(name));838 if (pobject->class_sym != NULL)839 symbol_print_fqn(pobject->class_sym);840 else841 printf("global");842 #endif843 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_TRACE849 printf("Return exising static object (mbr_var=%p).\n", mbr_var);850 #endif851 /* Return existing object. */852 return mbr_var;853 }854 855 /* Construct new object. */856 #ifdef DEBUG_RUN_TRACE857 printf("Construct new static object.\n");858 #endif859 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 need873 * 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 entry876 * point. This is too slow to use during normal execution.877 *878 * @param run Runner object879 * @param csi CSI to get static object of880 *881 * @return Static (class) object882 */883 rdata_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 function899 * @a fun. Only used in cases where we don't already have the object such900 * as when running the entry point. Otherwise this would be slow.901 *902 * @param run Runner object903 * @param fun Function to get static class object of904 *905 * @return Static (class) object906 */907 rdata_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);910 789 } 911 790 … … 1633 1512 1634 1513 /* Create exception object. */ 1635 run_new_csi_inst _ref(run, csi, sn_nonstatic, &exc_vi);1514 run_new_csi_inst(run, csi, &exc_vi); 1636 1515 assert(exc_vi->ic == ic_value); 1637 1516
Note:
See TracChangeset
for help on using the changeset viewer.