Changeset a46b69c for src/Parser
- Timestamp:
- Mar 23, 2021, 9:14:10 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f9c3100
- Parents:
- 6259c7e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r6259c7e ra46b69c 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:35:37202113 // Update Count : 114 112 // Last Modified On : Tue Mar 23 08:44:08 2021 13 // Update Count : 1149 14 14 // 15 15 … … 167 167 } 168 168 169 DeclarationNode * DeclarationNode::newFunction( const string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) {170 DeclarationNode * newnode = new DeclarationNode;171 newnode->name = name;172 newnode->type = new TypeData( TypeData::Function );173 newnode->type->function.params = param;174 newnode->type->function.body = body;175 176 if ( ret ) {177 newnode->type->base = ret->type;178 ret->type = nullptr;179 delete ret;180 } // if181 182 return newnode;183 } // DeclarationNode::newFunction184 185 186 169 DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) { 187 170 DeclarationNode * newnode = new DeclarationNode; … … 237 220 return newnode; 238 221 } // DeclarationNode::newForall 239 240 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) {241 DeclarationNode * newnode = new DeclarationNode;242 newnode->type = new TypeData( TypeData::SymbolicInst );243 newnode->type->symbolic.name = name;244 newnode->type->symbolic.isTypedef = true;245 newnode->type->symbolic.params = nullptr;246 return newnode;247 } // DeclarationNode::newFromTypedef248 222 249 223 DeclarationNode * DeclarationNode::newFromGlobalScope() { … … 289 263 } // DeclarationNode::newEnum 290 264 265 DeclarationNode * DeclarationNode::newName( const string * name ) { 266 DeclarationNode * newnode = new DeclarationNode; 267 assert( ! newnode->name ); 268 newnode->name = name; 269 return newnode; 270 } // DeclarationNode::newName 271 291 272 DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) { 292 DeclarationNode * newnode = new DeclarationNode; 293 newnode->name = name; 273 DeclarationNode * newnode = newName( name ); 294 274 newnode->enumeratorValue.reset( constant ); 295 275 return newnode; 296 276 } // DeclarationNode::newEnumConstant 297 277 298 DeclarationNode * DeclarationNode::newName( const string * name ) { 299 DeclarationNode * newnode = new DeclarationNode; 300 newnode->name = name; 301 return newnode; 302 } // DeclarationNode::newName 278 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) { 279 DeclarationNode * newnode = new DeclarationNode; 280 newnode->type = new TypeData( TypeData::SymbolicInst ); 281 newnode->type->symbolic.name = name; 282 newnode->type->symbolic.isTypedef = true; 283 newnode->type->symbolic.params = nullptr; 284 return newnode; 285 } // DeclarationNode::newFromTypedef 303 286 304 287 DeclarationNode * DeclarationNode::newFromTypeGen( const string * name, ExpressionNode * params ) { … … 312 295 313 296 DeclarationNode * DeclarationNode::newTypeParam( TypeDecl::Kind tc, const string * name ) { 314 DeclarationNode * newnode = new DeclarationNode;297 DeclarationNode * newnode = newName( name ); 315 298 newnode->type = nullptr; 316 assert( ! newnode->name );317 // newnode->variable.name = name;318 newnode->name = name;319 299 newnode->variable.tyClass = tc; 320 300 newnode->variable.assertions = nullptr; … … 343 323 344 324 DeclarationNode * DeclarationNode::newTypeDecl( const string * name, DeclarationNode * typeParams ) { 345 DeclarationNode * newnode = new DeclarationNode; 346 newnode->name = name; 325 DeclarationNode * newnode = newName( name ); 347 326 newnode->type = new TypeData( TypeData::Symbolic ); 348 327 newnode->type->symbolic.isTypedef = false; … … 416 395 return newnode; 417 396 } // DeclarationNode::newBuiltinType 397 398 DeclarationNode * DeclarationNode::newFunction( const string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) { 399 DeclarationNode * newnode = newName( name ); 400 newnode->type = new TypeData( TypeData::Function ); 401 newnode->type->function.params = param; 402 newnode->type->function.body = body; 403 404 if ( ret ) { 405 newnode->type->base = ret->type; 406 ret->type = nullptr; 407 delete ret; 408 } // if 409 410 return newnode; 411 } // DeclarationNode::newFunction 418 412 419 413 DeclarationNode * DeclarationNode::newAttribute( const string * name, ExpressionNode * expr ) { … … 885 879 } 886 880 887 DeclarationNode * DeclarationNode::cloneType( string * n ewName ) {888 DeclarationNode * newnode = new DeclarationNode;881 DeclarationNode * DeclarationNode::cloneType( string * name ) { 882 DeclarationNode * newnode = newName( name ); 889 883 newnode->type = maybeClone( type ); 890 884 newnode->copySpecifiers( this ); 891 assert( newName );892 newnode->name = newName;893 885 return newnode; 894 886 }
Note: See TracChangeset
for help on using the changeset viewer.