bool is_lt_no_level_params(level const & a, level const & b) { if (is_eqp(a, b)) return false; if (kind(a) != kind(b)) { if (kind(a) == level_kind::Param || kind(b) == level_kind::Param) return false; return kind(a) < kind(b); } switch (kind(a)) { case level_kind::Zero: lean_unreachable(); // LCOV_EXCL_LINE case level_kind::Param: return false; case level_kind::Global: return global_id(a) < global_id(b); case level_kind::Meta: return meta_id(a) < meta_id(b); case level_kind::Max: if (is_lt_no_level_params(max_lhs(a), max_lhs(b))) return true; else if (is_lt_no_level_params(max_lhs(b), max_lhs(a))) return false; else return is_lt_no_level_params(max_rhs(a), max_rhs(b)); case level_kind::IMax: if (is_lt_no_level_params(imax_lhs(a), imax_lhs(b))) return true; else if (is_lt_no_level_params(imax_lhs(b), imax_lhs(a))) return false; else return is_lt_no_level_params(imax_rhs(a), imax_rhs(b)); case level_kind::Succ: return is_lt_no_level_params(succ_of(a), succ_of(b)); } lean_unreachable(); }
optional<name> get_undef_global(level const & l, environment const & env) { optional<name> r; for_each(l, [&](level const & l) { if (!has_global(l) || r) return false; if (is_global(l) && !env.is_universe(global_id(l))) r = global_id(l); return true; }); return r; }
unsigned level_cases_on(vm_obj const & o, buffer<vm_obj> & data) { level const & l = to_level(o); switch (l.kind()) { case level_kind::Zero: break; case level_kind::Succ: data.push_back(to_obj(succ_of(l))); break; case level_kind::Max: data.push_back(to_obj(max_lhs(l))); data.push_back(to_obj(max_rhs(l))); break; case level_kind::IMax: data.push_back(to_obj(imax_lhs(l))); data.push_back(to_obj(imax_rhs(l))); break; case level_kind::Param: data.push_back(to_obj(param_id(l))); break; case level_kind::Global: data.push_back(to_obj(global_id(l))); break; case level_kind::Meta: data.push_back(to_obj(meta_id(l))); break; } return static_cast<unsigned>(l.kind()); }
void dump_parse_post_compile(Term* term) { std::cout << "dump_parse " << global_id(term) << ": "; for (int i=0; i < term->numInputs(); i++) { if (i != 0) std::cout << ", "; print_term(term->input(0), std::cout); } std::cout << std::endl; }
/* Reverts the object to the last remembered state. VALUE object: object to revert. */ void yard_revert_object_sync(VALUE object, char * gvar_name) { VALUE result = 0; struct global_entry * entry = NULL; if (object == NULL && gvar_name != NULL) { result = yard_fetch_global_variable(gvar_name, 0); entry = rb_global_entry(global_id(gvar_name)); rb_gvar_do_set(entry, result); } if (YARD_OBJECT_SAVED(object)) { result = yard_fetch_stored_object(&YARD_ID(object), 0); yard_set_object_by_yid(&YARD_ID(object), result); RBASIC(object)->yard_flags = YARD_OBJECT_STUB; yard_resolve_stub(object); } }
/* * Create a new lockspace in-memory object. */ static struct lockspace * new_lockspace(const char *name) { struct lockspace *ls; ls = malloc(sizeof(*ls)); if (!ls) fail(NULL); memset(ls, 0, sizeof(*ls)); ls->name = strdup(name); if (!ls->name) fail(NULL); ls->global_id = global_id(name); ls->minor = -1; ls->control_fd = -1; ls->stopped = node_mask(local_node); ls->next = lockspaces; lockspaces = ls; return ls; }
void search_every_global_name() { // This test is brave. We go through every single term in the world, find its // global name (if it exists), then see if we can find the original term using // the global name. circa::Value globalName; for (BlockIterator it(global_root_block()); it.unfinished(); it.advance()) { get_global_name(*it, &globalName); if (!is_string(&globalName)) continue; Term* searchResult = find_from_global_name(global_world(), as_cstring(&globalName)); if (searchResult != *it) { std::cout << "Global name search failed for term: " << global_id(*it) << ", with global name: " << as_cstring(&globalName) << std::endl; declare_current_test_failed(); } } }
void test_assert_function(Term* term, int line, const char* file) { if (term == NULL) { std::cout << "NULL term in " << file << ", line " << line << std::endl; declare_current_test_failed(); return; } if (has_static_error(term)) { std::cout << "Compile error on term " << global_id(term) << std::endl; print_static_error(term, std::cout); std::cout << std::endl; std::cout << "Occurred in " << file << ", line " << line << std::endl; declare_current_test_failed(); } if (is_bool(term_value(term)) && !as_bool(term_value(term))) { std::cout << "Assertion failed: " << get_term_source_text(term) << std::endl; std::cout << "Occurred in " << file << ", line " << line << std::endl; declare_current_test_failed(); } }
bool is_one_placeholder(level const & e) { return is_global(e) && global_id(e) == *g_placeholder_one_name; }
bool is_placeholder(level const & e) { return is_global(e) && is_placeholder(global_id(e)); }