@@ -12,7 +12,9 @@ use acvm::{
12
12
use errors:: AbiError ;
13
13
use input_parser:: InputValue ;
14
14
use iter_extended:: { try_btree_map, try_vecmap, vecmap} ;
15
- use noirc_frontend:: { Signedness , Type , TypeBinding , TypeVariableKind , Visibility } ;
15
+ use noirc_frontend:: {
16
+ graph:: CrateId , hir:: Context , Signedness , Type , TypeBinding , TypeVariableKind , Visibility ,
17
+ } ;
16
18
use serde:: { Deserialize , Serialize } ;
17
19
// This is the ABI used to bridge the different TOML formats for the initial
18
20
// witness, the partial witness generator and the interpreter.
@@ -53,7 +55,7 @@ pub enum AbiType {
53
55
} ,
54
56
Boolean ,
55
57
Struct {
56
- name : String ,
58
+ path : String ,
57
59
#[ serde(
58
60
serialize_with = "serialization::serialize_struct_fields" ,
59
61
deserialize_with = "serialization::deserialize_struct_fields"
@@ -117,7 +119,7 @@ pub enum Sign {
117
119
118
120
impl AbiType {
119
121
// TODO: Add `Context` argument for resolving fully qualified struct paths
120
- pub fn from_type ( typ : & Type ) -> Self {
122
+ pub fn from_type ( context : & Context , crate_id : & CrateId , typ : & Type ) -> Self {
121
123
// Note; use strict_eq instead of partial_eq when comparing field types
122
124
// in this method, you most likely want to distinguish between public and private
123
125
match typ {
@@ -127,7 +129,7 @@ impl AbiType {
127
129
. evaluate_to_u64 ( )
128
130
. expect ( "Cannot have variable sized arrays as a parameter to main" ) ;
129
131
let typ = typ. as_ref ( ) ;
130
- Self :: Array { length, typ : Box :: new ( Self :: from_type ( typ) ) }
132
+ Self :: Array { length, typ : Box :: new ( Self :: from_type ( context , crate_id , typ) ) }
131
133
}
132
134
Type :: Integer ( sign, bit_width) => {
133
135
let sign = match sign {
@@ -139,8 +141,10 @@ impl AbiType {
139
141
}
140
142
Type :: TypeVariable ( binding, TypeVariableKind :: IntegerOrField ) => {
141
143
match & * binding. borrow ( ) {
142
- TypeBinding :: Bound ( typ) => Self :: from_type ( typ) ,
143
- TypeBinding :: Unbound ( _) => Self :: from_type ( & Type :: default_int_type ( ) ) ,
144
+ TypeBinding :: Bound ( typ) => Self :: from_type ( context, crate_id, typ) ,
145
+ TypeBinding :: Unbound ( _) => {
146
+ Self :: from_type ( context, crate_id, & Type :: default_int_type ( ) )
147
+ }
144
148
}
145
149
}
146
150
Type :: Bool => Self :: Boolean ,
@@ -157,8 +161,10 @@ impl AbiType {
157
161
Type :: Struct ( def, ref args) => {
158
162
let struct_type = def. borrow ( ) ;
159
163
let fields = struct_type. get_fields ( args) ;
160
- let fields = vecmap ( fields, |( name, typ) | ( name, Self :: from_type ( & typ) ) ) ;
161
- Self :: Struct { fields, name : struct_type. name . to_string ( ) }
164
+ let fields =
165
+ vecmap ( fields, |( name, typ) | ( name, Self :: from_type ( context, crate_id, & typ) ) ) ;
166
+ let path = context. fully_qualified_struct_name ( crate_id, struct_type. id ) ;
167
+ Self :: Struct { fields, path }
162
168
}
163
169
Type :: Tuple ( _) => todo ! ( "as_abi_type not yet implemented for tuple types" ) ,
164
170
Type :: TypeVariable ( _, _) => unreachable ! ( ) ,
0 commit comments