MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / create_jar

Function create_jar

java-linker/src/main.rs:371–537  ·  view source on GitHub ↗

--- create_jar ---

(
    input_class_files: &[String],
    input_jar_files: &[String],
    final_output_jar_path: &str,
    main_class_name: Option<&str>,
)

Source from the content-addressed store, hash-verified

369fn remap_verification_type(
370 verification_type: &mut VerificationType,
371 indexes: &HashMap<u16, u16>,
372) -> io::Result<()> {
373 if let VerificationType::Object { cpool_index } = verification_type {
374 *cpool_index = remapped_constant_index(*cpool_index, indexes)?;
375 }
376 Ok(())
377}
378
379fn remap_stack_frame(frame: &mut StackFrame, indexes: &HashMap<u16, u16>) -> io::Result<()> {
380 match frame {
381 StackFrame::SameLocals1StackItemFrame { stack, .. }
382 | StackFrame::SameLocals1StackItemFrameExtended { stack, .. } => {
383 for item in stack {
384 remap_verification_type(item, indexes)?;
385 }
386 }
387 StackFrame::AppendFrame { locals, .. } => {
388 for item in locals {
389 remap_verification_type(item, indexes)?;
390 }
391 }
392 StackFrame::FullFrame { locals, stack, .. } => {
393 for item in locals.iter_mut().chain(stack.iter_mut()) {
394 remap_verification_type(item, indexes)?;
395 }
396 }
397 StackFrame::SameFrame { .. }
398 | StackFrame::ChopFrame { .. }
399 | StackFrame::SameFrameExtended { .. } => {}
400 }
401 Ok(())
402}
403
404fn remap_instruction(instruction: &mut Instruction, indexes: &HashMap<u16, u16>) -> io::Result<()> {
405 match instruction {
406 Instruction::Ldc(index) => {
407 let shifted = remapped_constant_index(u16::from(*index), indexes)?;
408 if let Ok(short_index) = u8::try_from(shifted) {
409 *index = short_index;
410 } else {
411 *instruction = Instruction::Ldc_w(shifted);
412 }
413 }
414 Instruction::Ldc_w(index)
415 | Instruction::Ldc2_w(index)
416 | Instruction::Getstatic(index)
417 | Instruction::Putstatic(index)
418 | Instruction::Getfield(index)
419 | Instruction::Putfield(index)
420 | Instruction::Invokevirtual(index)
421 | Instruction::Invokespecial(index)
422 | Instruction::Invokestatic(index)
423 | Instruction::Invokedynamic(index)
424 | Instruction::New(index)
425 | Instruction::Anewarray(index)
426 | Instruction::Checkcast(index)
427 | Instruction::Instanceof(index) => *index = remapped_constant_index(*index, indexes)?,
428 Instruction::Invokeinterface(index, _) | Instruction::Multianewarray(index, _) => {

Callers 1

mainFunction · 0.85

Calls 4

merge_input_jarsFunction · 0.85
add_manifest_to_jarFunction · 0.85
nameMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected