Changeset f5bace8
- Timestamp:
- Mar 25, 2022, 1:50:46 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 400b8be
- Parents:
- 64bdacc (diff), 8631c84 (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. - Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.cpp
r64bdacc rf5bace8 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 16 14:16:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 1 09:09:39202213 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 25 10:30:00 2022 13 // Update Count : 4 14 14 // 15 15 … … 19 19 #include <csignal> // MEMORY DEBUG -- for raise 20 20 #include <iostream> 21 #include <utility> 21 22 22 23 #include "Attribute.hpp" … … 76 77 void ast::ptr_base<node_t, ref_t>::_check() const { 77 78 // if(node) assert(node->was_ever_strong == false || node->strong_count > 0); 79 } 80 81 template< typename node_t, enum ast::Node::ref_type ref_t > 82 void ast::ptr_base<node_t, ref_t>::swap( ptr_base & other ) noexcept { 83 std::swap( this->node, other.node ); 84 _trap( this->node ); 85 _trap( other.node ); 78 86 } 79 87 -
src/AST/Node.hpp
r64bdacc rf5bace8 10 10 // Created On : Wed May 8 10:27:04 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jun 5 9:47:00 202013 // Update Count : 612 // Last Modified On : Fri Mar 25 10:33:00 2022 13 // Update Count : 7 14 14 // 15 15 … … 230 230 } 231 231 232 /// Swaps the nodes contained within two pointers. 233 void swap( ptr_base & other ) noexcept; 234 232 235 const node_t * get() const { _check(); return node; } 233 236 const node_t * operator->() const { _check(); return node; } … … 292 295 template< typename node_t > 293 296 using readonly = ptr_base< node_t, Node::ref_type::weak >; 297 298 /// Non-member swap that an participate in overload resolution. 299 template< typename node_t, enum Node::ref_type ref_t > 300 void swap( ptr_base< node_t, ref_t > & l, ptr_base< node_t, ref_t > & r ) { 301 l.swap( r ); 302 } 303 294 304 } 295 305 -
src/AST/Pass.impl.hpp
r64bdacc rf5bace8 354 354 // Take all the elements that are different in 'values' 355 355 // and swap them into 'container' 356 if( values[i] != nullptr ) s td::swap(container[i], values[i]);356 if( values[i] != nullptr ) swap(container[i], values[i]); 357 357 } 358 358 … … 1054 1054 auto n = __pass::mutate<core_t>(node); 1055 1055 for(size_t i = 0; i < new_clauses.size(); i++) { 1056 if(new_clauses.at(i).target.func != nullptr) s td::swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func);1056 if(new_clauses.at(i).target.func != nullptr) swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func); 1057 1057 1058 1058 for(size_t j = 0; j < new_clauses.at(i).target.args.size(); j++) { 1059 if(new_clauses.at(i).target.args.at(j) != nullptr) s td::swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j));1059 if(new_clauses.at(i).target.args.at(j) != nullptr) swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j)); 1060 1060 } 1061 1061 1062 if(new_clauses.at(i).stmt != nullptr) s td::swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt);1063 if(new_clauses.at(i).cond != nullptr) s td::swap(n->clauses.at(i).cond, new_clauses.at(i).cond);1062 if(new_clauses.at(i).stmt != nullptr) swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt); 1063 if(new_clauses.at(i).cond != nullptr) swap(n->clauses.at(i).cond, new_clauses.at(i).cond); 1064 1064 } 1065 1065 node = n; … … 2151 2151 2152 2152 if ( __visit_children() ) { 2153 { 2154 bool mutated = false; 2155 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map; 2156 for ( const auto & p : node->typeEnv ) { 2157 guard_symtab guard { *this }; 2158 auto new_node = p.second->accept( *this ); 2159 if (new_node != p.second) mutated = true; 2160 new_map.insert({ p.first, new_node }); 2161 } 2162 if (mutated) { 2163 auto new_node = __pass::mutate<core_t>( node ); 2164 new_node->typeEnv.swap( new_map ); 2165 node = new_node; 2166 } 2153 bool mutated = false; 2154 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map; 2155 for ( const auto & p : node->typeEnv ) { 2156 guard_symtab guard { *this }; 2157 auto new_node = p.second->accept( *this ); 2158 if (new_node != p.second) mutated = true; 2159 new_map.insert({ p.first, new_node }); 2160 } 2161 if (mutated) { 2162 auto new_node = __pass::mutate<core_t>( node ); 2163 new_node->typeEnv.swap( new_map ); 2164 node = new_node; 2167 2165 } 2168 2166 } -
src/ResolvExpr/RenameVars.h
r64bdacc rf5bace8 36 36 }; 37 37 const ast::Type * renameTyVars( const ast::Type *, RenameMode mode = GEN_USAGE, bool reset = true ); 38 39 38 40 39 /// resets internal state of renamer to avoid overflow 41 40 void resetTyVarRenaming(); 42 43 44 41 } // namespace ResolvExpr 45 42 -
src/ResolvExpr/ResolveTypeof.cc
r64bdacc rf5bace8 169 169 170 170 struct FixArrayDimension { 171 // should not require a mutable symbol table - prevent pass template instantiation172 171 const ResolveContext & context; 173 172 FixArrayDimension(const ResolveContext & context) : context( context ) {} … … 196 195 197 196 const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ResolveContext & context ) { 198 if (!decl->isTypeFixed) { 199 auto mutDecl = mutate(decl); 197 if (decl->isTypeFixed) { 198 return decl; 199 } 200 201 auto mutDecl = mutate(decl); 202 { 200 203 auto resolvedType = resolveTypeof(decl->type, context); 201 204 resolvedType = fixArrayType(resolvedType, context); 202 205 mutDecl->type = resolvedType; 203 204 // check variable length if object is an array. 205 // xxx - should this be part of fixObjectType? 206 207 /* 208 if (auto arrayType = dynamic_cast<const ast::ArrayType *>(resolvedType)) { 209 auto dimExpr = findSingleExpression(arrayType->dimension, ast::sizeType, symtab); 210 if (auto varexpr = arrayType->dimension.as<ast::VariableExpr>()) {// hoisted previously 211 if (InitTweak::isConstExpr(varexpr->var.strict_as<ast::ObjectDecl>()->init)) { 212 auto mutType = mutate(arrayType); 213 mutType->isVarLen = ast::LengthFlag::VariableLen; 214 mutDecl->type = mutType; 215 } 216 } 217 } 218 */ 219 220 221 if (!mutDecl->name.empty()) 222 mutDecl->mangleName = Mangle::mangle(mutDecl); // do not mangle unnamed variables 223 224 mutDecl->type = renameTyVars(mutDecl->type, RenameMode::GEN_EXPR_ID); 225 mutDecl->isTypeFixed = true; 226 return mutDecl; 227 } 228 return decl; 206 } 207 208 // Do not mangle unnamed variables. 209 if (!mutDecl->name.empty()) { 210 mutDecl->mangleName = Mangle::mangle(mutDecl); 211 } 212 213 mutDecl->type = renameTyVars(mutDecl->type, RenameMode::GEN_EXPR_ID); 214 mutDecl->isTypeFixed = true; 215 return mutDecl; 229 216 } 230 217 -
src/ResolvExpr/ResolveTypeof.h
r64bdacc rf5bace8 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ResolveTypeof.h -- 7 // ResolveTypeof.h -- 8 8 // 9 9 // Author : Richard C. Bilson
Note:
See TracChangeset
for help on using the changeset viewer.