bool action::is_equal(action const & a) const { if (kind() != a.kind()) return false; switch (kind()) { case action_kind::Skip: return true; case action_kind::Binder: case action_kind::Binders: case action_kind::Expr: return rbp() == a.rbp(); case action_kind::Ext: return m_ptr == a.m_ptr; case action_kind::LuaExt: return get_lua_fn() == a.get_lua_fn(); case action_kind::Exprs: return rbp() == a.rbp() && get_sep() == a.get_sep() && get_rec() == a.get_rec() && get_initial() == a.get_initial() && get_terminator() == a.get_terminator() && is_fold_right() == a.is_fold_right(); case action_kind::ScopedExpr: return rbp() == a.rbp() && get_rec() == a.get_rec(); } lean_unreachable(); // LCOV_EXCL_LINE }
STATIC void node_dump(Linear_s *t, Blknum_t blknum, int indent) { Buf_s *buf; Node_s *node; Blknum_t overflow; if (!blknum) return; buf = t_get(t, blknum); node = buf->d; Hrec_s rec; unint i; if (Dump_buf) { pr_buf(buf, indent); } pr_head(node, indent); for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); pr_indent(indent); printf("%ld. ", i); rec_dump(rec); } overflow = node->overflow; buf_put(&buf); if (overflow) { node_dump(t, overflow, indent+1); } }
STATIC void rec_copy(Node_s *dst, int a, Node_s *src, int b) { Hrec_s rec = get_rec(src, b); store_lump(dst, rec.val); store_key(dst, rec.key); store_end(dst, a); }
void mem_free(long index) { // Check if index is a valid start of a memory block if (get_rec(index) != START) return; // Free index set_rec(index, FREE); // Free all folowing USED longs for (long i = index + 1; i < N; i++) { if (get_rec(i) == USED) { set_rec(i, FREE); } else break; } }
STATIC void delete_rec(Node_s *node, unint i) { Hrec_s rec; aver(i < node->numrecs); rec = get_rec(node, i); node->free += rec.val.size + LEAF_OVERHEAD; --node->numrecs; if (i < node->numrecs) { memmove( &node->rec[i], &node->rec[i+1], (node->numrecs - i) * SZ_U16); } }
STATIC void pr_node(Node_s *node) { unint i; Hrec_s rec; pr_head(node, 0); for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); printf("%3ld. ", i); pr_rec(rec); putchar('\n'); } }
void mem_available(long *empty, long *large, long *n_holes) { long index, start = -1; *empty = 0; *large = 0; *n_holes = 0; for (index = 0; index < N; index++) { if (start < 0 && get_rec(index) == FREE) { start = index; } if (start >= 0) { if (get_rec(index) == FREE) { *empty += 1; } else { *n_holes += 1; if (*large < index - start) *large = index - start; start = -1; } } } if (start >= 0) { *n_holes += 1; if (*large < N - start) *large = N - start; } }
bool lemur::file::Keyfile::get( const char* key, void* value, int& actualSize, int maxSize ) const { assert( key && "key cannot be null" ); assert( value && "value cannot be null" ); assert( _handle && "call open() or create() first" ); assert( maxSize > 0 && "maxSize must be positive" ); int len = strlen(key); // fix for UTF-8 int error = get_rec( _handle, const_cast<char*>(key), len, (char*)value, &actualSize, maxSize ); if( error && error != getnokey_err ) LEMUR_THROW( LEMUR_KEYFILE_IO_ERROR, "Caught an internal error while getting record for key: " + key ); return error != getnokey_err; }
STATIC void lf_audit(const char *fn, unsigned line, Node_s *node) { Hrec_s rec; int free = BLOCK_SIZE - SZ_HEAD; int i; for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); free -= rec.val.size + LEAF_OVERHEAD; } if (free != node->free) { printf("%s<%d> free:%d != %d:node->free\n", fn, line, free, node->free); exit(2); } }
int build (char *ref_name, char *target_path, int k_mer, double error_rate, char *prefix) { char *position = mmaping (ref_name); bloom *bl = NEW (bloom); if (k_mer != 0) bl->k_mer = k_mer; else bl->k_mer = kmer_suggestion (get_size (ref_name)); bl->stat.e = error_rate; bl->dx = bl->k_mer*bl->k_mer; bl->stat.capacity = strlen (position); get_rec (&bl->stat); bloom_init (bl, bl->stat.elements, bl->stat.capacity, bl->stat.e, bl->stat.ideal_hashes, NULL, 3); ref_add (bl, position); save_bloom (ref_name, bl, prefix, target_path); return 0; }
void pr_mem_node(Node_s *node) { int i; printf("blknum %lld overflow %lld", (u64)node->blknum, (u64)node->overflow); printf(" numrecs %d free %d end %d\n", node->numrecs, node->free, node->end); for (i = 0; i < node->numrecs; i++) { printf(" %d", node->rec[i]); } printf("\n"); for (i = 0; i < node->numrecs; i++) { Hrec_s rec = get_rec(node, i); printf("%lld %d %s\n", (u64)rec.key, rec.val.size, (char *)rec.val.d); } }
void prg2txt (FILE *in, FILE *out, char *fname, int lowercase) { Addy_type start_addy; Basrec_type rec; char oline [MAXLINE]; int x; if (get_addy (in, &start_addy) == EOF || start_addy.whole_addy != START_ADDY) exit_wrong_fmt (fname); get_rec_len (ADDY_NULL); while (! (x = get_rec (in, &rec))) if (detoken (&rec, oline, MAXLINE, lowercase)) fprintf (out, "%u %s\n", rec.line_num.whole_addy, oline); if (x == EOF) exit_wrong_fmt (fname); return; }
NcValues* NcVar::get_rec(long rec) { return get_rec(get_dim(0), rec); }
NcValues* NcVar::get_rec(void) { return get_rec(get_dim(0), cur_rec[0]); }
STATIC void lf_rec_move(Node_s *dst, int i, Node_s *src, int j) { Hrec_s rec = get_rec(src, j); store_rec(dst, rec.key, rec.val, i); lf_del_rec(src, j); }