(
&self,
size: AddressSize,
name: &ExternalName,
)
| 391 | } |
| 392 | |
| 393 | fn function_address( |
| 394 | &self, |
| 395 | size: AddressSize, |
| 396 | name: &ExternalName, |
| 397 | ) -> Result<Address, MemoryError> { |
| 398 | let curr_func = self.get_current_function(); |
| 399 | let (entry, index) = match name { |
| 400 | ExternalName::User(username) => { |
| 401 | let ext_name = &curr_func.params.user_named_funcs()[*username]; |
| 402 | |
| 403 | // TODO: This is not optimal since we are looking up by string name |
| 404 | let index = self.functions.index_of(&ext_name.to_string()).unwrap(); |
| 405 | |
| 406 | (AddressFunctionEntry::UserFunction, index.as_u32()) |
| 407 | } |
| 408 | |
| 409 | ExternalName::TestCase(testname) => { |
| 410 | // TODO: This is not optimal since we are looking up by string name |
| 411 | let index = self.functions.index_of(&testname.to_string()).unwrap(); |
| 412 | |
| 413 | (AddressFunctionEntry::UserFunction, index.as_u32()) |
| 414 | } |
| 415 | ExternalName::LibCall(libcall) => { |
| 416 | // We don't properly have a "libcall" store, but we can use `LibCall::all()` |
| 417 | // and index into that. |
| 418 | let index = LibCall::all_libcalls() |
| 419 | .iter() |
| 420 | .position(|lc| lc == libcall) |
| 421 | .unwrap(); |
| 422 | |
| 423 | (AddressFunctionEntry::LibCall, index as u32) |
| 424 | } |
| 425 | _ => unimplemented!("function_address: {:?}", name), |
| 426 | }; |
| 427 | |
| 428 | Address::from_parts(size, AddressRegion::Function, entry as u64, index as u64) |
| 429 | } |
| 430 | |
| 431 | fn get_function_from_address(&self, address: Address) -> Option<InterpreterFunctionRef<'a>> { |
| 432 | let index = address.offset as u32; |
no test coverage detected