Changeset a2dbcff1 for src/CodeTools
- Timestamp:
- Dec 14, 2018, 2:47:57 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 107b01a
- Parents:
- 6ebc13f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/ResolvProtoDump.cc
r6ebc13f ra2dbcff1 51 51 52 52 /// Child constructor 53 ProtoDump(const ProtoDump* p, Type* r) 53 ProtoDump(const ProtoDump* p, Type* r) 54 54 : decls(), exprs(), subs(), closed(p->closed), parent(p), rtnType(r) {} 55 55 56 56 // Fix copy issues 57 ProtoDump(const ProtoDump& o) 58 : decls(o.decls), exprs(o.exprs), subs(o.subs), closed(o.closed), parent(o.parent), 57 ProtoDump(const ProtoDump& o) 58 : decls(o.decls), exprs(o.exprs), subs(o.subs), closed(o.closed), parent(o.parent), 59 59 rtnType(maybeClone(o.rtnType.get())) {} 60 60 ProtoDump( ProtoDump&& ) = default; … … 69 69 parent = o.parent; 70 70 rtnType.reset( maybeClone(o.rtnType.get()) ); 71 71 72 72 return *this; 73 73 } 74 ProtoDump& operator= (ProtoDump&&) = de fault;74 ProtoDump& operator= (ProtoDump&&) = delete; 75 75 76 76 private: … … 96 96 subs.emplace_back( std::move(sub.pass) ); 97 97 } 98 98 99 99 /// Whether lists should be separated, terminated, or preceded by their separator 100 100 enum septype { separated, terminated, preceded }; … … 102 102 /// builds space-separated list of types 103 103 template<typename V> 104 static void build( V& visitor, const std::list< Type* >& tys, std::stringstream& ss, 104 static void build( V& visitor, const std::list< Type* >& tys, std::stringstream& ss, 105 105 septype mode = separated ) { 106 106 if ( tys.empty() ) return; … … 121 121 /// builds list of types wrapped as tuple type 122 122 template<typename V> 123 static void buildAsTuple( V& visitor, const std::list< Type* >& tys, 123 static void buildAsTuple( V& visitor, const std::list< Type* >& tys, 124 124 std::stringstream& ss ) { 125 125 switch ( tys.size() ) { … … 162 162 if ( name.compare( 0, 10, "_operator_" ) == 0 ) { 163 163 ss << name.substr(10); 164 } else if ( name.compare( "_constructor" ) == 0 164 } else if ( name.compare( "_constructor" ) == 0 165 165 || name.compare( "_destructor" ) == 0 ) { 166 166 ss << name.substr(1); … … 173 173 174 174 /// replaces operators with resolv-proto names 175 static void rp_name( const std::string& name, std::stringstream& ss, 175 static void rp_name( const std::string& name, std::stringstream& ss, 176 176 std::string&& pre = "" ) { 177 177 // safety check for anonymous names … … 187 187 op_name( info.outputName, ss ); 188 188 return; 189 } 190 189 } 190 191 191 // replace retval names 192 192 if ( name.compare( 0, 8, "_retval_" ) == 0 ) { … … 195 195 return; 196 196 } 197 197 198 198 // default to just name, with first character in lowercase 199 ss << pre 199 ss << pre 200 200 << (char)std::tolower( static_cast<unsigned char>(name[0]) ) 201 201 << (name.c_str() + 1); … … 221 221 // strip trailing "_generic_" from autogen names (avoids some user-generation issues) 222 222 char generic[] = "_generic_"; size_t n_generic = sizeof(generic) - 1; 223 if ( stripped.size() >= n_generic 223 if ( stripped.size() >= n_generic 224 224 && stripped.substr( stripped.size() - n_generic ) == generic ) { 225 225 stripped.resize( stripped.size() - n_generic ); … … 237 237 unsigned depth; ///< Depth of nesting from root type 238 238 239 TypePrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 239 TypePrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 240 240 : ss(ss), closed(closed), depth(0) {} 241 241 … … 337 337 } 338 338 }; 339 339 340 340 /// builds description of function 341 341 void build( const std::string& name, FunctionType* fnTy, std::stringstream& ss ) { … … 350 350 for ( TypeDecl* tyvar : fnTy->forall ) { 351 351 for ( DeclarationWithType* assn : tyvar->assertions ) { 352 ss << " | "; 352 ss << " | "; 353 353 build( assn->name, assn->get_type(), ss ); 354 354 } … … 360 360 // ignore top-level references 361 361 Type *norefs = ty->stripReferences(); 362 362 363 363 // fall back to function declaration if function type 364 364 if ( PointerType* pTy = dynamic_cast< PointerType* >(norefs) ) { … … 409 409 std::stringstream& ss; ///< Output to print to 410 410 411 ExprPrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 411 ExprPrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 412 412 : closed(closed), ss(ss) {} 413 413 … … 476 476 visit_children = false; 477 477 } 478 478 479 479 /// Member access handled as function from aggregate to member 480 480 void previsit( UntypedMemberExpr* expr ) { … … 662 662 } 663 663 } 664 664 665 665 // add named parameters and returns to local scope 666 666 body.pass.addAll( decl->type->returnVals ); … … 679 679 void previsit( StructDecl* sd ) { addAggregateFields(sd); } 680 680 void previsit( UnionDecl* ud ) { addAggregateFields(ud); } 681 681 682 682 void previsit( EnumDecl* ed ) { 683 std::unique_ptr<Type> eType = 683 std::unique_ptr<Type> eType = 684 684 std::make_unique<BasicType>( Type::Qualifiers{}, BasicType::SignedInt ); 685 685 686 686 // add field names directly to enclosing scope 687 687 for ( Declaration* member : ed->members ) {
Note: See TracChangeset
for help on using the changeset viewer.