Skip to main content

evaluate_constant_value

Function evaluate_constant_value 

Source
pub fn evaluate_constant_value(
    name: &str,
    contract: &Contract,
    span: &AstSpan,
) -> Result<usize, CodegenError>
Expand description

Evaluates a constant to its numeric value as a usize

This is useful for builtin functions that need numeric constant values (e.g., __ASSERT_PC) without generating bytecode.

Returns an error if:

  • The constant doesn’t exist
  • The constant is __NOOP (has no numeric value)
  • The constant is a builtin function call
  • The constant value exceeds usize::MAX