Example #1
0
static format pp_child(level const & l, bool unicode, unsigned indent) {
    if (is_explicit(l) || is_param(l) || is_meta(l) || is_global(l)) {
        return pp(l, unicode, indent);
    } else {
        return paren(pp(l, unicode, indent));
    }
}
Example #2
0
 level collect(level const & l) {
     return replace(l, [&](level const & l) {
             if (is_meta(l)) {
                 name const & id = meta_id(l);
                 if (auto r = m_univ_meta_to_param.find(id)) {
                     return some_level(*r);
                 } else {
                     name n      = m_prefix.append_after(m_next_idx);
                     m_next_idx++;
                     level new_r = mk_param_univ(n);
                     m_univ_meta_to_param.insert(id, new_r);
                     m_univ_meta_to_param_inv.insert(n, l);
                     m_level_params.push_back(n);
                     return some_level(new_r);
                 }
             } else if (is_param(l)) {
                 name const & id = param_id(l);
                 if (!m_found_univ_params.contains(id)) {
                     m_found_univ_params.insert(id);
                     m_level_params.push_back(id);
                 }
             }
             return none_level();
         });
 }
Example #3
0
void collect_univ_params_core(level const & l, name_set & r) {
    for_each(l, [&](level const & l) {
            if (!has_param(l))
                return false;
            if (is_param(l))
                r.insert(param_id(l));
            return true;
        });
}
Example #4
0
static void print_child(std::ostream & out, level const & l) {
    if (is_explicit(l) || is_param(l) || is_meta(l) || is_global(l)) {
        print(out, l);
    } else {
        out << "(";
        print(out, l);
        out << ")";
    }
}
Example #5
0
optional<name> get_undef_param(level const & l, level_param_names const & ps) {
    optional<name> r;
    for_each(l, [&](level const & l) {
            if (!has_param(l) || r)
                return false;
            if (is_param(l) && std::find(ps.begin(), ps.end(), param_id(l)) == ps.end())
                r = param_id(l);
            return true;
        });
    return r;
}
Example #6
0
level instantiate(level const & l, level_param_names const & ps, levels const & ls) {
    lean_assert(length(ps) == length(ls));
    return replace(l, [=](level const & l) {
            if (!has_param(l)) {
                return some_level(l);
            } else if (is_param(l)) {
                name const & id = param_id(l);
                list<name> const *it1 = &ps;
                list<level> const * it2 = &ls;
                while (!is_nil(*it1)) {
                    if (head(*it1) == id)
                        return some_level(head(*it2));
                    it1 = &tail(*it1);
                    it2 = &tail(*it2);
                }
                return some_level(l);
            } else {
                return none_level();
            }
        });
}
Example #7
0
int boot_menu(int argc, wchar_t *argv[])
{
	ldr_config conf;
	int        resl;
	int        is_small;

	is_small = is_param(L"-small");
	do
	{
		if ( (argc == 3) && (wcscmp(argv[2], L"-enum") == 0) )
		{
			wchar_t  s_size[MAX_PATH];
			wchar_t  h_name[MAX_PATH];
			wchar_t *str;
			u64      size;
			int      i, bd_1, bd_2;

			wprintf(
				L"--------------------------------------------------------------\n"
				L"HDD |           name           |  size   | bootable | bootloader\n" 
				L"----+--------------------------+---------+----------+-----------\n");

			if (dc_get_boot_disk(&bd_1, &bd_2) != ST_OK) {
				bd_1 = bd_2 = -1;
			}

			for (i = 0; i < 100; i++)
			{
				if (size = dc_dsk_get_size(i, 0)) 
				{
					dc_format_byte_size(s_size, sizeof_w(s_size), size);

					if (dc_get_hw_name(i, 0, h_name, sizeof_w(h_name)) != ST_OK) {
						h_name[0] = 0;
					}
					
					if (dc_get_mbr_config(i, NULL, &conf) == ST_OK) {
						str = L"installed"; 
					} else {
						str = L"none";
					}

					wprintf(
						L"hd%d | %-24s | %-8s| %-8s | %s\n", 
						i, h_name, s_size, (i == bd_1) || (i == bd_2) ? L"yes":L"no", str
						);
				} 
			}
			resl = ST_OK; break;
		}

		if ( (argc >= 4) && (wcscmp(argv[2], L"-setmbr") == 0) )
		{
			int d_num;
			
			if (dsk_num(argv[3], &d_num) == 0) {
				resl = ST_OK; break;
			}			

			if ( (resl = dc_set_boot_interactive(d_num, is_small)) == ST_OK) {
				wprintf(L"Bootloader successfully installed to %s\n", argv[3]);
			}
			break; 
		}

		if ( (argc == 4) && (wcscmp(argv[2], L"-delmbr") == 0) )
		{
			int d_num;
			
			if (dsk_num(argv[3], &d_num) == 0) {
				resl = ST_OK; break;
			}

			if ( (resl = dc_unset_mbr(d_num)) == ST_OK ) {
				wprintf(L"Bootloader successfully removed from %s\n", argv[3]);
			}
			break;
		}

		if ( (argc == 4) && (wcscmp(argv[2], L"-updmbr") == 0) )
		{
			int d_num;
			
			if (dsk_num(argv[3], &d_num) == 0) {
				resl = ST_OK; break;
			}

			if ( (resl = dc_update_boot(d_num)) == ST_OK ) {
				wprintf(L"Bootloader on %s successfully updated\n", argv[3]);
			}
			break;
		}	

		if ( (argc >= 4) && (wcscmp(argv[2], L"-setpar") == 0) )
		{
			if ( (resl = dc_set_boot(argv[3], 0, is_small)) == ST_FORMAT_NEEDED )
			{
				wprintf(
				   L"Removable media not correctly formatted\n"
				   L"Format media? (Y/N)\n"
				   );

				if (tolower(_getch()) == 'y') {
					resl = dc_set_boot(argv[3], 1, is_small);
				} else {
					resl = ST_OK; break;
				}
			}

			if (resl != ST_OK) {
				break;
			}

			if ( (resl = dc_mbr_config_by_partition(argv[3], 0, &conf)) != ST_OK ) {
				break;
			}

			conf.options  |= OP_EXTERNAL;
			conf.boot_type = BT_AP_PASSWORD;

			boot_conf_menu(
				&conf, L"Please set bootloader options:");

			if ( (resl = dc_mbr_config_by_partition(argv[3], 1, &conf)) == ST_OK ) {
				wprintf(L"Bootloader successfully installed\n");
			}
			break;
		}

		if ( (argc >= 4) && (wcscmp(argv[2], L"-makeiso") == 0) )
		{
			if ( (resl = dc_make_iso(argv[3], is_small)) != ST_OK ) {
				break;
			}

			if ( (resl = dc_get_mbr_config(0, argv[3], &conf)) != ST_OK ) {
				break;
			}

			conf.options  |= OP_EXTERNAL;
			conf.boot_type = BT_MBR_FIRST;

			boot_conf_menu(
				&conf, L"Please set bootloader options:");

			if ( (resl = dc_set_mbr_config(0, argv[3], &conf)) == ST_OK ) {
				wprintf(L"Bootloader .iso image successfully created\n", argv[3]);
			}
			break;
		}

		if ( (argc >= 4) && (wcscmp(argv[2], L"-makepxe") == 0) )
		{
			if ( (resl = dc_make_pxe(argv[3], is_small)) != ST_OK ) {
				break;
			}

			if ( (resl = dc_get_mbr_config(0, argv[3], &conf)) != ST_OK ) {
				break;
			}

			conf.options  |= OP_EXTERNAL;
			conf.boot_type = BT_MBR_FIRST;

			boot_conf_menu(
				&conf, L"Please set bootloader options:");

			if ( (resl = dc_set_mbr_config(0, argv[3], &conf)) == ST_OK ) {
				wprintf(L"Bootloader PXE image successfully created\n", argv[3]);
			}
			break;
		}

		if ( (argc == 4) && (wcscmp(argv[2], L"-config") == 0) )
		{
			int      d_num;
			wchar_t *file;
			int      ispar;
			
			if ( ((argv[3][1] == L':')  && (argv[3][2] == 0)) ||
				 ((argv[3][0] == L'\\') && (argv[3][5] == L':')) )
			{
				ispar = 1;
			} else 
			{
				if (dsk_num(argv[3], &d_num) == 0) {
					file = argv[3]; d_num = 0;
				} else {
					file = NULL;
				}

				ispar = 0;
			}

			if (ispar != 0) {
				resl = dc_mbr_config_by_partition(argv[3], 0, &conf);
			} else {
				resl = dc_get_mbr_config(d_num, file, &conf);
			}

			if (resl != ST_OK) {
				break;
			}

			boot_conf_menu(
				&conf, L"Please change bootloader options:");

			if (ispar != 0) {
				resl = dc_mbr_config_by_partition(argv[3], 1, &conf);
			} else {
				resl = dc_set_mbr_config(d_num, file, &conf);
			}

			if (resl == ST_OK) {
				wprintf(L"Bootloader configuration successfully changed\n");
			}
			break;
		}
	} while (0);

	return resl;
}
Example #8
0
name const & level_id(level const & l) {
    lean_assert(is_param(l) || is_global(l) || is_meta(l));
    return to_param_core(l).m_id;
}
Example #9
0
name const & param_id(level const & l) { lean_assert(is_param(l)); return to_param_core(l).m_id; }
Example #10
0
bool is_param_core(level const & l) { return is_param(l) || is_global(l) || is_meta(l); }