Changeset 3f7e12cb for src/SynTree/Declaration.h
- Timestamp:
- Nov 8, 2017, 5:43:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 954908d
- Parents:
- 78315272 (diff), e35f30a (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/SynTree/Declaration.h
r78315272 r3f7e12cb 61 61 62 62 void fixUniqueId( void ); 63 virtual Declaration *clone() const = 0;64 virtual void accept( Visitor &v ) = 0;65 virtual Declaration *acceptMutator( Mutator &m ) = 0;66 virtual void print( std::ostream &os, int indent = 0 ) const= 0;67 virtual void printShort( std::ostream &os, int indent = 0) const = 0;63 virtual Declaration *clone() const override = 0; 64 virtual void accept( Visitor &v ) override = 0; 65 virtual Declaration *acceptMutator( Mutator &m ) override = 0; 66 virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0; 67 virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0; 68 68 69 69 static void dumpIds( std::ostream &os ); … … 106 106 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } 107 107 108 virtual DeclarationWithType *clone() const = 0;109 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;108 virtual DeclarationWithType *clone() const override = 0; 109 virtual DeclarationWithType *acceptMutator( Mutator &m ) override = 0; 110 110 111 111 virtual Type * get_type() const = 0; … … 128 128 virtual ~ObjectDecl(); 129 129 130 virtual Type * get_type() const { return type; }131 virtual void set_type(Type *newType) { type = newType; }130 virtual Type * get_type() const override { return type; } 131 virtual void set_type(Type *newType) override { type = newType; } 132 132 133 133 Initializer *get_init() const { return init; } … … 139 139 static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init ); 140 140 141 virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }142 virtual void accept( Visitor &v ) { v.visit( this ); }143 virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }144 virtual void print( std::ostream &os, int indent = 0 ) const;145 virtual void printShort( std::ostream &os, int indent = 0 ) const;141 virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); } 142 virtual void accept( Visitor &v ) override { v.visit( this ); } 143 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 144 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 145 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 146 146 }; 147 147 … … 157 157 virtual ~FunctionDecl(); 158 158 159 Type * get_type() const{ return type; }160 virtual void set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); }159 virtual Type * get_type() const override { return type; } 160 virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); } 161 161 162 162 FunctionType * get_functionType() const { return type; } … … 165 165 void set_statements( CompoundStmt *newValue ) { statements = newValue; } 166 166 167 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } 168 virtual void accept( Visitor &v ) { v.visit( this ); } 169 virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); } 170 virtual void print( std::ostream &os, int indent = 0 ) const; 171 virtual void printShort( std::ostream &os, int indent = 0 ) const; 167 static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ); 168 169 virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); } 170 virtual void accept( Visitor &v ) override { v.visit( this ); } 171 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 172 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 173 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 172 174 }; 173 175 … … 190 192 virtual std::string typeString() const = 0; 191 193 192 virtual NamedTypeDecl *clone() const = 0;193 virtual void print( std::ostream &os, int indent = 0 ) const;194 virtual void printShort( std::ostream &os, int indent = 0 ) const;194 virtual NamedTypeDecl *clone() const override = 0; 195 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 196 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 195 197 }; 196 198 … … 198 200 typedef NamedTypeDecl Parent; 199 201 public: 200 enum Kind { Any,Dtype, Ftype, Ttype };202 enum Kind { Dtype, Ftype, Ttype }; 201 203 202 204 Type * init; … … 214 216 }; 215 217 216 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );218 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr ); 217 219 TypeDecl( const TypeDecl &other ); 218 220 virtual ~TypeDecl(); … … 223 225 TypeDecl * set_init( Type * newValue ) { init = newValue; return this; } 224 226 225 bool isComplete() const { return kind == Any ||sized; }227 bool isComplete() const { return sized; } 226 228 bool get_sized() const { return sized; } 227 229 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 228 230 229 virtual std::string typeString() const ;231 virtual std::string typeString() const override; 230 232 virtual std::string genTypeString() const; 231 233 232 virtual TypeDecl *clone() const { return new TypeDecl( *this ); }233 virtual void accept( Visitor &v ) { v.visit( this ); }234 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }235 virtual void print( std::ostream &os, int indent = 0 ) const;234 virtual TypeDecl *clone() const override { return new TypeDecl( *this ); } 235 virtual void accept( Visitor &v ) override { v.visit( this ); } 236 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 237 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 236 238 237 239 private: … … 245 247 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 246 248 247 virtual std::string typeString() const ;248 249 virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }250 virtual void accept( Visitor &v ) { v.visit( this ); }251 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }249 virtual std::string typeString() const override; 250 251 virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); } 252 virtual void accept( Visitor &v ) override { v.visit( this ); } 253 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 252 254 private: 253 255 }; … … 274 276 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } 275 277 276 virtual void print( std::ostream &os, int indent = 0 ) const;277 virtual void printShort( std::ostream &os, int indent = 0 ) const;278 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 279 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 278 280 protected: 279 281 virtual std::string typeString() const = 0; … … 290 292 bool is_thread() { return kind == DeclarationNode::Thread; } 291 293 292 virtual StructDecl *clone() const { return new StructDecl( *this ); }293 virtual void accept( Visitor &v ) { v.visit( this ); }294 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }294 virtual StructDecl *clone() const override { return new StructDecl( *this ); } 295 virtual void accept( Visitor &v ) override { v.visit( this ); } 296 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 295 297 private: 296 298 DeclarationNode::Aggregate kind; 297 virtual std::string typeString() const ;299 virtual std::string typeString() const override; 298 300 }; 299 301 … … 304 306 UnionDecl( const UnionDecl &other ) : Parent( other ) {} 305 307 306 virtual UnionDecl *clone() const { return new UnionDecl( *this ); }307 virtual void accept( Visitor &v ) { v.visit( this ); }308 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }309 private: 310 virtual std::string typeString() const ;308 virtual UnionDecl *clone() const override { return new UnionDecl( *this ); } 309 virtual void accept( Visitor &v ) override { v.visit( this ); } 310 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 311 private: 312 virtual std::string typeString() const override; 311 313 }; 312 314 … … 317 319 EnumDecl( const EnumDecl &other ) : Parent( other ) {} 318 320 319 virtual EnumDecl *clone() const { return new EnumDecl( *this ); }320 virtual void accept( Visitor &v ) { v.visit( this ); }321 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }322 private: 323 virtual std::string typeString() const ;321 virtual EnumDecl *clone() const override { return new EnumDecl( *this ); } 322 virtual void accept( Visitor &v ) override { v.visit( this ); } 323 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 324 private: 325 virtual std::string typeString() const override; 324 326 }; 325 327 … … 332 334 TraitDecl( const TraitDecl &other ) : Parent( other ) {} 333 335 334 virtual TraitDecl *clone() const { return new TraitDecl( *this ); }335 virtual void accept( Visitor &v ) { v.visit( this ); }336 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }337 private: 338 virtual std::string typeString() const ;336 virtual TraitDecl *clone() const override { return new TraitDecl( *this ); } 337 virtual void accept( Visitor &v ) override { v.visit( this ); } 338 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 339 private: 340 virtual std::string typeString() const override; 339 341 }; 340 342 … … 350 352 void set_stmt( AsmStmt *newValue ) { stmt = newValue; } 351 353 352 virtual AsmDecl *clone() const { return new AsmDecl( *this ); } 353 virtual void accept( Visitor &v ) { v.visit( this ); } 354 virtual AsmDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); } 355 virtual void print( std::ostream &os, int indent = 0 ) const; 356 virtual void printShort( std::ostream &os, int indent = 0 ) const; 357 }; 358 359 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 354 virtual AsmDecl *clone() const override { return new AsmDecl( *this ); } 355 virtual void accept( Visitor &v ) override { v.visit( this ); } 356 virtual AsmDecl *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 357 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 358 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 359 }; 360 360 361 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 361 362
Note:
See TracChangeset
for help on using the changeset viewer.