Changeset 0bd3faf for src/SymTab
- Timestamp:
- Nov 13, 2023, 1:40:12 PM (6 months ago)
- Branches:
- master
- Children:
- 6ea85b22
- Parents:
- 25f2798
- Location:
- src/SymTab
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/FixFunction.cc
r25f2798 r0bd3faf 26 26 27 27 namespace { 28 struct FixFunction _newfinal : public ast::WithShortCircuiting {28 struct FixFunction final : public ast::WithShortCircuiting { 29 29 bool isVoid = false; 30 30 … … 70 70 71 71 const ast::DeclWithType * fixFunction( const ast::DeclWithType * dwt, bool & isVoid ) { 72 ast::Pass< FixFunction _new> fixer;72 ast::Pass< FixFunction > fixer; 73 73 dwt = dwt->accept( fixer ); 74 74 isVoid |= fixer.core.isVoid; … … 77 77 78 78 const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ) { 79 ast::Pass< FixFunction _new> fixer;79 ast::Pass< FixFunction > fixer; 80 80 type = type->accept( fixer ); 81 81 isVoid |= fixer.core.isVoid; -
src/SymTab/GenImplicitCall.cpp
r25f2798 r0bd3faf 32 32 template< typename OutIter > 33 33 ast::ptr< ast::Stmt > genCall( 34 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,34 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 35 35 const CodeLocation & loc, const std::string & fname, OutIter && out, 36 36 const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward ); … … 42 42 template< typename OutIter > 43 43 ast::ptr< ast::Stmt > genScalarCall( 44 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,44 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 45 45 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type, 46 46 const ast::Type * addCast = nullptr … … 98 98 template< typename OutIter > 99 99 void genArrayCall( 100 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,100 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 101 101 const CodeLocation & loc, const std::string & fname, OutIter && out, 102 102 const ast::ArrayType * array, const ast::Type * addCast = nullptr, … … 167 167 template< typename OutIter > 168 168 ast::ptr< ast::Stmt > genCall( 169 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,169 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 170 170 const CodeLocation & loc, const std::string & fname, OutIter && out, 171 171 const ast::Type * type, const ast::Type * addCast, LoopDirection forward … … 185 185 186 186 ast::ptr< ast::Stmt > genImplicitCall( 187 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,187 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 188 188 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, 189 189 LoopDirection forward -
src/SymTab/GenImplicitCall.hpp
r25f2798 r0bd3faf 26 26 /// dstParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 27 27 ast::ptr<ast::Stmt> genImplicitCall( 28 InitTweak::InitExpander _new& srcParam, const ast::Expr * dstParam,28 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 29 29 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, 30 30 LoopDirection forward = LoopForward -
src/SymTab/Mangler.cc
r25f2798 r0bd3faf 30 30 namespace { 31 31 /// Mangles names to a unique C identifier 32 struct Mangler _new : public ast::WithShortCircuiting, public ast::WithVisitorRef<Mangler_new>, public ast::WithGuards {33 Mangler _new( Mangle::Mode mode );34 Mangler _new( const Mangler_new& ) = delete;32 struct Mangler : public ast::WithShortCircuiting, public ast::WithVisitorRef<Mangler>, public ast::WithGuards { 33 Mangler( Mangle::Mode mode ); 34 Mangler( const Mangler & ) = delete; 35 35 36 36 void previsit( const ast::Node * ) { visit_children = false; } … … 72 72 73 73 private: 74 Mangler _new( bool mangleOverridable, bool typeMode, bool mangleGenericParams,74 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 75 75 int nextVarNum, const VarMapType& varNums ); 76 friend class ast::Pass<Mangler _new>;76 friend class ast::Pass<Mangler>; 77 77 78 78 private: … … 81 81 82 82 void printQualifiers( const ast::Type *type ); 83 }; // Mangler _new83 }; // Mangler 84 84 } // namespace 85 85 86 86 std::string mangle( const ast::Node * decl, Mangle::Mode mode ) { 87 return ast::Pass<Mangler _new>::read( decl, mode );87 return ast::Pass<Mangler>::read( decl, mode ); 88 88 } 89 89 90 90 namespace { 91 Mangler _new::Mangler_new( Mangle::Mode mode )91 Mangler::Mangler( Mangle::Mode mode ) 92 92 : nextVarNum( 0 ), isTopLevel( true ), 93 93 mangleOverridable ( ! mode.no_overrideable ), … … 95 95 mangleGenericParams( ! mode.no_generic_params ) {} 96 96 97 Mangler _new::Mangler_new( bool mangleOverridable, bool typeMode, bool mangleGenericParams,97 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 98 98 int nextVarNum, const VarMapType& varNums ) 99 99 : varNums( varNums ), nextVarNum( nextVarNum ), isTopLevel( false ), … … 101 101 mangleGenericParams( mangleGenericParams ) {} 102 102 103 void Mangler _new::mangleDecl( const ast::DeclWithType * decl ) {103 void Mangler::mangleDecl( const ast::DeclWithType * decl ) { 104 104 bool wasTopLevel = isTopLevel; 105 105 if ( isTopLevel ) { … … 131 131 } 132 132 133 void Mangler _new::postvisit( const ast::ObjectDecl * decl ) {133 void Mangler::postvisit( const ast::ObjectDecl * decl ) { 134 134 mangleDecl( decl ); 135 135 } 136 136 137 void Mangler _new::postvisit( const ast::FunctionDecl * decl ) {137 void Mangler::postvisit( const ast::FunctionDecl * decl ) { 138 138 mangleDecl( decl ); 139 139 } 140 140 141 void Mangler _new::postvisit( const ast::VoidType * voidType ) {141 void Mangler::postvisit( const ast::VoidType * voidType ) { 142 142 printQualifiers( voidType ); 143 143 mangleName += Encoding::void_t; 144 144 } 145 145 146 void Mangler _new::postvisit( const ast::BasicType * basicType ) {146 void Mangler::postvisit( const ast::BasicType * basicType ) { 147 147 printQualifiers( basicType ); 148 148 assertf( basicType->kind < ast::BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind ); … … 150 150 } 151 151 152 void Mangler _new::postvisit( const ast::PointerType * pointerType ) {152 void Mangler::postvisit( const ast::PointerType * pointerType ) { 153 153 printQualifiers( pointerType ); 154 154 // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers … … 157 157 } 158 158 159 void Mangler _new::postvisit( const ast::ArrayType * arrayType ) {159 void Mangler::postvisit( const ast::ArrayType * arrayType ) { 160 160 // TODO: encode dimension 161 161 printQualifiers( arrayType ); … … 164 164 } 165 165 166 void Mangler _new::postvisit( const ast::ReferenceType * refType ) {166 void Mangler::postvisit( const ast::ReferenceType * refType ) { 167 167 // don't print prefix (e.g. 'R') for reference types so that references and non-references do not overload. 168 168 // Further, do not print the qualifiers for a reference type (but do run printQualifers because of TypeDecls, etc.), … … 174 174 } 175 175 176 void Mangler _new::postvisit( const ast::FunctionType * functionType ) {176 void Mangler::postvisit( const ast::FunctionType * functionType ) { 177 177 printQualifiers( functionType ); 178 178 mangleName += Encoding::function; … … 189 189 } 190 190 191 void Mangler _new::mangleRef(191 void Mangler::mangleRef( 192 192 const ast::BaseInstType * refType, const std::string & prefix ) { 193 193 printQualifiers( refType ); … … 206 206 } 207 207 208 void Mangler _new::postvisit( const ast::StructInstType * aggregateUseType ) {208 void Mangler::postvisit( const ast::StructInstType * aggregateUseType ) { 209 209 mangleRef( aggregateUseType, Encoding::struct_t ); 210 210 } 211 211 212 void Mangler _new::postvisit( const ast::UnionInstType * aggregateUseType ) {212 void Mangler::postvisit( const ast::UnionInstType * aggregateUseType ) { 213 213 mangleRef( aggregateUseType, Encoding::union_t ); 214 214 } 215 215 216 void Mangler _new::postvisit( const ast::EnumInstType * aggregateUseType ) {216 void Mangler::postvisit( const ast::EnumInstType * aggregateUseType ) { 217 217 mangleRef( aggregateUseType, Encoding::enum_t ); 218 218 } 219 219 220 void Mangler _new::postvisit( const ast::TypeInstType * typeInst ) {220 void Mangler::postvisit( const ast::TypeInstType * typeInst ) { 221 221 VarMapType::iterator varNum = varNums.find( typeInst->name ); 222 222 if ( varNum == varNums.end() ) { … … 234 234 } 235 235 236 void Mangler _new::postvisit( const ast::TraitInstType * inst ) {236 void Mangler::postvisit( const ast::TraitInstType * inst ) { 237 237 printQualifiers( inst ); 238 238 mangleName += std::to_string( inst->name.size() ) + inst->name; 239 239 } 240 240 241 void Mangler _new::postvisit( const ast::TupleType * tupleType ) {241 void Mangler::postvisit( const ast::TupleType * tupleType ) { 242 242 printQualifiers( tupleType ); 243 243 mangleName += Encoding::tuple + std::to_string( tupleType->types.size() ); … … 245 245 } 246 246 247 void Mangler _new::postvisit( const ast::VarArgsType * varArgsType ) {247 void Mangler::postvisit( const ast::VarArgsType * varArgsType ) { 248 248 printQualifiers( varArgsType ); 249 249 static const std::string vargs = "__builtin_va_list"; … … 251 251 } 252 252 253 void Mangler _new::postvisit( const ast::ZeroType * ) {253 void Mangler::postvisit( const ast::ZeroType * ) { 254 254 mangleName += Encoding::zero; 255 255 } 256 256 257 void Mangler _new::postvisit( const ast::OneType * ) {257 void Mangler::postvisit( const ast::OneType * ) { 258 258 mangleName += Encoding::one; 259 259 } 260 260 261 void Mangler _new::postvisit( const ast::QualifiedType * qualType ) {261 void Mangler::postvisit( const ast::QualifiedType * qualType ) { 262 262 bool inqual = inQualifiedType; 263 263 if ( !inqual ) { … … 275 275 } 276 276 277 void Mangler _new::postvisit( const ast::TypeDecl * decl ) {277 void Mangler::postvisit( const ast::TypeDecl * decl ) { 278 278 // TODO: is there any case where mangling a TypeDecl makes sense? If so, this code needs to be 279 279 // fixed to ensure that two TypeDecls mangle to the same name when they are the same type and vice versa. … … 281 281 // and the case has not yet come up in practice. Alternatively, if not then this code can be removed 282 282 // aside from the assert false. 283 assertf(false, "Mangler _newshould not visit typedecl: %s", toCString(decl));283 assertf(false, "Mangler should not visit typedecl: %s", toCString(decl)); 284 284 assertf( decl->kind < ast::TypeDecl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind ); 285 285 mangleName += Encoding::typeVariables[ decl->kind ] + std::to_string( decl->name.length() ) + decl->name; … … 293 293 } 294 294 295 void Mangler _new::printQualifiers( const ast::Type * type ) {295 void Mangler::printQualifiers( const ast::Type * type ) { 296 296 // skip if not including qualifiers 297 297 if ( typeMode ) return; … … 318 318 } // for 319 319 for ( auto & assert : funcType->assertions ) { 320 assertionNames.push_back( ast::Pass<Mangler _new>::read(320 assertionNames.push_back( ast::Pass<Mangler>::read( 321 321 assert->var.get(), 322 322 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) );
Note: See TracChangeset
for help on using the changeset viewer.