|
16 | 16 |
|
17 | 17 | use super::*; |
18 | 18 |
|
19 | | -use leo_ast::{IntegerType, Mode, Type}; |
| 19 | +use leo_ast::{IntegerType, Interface, Mode, Type}; |
20 | 20 |
|
21 | 21 | impl CodeGeneratingVisitor<'_> { |
22 | 22 | pub fn visit_type(&self, input: &Type) -> AleoType { |
@@ -117,46 +117,34 @@ impl CodeGeneratingVisitor<'_> { |
117 | 117 | (self.visit_type(type_), visibility) |
118 | 118 | } |
119 | 119 |
|
120 | | - /// Maps a dynamic call input type and mode to an AVM type with visibility. |
121 | | - /// Record types (both concrete and `dyn record`) become `DynamicRecord` (no visibility). |
122 | | - /// All others use the provided visibility (defaulting to Private). |
| 120 | + /// Maps a dynamic call input type to an AVM type. `dyn record` and interface record types |
| 121 | + /// become `DynamicRecord`; all others use the provided visibility. |
123 | 122 | pub fn dynamic_call_input_type( |
124 | 123 | &self, |
125 | 124 | type_: &Type, |
126 | 125 | visibility: Option<AleoVisibility>, |
| 126 | + interface: Option<&Interface>, |
127 | 127 | ) -> (AleoType, Option<AleoVisibility>) { |
128 | | - if matches!(type_, Type::DynRecord) { |
| 128 | + if matches!(type_, Type::DynRecord) || interface.is_some_and(|i| i.is_record_type(type_)) { |
129 | 129 | return (AleoType::DynamicRecord, None); |
130 | 130 | } |
131 | | - if let Type::Composite(composite) = type_ { |
132 | | - let composite_location = composite.path.expect_global_location(); |
133 | | - let this_program_name = self.program_id.unwrap().as_symbol(); |
134 | | - if self.state.symbol_table.lookup_record(this_program_name, composite_location).is_some() { |
135 | | - return (AleoType::DynamicRecord, None); |
136 | | - } |
137 | | - } |
138 | 131 | (self.visit_type(type_), visibility) |
139 | 132 | } |
140 | 133 |
|
141 | | - /// Maps a dynamic call output type and mode to an AVM type with visibility. |
142 | | - /// Futures become `DynamicFuture` (no visibility), record types (both concrete |
143 | | - /// and `dyn record`) become `DynamicRecord` (no visibility), all others use the |
144 | | - /// provided mode (defaulting to Private). |
145 | | - pub fn dynamic_call_output_type(&self, type_: &Type, mode: Mode) -> (AleoType, Option<AleoVisibility>) { |
| 134 | + /// Maps a dynamic call output type to an AVM type. Futures become `DynamicFuture`, `dyn record` |
| 135 | + /// and interface record types become `DynamicRecord`; all others use the provided mode. |
| 136 | + pub fn dynamic_call_output_type( |
| 137 | + &self, |
| 138 | + type_: &Type, |
| 139 | + mode: Mode, |
| 140 | + interface: Option<&Interface>, |
| 141 | + ) -> (AleoType, Option<AleoVisibility>) { |
146 | 142 | if matches!(type_, Type::Future(..)) { |
147 | 143 | (AleoType::DynamicFuture, None) |
148 | | - } else if matches!(type_, Type::DynRecord) { |
| 144 | + } else if matches!(type_, Type::DynRecord) || interface.is_some_and(|i| i.is_record_type(type_)) { |
149 | 145 | (AleoType::DynamicRecord, None) |
150 | 146 | } else { |
151 | 147 | let viz = AleoVisibility::maybe_from(mode).or(Some(AleoVisibility::Private)); |
152 | | - // Check if this is a concrete record type — those also become DynamicRecord. |
153 | | - if let Type::Composite(composite) = type_ { |
154 | | - let composite_location = composite.path.expect_global_location(); |
155 | | - let this_program_name = self.program_id.unwrap().as_symbol(); |
156 | | - if self.state.symbol_table.lookup_record(this_program_name, composite_location).is_some() { |
157 | | - return (AleoType::DynamicRecord, None); |
158 | | - } |
159 | | - } |
160 | 148 | self.visit_type_with_visibility(type_, viz) |
161 | 149 | } |
162 | 150 | } |
|
0 commit comments