Changeset 0bf0b97 for src/GenPoly
- Timestamp:
- Oct 13, 2023, 10:10:45 AM (10 months ago)
- Branches:
- master
- Children:
- 8cbe732
- Parents:
- e85a72b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/BoxNew.cpp
re85a72b8 r0bf0b97 95 95 /// Adds parameters for otype size and alignment to a function type. 96 96 void addSTypeParams( 97 ast:: FunctionDecl * decl,97 ast::vector<ast::DeclWithType> & params, 98 98 ast::vector<ast::TypeDecl> const & sizedParams ) { 99 // TODO: Can we fold this into buildLayoutFunction to avoid rebuilding?100 ast::FunctionType * type = ast::mutate( decl->type.get() );101 99 for ( ast::ptr<ast::TypeDecl> const & sizedParam : sizedParams ) { 102 100 ast::TypeInstType inst( sizedParam ); 103 101 std::string paramName = Mangle::mangleType( &inst ); 104 decl->params.emplace_back( new ast::ObjectDecl(102 params.emplace_back( new ast::ObjectDecl( 105 103 sizedParam->location, 106 104 sizeofName( paramName ), 107 105 makeSizeAlignType() 108 106 ) ); 109 type->params.emplace_back( makeSizeAlignType() ); 110 decl->params.emplace_back( new ast::ObjectDecl( 107 params.emplace_back( new ast::ObjectDecl( 111 108 sizedParam->location, 112 109 alignofName( paramName ), 113 110 makeSizeAlignType() 114 111 ) ); 115 type->params.emplace_back( makeSizeAlignType() ); 116 } 117 decl->type = type; 112 } 118 113 } 119 114 … … 129 124 }; 130 125 131 // TODO: Is there a better way to handle the different besides a flag?132 126 LayoutData buildLayoutFunction( 133 127 CodeLocation const & location, ast::AggregateDecl const * aggr, 128 ast::vector<ast::TypeDecl> const & sizedParams, 134 129 bool isInFunction, bool isStruct ) { 135 130 ast::ObjectDecl * sizeParam = new ast::ObjectDecl( … … 153 148 params.push_back( offsetParam ); 154 149 } 150 addSTypeParams( params, sizedParams ); 155 151 156 152 // Routines at global scope marked "static" to prevent multiple … … 238 234 239 235 // Build layout function signature. 240 LayoutData layout = 241 buildLayoutFunction( location, decl, isInFunction(), true );236 LayoutData layout = buildLayoutFunction( 237 location, decl, sizedParams, isInFunction(), true ); 242 238 ast::FunctionDecl * layoutDecl = layout.function; 243 239 // Also return these or extract them from the parameter list? … … 246 242 ast::ObjectDecl const * offsetofParam = layout.offsetofParam; 247 243 assert( nullptr != layout.offsetofParam ); 248 addSTypeParams( layoutDecl, sizedParams );249 244 250 245 // Calculate structure layout in function body. … … 313 308 314 309 // Build layout function signature. 315 LayoutData layout = 316 buildLayoutFunction( location, decl, isInFunction(), false );310 LayoutData layout = buildLayoutFunction( 311 location, decl, sizedParams, isInFunction(), false ); 317 312 ast::FunctionDecl * layoutDecl = layout.function; 318 313 // Also return these or extract them from the parameter list? … … 320 315 ast::ObjectDecl const * alignofParam = layout.alignofParam; 321 316 assert( nullptr == layout.offsetofParam ); 322 addSTypeParams( layoutDecl, sizedParams );323 317 324 318 // Calculate union layout in function body.
Note: See TracChangeset
for help on using the changeset viewer.