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

Function divide_constants

src/oomir/interpret.rs:397–430  ·  view source on GitHub ↗
(op1: Constant, op2: Constant)

Source from the content-addressed store, hash-verified

395 (Constant::U64(a), Constant::U64(b)) => Some(a.cmp(&b)),
396 (Constant::U32(a), Constant::U32(b)) => Some(a.cmp(&b)),
397 (Constant::U16(a), Constant::U16(b)) => Some(a.cmp(&b)),
398 (Constant::U8(a), Constant::U8(b)) => Some(a.cmp(&b)),
399 (Constant::I32(a), Constant::I32(b)) => Some(a.cmp(&b)),
400 (Constant::I16(a), Constant::I16(b)) => Some(a.cmp(&b)),
401 (Constant::I8(a), Constant::I8(b)) => Some(a.cmp(&b)),
402 (Constant::Boolean(a), Constant::Boolean(b)) => Some(a.cmp(&b)),
403 (Constant::Char(a), Constant::Char(b)) => Some(a.cmp(&b)),
404 (Constant::String(a), Constant::String(b)) => Some(a.cmp(&b)),
405 (Constant::Unit, Constant::Unit) => Some(std::cmp::Ordering::Equal),
406
407 // Complex types (basic equality was needed for recursion, maybe add cmp?)
408 (Constant::Array(ty1, elems1), Constant::Array(ty2, elems2)) => {
409 if ty1 != ty2 || elems1.len() != elems2.len() {
410 // Decide if different types/lengths are comparable (e.g., Less/Greater) or just None
411 return None;
412 }
413 // Lexicographical comparison
414 for (e1, e2) in elems1.iter().zip(elems2.iter()) {
415 match compare_constants(e1.clone(), e2.clone())? {
416 std::cmp::Ordering::Equal => continue,
417 other => return Some(other),
418 }
419 }
420 Some(std::cmp::Ordering::Equal)
421 }
422
423 (
424 Constant::Instance {
425 class_name: cn1,
426 fields: f1,
427 params: p1,
428 ..
429 },
430 Constant::Instance {
431 class_name: cn2,
432 fields: f2,
433 params: p2,

Callers 1

Calls 5

unify_ops_typeFunction · 0.85
parse_constant_to_bigintFunction · 0.85
bigdecimal_to_constantFunction · 0.85
is_zeroMethod · 0.80

Tested by

no test coverage detected