Skip to content

Store Namespace reference in Binary#1800

Merged
seanyoung merged 1 commit intohyperledger-solang:mainfrom
trail-of-forks:store-ns-in-binary
Jun 3, 2025
Merged

Store Namespace reference in Binary#1800
seanyoung merged 1 commit intohyperledger-solang:mainfrom
trail-of-forks:store-ns-in-binary

Conversation

@smoelius
Copy link
Contributor

@smoelius smoelius commented May 30, 2025

Apologies for opening a PR without opening an issue first, but I wanted to be sure what I'm proposing is possible.

The PR's main change is to store a reference to the Namespace in the Binary:

pub ns: &'a Namespace,

This saves having to pass the Namespace around while emitting code.

I tried to find all functions that take both a Binary and Namespace and make it so that they instead take just a Binary and access the Namespace therefrom, but I'm not 100% certain I found all such functions.

All tests pass for me locally following these changes.


Aside: If you are open to fixing #1799, I would do that first. I could then rebase these changes onto that. Doing so would provide some additional assurance that this PR contains no accidental changes.

Copy link
Contributor

@seanyoung seanyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, this had never occurred to me but it's a nice cleanup. Thank you!

@smoelius
Copy link
Contributor Author

smoelius commented Jun 2, 2025

If/when #1802 is merged, I will rebase this PR.

@smoelius smoelius force-pushed the store-ns-in-binary branch from 6fccc02 to 53a4e7f Compare June 2, 2025 21:00
@smoelius
Copy link
Contributor Author

smoelius commented Jun 2, 2025

Here is a diff of the previous patch with the current one, if interested.

Diff of patches
540c540
< index 3ee76d96..12ba29a9 100644
---
> index 9aa7aed7..ad9d83da 100644
1489,1492c1489,1492
< -    let l = expression(target, binary, left, vartab, function, ns).into_array_value();
< -    let r = expression(target, binary, right, vartab, function, ns).into_array_value();
< +    let l = expression(target, binary, left, vartab, function).into_array_value();
< +    let r = expression(target, binary, right, vartab, function).into_array_value();
---
> -    let l = expression(target, bin, left, vartab, function, ns).into_array_value();
> -    let r = expression(target, bin, right, vartab, function, ns).into_array_value();
> +    let l = expression(target, bin, left, vartab, function).into_array_value();
> +    let r = expression(target, bin, right, vartab, function).into_array_value();
1494,1497c1494,1497
< -    let left = binary.build_alloca(function, binary.address_type(ns), "left");
< -    let right = binary.build_alloca(function, binary.address_type(ns), "right");
< +    let left = binary.build_alloca(function, binary.address_type(), "left");
< +    let right = binary.build_alloca(function, binary.address_type(), "right");
---
> -    let left = bin.build_alloca(function, bin.address_type(ns), "left");
> -    let right = bin.build_alloca(function, bin.address_type(ns), "right");
> +    let left = bin.build_alloca(function, bin.address_type(), "left");
> +    let right = bin.build_alloca(function, bin.address_type(), "right");
1499,1503c1499,1503
<      binary.builder.build_store(left, l).unwrap();
<      binary.builder.build_store(right, r).unwrap();
< @@ -2197,7 +2173,7 @@ pub(super) fn compare_address<'a, T: TargetRuntime<'a> + ?Sized>(
<                  binary
<                      .context
---
>      bin.builder.build_store(left, l).unwrap();
>      bin.builder.build_store(right, r).unwrap();
> @@ -2196,7 +2172,7 @@ pub(super) fn compare_address<'a, T: TargetRuntime<'a> + ?Sized>(
>                  right.into(),
>                  bin.context
1506c1506
< +                    .const_int(binary.ns.address_length as u64, false)
---
> +                    .const_int(bin.ns.address_length as u64, false)
1510c1510
< @@ -2220,7 +2196,6 @@ fn runtime_cast<'a>(
---
> @@ -2218,7 +2194,6 @@ fn runtime_cast<'a>(
1518c1518
< @@ -2247,7 +2222,7 @@ fn runtime_cast<'a>(
---
> @@ -2245,7 +2220,7 @@ fn runtime_cast<'a>(
1527c1527
< @@ -2266,18 +2241,18 @@ fn runtime_cast<'a>(
---
> @@ -2264,18 +2239,18 @@ fn runtime_cast<'a>(
1549c1549
< @@ -2288,13 +2263,13 @@ fn runtime_cast<'a>(
---
> @@ -2286,13 +2261,13 @@ fn runtime_cast<'a>(
1566c1566
< @@ -2305,7 +2280,7 @@ fn runtime_cast<'a>(
---
> @@ -2303,7 +2278,7 @@ fn runtime_cast<'a>(
1575c1575
< @@ -2321,31 +2296,31 @@ fn runtime_cast<'a>(
---
> @@ -2319,31 +2294,31 @@ fn runtime_cast<'a>(
1613c1613
< @@ -2372,9 +2347,9 @@ fn runtime_cast<'a>(
---
> @@ -2370,9 +2345,9 @@ fn runtime_cast<'a>(
1625c1625
< @@ -2388,7 +2363,7 @@ fn runtime_cast<'a>(
---
> @@ -2386,7 +2361,7 @@ fn runtime_cast<'a>(
1634c1634
< @@ -2400,7 +2375,7 @@ fn runtime_cast<'a>(
---
> @@ -2398,7 +2373,7 @@ fn runtime_cast<'a>(
1643c1643
< @@ -2426,7 +2401,7 @@ fn runtime_cast<'a>(
---
> @@ -2424,7 +2399,7 @@ fn runtime_cast<'a>(
1652c1652
< @@ -2464,7 +2439,6 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
---
> @@ -2462,7 +2437,6 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
1660c1660
< @@ -2472,7 +2446,7 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
---
> @@ -2470,7 +2444,7 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
1669c1669
< @@ -2492,7 +2466,6 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
---
> @@ -2490,7 +2464,6 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
1677c1677
< @@ -2540,9 +2513,9 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
---
> @@ -2538,9 +2511,9 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
1689c1689
< @@ -2555,7 +2528,6 @@ fn basic_value_to_slice<'a>(
---
> @@ -2553,7 +2526,6 @@ fn basic_value_to_slice<'a>(
1697c1697
< @@ -2571,20 +2543,23 @@ fn basic_value_to_slice<'a>(
---
> @@ -2569,20 +2541,23 @@ fn basic_value_to_slice<'a>(
1728c1728
< @@ -2612,7 +2587,7 @@ fn basic_value_to_slice<'a>(
---
> @@ -2610,7 +2585,7 @@ fn basic_value_to_slice<'a>(
1737c1737
< @@ -2627,7 +2602,7 @@ fn basic_value_to_slice<'a>(
---
> @@ -2625,7 +2600,7 @@ fn basic_value_to_slice<'a>(
1746c1746
< @@ -2651,7 +2626,7 @@ fn basic_value_to_slice<'a>(
---
> @@ -2649,7 +2624,7 @@ fn basic_value_to_slice<'a>(
1755c1755
< @@ -2665,14 +2640,13 @@ fn basic_value_to_slice<'a>(
---
> @@ -2663,14 +2638,13 @@ fn basic_value_to_slice<'a>(
2676c2676
< index 700abcb0..53c4d09f 100644
---
> index e642cb1d..18b23794 100644
2819c2819
< -    fn value_transferred<'b>(&self, binary: &Binary<'b>, ns: &Namespace) -> IntValue<'b>;
---
> -    fn value_transferred<'b>(&self, bin: &Binary<'b>, ns: &Namespace) -> IntValue<'b>;
2823c2823
< -    fn selfdestruct<'b>(&self, binary: &Binary<'b>, addr: ArrayValue<'b>, ns: &Namespace);
---
> -    fn selfdestruct<'b>(&self, bin: &Binary<'b>, addr: ArrayValue<'b>, ns: &Namespace);
2837c2837
< index 4078efad..9d9566e1 100644
---
> index 64317509..e94d4caa 100644
2842c2842
<          let mut binary = Binary::new(
---
>          let mut bin = Binary::new(
2853,2854c2853,2854
< -        binary.set_early_value_aborts(contract, ns);
< +        binary.set_early_value_aborts(contract);
---
> -        bin.set_early_value_aborts(contract, ns);
> +        bin.set_early_value_aborts(contract);
2856c2856
<          let scratch_len = binary.module.add_global(
---
>          let scratch_len = bin.module.add_global(
2860c2860
<          target.declare_externals(&binary);
---
>          target.declare_externals(&bin);
2862,2863c2862,2863
< -        emit_functions(&mut target, &mut binary, contract, ns);
< +        emit_functions(&mut target, &mut binary, contract);
---
> -        emit_functions(&mut target, &mut bin, contract, ns);
> +        emit_functions(&mut target, &mut bin, contract);
2866c2866
<          let mut storage_initializers = binary
---
>          let mut storage_initializers = bin
2871,2874c2871,2874
< -        target.emit_dispatch(Some(storage_initializer), &mut binary, ns);
< -        target.emit_dispatch(None, &mut binary, ns);
< +        target.emit_dispatch(Some(storage_initializer), &mut binary);
< +        target.emit_dispatch(None, &mut binary);
---
> -        target.emit_dispatch(Some(storage_initializer), &mut bin, ns);
> -        target.emit_dispatch(None, &mut bin, ns);
> +        target.emit_dispatch(Some(storage_initializer), &mut bin);
> +        target.emit_dispatch(None, &mut bin);
2876c2876
<          binary.internalize(&[
---
>          bin.internalize(&[
2878c2878
< @@ -281,12 +281,7 @@ impl PolkadotTarget {
---
> @@ -274,12 +274,7 @@ impl PolkadotTarget {
2892c2892
< @@ -298,7 +293,7 @@ impl PolkadotTarget {
---
> @@ -291,7 +286,7 @@ impl PolkadotTarget {
2902c2902
< index 733ef9b0..d88169e1 100644
---
> index c53b8ff4..bb0a3579 100644
2914,2920c2914,2916
< @@ -47,7 +47,6 @@ impl StorageSlot for PolkadotTarget {
<          &self,
<          binary: &Binary<'a>,
<          slot: PointerValue<'a>,
< -        ns: &Namespace,
<      ) -> ArrayValue<'a> {
<          emit_context!(binary);
---
> @@ -43,18 +43,13 @@ impl StorageSlot for PolkadotTarget {
>          );
>      }
2922c2918,2925
< @@ -55,7 +54,7 @@ impl StorageSlot for PolkadotTarget {
---
> -    fn get_storage_address<'a>(
> -        &self,
> -        bin: &Binary<'a>,
> -        slot: PointerValue<'a>,
> -        ns: &Namespace,
> -    ) -> ArrayValue<'a> {
> +    fn get_storage_address<'a>(&self, bin: &Binary<'a>, slot: PointerValue<'a>) -> ArrayValue<'a> {
>          emit_context!(bin);
2924,2925c2927,2929
<          binary
<              .builder
---
>          let (scratch_buf, scratch_len) = scratch_buf!();
>  
>          bin.builder
2927c2931
< +            .build_store(scratch_len, i32_const!(binary.ns.address_length as u64))
---
> +            .build_store(scratch_len, i32_const!(bin.ns.address_length as u64))
2931c2935,2936
< @@ -76,10 +75,10 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -73,10 +68,10 @@ impl StorageSlot for PolkadotTarget {
>              .build_select(
2933,2936c2938,2940
<                  binary
<                      .builder
< -                    .build_load(binary.address_type(ns), scratch_buf, "address")
< +                    .build_load(binary.address_type(), scratch_buf, "address")
---
>                  bin.builder
> -                    .build_load(bin.address_type(ns), scratch_buf, "address")
> +                    .build_load(bin.address_type(), scratch_buf, "address")
2939,2940c2943,2944
< -                binary.address_type(ns).const_zero(),
< +                binary.address_type().const_zero(),
---
> -                bin.address_type(ns).const_zero(),
> +                bin.address_type().const_zero(),
2944c2948
< @@ -103,15 +102,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -100,15 +95,14 @@ impl StorageSlot for PolkadotTarget {
2962c2966
< @@ -141,11 +139,10 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -138,11 +132,10 @@ impl StorageSlot for PolkadotTarget {
2977c2981
< @@ -165,14 +162,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -162,14 +155,14 @@ impl StorageSlot for PolkadotTarget {
2994c2998
< @@ -206,7 +203,6 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -203,7 +196,6 @@ impl StorageSlot for PolkadotTarget {
3002c3006
< @@ -221,15 +217,15 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -218,15 +210,15 @@ impl StorageSlot for PolkadotTarget {
3022c3026
< @@ -246,7 +242,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -243,7 +235,7 @@ impl StorageSlot for PolkadotTarget {
3031c3035
< @@ -263,8 +259,8 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -260,8 +252,8 @@ impl StorageSlot for PolkadotTarget {
3042c3046
< @@ -277,8 +273,8 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -274,8 +266,8 @@ impl StorageSlot for PolkadotTarget {
3053c3057
< @@ -298,7 +294,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -295,7 +287,7 @@ impl StorageSlot for PolkadotTarget {
3062c3066
< @@ -308,14 +304,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -305,14 +297,14 @@ impl StorageSlot for PolkadotTarget {
3079c3083
< @@ -325,11 +321,11 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -322,11 +314,11 @@ impl StorageSlot for PolkadotTarget {
3093c3097
< @@ -337,11 +333,11 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -334,11 +326,11 @@ impl StorageSlot for PolkadotTarget {
3107c3111
< @@ -353,12 +349,12 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -350,12 +342,12 @@ impl StorageSlot for PolkadotTarget {
3122c3126
< @@ -374,7 +370,6 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -371,7 +363,6 @@ impl StorageSlot for PolkadotTarget {
3130c3134
< @@ -388,7 +383,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -385,7 +376,7 @@ impl StorageSlot for PolkadotTarget {
3139c3143
< @@ -396,11 +391,11 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -393,11 +384,11 @@ impl StorageSlot for PolkadotTarget {
3154c3158
< @@ -415,15 +410,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -412,15 +403,14 @@ impl StorageSlot for PolkadotTarget {
3172c3176
< @@ -437,7 +431,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -434,7 +424,7 @@ impl StorageSlot for PolkadotTarget {
3181c3185
< @@ -452,7 +446,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -449,7 +439,7 @@ impl StorageSlot for PolkadotTarget {
3190c3194
< @@ -461,7 +455,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -458,7 +448,7 @@ impl StorageSlot for PolkadotTarget {
3199c3203
< @@ -471,14 +465,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -468,14 +458,14 @@ impl StorageSlot for PolkadotTarget {
3216c3220
< @@ -487,13 +481,12 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -484,13 +474,12 @@ impl StorageSlot for PolkadotTarget {
3231c3235
< @@ -511,7 +504,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -508,7 +497,7 @@ impl StorageSlot for PolkadotTarget {
3240c3244
< @@ -523,8 +516,8 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -520,8 +509,8 @@ impl StorageSlot for PolkadotTarget {
3251c3255
< @@ -540,15 +533,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -537,15 +526,14 @@ impl StorageSlot for PolkadotTarget {
3269c3273
< @@ -564,14 +556,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -561,14 +549,14 @@ impl StorageSlot for PolkadotTarget {
3287c3291
< @@ -581,11 +573,11 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -578,11 +566,11 @@ impl StorageSlot for PolkadotTarget {
3301c3305
< @@ -596,10 +588,10 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -593,10 +581,10 @@ impl StorageSlot for PolkadotTarget {
3316c3320
< @@ -607,24 +599,16 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -604,24 +592,16 @@ impl StorageSlot for PolkadotTarget {
3344c3348
< @@ -644,13 +628,13 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -641,13 +621,13 @@ impl StorageSlot for PolkadotTarget {
3360c3364
< @@ -671,16 +655,11 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -668,16 +648,11 @@ impl StorageSlot for PolkadotTarget {
3379c3383
< @@ -693,7 +672,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -690,7 +665,7 @@ impl StorageSlot for PolkadotTarget {
3388c3392
< @@ -712,7 +691,7 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -709,7 +684,7 @@ impl StorageSlot for PolkadotTarget {
3397c3401
< @@ -724,7 +703,6 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -721,7 +696,6 @@ impl StorageSlot for PolkadotTarget {
3405c3409
< @@ -737,14 +715,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -734,14 +708,14 @@ impl StorageSlot for PolkadotTarget {
3423c3427
< @@ -771,7 +749,6 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -768,7 +742,6 @@ impl StorageSlot for PolkadotTarget {
3431c3435
< @@ -787,14 +764,14 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -784,14 +757,14 @@ impl StorageSlot for PolkadotTarget {
3449c3453
< @@ -803,21 +780,21 @@ impl StorageSlot for PolkadotTarget {
---
> @@ -800,21 +773,21 @@ impl StorageSlot for PolkadotTarget {
3477c3481
< index 48ada7cd..78721bd4 100644
---
> index 09e0d91a..69d3b0a6 100644
3490c3494
<          binary: &Binary<'a>,
---
>          bin: &Binary<'a>,
3495c3499
<          emit_context!(binary);
---
>          emit_context!(bin);
3499c3503
< +        let len = binary.ns.address_length + 4;
---
> +        let len = bin.ns.address_length + 4;
3503c3507
< @@ -301,7 +300,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -285,7 +284,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3509c3513
<          emit_context!(binary);
---
>          emit_context!(bin);
3511c3515
< @@ -364,9 +362,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -342,9 +340,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3517,3519c3521,3523
< -        let (revert_out, revert_out_len) = binary.panic_data_const(ns, PanicCode::ArrayIndexOob);
< +        let (revert_out, revert_out_len) = binary.panic_data_const(PanicCode::ArrayIndexOob);
<          self.assert_failure(binary, revert_out, revert_out_len);
---
> -        let (revert_out, revert_out_len) = bin.panic_data_const(ns, PanicCode::ArrayIndexOob);
> +        let (revert_out, revert_out_len) = bin.panic_data_const(PanicCode::ArrayIndexOob);
>          self.assert_failure(bin, revert_out, revert_out_len);
3521,3522c3525,3526
<          binary.builder.position_at_end(retrieve_block);
< @@ -397,7 +394,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          bin.builder.position_at_end(retrieve_block);
> @@ -373,7 +370,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3529,3530c3533,3534
<          emit_context!(binary);
< @@ -456,13 +452,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          emit_context!(bin);
> @@ -426,13 +422,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3533,3534c3537,3538
<          binary.builder.position_at_end(bang_block);
< -        binary.log_runtime_error(
---
>          bin.builder.position_at_end(bang_block);
> -        bin.log_runtime_error(
3540,3543c3544,3547
< -        let (revert_out, revert_out_len) = binary.panic_data_const(ns, PanicCode::ArrayIndexOob);
< +        binary.log_runtime_error(self, "storage index out of bounds".to_string(), Some(loc));
< +        let (revert_out, revert_out_len) = binary.panic_data_const(PanicCode::ArrayIndexOob);
<          self.assert_failure(binary, revert_out, revert_out_len);
---
> -        let (revert_out, revert_out_len) = bin.panic_data_const(ns, PanicCode::ArrayIndexOob);
> +        bin.log_runtime_error(self, "storage index out of bounds".to_string(), Some(loc));
> +        let (revert_out, revert_out_len) = bin.panic_data_const(PanicCode::ArrayIndexOob);
>          self.assert_failure(bin, revert_out, revert_out_len);
3545,3546c3549,3550
<          binary.builder.position_at_end(retrieve_block);
< @@ -498,7 +489,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          bin.builder.position_at_end(retrieve_block);
> @@ -467,7 +458,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3552c3556
<          emit_context!(binary);
---
>          emit_context!(bin);
3554c3558
< @@ -584,7 +574,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -547,7 +537,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3561,3562c3565,3566
<          emit_context!(binary);
< @@ -643,13 +632,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          emit_context!(bin);
> @@ -600,13 +589,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3565,3566c3569,3570
<          binary.builder.position_at_end(bang_block);
< -        binary.log_runtime_error(
---
>          bin.builder.position_at_end(bang_block);
> -        bin.log_runtime_error(
3572,3575c3576,3579
< -        let (revert_out, revert_out_len) = binary.panic_data_const(ns, PanicCode::EmptyArrayPop);
< +        binary.log_runtime_error(self, "pop from empty storage array".to_string(), Some(loc));
< +        let (revert_out, revert_out_len) = binary.panic_data_const(PanicCode::EmptyArrayPop);
<          self.assert_failure(binary, revert_out, revert_out_len);
---
> -        let (revert_out, revert_out_len) = bin.panic_data_const(ns, PanicCode::EmptyArrayPop);
> +        bin.log_runtime_error(self, "pop from empty storage array".to_string(), Some(loc));
> +        let (revert_out, revert_out_len) = bin.panic_data_const(PanicCode::EmptyArrayPop);
>          self.assert_failure(bin, revert_out, revert_out_len);
3577,3578c3581,3583
<          binary.builder.position_at_end(retrieve_block);
< @@ -676,7 +660,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          bin.builder.position_at_end(retrieve_block);
> @@ -631,7 +615,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>  
3580,3583c3585,3587
<                  binary
<                      .builder
< -                    .build_load(binary.llvm_type(ty, ns), offset, "popped_value")
< +                    .build_load(binary.llvm_type(ty), offset, "popped_value")
---
>                  bin.builder
> -                    .build_load(bin.llvm_type(ty, ns), offset, "popped_value")
> +                    .build_load(bin.llvm_type(ty), offset, "popped_value")
3587c3591
< @@ -700,7 +684,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -655,7 +639,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3593c3597
<          emit_context!(binary);
---
>          emit_context!(bin);
3595c3599
< @@ -773,7 +756,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -722,7 +705,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3601c3605
<          emit_context!(binary);
---
>          emit_context!(bin);
3603c3607
< @@ -832,14 +814,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -781,14 +763,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3610c3614
<          emit_context!(binary);
---
>          emit_context!(bin);
3613c3617
< +        let created_contract = &binary.ns.contracts[contract_no];
---
> +        let created_contract = &bin.ns.contracts[contract_no];
3615,3616c3619,3620
< -        let code = created_contract.emit(ns, binary.options, contract_no);
< +        let code = created_contract.emit(binary.ns, binary.options, contract_no);
---
> -        let code = created_contract.emit(ns, bin.options, contract_no);
> +        let code = created_contract.emit(bin.ns, bin.options, contract_no);
3620c3624
< @@ -866,12 +847,12 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -813,12 +794,12 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3622c3626
<          let value_ptr = binary
---
>          let value_ptr = bin
3624,3625c3628,3629
< -            .build_alloca(binary.value_type(ns), "balance")
< +            .build_alloca(binary.value_type(), "balance")
---
> -            .build_alloca(bin.value_type(ns), "balance")
> +            .build_alloca(bin.value_type(), "balance")
3630,3632c3634,3636
< -            .unwrap_or_else(|| binary.value_type(ns).const_zero());
< +            .unwrap_or_else(|| binary.value_type().const_zero());
<          binary.builder.build_store(value_ptr, value).unwrap();
---
> -            .unwrap_or_else(|| bin.value_type(ns).const_zero());
> +            .unwrap_or_else(|| bin.value_type().const_zero());
>          bin.builder.build_store(value_ptr, value).unwrap();
3635c3639,3640
< @@ -888,7 +869,10 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -834,7 +815,10 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>              .unwrap();
3637,3638c3642
<          binary
<              .builder
---
>          bin.builder
3642c3646
< +                i32_const!(binary.ns.address_length as u64 * 32),
---
> +                i32_const!(bin.ns.address_length as u64 * 32),
3646,3647c3650,3651
<          binary
< @@ -930,7 +914,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          bin.builder
> @@ -875,7 +859,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3654,3655c3658,3659
<          emit_context!(binary);
< @@ -946,7 +929,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          emit_context!(bin);
> @@ -890,7 +873,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3657c3661
<                  let value_ptr = binary
---
>                  let value_ptr = bin
3659,3660c3663,3664
< -                    .build_alloca(binary.value_type(ns), "balance")
< +                    .build_alloca(binary.value_type(), "balance")
---
> -                    .build_alloca(bin.value_type(ns), "balance")
> +                    .build_alloca(bin.value_type(), "balance")
3662,3664c3666,3668
<                  binary
<                      .builder
< @@ -1023,7 +1006,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>                  bin.builder
>                      .build_store(value_ptr, contract_args.value.unwrap())
> @@ -962,7 +945,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3666c3670
<                  binary.builder.position_at_end(not_found_block);
---
>                  bin.builder.position_at_end(not_found_block);
3668,3673c3672,3677
< -                binary.log_runtime_error(self, msg.into(), Some(loc), ns);
< +                binary.log_runtime_error(self, msg.into(), Some(loc));
<                  binary
<                      .builder
<                      .build_unconditional_branch(done_block)
< @@ -1069,7 +1052,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> -                bin.log_runtime_error(self, msg.into(), Some(loc), ns);
> +                bin.log_runtime_error(self, msg.into(), Some(loc));
>                  bin.builder.build_unconditional_branch(done_block).unwrap();
>  
>                  bin.builder.position_at_end(call_block);
> @@ -1002,7 +985,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3680,3681c3684,3685
<          emit_context!(binary);
< @@ -1077,7 +1059,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          emit_context!(bin);
> @@ -1010,7 +992,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3683c3687
<          let value_ptr = binary
---
>          let value_ptr = bin
3685,3686c3689,3690
< -            .build_alloca(binary.value_type(ns), "balance")
< +            .build_alloca(binary.value_type(), "balance")
---
> -            .build_alloca(bin.value_type(ns), "balance")
> +            .build_alloca(bin.value_type(), "balance")
3688c3692
<          binary.builder.build_store(value_ptr, value).unwrap();
---
>          bin.builder.build_store(value_ptr, value).unwrap();
3690c3694
< @@ -1086,9 +1068,9 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1019,9 +1001,9 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3695c3699
< +                i32_const!(binary.ns.address_length as u64).into(),
---
> +                i32_const!(bin.ns.address_length as u64).into(),
3698c3702
< +                i32_const!(binary.ns.value_length as u64).into()
---
> +                i32_const!(bin.ns.value_length as u64).into()
3702c3706
< @@ -1119,12 +1101,12 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1052,13 +1034,10 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3706,3708c3710,3712
< -    fn value_transferred<'b>(&self, binary: &Binary<'b>, ns: &ast::Namespace) -> IntValue<'b> {
< +    fn value_transferred<'b>(&self, binary: &Binary<'b>) -> IntValue<'b> {
<          emit_context!(binary);
---
> -    fn value_transferred<'b>(&self, bin: &Binary<'b>, ns: &ast::Namespace) -> IntValue<'b> {
> +    fn value_transferred<'b>(&self, bin: &Binary<'b>) -> IntValue<'b> {
>          emit_context!(bin);
3710,3714c3714,3718
<          let value = binary
<              .builder
< -            .build_alloca(binary.value_type(ns), "value")
< +            .build_alloca(binary.value_type(), "value")
<              .unwrap();
---
> -        let value = bin
> -            .builder
> -            .build_alloca(bin.value_type(ns), "value")
> -            .unwrap();
> +        let value = bin.builder.build_alloca(bin.value_type(), "value").unwrap();
3716,3719c3720
<          let value_len = binary
< @@ -1134,7 +1116,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
<  
<          binary
---
>          let value_len = bin
3720a3722,3725
> @@ -1066,7 +1045,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>              .unwrap();
>  
>          bin.builder
3722c3727
< +            .build_store(value_len, i32_const!(binary.ns.value_length as u64))
---
> +            .build_store(value_len, i32_const!(bin.ns.value_length as u64))
3726c3731,3732
< @@ -1145,18 +1127,18 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1076,18 +1055,18 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>          );
3728,3731c3734,3736
<          binary
<              .builder
< -            .build_load(binary.value_type(ns), value, "value_transferred")
< +            .build_load(binary.value_type(), value, "value_transferred")
---
>          bin.builder
> -            .build_load(bin.value_type(ns), value, "value_transferred")
> +            .build_load(bin.value_type(), value, "value_transferred")
3737,3739c3742,3744
< -    fn selfdestruct<'b>(&self, binary: &Binary<'b>, addr: ArrayValue<'b>, ns: &ast::Namespace) {
< +    fn selfdestruct<'b>(&self, binary: &Binary<'b>, addr: ArrayValue<'b>) {
<          emit_context!(binary);
---
> -    fn selfdestruct<'b>(&self, bin: &Binary<'b>, addr: ArrayValue<'b>, ns: &ast::Namespace) {
> +    fn selfdestruct<'b>(&self, bin: &Binary<'b>, addr: ArrayValue<'b>) {
>          emit_context!(bin);
3741c3746
<          let address = binary
---
>          let address = bin
3743,3744c3748,3749
< -            .build_alloca(binary.address_type(ns), "address")
< +            .build_alloca(binary.address_type(), "address")
---
> -            .build_alloca(bin.address_type(ns), "address")
> +            .build_alloca(bin.address_type(), "address")
3747,3748c3752,3753
<          binary.builder.build_store(address, addr).unwrap();
< @@ -1175,7 +1157,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>          bin.builder.build_store(address, addr).unwrap();
> @@ -1106,7 +1085,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3754c3759
<          emit_context!(binary);
---
>          emit_context!(bin);
3756c3761
< @@ -1197,10 +1178,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1128,7 +1106,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3758c3763
<          let temp = binary
---
>          let temp = bin
3760,3764c3765,3766
< -            .build_alloca(
< -                binary.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
< -                "hash",
< -            )
< +            .build_alloca(binary.llvm_type(&ast::Type::Bytes(hashlen as u8)), "hash")
---
> -            .build_alloca(bin.llvm_type(&ast::Type::Bytes(hashlen as u8), ns), "hash")
> +            .build_alloca(bin.llvm_type(&ast::Type::Bytes(hashlen as u8)), "hash")
3768,3770c3770,3772
< @@ -1211,7 +1189,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
<          binary
<              .builder
---
> @@ -1138,7 +1116,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>  
>          bin.builder
3772,3773c3774,3775
< -                binary.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
< +                binary.llvm_type(&ast::Type::Bytes(hashlen as u8)),
---
> -                bin.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
> +                bin.llvm_type(&ast::Type::Bytes(hashlen as u8)),
3777c3779
< @@ -1314,7 +1292,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1232,7 +1210,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3783c3785
<          emit_context!(binary);
---
>          emit_context!(bin);
3785c3787
< @@ -1456,14 +1433,14 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1363,13 +1340,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3787c3789
<                      binary.context.i64_type().const_int(1, false)
---
>                      bin.context.i64_type().const_int(1, false)
3789,3790c3791,3792
< -                    expression(self, binary, &args[0], vartab, function, ns).into_int_value()
< +                    expression(self, binary, &args[0], vartab, function).into_int_value()
---
> -                    expression(self, bin, &args[0], vartab, function, ns).into_int_value()
> +                    expression(self, bin, &args[0], vartab, function).into_int_value()
3795,3796c3797
<                  binary
<                      .builder
---
>                  bin.builder
3798c3799
< +                    .build_store(scratch_len, i32_const!(binary.ns.value_length as u64))
---
> +                    .build_store(scratch_len, i32_const!(bin.ns.value_length as u64))
3802c3803,3804
< @@ -1477,7 +1454,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1381,7 +1358,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  bin.builder
3804,3805c3806
<                          binary
<                              .context
---
>                          bin.context
3807c3808
< +                            .custom_width_int_type(binary.ns.value_length as u32 * 8),
---
> +                            .custom_width_int_type(bin.ns.value_length as u32 * 8),
3811c3812,3813
< @@ -1491,7 +1468,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1394,7 +1371,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  let (scratch_buf, scratch_len) = scratch_buf!();
3813,3814c3815
<                  binary
<                      .builder
---
>                  bin.builder
3816c3817
< +                    .build_store(scratch_len, i32_const!(binary.ns.address_length as u64))
---
> +                    .build_store(scratch_len, i32_const!(bin.ns.address_length as u64))
3820c3821,3822
< @@ -1502,13 +1479,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1404,13 +1381,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  );
3822,3825c3824,3826
<                  binary
<                      .builder
< -                    .build_load(binary.address_type(ns), scratch_buf, "caller")
< +                    .build_load(binary.address_type(), scratch_buf, "caller")
---
>                  bin.builder
> -                    .build_load(bin.address_type(ns), scratch_buf, "caller")
> +                    .build_load(bin.address_type(), scratch_buf, "caller")
3831,3832c3832,3833
< -            } => self.value_transferred(binary, ns).into(),
< +            } => self.value_transferred(binary).into(),
---
> -            } => self.value_transferred(bin, ns).into(),
> +            } => self.value_transferred(bin).into(),
3836c3837
< @@ -1516,7 +1493,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1418,7 +1395,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3841c3842
< +                    binary.ns.value_length as u32 * 8
---
> +                    bin.ns.value_length as u32 * 8
3845c3846,3847
< @@ -1527,7 +1504,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1428,7 +1405,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  let (scratch_buf, scratch_len) = scratch_buf!();
3847,3848c3849
<                  binary
<                      .builder
---
>                  bin.builder
3850c3851
< +                    .build_store(scratch_len, i32_const!(binary.ns.address_length as u64))
---
> +                    .build_store(scratch_len, i32_const!(bin.ns.address_length as u64))
3854c3855,3856
< @@ -1549,7 +1526,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1449,7 +1426,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  let (scratch_buf, scratch_len) = scratch_buf!();
3856,3857c3858
<                  binary
<                      .builder
---
>                  bin.builder
3859c3860
< +                    .build_store(scratch_len, i32_const!(binary.ns.value_length as u64))
---
> +                    .build_store(scratch_len, i32_const!(bin.ns.value_length as u64))
3863c3864,3865
< @@ -1560,7 +1537,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1459,7 +1436,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
>                  );
3865,3868c3867,3869
<                  binary
<                      .builder
< -                    .build_load(binary.value_type(ns), scratch_buf, "balance")
< +                    .build_load(binary.value_type(), scratch_buf, "balance")
---
>                  bin.builder
> -                    .build_load(bin.value_type(ns), scratch_buf, "balance")
> +                    .build_load(bin.value_type(), scratch_buf, "balance")
3872c3873
< @@ -1573,7 +1550,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1472,14 +1449,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3880,3882c3881,3882
< @@ -1583,7 +1559,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
<              .build_alloca(slot.get_type(), "slot")
<              .unwrap();
---
>          // to store it
>          let slot_ptr = bin.builder.build_alloca(slot.get_type(), "slot").unwrap();
3884,3885c3884,3885
< -        self.storage_load_slot(binary, ty, slot, slot_ptr, function, ns)
< +        self.storage_load_slot(binary, ty, slot, slot_ptr, function)
---
> -        self.storage_load_slot(bin, ty, slot, slot_ptr, function, ns)
> +        self.storage_load_slot(bin, ty, slot, slot_ptr, function)
3889c3889
< @@ -1594,7 +1570,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1490,12 +1466,11 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3896,3899c3896
<          let slot_ptr = binary
< @@ -1602,7 +1577,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
<              .build_alloca(slot.get_type(), "slot")
<              .unwrap();
---
>          let slot_ptr = bin.builder.build_alloca(slot.get_type(), "slot").unwrap();
3901,3902c3898,3899
< -        self.storage_store_slot(binary, ty, slot, slot_ptr, dest, function, ns);
< +        self.storage_store_slot(binary, ty, slot, slot_ptr, dest, function);
---
> -        self.storage_store_slot(bin, ty, slot, slot_ptr, dest, function, ns);
> +        self.storage_store_slot(bin, ty, slot, slot_ptr, dest, function);
3906c3903
< @@ -1611,11 +1586,10 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1504,11 +1479,10 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3919c3916
< @@ -1625,7 +1599,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1518,7 +1492,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3925c3922
<          emit_context!(binary);
---
>          emit_context!(bin);
3927c3924
< @@ -1682,7 +1655,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
> @@ -1572,7 +1545,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3929c3926
<                  let address = binary
---
>                  let address = bin
3931,3932c3928,3929
< -                    .build_alloca(binary.address_type(ns), "maybe_contract")
< +                    .build_alloca(binary.address_type(), "maybe_contract")
---
> -                    .build_alloca(bin.address_type(ns), "maybe_contract")
> +                    .build_alloca(bin.address_type(), "maybe_contract")
3934,3936c3931,3933
<                  binary
<                      .builder
< @@ -1735,7 +1708,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
---
>                  bin.builder
>                      .build_store(address, args[0].into_array_value())
> @@ -1621,7 +1594,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
3945c3942
< index 43dc943f..2a3fd10e 100644
---
> index a7ff4361..4b84c42d 100644
3963c3960
<          let mut binary = Binary::new(
---
>          let mut bin = Binary::new(
3970c3967
< @@ -68,9 +67,9 @@ impl SolanaTarget {
---
> @@ -67,9 +66,9 @@ impl SolanaTarget {
3974,3975c3971,3972
< -        target.declare_externals(&mut binary, ns);
< +        target.declare_externals(&mut binary);
---
> -        target.declare_externals(&mut bin, ns);
> +        target.declare_externals(&mut bin);
3977,3978c3974,3975
< -        emit_functions(&mut target, &mut binary, contract, ns);
< +        emit_functions(&mut target, &mut binary, contract);
---
> -        emit_functions(&mut target, &mut bin, contract, ns);
> +        emit_functions(&mut target, &mut bin, contract);
3980c3977
<          binary.internalize(&[
---
>          bin.internalize(&[
3982,3983c3979,3980
< @@ -90,16 +89,13 @@ impl SolanaTarget {
<          binary
---
> @@ -89,16 +88,13 @@ impl SolanaTarget {
>          bin
3986,3993c3983,3990
< -    fn declare_externals(&self, binary: &mut Binary, ns: &ast::Namespace) {
< +    fn declare_externals(&self, binary: &mut Binary) {
<          let void_ty = binary.context.void_type();
<          let u8_ptr = binary.context.i8_type().ptr_type(AddressSpace::default());
<          let u64_ty = binary.context.i64_type();
<          let u32_ty = binary.context.i32_type();
< -        let address = binary.address_type(ns).ptr_type(AddressSpace::default());
< -        let seeds = binary.llvm_type(
---
> -    fn declare_externals(&self, bin: &mut Binary, ns: &ast::Namespace) {
> +    fn declare_externals(&self, bin: &mut Binary) {
>          let void_ty = bin.context.void_type();
>          let u8_ptr = bin.context.i8_type().ptr_type(AddressSpace::default());
>          let u64_ty = bin.context.i64_type();
>          let u32_ty = bin.context.i32_type();
> -        let address = bin.address_type(ns).ptr_type(AddressSpace::default());
> -        let seeds = bin.llvm_type(
3997,3998c3994,3995
< +        let address = binary.address_type().ptr_type(AddressSpace::default());
< +        let seeds = binary.llvm_type(&Type::Ref(Box::new(Type::Slice(Box::new(Type::Bytes(1))))));
---
> +        let address = bin.address_type().ptr_type(AddressSpace::default());
> +        let seeds = bin.llvm_type(&Type::Ref(Box::new(Type::Slice(Box::new(Type::Bytes(1))))));
4000c3997
<          let sol_bytes = binary
---
>          let sol_bytes = bin
4002c3999
< @@ -325,9 +321,8 @@ impl SolanaTarget {
---
> @@ -312,9 +308,8 @@ impl SolanaTarget {
4009c4006
< +        if !zero && !ty.is_dynamic(binary.ns) {
---
> +        if !zero && !ty.is_dynamic(bin.ns) {
4013c4010
< @@ -365,7 +360,7 @@ impl SolanaTarget {
---
> @@ -350,7 +345,7 @@ impl SolanaTarget {
4018c4015
< +            if elem_ty.is_dynamic(binary.ns) || zero {
---
> +            if elem_ty.is_dynamic(bin.ns) || zero {
4020,4022c4017,4019
<                      binary
<                          .context
< @@ -380,10 +375,10 @@ impl SolanaTarget {
---
>                      bin.context
>                          .i32_type()
> @@ -364,10 +359,10 @@ impl SolanaTarget {
4026,4027c4023,4024
< -                    self.storage_array_length(binary, function, slot, elem_ty, ns)
< +                    self.storage_array_length(binary, function, slot, elem_ty)
---
> -                    self.storage_array_length(bin, function, slot, elem_ty, ns)
> +                    self.storage_array_length(bin, function, slot, elem_ty)
4031c4028
< +                let elem_size = elem_ty.solana_storage_size(binary.ns).to_u64().unwrap();
---
> +                let elem_size = elem_ty.solana_storage_size(bin.ns).to_u64().unwrap();
4034,4038c4031,4042
<                  let mut builder = LoopBuilder::new(binary, function);
< @@ -405,7 +400,6 @@ impl SolanaTarget {
<                      offset_val,
<                      function,
<                      zero,
---
>                  let mut builder = LoopBuilder::new(bin, function);
> @@ -382,15 +377,7 @@ impl SolanaTarget {
>  
>                  let elem_ty = ty.array_deref();
>  
> -                self.storage_free(
> -                    bin,
> -                    elem_ty.deref_any(),
> -                    data,
> -                    offset_val,
> -                    function,
> -                    zero,
4040c4044,4045
<                  );
---
> -                );
> +                self.storage_free(bin, elem_ty.deref_any(), data, offset_val, function, zero);
4042,4043c4047,4049
<                  let offset_val = binary
< @@ -443,8 +437,8 @@ impl SolanaTarget {
---
>                  let offset_val = bin
>                      .builder
> @@ -426,8 +413,8 @@ impl SolanaTarget {
4049,4050c4055,4056
< +            for (i, field) in struct_ty.definition(binary.ns).fields.iter().enumerate() {
< +                let field_offset = struct_ty.definition(binary.ns).storage_offsets[i]
---
> +            for (i, field) in struct_ty.definition(bin.ns).fields.iter().enumerate() {
> +                let field_offset = struct_ty.definition(bin.ns).storage_offsets[i]
4054c4060
< @@ -457,17 +451,17 @@ impl SolanaTarget {
---
> @@ -440,16 +427,16 @@ impl SolanaTarget {
4058,4059c4064,4065
< -                self.storage_free(binary, &field.ty, data, offset, function, zero, ns);
< +                self.storage_free(binary, &field.ty, data, offset, function, zero);
---
> -                self.storage_free(bin, &field.ty, data, offset, function, zero, ns);
> +                self.storage_free(bin, &field.ty, data, offset, function, zero);
4062,4063c4068,4069
< -            let ty = binary.llvm_type(ty, ns);
< +            let ty = binary.llvm_type(ty);
---
> -            let ty = bin.llvm_type(ty, ns);
> +            let ty = bin.llvm_type(ty);
4065,4066c4071
<              binary
<                  .builder
---
>              bin.builder
4070,4071c4075,4076
< -            let ty = binary.llvm_type(ty, ns);
< +            let ty = binary.llvm_type(ty);
---
> -            let ty = bin.llvm_type(ty, ns);
> +            let ty = bin.llvm_type(ty);
4073,4076c4078,4081
<              binary
<                  .builder
< @@ -482,7 +476,6 @@ impl SolanaTarget {
<          binary: &Binary<'b>,
---
>              bin.builder
>                  .build_store(member, ty.into_int_type().const_zero())
> @@ -463,7 +450,6 @@ impl SolanaTarget {
>          bin: &Binary<'b>,
4083c4088
< @@ -490,7 +483,7 @@ impl SolanaTarget {
---
> @@ -471,7 +457,7 @@ impl SolanaTarget {
4085c4090
<              binary.context.i32_type().into()
---
>              bin.context.i32_type().into()
4087,4088c4092,4093
< -            binary.llvm_type(key_ty, ns)
< +            binary.llvm_type(key_ty)
---
> -            bin.llvm_type(key_ty, ns)
> +            bin.llvm_type(key_ty)
4091,4092c4096,4097
<          binary
< @@ -502,7 +495,7 @@ impl SolanaTarget {
---
>          bin.context
> @@ -482,7 +468,7 @@ impl SolanaTarget {
4094c4099
<                          binary.context.i32_type().into()
---
>                          bin.context.i32_type().into()
4096,4097c4101,4102
< -                        binary.llvm_type(value_ty, ns) // value
< +                        binary.llvm_type(value_ty) // value
---
> -                        bin.llvm_type(value_ty, ns) // value
> +                        bin.llvm_type(value_ty) // value
4101,4102c4106,4107
< @@ -516,12 +509,11 @@ impl SolanaTarget {
<          binary: &Binary<'b>,
---
> @@ -496,12 +482,11 @@ impl SolanaTarget {
>          bin: &Binary<'b>,
4111,4112c4116,4117
< +            key_ty.to_llvm_string(binary.ns),
< +            value_ty.to_llvm_string(binary.ns)
---
> +            key_ty.to_llvm_string(bin.ns),
> +            value_ty.to_llvm_string(bin.ns)
4115,4117c4120,4122
<          if let Some(function) = binary.module.get_function(&function_name) {
< @@ -533,7 +525,6 @@ impl SolanaTarget {
<          let function_ty = binary.function_type(
---
>          if let Some(function) = bin.module.get_function(&function_name) {
> @@ -513,7 +498,6 @@ impl SolanaTarget {
>          let function_ty = bin.function_type(
4124c4129
< @@ -548,7 +539,7 @@ impl SolanaTarget {
---
> @@ -527,7 +511,7 @@ impl SolanaTarget {
4128,4129c4133,4134
< -        let entry_ty = self.sparse_entry(binary, key_ty, value_ty, ns);
< +        let entry_ty = self.sparse_entry(binary, key_ty, value_ty);
---
> -        let entry_ty = self.sparse_entry(bin, key_ty, value_ty, ns);
> +        let entry_ty = self.sparse_entry(bin, key_ty, value_ty);
4133c4138
< @@ -572,7 +563,7 @@ impl SolanaTarget {
---
> @@ -550,7 +534,7 @@ impl SolanaTarget {
4137,4138c4142,4143
< -        let address = binary.build_alloca(function, binary.address_type(ns), "address");
< +        let address = binary.build_alloca(function, binary.address_type(), "address");
---
> -        let address = bin.build_alloca(function, bin.address_type(ns), "address");
> +        let address = bin.build_alloca(function, bin.address_type(), "address");
4142c4147
< @@ -603,7 +594,7 @@ impl SolanaTarget {
---
> @@ -579,7 +563,7 @@ impl SolanaTarget {
4147,4151c4152,4156
< +        } else if key_ty.bits(binary.ns) > 64 {
<              binary
<                  .builder
<                  .build_int_truncate(key.into_int_value(), binary.context.i64_type(), "")
< @@ -773,7 +764,7 @@ impl SolanaTarget {
---
> +        } else if key_ty.bits(bin.ns) > 64 {
>              bin.builder
>                  .build_int_truncate(key.into_int_value(), bin.context.i64_type(), "")
>                  .unwrap()
> @@ -736,7 +720,7 @@ impl SolanaTarget {
4153c4158
<              let entry_key = binary
---
>              let entry_key = bin
4155,4156c4160,4161
< -                .build_load(binary.llvm_type(key_ty, ns), ptr, "key")
< +                .build_load(binary.llvm_type(key_ty), ptr, "key")
---
> -                .build_load(bin.llvm_type(key_ty, ns), ptr, "key")
> +                .build_load(bin.llvm_type(key_ty), ptr, "key")
4159,4160c4164,4165
<              binary
< @@ -1044,13 +1035,12 @@ impl SolanaTarget {
---
>              bin.builder
> @@ -982,13 +966,12 @@ impl SolanaTarget {
4166c4171
<          let offset = binary.build_alloca(function, binary.context.i32_type(), "offset");
---
>          let offset = bin.build_alloca(function, bin.context.i32_type(), "offset");
4168c4173
<          let current_block = binary.builder.get_insert_block().unwrap();
---
>          let current_block = bin.builder.get_insert_block().unwrap();
4170,4171c4175,4176
< -        let lookup = self.sparse_lookup_function(binary, key_ty, value_ty, ns);
< +        let lookup = self.sparse_lookup_function(binary, key_ty, value_ty);
---
> -        let lookup = self.sparse_lookup_function(bin, key_ty, value_ty, ns);
> +        let lookup = self.sparse_lookup_function(bin, key_ty, value_ty);
4173c4178
<          binary.builder.position_at_end(current_block);
---
>          bin.builder.position_at_end(current_block);
4175c4180
< @@ -1108,7 +1098,6 @@ impl SolanaTarget {
---
> @@ -1044,7 +1027,6 @@ impl SolanaTarget {
4181,4183c4186
<          let account_info_ty = binary
<              .module
< @@ -1147,13 +1136,13 @@ impl SolanaTarget {
---
>          let account_info_ty = bin.module.get_struct_type("struct.SolAccountInfo").unwrap();
4185c4188,4190
<                  let slice_alloca = binary.build_alloca(
---
> @@ -1078,13 +1060,13 @@ impl SolanaTarget {
>  
>                  let slice_alloca = bin.build_alloca(
4187,4188c4192,4193
< -                    binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
< +                    binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
---
> -                    bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
> +                    bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
4191c4196
<                  let data_elem = binary
---
>                  let data_elem = bin
4194,4195c4199,4200
< -                        binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
< +                        binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
---
> -                        bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
> +                        bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
4199,4200c4204,4205
< @@ -1163,7 +1152,7 @@ impl SolanaTarget {
<                  let data_len_elem = binary
---
> @@ -1094,7 +1076,7 @@ impl SolanaTarget {
>                  let data_len_elem = bin
4203,4204c4208,4209
< -                        binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
< +                        binary.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
---
> -                        bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1))), ns),
> +                        bin.llvm_type(&ast::Type::Slice(Box::new(Type::Bytes(1)))),
4208c4213
< @@ -1195,7 +1184,6 @@ impl SolanaTarget {
---
> @@ -1125,7 +1107,6 @@ impl SolanaTarget {
4214c4219
<          let instruction_ty: BasicTypeEnum = binary
---
>          let instruction_ty: BasicTypeEnum = bin
4216c4221,4222
< @@ -1208,7 +1196,7 @@ impl SolanaTarget {
---
> @@ -1136,7 +1117,7 @@ impl SolanaTarget {
>                          .unwrap()
4219,4221c4225,4226
<                      binary
< -                        .llvm_type(&Type::Struct(StructType::AccountMeta), ns)
< +                        .llvm_type(&Type::Struct(StructType::AccountMeta))
---
> -                    bin.llvm_type(&Type::Struct(StructType::AccountMeta), ns)
> +                    bin.llvm_type(&Type::Struct(StructType::AccountMeta))
4224c4229
<                      binary.context.i64_type().as_basic_type_enum(),
---
>                      bin.context.i64_type().as_basic_type_enum(),
4226c4231
< index f5a14ff7..4d7414b8 100644
---
> index 3d86ccaa..5181a566 100644
4245c4250
<          let data = self.contract_storage_data(binary);
---
>          let data = self.contract_storage_data(bin);
4247,4248c4252,4253
< -        self.storage_free(binary, ty, data, *slot, function, true, ns);
< +        self.storage_free(binary, ty, data, *slot, function, true);
---
> -        self.storage_free(bin, ty, data, *slot, function, true, ns);
> +        self.storage_free(bin, ty, data, *slot, function, true);
4253c4258
<          _binary: &Binary<'a>,
---
>          _bin: &Binary<'a>,
4266c4271
<          let data = self.contract_storage_data(binary);
---
>          let data = self.contract_storage_data(bin);
4268c4273
< @@ -131,7 +128,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -129,7 +126,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4275,4276c4280,4281
<              binary,
< @@ -171,7 +167,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              bin,
> @@ -163,7 +159,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4283,4284c4288,4289
<          let data = self.contract_storage_data(binary);
< @@ -217,12 +212,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>          let data = self.contract_storage_data(bin);
> @@ -207,12 +202,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4287,4288c4292,4293
<          binary.builder.position_at_end(bang_block);
< -        binary.log_runtime_error(
---
>          bin.builder.position_at_end(bang_block);
> -        bin.log_runtime_error(
4294c4299
< +        binary.log_runtime_error(self, "storage index out of bounds".to_string(), Some(loc));
---
> +        bin.log_runtime_error(self, "storage index out of bounds".to_string(), Some(loc));
4296,4298c4301,4303
<              binary,
<              binary
< @@ -257,19 +247,18 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              bin,
>              bin.context
> @@ -242,19 +232,18 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4304c4309
<          let account = self.contract_storage_account(binary);
---
>          let account = self.contract_storage_account(bin);
4307c4312
< -            self.sparse_lookup(binary, function, key, value, slot, index, ns)
---
> -            self.sparse_lookup(bin, function, key, value, slot, index, ns)
4309,4310c4314,4315
< +            self.sparse_lookup(binary, function, key, value, slot, index)
< +        } else if ty.is_sparse_solana(binary.ns) {
---
> +            self.sparse_lookup(bin, function, key, value, slot, index)
> +        } else if ty.is_sparse_solana(bin.ns) {
4316,4317c4321,4322
< -            self.sparse_lookup(binary, function, &key, &elem_ty, slot, index, ns)
< +            self.sparse_lookup(binary, function, &key, &elem_ty, slot, index)
---
> -            self.sparse_lookup(bin, function, &key, &elem_ty, slot, index, ns)
> +            self.sparse_lookup(bin, function, &key, &elem_ty, slot, index)
4321,4327c4326,4329
< @@ -315,10 +304,10 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<  
<              let elem_ty = ty.storage_array_elem().deref_into();
<  
< -            let elem_size = binary
< -                .context
< -                .i32_type()
---
> @@ -298,7 +287,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>              let elem_size = bin
>                  .context
>                  .i32_type()
4329,4332c4331
< +            let elem_size = binary.context.i32_type().const_int(
< +                elem_ty.solana_storage_size(binary.ns).to_u64().unwrap(),
< +                false,
< +            );
---
> +                .const_int(elem_ty.solana_storage_size(bin.ns).to_u64().unwrap(), false);
4334,4336c4333,4335
<              binary
<                  .builder
< @@ -341,7 +330,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              bin.builder
>                  .build_int_add(
> @@ -319,7 +308,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4342,4345c4341,4344
<          let data = self.contract_storage_data(binary);
<          let account = self.contract_storage_account(binary);
< @@ -375,7 +363,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<          let member_size = binary
---
>          let data = self.contract_storage_data(bin);
>          let account = self.contract_storage_account(bin);
> @@ -352,7 +340,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>          let member_size = bin
4349,4350c4348,4349
< +            .const_int(ty.storage_slots(binary.ns).to_u64().unwrap(), false);
<          let new_length = binary
---
> +            .const_int(ty.storage_slots(bin.ns).to_u64().unwrap(), false);
>          let new_length = bin
4353c4352
< @@ -440,10 +428,10 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -412,10 +400,10 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4357,4358c4356,4357
< -            self.storage_store(binary, ty, false, &mut new_offset, val, function, ns, &None);
< +            self.storage_store(binary, ty, false, &mut new_offset, val, function, &None);
---
> -            self.storage_store(bin, ty, false, &mut new_offset, val, function, ns, &None);
> +            self.storage_store(bin, ty, false, &mut new_offset, val, function, &None);
4362c4361
< +        if ty.is_reference_type(binary.ns) {
---
> +        if ty.is_reference_type(bin.ns) {
4366c4365
< @@ -459,7 +447,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -431,7 +419,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4373,4374c4372,4373
<          let data = self.contract_storage_data(binary);
< @@ -511,12 +498,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>          let data = self.contract_storage_data(bin);
> @@ -481,12 +468,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4377,4378c4376,4377
<          binary.builder.position_at_end(bang_block);
< -        binary.log_runtime_error(
---
>          bin.builder.position_at_end(bang_block);
> -        bin.log_runtime_error(
4384c4383
< +        binary.log_runtime_error(self, "pop from empty storage array".to_string(), Some(loc));
---
> +        bin.log_runtime_error(self, "pop from empty storage array".to_string(), Some(loc));
4386,4389c4385,4388
<              binary,
<              binary
< @@ -532,7 +514,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<          let member_size = binary
---
>              bin,
>              bin.context
> @@ -501,7 +483,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>          let member_size = bin
4393c4392
< +            .const_int(ty.storage_slots(binary.ns).to_u64().unwrap(), false);
---
> +            .const_int(ty.storage_slots(bin.ns).to_u64().unwrap(), false);
4395c4394
<          let new_length = binary
---
>          let new_length = bin
4397,4398c4396,4397
< @@ -545,13 +527,13 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<              .unwrap();
---
> @@ -511,13 +493,13 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>          let mut old_elem_offset = bin.builder.build_int_add(offset, new_length, "").unwrap();
4401,4402c4400,4401
< -            Some(self.storage_load(binary, ty, &mut old_elem_offset, function, ns, &None))
< +            Some(self.storage_load(binary, ty, &mut old_elem_offset, function, &None))
---
> -            Some(self.storage_load(bin, ty, &mut old_elem_offset, function, ns, &None))
> +            Some(self.storage_load(bin, ty, &mut old_elem_offset, function, &None))
4408,4409c4407,4408
< -        self.storage_free(binary, ty, data, old_elem_offset, function, false, ns);
< +        self.storage_free(binary, ty, data, old_elem_offset, function, false);
---
> -        self.storage_free(bin, ty, data, old_elem_offset, function, false, ns);
> +        self.storage_free(bin, ty, data, old_elem_offset, function, false);
4412,4413c4411,4412
<          binary
< @@ -577,7 +559,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>          bin.builder
> @@ -542,7 +524,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4419c4418
<          let data = self.contract_storage_data(binary);
---
>          let data = self.contract_storage_data(bin);
4421,4422c4420,4421
< @@ -598,7 +579,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<          let member_size = binary
---
> @@ -562,7 +543,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>          let member_size = bin
4426c4425
< +            .const_int(elem_ty.storage_slots(binary.ns).to_u64().unwrap(), false);
---
> +            .const_int(elem_ty.storage_slots(bin.ns).to_u64().unwrap(), false);
4428c4427
<          let length_bytes = binary
---
>          let length_bytes = bin
4430c4429
< @@ -638,7 +619,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -601,7 +582,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4437,4438c4436,4437
<          let data = self.contract_storage_data(binary);
< @@ -696,7 +676,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>          let data = self.contract_storage_data(bin);
> @@ -656,7 +636,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4442,4443c4441,4442
< -                let llvm_ty = binary.llvm_type(ty.deref_any(), ns);
< +                let llvm_ty = binary.llvm_type(ty.deref_any());
---
> -                let llvm_ty = bin.llvm_type(ty.deref_any(), ns);
> +                let llvm_ty = bin.llvm_type(ty.deref_any());
4445c4444
<                  let size = binary
---
>                  let size = bin
4447c4446
< @@ -720,8 +700,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -680,8 +660,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4453,4454c4452,4453
< +                for (i, field) in struct_ty.definition(binary.ns).fields.iter().enumerate() {
< +                    let field_offset = struct_ty.definition(binary.ns).storage_offsets[i]
---
> +                for (i, field) in struct_ty.definition(bin.ns).fields.iter().enumerate() {
> +                    let field_offset = struct_ty.definition(bin.ns).storage_offsets[i]
4458c4457
< @@ -734,8 +714,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -694,7 +674,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4462,4464c4461,4462
< -                    let val =
< -                        self.storage_load(binary, &field.ty, &mut offset, function, ns, &None);
< +                    let val = self.storage_load(binary, &field.ty, &mut offset, function, &None);
---
> -                    let val = self.storage_load(bin, &field.ty, &mut offset, function, ns, &None);
> +                    let val = self.storage_load(bin, &field.ty, &mut offset, function, &None);
4467,4468c4465,4466
<                          binary
< @@ -752,8 +731,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                          bin.builder
> @@ -710,8 +690,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4473,4477c4471,4474
< -                        let load_ty = binary.llvm_type(&field.ty, ns);
< +                    let val = if field.ty.is_fixed_reference_type(binary.ns) {
< +                        let load_ty = binary.llvm_type(&field.ty);
<                          binary
<                              .builder
---
> -                        let load_ty = bin.llvm_type(&field.ty, ns);
> +                    let val = if field.ty.is_fixed_reference_type(bin.ns) {
> +                        let load_ty = bin.llvm_type(&field.ty);
>                          bin.builder
4479c4476,4477
< @@ -768,7 +747,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                              .unwrap()
> @@ -725,7 +705,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4483,4484c4481,4482
< -                let llvm_ty = binary.llvm_type(ty.deref_any(), ns);
< +                let llvm_ty = binary.llvm_type(ty.deref_any());
---
> -                let llvm_ty = bin.llvm_type(ty.deref_any(), ns);
> +                let llvm_ty = bin.llvm_type(ty.deref_any());
4488c4486
< @@ -807,7 +786,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -764,7 +744,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4492,4494c4490,4492
< -                    let llvm_elem_ty = binary.llvm_field_ty(elem_ty, ns);
< +                    let llvm_elem_ty = binary.llvm_field_ty(elem_ty);
<                      let elem_size = binary
---
> -                    let llvm_elem_ty = bin.llvm_field_ty(elem_ty, ns);
> +                    let llvm_elem_ty = bin.llvm_field_ty(elem_ty);
>                      let elem_size = bin
4497c4495
< @@ -817,7 +796,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -774,7 +754,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4501,4502c4499,4500
< -                    length = self.storage_array_length(binary, function, slot, elem_ty, ns);
< +                    length = self.storage_array_length(binary, function, slot, elem_ty);
---
> -                    length = self.storage_array_length(bin, function, slot, elem_ty, ns);
> +                    length = self.storage_array_length(bin, function, slot, elem_ty);
4504c4502
<                      slot = binary
---
>                      slot = bin
4506c4504
< @@ -826,11 +805,11 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -783,11 +763,11 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4509c4507
<                      dest = binary
---
>                      dest = bin
4516c4514
< +                let elem_size = elem_ty.solana_storage_size(binary.ns).to_u64().unwrap();
---
> +                let elem_size = elem_ty.solana_storage_size(bin.ns).to_u64().unwrap();
4519,4520c4517,4518
<                  let mut builder = LoopBuilder::new(binary, function);
< @@ -841,7 +820,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                  let mut builder = LoopBuilder::new(bin, function);
> @@ -797,7 +777,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4522c4520
<                  let index = builder.over(binary, binary.context.i32_type().const_zero(), length);
---
>                  let index = builder.over(bin, bin.context.i32_type().const_zero(), length);
4524,4525c4522,4523
< -                let elem = binary.array_subscript(ty.deref_any(), dest, index, ns);
< +                let elem = binary.array_subscript(ty.deref_any(), dest, index);
---
> -                let elem = bin.array_subscript(ty.deref_any(), dest, index, ns);
> +                let elem = bin.array_subscript(ty.deref_any(), dest, index);
4529c4527
< @@ -852,12 +831,11 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -808,12 +788,11 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4538,4542c4536,4539
< -                    let load_ty = binary.llvm_type(elem_ty.deref_any(), ns);
< +                let val = if elem_ty.deref_memory().is_fixed_reference_type(binary.ns) {
< +                    let load_ty = binary.llvm_type(elem_ty.deref_any());
<                      binary
<                          .builder
---
> -                    let load_ty = bin.llvm_type(elem_ty.deref_any(), ns);
> +                let val = if elem_ty.deref_memory().is_fixed_reference_type(bin.ns) {
> +                    let load_ty = bin.llvm_type(elem_ty.deref_any());
>                      bin.builder
4544c4541,4542
< @@ -887,7 +865,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                          .unwrap()
> @@ -842,7 +821,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4546c4544
<              _ => binary
---
>              _ => bin
4548,4549c4546,4547
< -                .build_load(binary.llvm_var_ty(ty, ns), member, "")
< +                .build_load(binary.llvm_var_ty(ty), member, "")
---
> -                .build_load(bin.llvm_var_ty(ty, ns), member, "")
> +                .build_load(bin.llvm_var_ty(ty), member, "")
4553c4551
< @@ -900,7 +878,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -855,7 +834,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4560,4561c4558,4559
<          let data = self.contract_storage_data(binary);
< @@ -1105,7 +1082,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>          let data = self.contract_storage_data(bin);
> @@ -1041,7 +1019,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4565,4566c4563,4564
< -                self.storage_free(binary, ty, data, *offset, function, false, ns);
< +                self.storage_free(binary, ty, data, *offset, function, false);
---
> -                self.storage_free(bin, ty, data, *offset, function, false, ns);
> +                self.storage_free(bin, ty, data, *offset, function, false);
4570,4576c4568,4571
< @@ -1121,10 +1098,10 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<  
<              if Some(&ast::ArrayLength::Dynamic) == dim.last() {
<                  // reallocate to the right size
< -                let member_size = binary
< -                    .context
< -                    .i32_type()
---
> @@ -1059,7 +1037,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>                  let member_size = bin
>                      .context
>                      .i32_type()
4578,4582c4573,4574
< +                let member_size = binary.context.i32_type().const_int(
< +                    elem_ty.solana_storage_size(binary.ns).to_u64().unwrap(),
< +                    false,
< +                );
<                  let new_length = binary
---
> +                    .const_int(elem_ty.solana_storage_size(bin.ns).to_u64().unwrap(), false);
>                  let new_length = bin
4585c4577
< @@ -1187,7 +1164,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1118,7 +1096,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4590c4582
< +            let elem_size = elem_ty.solana_storage_size(binary.ns).to_u64().unwrap();
---
> +            let elem_size = elem_ty.solana_storage_size(bin.ns).to_u64().unwrap();
4593,4594c4585,4586
<              let mut builder = LoopBuilder::new(binary, function);
< @@ -1198,7 +1175,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              let mut builder = LoopBuilder::new(bin, function);
> @@ -1129,7 +1107,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4596c4588
<              let index = builder.over(binary, binary.context.i32_type().const_zero(), length);
---
>              let index = builder.over(bin, bin.context.i32_type().const_zero(), length);
4598,4599c4590,4591
< -            let elem = binary.array_subscript(ty, val.into_pointer_value(), index, ns);
< +            let elem = binary.array_subscript(ty, val.into_pointer_value(), index);
---
> -            let elem = bin.array_subscript(ty, val.into_pointer_value(), index, ns);
> +            let elem = bin.array_subscript(ty, val.into_pointer_value(), index);
4603c4595
< @@ -1209,16 +1186,16 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1140,20 +1118,19 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4608c4600
< +                if elem_ty.deref_memory().is_fixed_reference_type(binary.ns) {
---
> +                if elem_ty.deref_memory().is_fixed_reference_type(bin.ns) {
4612,4615c4604,4606
< +                    let load_ty = if elem_ty.is_dynamic(binary.ns) {
<                          binary
< -                            .llvm_type(elem_ty.deref_memory(), ns)
< +                            .llvm_type(elem_ty.deref_memory())
---
> -                        bin.llvm_type(elem_ty.deref_memory(), ns)
> +                    let load_ty = if elem_ty.is_dynamic(bin.ns) {
> +                        bin.llvm_type(elem_ty.deref_memory())
4619,4620c4610,4611
< -                        binary.llvm_type(elem_ty.deref_memory(), ns)
< +                        binary.llvm_type(elem_ty.deref_memory())
---
> -                        bin.llvm_type(elem_ty.deref_memory(), ns)
> +                        bin.llvm_type(elem_ty.deref_memory())
4622,4625c4613
<                      binary
<                          .builder
< @@ -1226,7 +1203,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<                          .unwrap()
---
>                      bin.builder.build_load(load_ty, elem, "array_elem").unwrap()
4632c4620
< @@ -1245,8 +1221,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1172,8 +1149,8 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4634c4622
<              builder.finish(binary);
---
>              builder.finish(bin);
4638,4639c4626,4627
< +            for (i, field) in struct_ty.definition(binary.ns).fields.iter().enumerate() {
< +                let field_offset = struct_ty.definition(binary.ns).storage_offsets[i]
---
> +            for (i, field) in struct_ty.definition(bin.ns).fields.iter().enumerate() {
> +                let field_offset = struct_ty.definition(bin.ns).storage_offsets[i]
4643c4631
< @@ -1259,7 +1235,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1186,7 +1163,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4647,4648c4635,4636
< -                let val_ty = binary.llvm_type(ty, ns);
< +                let val_ty = binary.llvm_type(ty);
---
> -                let val_ty = bin.llvm_type(ty, ns);
> +                let val_ty = bin.llvm_type(ty);
4650,4652c4638,4640
<                      binary
<                          .builder
< @@ -1277,7 +1253,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                      bin.builder
>                          .build_gep(
> @@ -1203,7 +1180,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4656,4657c4644,4645
< -                    self.storage_free(binary, &field.ty, data, offset, function, false, ns);
< +                    self.storage_free(binary, &field.ty, data, offset, function, false);
---
> -                    self.storage_free(bin, &field.ty, data, offset, function, false, ns);
> +                    self.storage_free(bin, &field.ty, data, offset, function, false);
4661c4649
< @@ -1285,16 +1261,16 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1211,22 +1188,21 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4666c4654
< +                    if field.ty.is_fixed_reference_type(binary.ns) {
---
> +                    if field.ty.is_fixed_reference_type(bin.ns) {
4670,4673c4658,4660
< +                        let load_ty = if field.ty.is_dynamic(binary.ns) {
<                              binary
< -                                .llvm_type(&field.ty, ns)
< +                                .llvm_type(&field.ty)
---
> -                            bin.llvm_type(&field.ty, ns)
> +                        let load_ty = if field.ty.is_dynamic(bin.ns) {
> +                            bin.llvm_type(&field.ty)
4677,4678c4664,4665
< -                            binary.llvm_type(&field.ty, ns)
< +                            binary.llvm_type(&field.ty)
---
> -                            bin.llvm_type(&field.ty, ns)
> +                            bin.llvm_type(&field.ty)
4680,4682c4667,4668
<                          binary
<                              .builder
< @@ -1302,7 +1278,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>                          bin.builder
>                              .build_load(load_ty, elem, field.name_as_str())
4690c4676
< @@ -1317,7 +1292,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1241,7 +1217,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4698c4684
< @@ -1384,7 +1358,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1301,7 +1276,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4706c4692
< @@ -1394,7 +1367,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1311,7 +1285,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4710,4711c4696,4697
< -        self.build_invoke_signed_c(binary, function, payload, payload_len, contract_args, ns);
< +        self.build_invoke_signed_c(binary, function, payload, payload_len, contract_args);
---
> -        self.build_invoke_signed_c(bin, function, payload, payload_len, contract_args, ns);
> +        self.build_invoke_signed_c(bin, function, payload, payload_len, contract_args);
4715c4701
< @@ -1404,7 +1377,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1321,7 +1295,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4723c4709
< @@ -1421,7 +1393,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1338,7 +1311,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4727,4728c4713,4714
< -            let address = binary.build_alloca(function, binary.address_type(ns), "address");
< +            let address = binary.build_alloca(function, binary.address_type(), "address");
---
> -            let address = bin.build_alloca(function, bin.address_type(ns), "address");
> +            let address = bin.build_alloca(function, bin.address_type(), "address");
4730,4732c4716,4718
<              binary
<                  .builder
< @@ -1457,7 +1429,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              bin.builder
>                  .build_store(address, args[1].into_array_value())
> @@ -1373,7 +1346,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4736,4737c4722,4723
< -            let address = binary.build_alloca(function, binary.address_type(ns), "address");
< +            let address = binary.build_alloca(function, binary.address_type(), "address");
---
> -            let address = bin.build_alloca(function, bin.address_type(ns), "address");
> +            let address = bin.build_alloca(function, bin.address_type(), "address");
4739,4741c4725,4727
<              binary
<                  .builder
< @@ -1498,7 +1470,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
>              bin.builder
>                  .build_store(address, args[1].into_array_value())
> @@ -1413,7 +1386,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4749c4735
< @@ -1515,7 +1486,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1429,7 +1401,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4753,4754c4739,4740
< -        self.build_invoke_signed_c(binary, function, payload, payload_len, contract_args, ns);
< +        self.build_invoke_signed_c(binary, function, payload, payload_len, contract_args);
---
> -        self.build_invoke_signed_c(bin, function, payload, payload_len, contract_args, ns);
> +        self.build_invoke_signed_c(bin, function, payload, payload_len, contract_args);
4758c4744
< @@ -1653,7 +1624,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1558,7 +1530,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4762c4748
< -    fn value_transferred<'b>(&self, _binary: &Binary<'b>, _ns: &ast::Namespace) -> IntValue<'b> {
---
> -    fn value_transferred<'b>(&self, _bin: &Binary<'b>, _ns: &ast::Namespace) -> IntValue<'b> {
4767c4753
< @@ -1665,14 +1636,13 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1570,14 +1542,13 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4778c4764
< -    fn selfdestruct<'b>(&self, _binary: &Binary<'b>, _addr: ArrayValue<'b>, _ns: &ast::Namespace) {
---
> -    fn selfdestruct<'b>(&self, _bin: &Binary<'b>, _addr: ArrayValue<'b>, _ns: &ast::Namespace) {
4783c4769
< @@ -1762,7 +1732,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1655,7 +1626,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4791c4777
< @@ -1987,18 +1956,18 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1859,17 +1829,17 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4795,4796c4781,4782
< -                let address = binary.build_alloca(function, binary.address_type(ns), "address");
< +                let address = binary.build_alloca(function, binary.address_type(), "address");
---
> -                let address = bin.build_alloca(function, bin.address_type(ns), "address");
> +                let address = bin.build_alloca(function, bin.address_type(), "address");
4798,4799c4784
<                  binary
<                      .builder
---
>                  bin.builder
4802,4803c4787,4788
< -                        expression(self, binary, &args[0], vartab, function, ns).into_array_value(),
< +                        expression(self, binary, &args[0], vartab, function).into_array_value(),
---
> -                        expression(self, bin, &args[0], vartab, function, ns).into_array_value(),
> +                        expression(self, bin, &args[0], vartab, function).into_array_value(),
4807,4812c4792,4797
< -                let message = expression(self, binary, &args[1], vartab, function, ns);
< -                let signature = expression(self, binary, &args[2], vartab, function, ns);
< +                let message = expression(self, binary, &args[1], vartab, function);
< +                let signature = expression(self, binary, &args[2], vartab, function);
<                  let parameters = self.sol_parameters(binary);
<                  let signature_verify = binary.module.get_function("signature_verify").unwrap();
---
> -                let message = expression(self, bin, &args[1], vartab, function, ns);
> -                let signature = expression(self, bin, &args[2], vartab, function, ns);
> +                let message = expression(self, bin, &args[1], vartab, function);
> +                let signature = expression(self, bin, &args[2], vartab, function);
>                  let parameters = self.sol_parameters(bin);
>                  let signature_verify = bin.module.get_function("signature_verify").unwrap();
4814c4799
< @@ -2094,9 +2063,9 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1957,9 +1927,9 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4818,4819c4803,4804
< -                    expression(self, binary, expr, vartab, function, ns).into_pointer_value();
< +                    expression(self, binary, expr, vartab, function).into_pointer_value();
---
> -                    expression(self, bin, expr, vartab, function, ns).into_pointer_value();
> +                    expression(self, bin, expr, vartab, function).into_pointer_value();
4821,4822c4806,4807
< -                self.account_info_member(binary, function, account_info, *member, ns)
< +                self.account_info_member(binary, function, account_info, *member)
---
> -                self.account_info_member(bin, function, account_info, *member, ns)
> +                self.account_info_member(bin, function, account_info, *member)
4826c4811
< @@ -2110,7 +2079,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -1973,7 +1943,6 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4834c4819
< @@ -2197,7 +2165,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
---
> @@ -2052,7 +2021,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
4836c4821
<          let temp = binary.build_alloca(
---
>          let temp = bin.build_alloca(
4838,4839c4823,4824
< -            binary.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
< +            binary.llvm_type(&ast::Type::Bytes(hashlen as u8)),
---
> -            bin.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
> +            bin.llvm_type(&ast::Type::Bytes(hashlen as u8)),
4843,4845c4828,4830
< @@ -2217,7 +2185,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
<          binary
<              .builder
---
> @@ -2070,7 +2039,7 @@ impl<'a> TargetRuntime<'a> for SolanaTarget {
>  
>          bin.builder
4847,4848c4832,4833
< -                binary.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
< +                binary.llvm_type(&ast::Type::Bytes(hashlen as u8)),
---
> -                bin.llvm_type(&ast::Type::Bytes(hashlen as u8), ns),
> +                bin.llvm_type(&ast::Type::Bytes(hashlen as u8)),
4853c4838
< index 06b48e98..076e7fba 100644
---
> index 26403ac1..66aa32d2 100644
4858c4843
<          let mut binary = Binary::new(
---
>          let mut bin = Binary::new(
4865,4868c4850,4856
< @@ -141,7 +141,6 @@ impl SorobanTarget {
<          Self::emit_functions_with_spec(
<              contract,
<              &mut binary,
---
> @@ -138,14 +138,7 @@ impl SorobanTarget {
>  
>          let mut export_list = Vec::new();
>          Self::declare_externals(&mut bin);
> -        Self::emit_functions_with_spec(
> -            contract,
> -            &mut bin,
4870,4873c4858,4866
<              context,
<              contract_no,
<              &mut export_list,
< @@ -160,7 +159,6 @@ impl SorobanTarget {
---
> -            context,
> -            contract_no,
> -            &mut export_list,
> -        );
> +        Self::emit_functions_with_spec(contract, &mut bin, context, contract_no, &mut export_list);
>          bin.internalize(export_list.as_slice());
>  
>          Self::emit_initializer(&mut bin, ns);
> @@ -160,7 +153,6 @@ impl SorobanTarget {
4876c4869
<          binary: &mut Binary<'a>,
---
>          bin: &mut Binary<'a>,
4881,4882c4874,4875
< @@ -171,7 +169,6 @@ impl SorobanTarget {
<              let ftype = binary.function_type(
---
> @@ -171,7 +163,6 @@ impl SorobanTarget {
>              let ftype = bin.function_type(
4889c4882
< @@ -214,7 +211,7 @@ impl SorobanTarget {
---
> @@ -213,7 +204,7 @@ impl SorobanTarget {
4893,4894c4886,4887
< -            emit_cfg(&mut SorobanTarget, binary, contract, cfg, func_decl, ns);
< +            emit_cfg(&mut SorobanTarget, binary, contract, cfg, func_decl);
---
> -            emit_cfg(&mut SorobanTarget, bin, contract, cfg, func_decl, ns);
> +            emit_cfg(&mut SorobanTarget, bin, contract, cfg, func_decl);
4899c4892
< index a5cb032e..dc1d25a0 100644
---
> index 56d1e1d5..625e4f14 100644
4919c4912
< @@ -79,7 +78,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -75,7 +74,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4926,4927c4919,4920
<          emit_context!(binary);
< @@ -123,7 +121,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
>          emit_context!(bin);
> @@ -115,7 +113,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4935c4928
< @@ -164,7 +161,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -156,7 +153,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4943c4936
< @@ -176,7 +172,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -168,7 +164,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4951c4944
< @@ -188,7 +183,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -180,7 +175,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4959c4952
< @@ -201,7 +195,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -193,7 +187,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4967c4960
< @@ -213,7 +206,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -205,7 +198,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4975c4968
< @@ -225,7 +217,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -217,7 +209,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4983c4976
< @@ -237,7 +228,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -229,7 +220,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4991c4984
< @@ -249,7 +239,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -241,7 +231,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
4999c4992
< @@ -308,7 +297,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -300,7 +289,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5007c5000
< @@ -324,7 +312,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -316,7 +304,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5015c5008
< @@ -341,7 +328,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -333,7 +320,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5023c5016
< @@ -448,7 +434,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -440,7 +426,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5031c5024
< @@ -461,7 +446,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -453,7 +438,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5039c5032
< @@ -618,12 +602,12 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -610,12 +594,12 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5043,5044c5036,5037
< -    fn value_transferred<'b>(&self, binary: &Binary<'b>, ns: &Namespace) -> IntValue<'b> {
< +    fn value_transferred<'b>(&self, binary: &Binary<'b>) -> IntValue<'b> {
---
> -    fn value_transferred<'b>(&self, bin: &Binary<'b>, ns: &Namespace) -> IntValue<'b> {
> +    fn value_transferred<'b>(&self, bin: &Binary<'b>) -> IntValue<'b> {
5049,5050c5042,5043
< -    fn selfdestruct<'b>(&self, binary: &Binary<'b>, addr: ArrayValue<'b>, ns: &Namespace) {
< +    fn selfdestruct<'b>(&self, binary: &Binary<'b>, addr: ArrayValue<'b>) {
---
> -    fn selfdestruct<'b>(&self, bin: &Binary<'b>, addr: ArrayValue<'b>, ns: &Namespace) {
> +    fn selfdestruct<'b>(&self, bin: &Binary<'b>, addr: ArrayValue<'b>) {
5054c5047
< @@ -635,7 +619,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
---
> @@ -627,7 +611,6 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
5063c5056
< index db61956e..d68befbc 100644
---
> index 410f6cb6..089f80df 100644
5075,5078c5068,5075
< @@ -19,7 +19,6 @@ pub(super) trait StorageSlot {
<          &self,
<          binary: &Binary<'a>,
<          slot: PointerValue<'a>,
---
> @@ -15,12 +15,7 @@ pub(super) trait StorageSlot {
>          dest_ty: BasicTypeEnum,
>      );
>  
> -    fn get_storage_address<'a>(
> -        &self,
> -        bin: &Binary<'a>,
> -        slot: PointerValue<'a>,
5080c5077,5078
<      ) -> ArrayValue<'a>;
---
> -    ) -> ArrayValue<'a>;
> +    fn get_storage_address<'a>(&self, bin: &Binary<'a>, slot: PointerValue<'a>) -> ArrayValue<'a>;
5083c5081,5082
< @@ -33,7 +32,6 @@ pub(super) trait StorageSlot {
---
>      fn storage_delete_single_slot(&self, bin: &Binary, slot: PointerValue);
> @@ -33,7 +28,6 @@ pub(super) trait StorageSlot {
5091c5090
< @@ -45,7 +43,6 @@ pub(super) trait StorageSlot {
---
> @@ -45,7 +39,6 @@ pub(super) trait StorageSlot {
5099c5098
< @@ -56,6 +53,5 @@ pub(super) trait StorageSlot {
---
> @@ -56,6 +49,5 @@ pub(super) trait StorageSlot {

@smoelius smoelius force-pushed the store-ns-in-binary branch from 53a4e7f to 03b000a Compare June 2, 2025 21:14
Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
@smoelius smoelius force-pushed the store-ns-in-binary branch from 03b000a to a293eed Compare June 2, 2025 22:11
@seanyoung seanyoung merged commit 9c02c83 into hyperledger-solang:main Jun 3, 2025
14 of 17 checks passed
@seanyoung
Copy link
Contributor

Great stuff, thank you @smoelius

@smoelius smoelius deleted the store-ns-in-binary branch June 3, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants