diff options
Diffstat (limited to 'src/compiler/base.zc')
| -rw-r--r-- | src/compiler/base.zc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/compiler/base.zc b/src/compiler/base.zc index 3135b39..03a575c 100644 --- a/src/compiler/base.zc +++ b/src/compiler/base.zc @@ -240,7 +240,7 @@ word lt_marks; int lt_nmarks, lt_markcap, lt_next_mark; char* lt_mark_file; int word lt_buf, lt_head, lt_file_at; int lt_top, lt_cap, lt_base = 0 - 1, lt_file_img; char* lt_file; char[2100] dbuf_initial; char* dbuf = dbuf_initial; int docbufcap = 2100; int dn, dlast, dline, docpending, dsect; char[2100] dsnap_initial; char* dsnap = dsnap_initial; int docsnapcap = 2100; int dsn, dnm; char[300] dnmb_initial; char* dnmb = dnmb_initial; int docnamecap = 300; -int pk_tk, pk_tv, pq_n; word[4] pq_tk; word[4] pq_tv; word[4] pq_gl; word[4] pq_ln; // up to 4 tokens of lookahead +int pk_tk, pk_tv, pq_n; word[4] pq_tk = {}; word[4] pq_tv = {}; word[4] pq_gl = {}; word[4] pq_ln = {}; // up to 4 tokens of lookahead int here, hdelta, hlimit, ptop; int code_chunk = rt.CODE_END; word image_buffer, image_words; int image_active, image_org, image_capacity, image_size; @@ -254,7 +254,7 @@ int fn_return_type; // a consistent return type inferred from the function body // effects come from the real compiler's uses, stores, returns and call edges; unknown bodies stay conservative. const int EF_READ = 1, EF_WRITE = 2, EF_RETAIN = 4, EF_CONSUME = 8, EF_UNKNOWN = 16, EF_ALIAS = 32, EF_IDENTITY = 64; word effect_symbols, effect_edges, effect_requirements, effect_current; int effect_floor, effect_argument_base; -word local_origin, local_origin_mask, local_cell, local_captured, local_ended, local_end_info, local_shadow, xshadow, effect_shadows; int argowner_mask; word effect_value, argorigin_mask; int capture_enabled; word[1] capture_dummy; +word local_origin, local_origin_mask, local_cell, local_captured, local_ended, local_end_info, local_shadow, xshadow, effect_shadows, linited; int argowner_mask; word effect_value, argorigin_mask; int capture_enabled; word[1] capture_dummy = {}; // drops (docs/design/destructors.md): the code position just past a drop form (a fresh // value with a drop still on the stack there), the type `this` gets in the next closure, // a local whose drop is set, a mailbox send whose arguments are checked, and o3 block depth. @@ -308,7 +308,7 @@ int ifon; word ifs, ifr; int nif; word ifx; int nifx; word ift; int nift; word i word if_edges, if_value, if_local; int ifrcap = NIF, ifxcap = IFN, iftcap = IFT; int fldst, fldi; // the one struct a bare address's field name resolved to -char*[8] tpn; int ntp; // type parameters in scope +char*[8] tpn = {}; int ntp; // type parameters in scope // reading a return type: unknown names are type parameters declared after the function's name int tvauto; // the typedefs of the blocks being compiled: three words each (the symbol, the block depth and the @@ -328,8 +328,8 @@ int s_ld8, s_st8, s_ld16, s_st16, s_ld32, s_st32; // table of shared variables, hold_count the blocks so far. a shared variable's symbol has // F_SHARED and its block's rank above it in sflag. const int F_SHARED = 131072, F_SHARED_RANK = 262144; -int hold_cur, fhold, hold_count, hold_desc, hold_nshared; word[128] hold_tab; -int o3on, o3nxt, o3one; word[32] o3sl; word[32] o3rg; int no3sl; word[O3_REGIONS * 67] o3pend_initial; word o3pend = o3pend_initial; int o3pendcap = O3_REGIONS, no3pend; word[80] o3dsc; int o3fs, o3na, o3fn0; +int hold_cur, fhold, hold_count, hold_desc, hold_nshared; word[128] hold_tab = {}; +int o3on, o3nxt, o3one; word[32] o3sl = {}; word[32] o3rg = {}; int no3sl; word[O3_REGIONS * 67] o3pend_initial; word o3pend = o3pend_initial; int o3pendcap = O3_REGIONS, no3pend; word[80] o3dsc = {}; int o3fs, o3na, o3fn0; // o3free holds registers released by closed scopes; o3cache holds the items pointer and length slots for fixed arrays. word[8] o3free; int no3free, o3nreg; word[NL] o3cache_initial; word o3cache = o3cache_initial; int argloc, s_hitems, s_hlen, s_fatten; // operator names used by numeric type checks. @@ -348,18 +348,18 @@ int sx_push, sx_pop, sx_resize, sx_defer, sx_asm, sx_quote, sx_new, sx_int, sx_c // local lower bound / len(array); one proof record per live loop int nfact, factcap = RANGE_FACTS; word[RANGE_FACTS] floc_initial, flo_initial, flen_initial; word floc = floc_initial, flo = flo_initial, flen = flen_initial; int s_len_s, s_at_s, s_slice_s, s_cat_s, s_eq_s, s_lt_s, s_le_s, s_put_bs, s_put_s, s_n_to_s, s_new_s; -int mdg; word[8] mdn; // the type parameters of the generic struct whose methods are being compiled +int mdg; word[8] mdn = {}; // the type parameters of the generic struct whose methods are being compiled word[8] gbind; int ngbind; // explicit type arguments for the next call: f<int>(...) // generic functions. the template (type parameters stay variables) is compiled once, as before, // and its tokens are kept; a call whose type arguments are all known gets an instance, the same // tokens compiled again with the parameters bound to those types, so new(T) and sizeof(T) // inside it mean the real type. instances are compiled after the item that asked for them. int grec; word gbuf; int gn, gcap; // the tokens of the top-level item being read -int gnew, gnew_np; word[8] gnew_nm; // a generic function was just defined +int gnew, gnew_np; word[8] gnew_nm = {}; // a generic function was just defined int fn_method_compile, fnpatchseq; word gtab; int gt_n, gtcap = 64, gicap = 128; word gt_sym, gt_tok, gt_np, gt_module, gt_imports, gt_source; int gt_nm; // the columns are allocated at the first generic function int gi_n; word gi_t, gi_sym, gi_ar, gi_done; -int ginst; word[8] gnm; word[8] gib; int gng, ginsn; // compiling an instance: the names and what they stand for +int ginst; word[8] gnm = {}; word[8] gib = {}; int gng, ginsn; // compiling an instance: the names and what they stand for int s_this; const int NCLO = 8; /* initial closure nesting capacity; grows when more closures are compiled */ const int NCAP = 32; /* initial capture capacity per closure; grows when more variables are captured */ @@ -376,7 +376,7 @@ word[NCLO] clo_hi_initial; word clo_hi = clo_hi_initial; word[NCLO] clo_n_initial; word clo_n = clo_n_initial; word[NCLO] clo_env_initial; word clo_env = clo_env_initial; word[NCLO] clo_ret_initial; word clo_ret = clo_ret_initial; -char*[256] clo_name_initial; char** clo_name = clo_name_initial; +char*[256] clo_name_initial = {}; char** clo_name = clo_name_initial; word[256] clo_loc_initial; word clo_loc = clo_loc_initial; word[256] clo_via_initial; word clo_via = clo_via_initial; @@ -704,7 +704,7 @@ word sdoff, sdsrc; // workspace folder an editor passes in, inc_hook a function that gives the text of a file the editor // sent (a host with no files of its own), incres the path an include was found at char* incdir, increoot, incres, std_buf, icon_buf; char*(char*.m) inc_hook; int std_done, icon_done; -word rsrec, rstmp; word[32] pnoffs; word[32] pnplaces; int rsn, rscap, rsbase, nameoff; +word rsrec, rstmp; word[32] pnoffs = {}; word[32] pnplaces = {}; int rsn, rscap, rsbase, nameoff; // ownership at a reference: record word 11 holds the local's state (S_* + 1, plus 16 when // it owns its object) and word 12 the declaration offset (+ 1) of the owner it borrows from. // transfers are logged as events, EV_W words each: the local's declaration offset, what @@ -785,6 +785,7 @@ int reserve_locals(int need) { if (local_ended) local_ended = chk_resize(local_ended, nloc, cap); if (local_end_info) local_end_info = chk_resize(local_end_info, nloc, cap); if (local_shadow) local_shadow = chk_resize(local_shadow, nloc, cap); + if (linited) linited = chk_resize(linited, nloc, cap); lafact = chk_resize(lafact, nloc, cap); laaddr = chk_resize(laaddr, nloc, cap); lprev = chk_resize(lprev, nloc, cap); if (lvkind) { lvkind = chk_resize(lvkind, nloc, cap); lvvalue = chk_resize(lvvalue, nloc, cap); lvescaped = chk_resize(lvescaped, nloc, cap); } o3cache = chk_resize(o3cache, nloc, cap); @@ -1506,8 +1507,8 @@ int o3promote(int i) { int o3mkcache(int i) { int k; if (!o3on || ltype[i][0] != TY_DYN || !ltype[i][3] || tbytes(ltype[i][4])) return 0; - k = newloc(s_hitems); fslots++; ltag[k] = 16; o3promote(k); - newloc(s_hlen); fslots++; ltag[k + 1] = 16; o3promote(k + 1); + k = newloc(s_hitems); fslots++; ltag[k] = 16; o3promote(k); mark_inited(k); + newloc(s_hlen); fslots++; ltag[k + 1] = 16; o3promote(k + 1); mark_inited(k + 1); o3cache[i] = k; return 0; } |
