(
instructions: &[Instruction],
initial_locals: &[FrameValue],
local_hints: &[FrameValue],
max_locals: u16,
constant_pool: &mut InternedConstantPool,
context: &str,
)
| 230 | |
| 231 | let descriptor = jvm::JavaString::from(descriptor); |
| 232 | let (params, _) = FieldType::parse_method_descriptor(&descriptor)?; |
| 233 | for param in ¶ms { |
| 234 | push_local_value(&mut locals, frame_value_from_field_type(param)); |
| 235 | } |
| 236 | Ok(locals) |
| 237 | } |
| 238 | |
| 239 | pub(super) fn local_hints_for_oomir_locals( |
| 240 | local_var_map: &HashMap<(String, oomir::Type), u16>, |
| 241 | max_locals: u16, |
| 242 | ) -> Vec<FrameValue> { |
| 243 | let mut hints = vec![FrameValue::Top; max_locals as usize]; |
| 244 | for ((_, ty), local_index) in local_var_map { |
| 245 | set_slot_value(&mut hints, *local_index, frame_value_from_oomir_type(ty)); |
| 246 | } |
| 247 | hints |
| 248 | } |
| 249 | |
| 250 | pub(super) fn build_stack_map_attributes( |
| 251 | instructions: &[Instruction], |
| 252 | initial_locals: &[FrameValue], |
| 253 | local_hints: &[FrameValue], |
| 254 | max_locals: u16, |
| 255 | constant_pool: &mut InternedConstantPool, |
| 256 | context: &str, |
| 257 | exception_table: &[ExceptionTableEntry], |
| 258 | ) -> jvm::Result<Vec<Attribute>> { |
| 259 | let analysis = solve_frame_states( |
| 260 | instructions, |
| 261 | initial_locals, |
| 262 | local_hints, |
| 263 | max_locals as usize, |
| 264 | constant_pool, |
| 265 | context, |
| 266 | exception_table, |
| 267 | )?; |
| 268 | build_stack_map_attributes_from_analysis( |
| 269 | instructions, |
| 270 | initial_locals, |
| 271 | constant_pool, |
| 272 | exception_table, |
| 273 | &analysis, |
| 274 | ) |
| 275 | } |
| 276 | |
| 277 | pub(super) fn build_stack_map_attributes_from_analysis( |
| 278 | instructions: &[Instruction], |
| 279 | initial_locals: &[FrameValue], |
| 280 | constant_pool: &mut InternedConstantPool, |
| 281 | exception_table: &[ExceptionTableEntry], |
| 282 | analysis: &FrameAnalysis, |
| 283 | ) -> jvm::Result<Vec<Attribute>> { |
| 284 | let mut target_offsets = branch_targets(instructions); |
| 285 | target_offsets.extend(exception_table.iter().map(|entry| entry.handler_pc)); |
| 286 | if instructions.is_empty() || target_offsets.is_empty() { |
| 287 | return Ok(Vec::new()); |
| 288 | } |
| 289 |
no test coverage detected