| 2216 | } |
| 2217 | |
| 2218 | // Section 2: Consts (lazy: read length prefix, slice bytes, defer parse) |
| 2219 | let num_consts = get_u64(buf)?; |
| 2220 | // §2 file order (ascending addresses, enforced below) — §3 hints |
| 2221 | // and §5 named entries key their constants by index into it. |
| 2222 | let mut consts_order: Vec<Address> = |
| 2223 | Vec::with_capacity(capped_capacity(num_consts, buf)); |
| 2224 | let mut const_windows: Vec<(Address, &[u8])> = |
| 2225 | Vec::with_capacity(capped_capacity(num_consts, buf)); |
| 2226 | for i in 0..num_consts { |
| 2227 | let addr = get_address(buf)?; |
| 2228 | let len = Tag0::get(buf)?.size as usize; |
| 2229 | if buf.len() < len { |
| 2230 | return Err(format!( |
| 2231 | "Env::get: need {} bytes for constant, have {}", |
| 2232 | len, |
| 2233 | buf.len() |
| 2234 | )); |