Changeset fb114fa1 for src/Parser
- Timestamp:
- Sep 27, 2016, 11:22:48 AM (9 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:
- 4b1fd2c
- Parents:
- 3b5e3aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/DeclarationNode.cc ¶
r3b5e3aa rfb114fa1 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 24 11:12:52201613 // Update Count : 6 2712 // Last Modified On : Mon Sep 26 22:18:40 2016 13 // Update Count : 640 14 14 // 15 15 … … 92 92 93 93 newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr; 94 newnode->variable.tyClass = variable.tyClass; 94 95 newnode->variable.assertions = maybeClone( variable.assertions ); 95 newnode->variable.tyClass = variable.tyClass;96 96 97 97 newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr; … … 148 148 } 149 149 150 DeclarationNode * DeclarationNode::newFunction( st d::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {150 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) { 151 151 DeclarationNode * newnode = new DeclarationNode; 152 152 newnode->name = name; 153 154 153 newnode->type = new TypeData( TypeData::Function ); 155 154 newnode->type->function.params = param; … … 222 221 } // DeclarationNode::newLength 223 222 224 DeclarationNode * DeclarationNode::newFromTypedef( st d::string * name ) {223 DeclarationNode * DeclarationNode::newFromTypedef( string * name ) { 225 224 DeclarationNode * newnode = new DeclarationNode; 226 225 newnode->type = new TypeData( TypeData::SymbolicInst ); 227 newnode->type->symbolic.name = name ? new string( *name ) : nullptr;226 newnode->type->symbolic.name = name; 228 227 newnode->type->symbolic.isTypedef = true; 229 228 newnode->type->symbolic.params = nullptr; … … 231 230 } // DeclarationNode::newFromTypedef 232 231 233 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const st d::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {232 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 234 233 DeclarationNode * newnode = new DeclarationNode; 235 234 newnode->type = new TypeData( TypeData::Aggregate ); 236 235 newnode->type->aggregate.kind = kind; 237 236 if ( name ) { 238 newnode->type->aggregate.name = n ew string( *name );237 newnode->type->aggregate.name = name; 239 238 } else { // anonymous aggregate ? 240 239 newnode->type->aggregate.name = new string( anonymous.newName() ); … … 246 245 } // DeclarationNode::newAggregate 247 246 248 DeclarationNode * DeclarationNode::newEnum( std::string * name, DeclarationNode * constants ) { 249 DeclarationNode * newnode = new DeclarationNode; 250 newnode->name = name; 247 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants ) { 248 DeclarationNode * newnode = new DeclarationNode; 251 249 newnode->type = new TypeData( TypeData::Enum ); 252 250 if ( name ) { 253 newnode->type->enumeration.name = n ew string( *name );251 newnode->type->enumeration.name = name; 254 252 } else { // anonymous aggregate ? 255 253 newnode->type->enumeration.name = new string( anonymous.newName() ); … … 259 257 } // DeclarationNode::newEnum 260 258 261 DeclarationNode * DeclarationNode::newEnumConstant( st d::string * name, ExpressionNode * constant ) {259 DeclarationNode * DeclarationNode::newEnumConstant( string * name, ExpressionNode * constant ) { 262 260 DeclarationNode * newnode = new DeclarationNode; 263 261 newnode->name = name; … … 267 265 } // DeclarationNode::newEnumConstant 268 266 269 DeclarationNode * DeclarationNode::newName( st d::string * name ) {267 DeclarationNode * DeclarationNode::newName( string * name ) { 270 268 DeclarationNode * newnode = new DeclarationNode; 271 269 newnode->name = name; … … 273 271 } // DeclarationNode::newName 274 272 275 DeclarationNode * DeclarationNode::newFromTypeGen( st d::string * name, ExpressionNode * params ) {273 DeclarationNode * DeclarationNode::newFromTypeGen( string * name, ExpressionNode * params ) { 276 274 DeclarationNode * newnode = new DeclarationNode; 277 275 newnode->type = new TypeData( TypeData::SymbolicInst ); 278 newnode->type->symbolic.name = name ? new string( *name ) : nullptr;276 newnode->type->symbolic.name = name; 279 277 newnode->type->symbolic.isTypedef = false; 280 278 newnode->type->symbolic.actuals = params; … … 282 280 } // DeclarationNode::newFromTypeGen 283 281 284 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, std::string * name ) { 285 DeclarationNode * newnode = new DeclarationNode; 286 newnode->name = name; 287 // newnode->type = new TypeData( TypeData::Variable ); 282 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, string * name ) { 283 DeclarationNode * newnode = new DeclarationNode; 288 284 newnode->type = nullptr; 289 285 newnode->variable.tyClass = tc; 290 newnode->variable.name = n ewnode->name ? new string( *newnode->name ) : nullptr;286 newnode->variable.name = name; 291 287 return newnode; 292 288 } // DeclarationNode::newTypeParam 293 289 294 DeclarationNode * DeclarationNode::newTrait( const st d::string * name, DeclarationNode * params, DeclarationNode * asserts ) {290 DeclarationNode * DeclarationNode::newTrait( const string * name, DeclarationNode * params, DeclarationNode * asserts ) { 295 291 DeclarationNode * newnode = new DeclarationNode; 296 292 newnode->type = new TypeData( TypeData::Aggregate ); … … 302 298 } // DeclarationNode::newTrait 303 299 304 DeclarationNode * DeclarationNode::newTraitUse( const st d::string * name, ExpressionNode * params ) {300 DeclarationNode * DeclarationNode::newTraitUse( const string * name, ExpressionNode * params ) { 305 301 DeclarationNode * newnode = new DeclarationNode; 306 302 newnode->type = new TypeData( TypeData::AggregateInst ); … … 312 308 } // DeclarationNode::newTraitUse 313 309 314 DeclarationNode * DeclarationNode::newTypeDecl( std::string * name, DeclarationNode * typeParams ) { 315 DeclarationNode * newnode = new DeclarationNode; 316 newnode->name = name; 310 DeclarationNode * DeclarationNode::newTypeDecl( string * name, DeclarationNode * typeParams ) { 311 DeclarationNode * newnode = new DeclarationNode; 317 312 newnode->type = new TypeData( TypeData::Symbolic ); 318 313 newnode->type->symbolic.isTypedef = false; 319 314 newnode->type->symbolic.params = typeParams; 320 newnode->type->symbolic.name = n ewnode->name;315 newnode->type->symbolic.name = name; 321 316 return newnode; 322 317 } // DeclarationNode::newTypeDecl … … 377 372 } // DeclarationNode::newBuiltinType 378 373 379 DeclarationNode * DeclarationNode::newAttr( std::string * name, ExpressionNode * expr ) { 380 DeclarationNode * newnode = new DeclarationNode; 381 // newnode->type = new TypeData( TypeData::Attr ); 374 DeclarationNode * DeclarationNode::newAttr( string * name, ExpressionNode * expr ) { 375 DeclarationNode * newnode = new DeclarationNode; 382 376 newnode->type = nullptr; 383 377 newnode->attr.name = name; … … 386 380 } 387 381 388 DeclarationNode * DeclarationNode::newAttr( std::string * name, DeclarationNode * type ) { 389 DeclarationNode * newnode = new DeclarationNode; 390 // newnode->type = new TypeData( TypeData::Attr ); 382 DeclarationNode * DeclarationNode::newAttr( string * name, DeclarationNode * type ) { 383 DeclarationNode * newnode = new DeclarationNode; 391 384 newnode->type = nullptr; 392 385 newnode->attr.name = name; … … 520 513 dst->basictype = src->basictype; 521 514 } else if ( src->basictype != DeclarationNode::NoBasicType ) 522 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src );515 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src ); 523 516 524 517 if ( dst->complextype == DeclarationNode::NoComplexType ) { 525 518 dst->complextype = src->complextype; 526 519 } else if ( src->complextype != DeclarationNode::NoComplexType ) 527 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src );520 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src ); 528 521 529 522 if ( dst->signedness == DeclarationNode::NoSignedness ) { 530 523 dst->signedness = src->signedness; 531 524 } else if ( src->signedness != DeclarationNode::NoSignedness ) 532 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src );525 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src ); 533 526 534 527 if ( dst->length == DeclarationNode::NoLength ) { … … 537 530 dst->length = DeclarationNode::LongLong; 538 531 } else if ( src->length != DeclarationNode::NoLength ) 539 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src );532 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src ); 540 533 } // if 541 534 break; … … 643 636 } 644 637 645 DeclarationNode * DeclarationNode::addName( st d::string * newname ) {638 DeclarationNode * DeclarationNode::addName( string * newname ) { 646 639 assert( ! name ); 647 640 name = newname;
Note: See TracChangeset
for help on using the changeset viewer.