wasm: Implement Str.split

This commit is contained in:
Brian Carroll 2022-07-04 09:29:36 +01:00
parent d2dbb0001a
commit 02ec30425c
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7
7 changed files with 267 additions and 259 deletions

View file

@ -184,7 +184,8 @@ pub fn build_app_module<'a>(
}
let (module, called_preload_fns) = backend.finalize();
let main_function_index = maybe_main_fn_index.unwrap();
let main_function_index =
maybe_main_fn_index.expect("The app must expose at least one value to the host");
(module, called_preload_fns, main_function_index)
}

View file

@ -235,15 +235,7 @@ impl<'a> LowLevelCall<'a> {
self.load_args_and_call_zig(backend, bitcode::STR_STARTS_WITH_SCALAR)
}
StrEndsWith => self.load_args_and_call_zig(backend, bitcode::STR_ENDS_WITH),
StrSplit => {
// LLVM implementation (build_str.rs) does the following
// 1. Call bitcode::STR_COUNT_SEGMENTS
// 2. Allocate a `List Str`
// 3. Call bitcode::STR_STR_SPLIT_IN_PLACE
// 4. Write the elements and length of the List
// To do this here, we need full access to WasmBackend, or we could make a Zig wrapper
todo!("{:?}", self.lowlevel);
}
StrSplit => self.load_args_and_call_zig(backend, bitcode::STR_STR_SPLIT),
StrCountGraphemes => {
self.load_args_and_call_zig(backend, bitcode::STR_COUNT_GRAPEHEME_CLUSTERS)
}