chore(library/init/string): remove string.iterator_imp
This commit is contained in:
parent
fd46adb7b3
commit
dc937281b3
6 changed files with 17 additions and 15 deletions
|
|
@ -53,15 +53,10 @@ def fold {α} (a : α) (f : α → char → α) (s : string) : α :=
|
|||
s.to_list.foldl f a
|
||||
|
||||
/- In the VM, the string iterator is implemented as a pointer to the string being iterated + index.
|
||||
|
||||
TODO: we currently cannot mark interator_imp as private because
|
||||
we need to bind string_imp.mk and string_imp.cases_on in the VM.
|
||||
-/
|
||||
structure iterator_imp :=
|
||||
TODO: mark it opaque. -/
|
||||
structure iterator :=
|
||||
(fst : list char) (snd : list char)
|
||||
|
||||
def iterator := iterator_imp
|
||||
|
||||
def mk_iterator : string → iterator
|
||||
| ⟨s⟩ := ⟨[], s⟩
|
||||
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ bool is_runtime_builtin_type(name const & n) {
|
|||
/* TODO(Leo): use an attribute? */
|
||||
return
|
||||
n == get_string_name() ||
|
||||
n == get_string_iterator_name() ||
|
||||
n == get_uint8_name() ||
|
||||
n == get_uint16_name() ||
|
||||
n == get_uint32_name() ||
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ name const * g_sizeof = nullptr;
|
|||
name const * g_sorry_ax = nullptr;
|
||||
name const * g_string = nullptr;
|
||||
name const * g_string_empty = nullptr;
|
||||
name const * g_string_iterator = nullptr;
|
||||
name const * g_string_str = nullptr;
|
||||
name const * g_string_empty_ne_str = nullptr;
|
||||
name const * g_string_str_ne_empty = nullptr;
|
||||
|
|
@ -488,6 +489,7 @@ void initialize_constants() {
|
|||
g_sorry_ax = new name{"sorry_ax"};
|
||||
g_string = new name{"string"};
|
||||
g_string_empty = new name{"string", "empty"};
|
||||
g_string_iterator = new name{"string", "iterator"};
|
||||
g_string_str = new name{"string", "str"};
|
||||
g_string_empty_ne_str = new name{"string", "empty_ne_str"};
|
||||
g_string_str_ne_empty = new name{"string", "str_ne_empty"};
|
||||
|
|
@ -753,6 +755,7 @@ void finalize_constants() {
|
|||
delete g_sorry_ax;
|
||||
delete g_string;
|
||||
delete g_string_empty;
|
||||
delete g_string_iterator;
|
||||
delete g_string_str;
|
||||
delete g_string_empty_ne_str;
|
||||
delete g_string_str_ne_empty;
|
||||
|
|
@ -1017,6 +1020,7 @@ name const & get_sizeof_name() { return *g_sizeof; }
|
|||
name const & get_sorry_ax_name() { return *g_sorry_ax; }
|
||||
name const & get_string_name() { return *g_string; }
|
||||
name const & get_string_empty_name() { return *g_string_empty; }
|
||||
name const & get_string_iterator_name() { return *g_string_iterator; }
|
||||
name const & get_string_str_name() { return *g_string_str; }
|
||||
name const & get_string_empty_ne_str_name() { return *g_string_empty_ne_str; }
|
||||
name const & get_string_str_ne_empty_name() { return *g_string_str_ne_empty; }
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ name const & get_sizeof_name();
|
|||
name const & get_sorry_ax_name();
|
||||
name const & get_string_name();
|
||||
name const & get_string_empty_name();
|
||||
name const & get_string_iterator_name();
|
||||
name const & get_string_str_name();
|
||||
name const & get_string_empty_ne_str_name();
|
||||
name const & get_string_str_ne_empty_name();
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ sizeof
|
|||
sorry_ax
|
||||
string
|
||||
string.empty
|
||||
string.iterator
|
||||
string.str
|
||||
string.empty_ne_str
|
||||
string.str_ne_empty
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ static pair<std::string, size_t> rev_list_as_string(vm_obj const & lst) {
|
|||
return mk_pair(s, len);
|
||||
}
|
||||
|
||||
vm_obj string_iterator_imp_mk(vm_obj const & l1, vm_obj const & l2) {
|
||||
vm_obj string_iterator_mk(vm_obj const & l1, vm_obj const & l2) {
|
||||
pair<std::string, size_t> p1 = rev_list_as_string(l1);
|
||||
pair<std::string, size_t> p2 = list_as_string(l2);
|
||||
std::string s = p1.first;
|
||||
|
|
@ -421,7 +421,7 @@ vm_obj string_iterator_imp_mk(vm_obj const & l1, vm_obj const & l2) {
|
|||
return mk_vm_pair(new_s, mk_vm_nat(p1.second));
|
||||
}
|
||||
|
||||
unsigned string_iterator_imp_cases_on(vm_obj const & o, buffer<vm_obj> & data) {
|
||||
unsigned string_iterator_cases_on(vm_obj const & o, buffer<vm_obj> & data) {
|
||||
vm_obj p = string_iterator_prev_to_string(o);
|
||||
vm_obj n = string_iterator_remaining_to_string(o);
|
||||
data.push_back(string_to_list_core(to_vm_string(p).m_value, true /* reverse */));
|
||||
|
|
@ -429,12 +429,12 @@ unsigned string_iterator_imp_cases_on(vm_obj const & o, buffer<vm_obj> & data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
vm_obj string_iterator_imp_fst(vm_obj const & o) {
|
||||
vm_obj string_iterator_fst(vm_obj const & o) {
|
||||
vm_obj p = string_iterator_prev_to_string(o);
|
||||
return string_to_list_core(to_vm_string(p).m_value, true /* reverse */);
|
||||
}
|
||||
|
||||
vm_obj string_iterator_imp_snd(vm_obj const & o) {
|
||||
vm_obj string_iterator_snd(vm_obj const & o) {
|
||||
vm_obj n = string_iterator_remaining_to_string(o);
|
||||
return string_to_list_core(to_vm_string(n).m_value);
|
||||
}
|
||||
|
|
@ -529,10 +529,10 @@ void initialize_vm_string() {
|
|||
DECLARE_VM_BUILTIN(name({"string", "iterator", "prev_to_string"}), string_iterator_prev_to_string);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator", "extract"}), string_iterator_extract);
|
||||
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator_imp", "mk"}), string_iterator_imp_mk);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator_imp", "fst"}), string_iterator_imp_fst);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator_imp", "snd"}), string_iterator_imp_snd);
|
||||
DECLARE_VM_CASES_BUILTIN(name({"string", "iterator_imp", "cases_on"}), string_iterator_imp_cases_on);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator", "mk"}), string_iterator_mk);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator", "fst"}), string_iterator_fst);
|
||||
DECLARE_VM_BUILTIN(name({"string", "iterator", "snd"}), string_iterator_snd);
|
||||
DECLARE_VM_CASES_BUILTIN(name({"string", "iterator", "cases_on"}), string_iterator_cases_on);
|
||||
}
|
||||
|
||||
void finalize_vm_string() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue