MCPcopy Create free account
hub / github.com/Rust-API/Rust-API-Bypass-Checker / refine_parameters

Method refine_parameters

src/analysis/memory/symbolic_value.rs:345–433  ·  view source on GitHub ↗

Returns a value that is simplified (refined) by replacing parameter values with their corresponding argument values. If no refinement is possible the result is simply a clone of this value.

(
        &self,
        arguments: &[(Rc<Path>, Rc<SymbolicValue>)],
        // fresh: usize,
    )

Source from the content-addressed store, hash-verified

343 /// with their corresponding argument values. If no refinement is possible
344 /// the result is simply a clone of this value.
345 fn refine_parameters(
346 &self,
347 arguments: &[(Rc<Path>, Rc<SymbolicValue>)],
348 // fresh: usize,
349 ) -> Rc<SymbolicValue> {
350 match &self.expression {
351 Expression::Drop(..) => self.clone(),
352 Expression::Numerical(..) => self.clone(),
353 Expression::Bottom | Expression::Top => self.clone(),
354 Expression::And { left, right } => left
355 .refine_parameters(arguments)
356 .and(right.refine_parameters(arguments)),
357 Expression::CompileTimeConstant(..) => self.clone(),
358 Expression::Cast {
359 operand,
360 target_type,
361 } => operand
362 .refine_parameters(arguments)
363 .cast(target_type.clone()),
364 Expression::Equals { left, right } => left
365 .refine_parameters(arguments)
366 .equals(right.refine_parameters(arguments)),
367 Expression::GreaterOrEqual { left, right } => left
368 .refine_parameters(arguments)
369 .greater_or_equal(right.refine_parameters(arguments)),
370 Expression::GreaterThan { left, right } => left
371 .refine_parameters(arguments)
372 .greater_than(right.refine_parameters(arguments)),
373 Expression::HeapBlock { .. } => self.clone(),
374 Expression::Join { left, right } => left
375 .refine_parameters(arguments)
376 .join(right.refine_parameters(arguments)),
377 Expression::LessOrEqual { left, right } => left
378 .refine_parameters(arguments)
379 .less_or_equal(right.refine_parameters(arguments)),
380 Expression::LessThan { left, right } => left
381 .refine_parameters(arguments)
382 .less_than(right.refine_parameters(arguments)),
383 Expression::LogicalNot { operand } => {
384 operand.refine_parameters(arguments).logical_not()
385 }
386 Expression::Ne { left, right } => left
387 .refine_parameters(arguments)
388 .not_equals(right.refine_parameters(arguments)),
389 Expression::Mul { left, right } => left
390 .refine_parameters(arguments)
391 .mul(right.refine_parameters(arguments)),
392 Expression::Or { left, right } => left
393 .refine_parameters(arguments)
394 .or(right.refine_parameters(arguments)),
395 Expression::Reference(path) => {
396 // if the path is a parameter, the reference is an artifact of its type
397 // and needs to be removed in the call context
398 match &path.value {
399 PathEnum::Parameter { ordinal } => arguments[*ordinal - 1].1.clone(),
400 _ => {
401 let refined_path = path.refine_parameters(arguments);
402 SymbolicValue::make_reference(refined_path)

Callers

nothing calls this directly

Calls 15

andMethod · 0.80
orMethod · 0.80
widenMethod · 0.80
offsetMethod · 0.80
castMethod · 0.45
equalsMethod · 0.45
greater_or_equalMethod · 0.45
greater_thanMethod · 0.45
joinMethod · 0.45
less_or_equalMethod · 0.45
less_thanMethod · 0.45
logical_notMethod · 0.45

Tested by

no test coverage detected