Changeset d672350 for src/ResolvExpr/ResolveTypeof.cc
- Timestamp:
- Mar 21, 2022, 1:44:06 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- a76202d
- Parents:
- ef3c383 (diff), dbe2533 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ResolveTypeof.cc
ref3c383 rd672350 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:12:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue May 19 16:49:04 201513 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Mar 16 16:09:00 2022 13 // Update Count : 4 14 14 // 15 15 … … 22 22 #include "AST/Node.hpp" 23 23 #include "AST/Pass.hpp" 24 #include "AST/TranslationUnit.hpp" 24 25 #include "AST/Type.hpp" 25 26 #include "AST/TypeEnvironment.hpp" … … 119 120 namespace { 120 121 struct ResolveTypeof_new : public ast::WithShortCircuiting { 121 const ast::SymbolTable & localSymtab; 122 123 ResolveTypeof_new( const ast::SymbolTable & syms ) : localSymtab( syms ) {} 122 const ResolveContext & context; 123 124 ResolveTypeof_new( const ResolveContext & context ) : 125 context( context ) {} 124 126 125 127 void previsit( const ast::TypeofType * ) { visit_children = false; } … … 137 139 ast::TypeEnvironment dummy; 138 140 ast::ptr< ast::Expr > newExpr = 139 resolveInVoidContext( typeofType->expr, localSymtab, dummy );141 resolveInVoidContext( typeofType->expr, context, dummy ); 140 142 assert( newExpr->result && ! newExpr->result->isVoid() ); 141 143 newType = newExpr->result; … … 161 163 } // anonymous namespace 162 164 163 const ast::Type * resolveTypeof( const ast::Type * type , const ast::SymbolTable & symtab) {164 ast::Pass< ResolveTypeof_new > mutator { symtab };165 const ast::Type * resolveTypeof( const ast::Type * type , const ResolveContext & context ) { 166 ast::Pass< ResolveTypeof_new > mutator( context ); 165 167 return type->accept( mutator ); 166 168 } … … 168 170 struct FixArrayDimension { 169 171 // should not require a mutable symbol table - prevent pass template instantiation 170 const ast::SymbolTable & _symtab;171 FixArrayDimension(const ast::SymbolTable & symtab): _symtab(symtab) {}172 const ResolveContext & context; 173 FixArrayDimension(const ResolveContext & context) : context( context ) {} 172 174 173 175 const ast::ArrayType * previsit (const ast::ArrayType * arrayType) { 174 176 if (!arrayType->dimension) return arrayType; 175 177 auto mutType = mutate(arrayType); 176 ast::ptr<ast::Type> sizetype = ast::sizeType ? ast::sizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt); 177 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, _symtab); 178 auto globalSizeType = context.global.sizeType; 179 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt); 180 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context ); 178 181 179 182 if (InitTweak::isConstExpr(mutType->dimension)) { … … 187 190 }; 188 191 189 const ast::Type * fixArrayType( const ast::Type * type, const ast::SymbolTable & symtab) {190 ast::Pass<FixArrayDimension> visitor {symtab};192 const ast::Type * fixArrayType( const ast::Type * type, const ResolveContext & context ) { 193 ast::Pass<FixArrayDimension> visitor(context); 191 194 return type->accept(visitor); 192 195 } 193 196 194 const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ast::SymbolTable & symtab) {195 if (!decl->isTypeFixed) { 197 const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ResolveContext & context ) { 198 if (!decl->isTypeFixed) { 196 199 auto mutDecl = mutate(decl); 197 auto resolvedType = resolveTypeof(decl->type, symtab);198 resolvedType = fixArrayType(resolvedType, symtab);200 auto resolvedType = resolveTypeof(decl->type, context); 201 resolvedType = fixArrayType(resolvedType, context); 199 202 mutDecl->type = resolvedType; 200 203
Note:
See TracChangeset
for help on using the changeset viewer.