void jl_load(const char *fname) { char *fpath = jl_find_file_in_path(fname); jl_start_parsing_file(fpath); jl_parse_eval_all(fpath); if (fpath != fname) free(fpath); }
void jl_load(const char *fname) { char *fpath = jl_find_file_in_path(fname); jl_value_t *ast = jl_parse_file(fpath); if (ast == (jl_value_t*)jl_null) { if (fpath != fname) free(fpath); jl_errorf("could not open file %s", fpath); } JL_GC_PUSH(&ast); jl_load_file_expr(fpath, ast); JL_GC_POP(); if (fpath != fname) free(fpath); }
DLLEXPORT void jl_restore_system_image(char *fname) { ios_t f; char *fpath = jl_find_file_in_path(fname); if (ios_file(&f, fpath, 1, 0, 0, 0) == NULL) { ios_printf(ios_stderr, "system image file not found\n"); exit(1); } #ifdef JL_GC_MARKSWEEP int en = jl_gc_is_enabled(); jl_gc_disable(); #endif tagtype_list = jl_alloc_cell_1d(0); jl_array_type->env = jl_deserialize_value(&f); jl_base_module = (jl_module_t*)jl_deserialize_value(&f); jl_current_module = (jl_module_t*)jl_deserialize_value(&f); jl_system_module = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("System")); jl_array_t *idtl = (jl_array_t*)jl_deserialize_value(&f); // rehash IdTables for(int i=0; i < idtl->length; i++) { jl_value_t *v = jl_cellref(idtl, i); jl_idtable_rehash(&((jl_array_t**)v)[1], ((jl_array_t**)v)[1]->length); } // cache builtin parametric types for(int i=0; i < tagtype_list->length; i++) { jl_value_t *v = jl_cellref(tagtype_list, i); uint32_t uid=0; if (jl_is_struct_type(v)) uid = ((jl_struct_type_t*)v)->uid; else if (jl_is_bits_type(v)) uid = ((jl_bits_type_t*)v)->uid; jl_cache_type_((jl_tag_type_t*)v); if (jl_is_struct_type(v)) ((jl_struct_type_t*)v)->uid = uid; else if (jl_is_bits_type(v)) ((jl_bits_type_t*)v)->uid = uid; } jl_get_builtin_hooks(); jl_get_system_hooks(); jl_boot_file_loaded = 1; jl_typeinf_func = (jl_function_t*)jl_get_global(jl_system_module, jl_symbol("typeinf_ext")); jl_init_box_caches(); //jl_deserialize_finalizers(&f); jl_set_t_uid_ctr(read_int32(&f)); jl_set_gs_ctr(read_int32(&f)); htable_reset(&backref_table, 0); ios_t ss; ios_mem(&ss, 0); ios_copyuntil(&ss, &f, '\0'); ios_close(&f); if (fpath != fname) free(fpath); #ifdef JL_GC_MARKSWEEP if (en) jl_gc_enable(); #endif // TODO: there is no exception handler here! jl_load_file_string(ss.buf); ios_close(&ss); }