@@ -207,10 +207,47 @@ pub fn get_name_and_type(
207
207
for_parameter : bool ,
208
208
) -> Result < DeclaratorInfo , ParseError > {
209
209
let ( name, decorators) = get_name_and_decorators ( ctx, declarator) ?;
210
- let type_base = get_type_base ( ctx, declaration_specifiers, declarator. source ) ?;
210
+ let type_base = get_type_base ( ctx, declaration_specifiers, declaration_specifiers. source ) ?;
211
+ let ast_type = apply_decorators ( ctx, & decorators, type_base. ast_type , for_parameter) ?;
211
212
212
- let mut ast_type = type_base. ast_type ;
213
+ Ok ( DeclaratorInfo {
214
+ name,
215
+ ast_type,
216
+ specifiers : type_base. specifiers ,
217
+ } )
218
+ }
219
+
220
+ #[ derive( Clone , Debug ) ]
221
+ pub struct AbstractDeclaratorInfo {
222
+ pub ast_type : Type ,
223
+ pub specifiers : TypeBaseSpecifiers ,
224
+ }
225
+
226
+ pub fn get_type (
227
+ ctx : & mut TranslateCtx ,
228
+ abstract_declarator : Option < & AbstractDeclarator > ,
229
+ declaration_specifiers : & DeclarationSpecifiers ,
230
+ for_parameter : bool ,
231
+ ) -> Result < AbstractDeclaratorInfo , ParseError > {
232
+ let decorators = abstract_declarator
233
+ . map ( |abstract_declarator| get_decorators ( ctx, abstract_declarator) )
234
+ . transpose ( ) ?
235
+ . unwrap_or_default ( ) ;
236
+ let type_base = get_type_base ( ctx, declaration_specifiers, declaration_specifiers. source ) ?;
237
+ let ast_type = apply_decorators ( ctx, & decorators, type_base. ast_type , for_parameter) ?;
238
+
239
+ Ok ( AbstractDeclaratorInfo {
240
+ ast_type,
241
+ specifiers : type_base. specifiers ,
242
+ } )
243
+ }
213
244
245
+ fn apply_decorators (
246
+ ctx : & mut TranslateCtx ,
247
+ decorators : & Decorators ,
248
+ mut ast_type : Type ,
249
+ for_parameter : bool ,
250
+ ) -> Result < Type , ParseError > {
214
251
for decorator in decorators. iter ( ) {
215
252
match decorator {
216
253
Decorator :: Pointer ( pointer) => {
@@ -223,14 +260,10 @@ pub fn get_name_and_type(
223
260
Decorator :: Function ( function) => {
224
261
ast_type = decorate_function ( ast_type, function, decorator. source ( ) ) ?;
225
262
}
226
- }
263
+ } ;
227
264
}
228
265
229
- Ok ( DeclaratorInfo {
230
- name,
231
- ast_type,
232
- specifiers : type_base. specifiers ,
233
- } )
266
+ Ok ( ast_type)
234
267
}
235
268
236
269
fn get_name_and_decorators (
0 commit comments