Changeset 19b5d6b for src/Parser/DeclarationNode.cc
- Timestamp:
- Oct 4, 2016, 11:25:00 AM (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:
- 40744af8, a7976d79
- Parents:
- 6295081 (diff), 4b1fd2c (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/Parser/DeclarationNode.cc
r6295081 r19b5d6b 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Sep 14 23:13:28201613 // Update Count : 50212 // Last Modified On : Mon Sep 26 22:18:40 2016 13 // Update Count : 640 14 14 // 15 15 … … 31 31 32 32 // These must remain in the same order as the corresponding DeclarationNode enumerations. 33 const char * DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" };34 const char * DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" };35 const char * DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" };36 const char * DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" };37 const char * DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" };38 const char * DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" };39 const char * DeclarationNode::aggregateName[] = { "struct", "union", "context" };40 const char * DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" };41 const char * DeclarationNode::builtinTypeName[] = { "__builtin_va_list" };33 const char * DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" }; 34 const char * DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" }; 35 const char * DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" }; 36 const char * DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" }; 37 const char * DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" }; 38 const char * DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" }; 39 const char * DeclarationNode::aggregateName[] = { "struct", "union", "context" }; 40 const char * DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" }; 41 const char * DeclarationNode::builtinTypeName[] = { "__builtin_va_list" }; 42 42 43 43 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 46 46 47 47 DeclarationNode::DeclarationNode() : 48 type( 0),48 type( nullptr ), 49 49 storageClass( NoStorageClass ), 50 50 isInline( false ), 51 51 isNoreturn( false ), 52 bitfieldWidth( 0),53 initializer( 0),52 bitfieldWidth( nullptr ), 53 initializer( nullptr ), 54 54 hasEllipsis( false ), 55 55 linkage( ::linkage ), 56 56 extension( false ) { 57 58 variable.name = nullptr; 57 59 variable.tyClass = DeclarationNode::Otype; 58 60 variable.assertions = nullptr; 59 61 62 attr.name = nullptr; 60 63 attr.expr = nullptr; 61 64 attr.type = nullptr; … … 63 66 64 67 DeclarationNode::~DeclarationNode() { 68 delete attr.name; 65 69 delete attr.expr; 66 70 delete attr.type; 71 72 delete variable.name; 73 delete variable.assertions; 74 67 75 delete type; 68 76 delete bitfieldWidth; … … 70 78 } 71 79 72 DeclarationNode * DeclarationNode::clone() const {73 DeclarationNode * newnode = new DeclarationNode;80 DeclarationNode * DeclarationNode::clone() const { 81 DeclarationNode * newnode = new DeclarationNode; 74 82 newnode->type = maybeClone( type ); 75 newnode->name = name ;83 newnode->name = name ? new string( *name ) : nullptr; 76 84 newnode->storageClass = storageClass; 77 85 newnode->isInline = isInline; … … 83 91 newnode->linkage = linkage; 84 92 93 newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr; 94 newnode->variable.tyClass = variable.tyClass; 85 95 newnode->variable.assertions = maybeClone( variable.assertions ); 86 newnode->variable.name = variable.name; 87 newnode->variable.tyClass = variable.tyClass; 88 96 97 newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr; 89 98 newnode->attr.expr = maybeClone( attr.expr ); 90 99 newnode->attr.type = maybeClone( attr.type ); … … 98 107 void DeclarationNode::print( std::ostream &os, int indent ) const { 99 108 os << string( indent, ' ' ); 100 if ( name == "" ) { 109 if ( name ) { 110 os << *name << ": "; 111 } else { 101 112 os << "unnamed: "; 102 } else {103 os << name << ": ";104 113 } // if 105 114 … … 122 131 } // if 123 132 124 if ( initializer != 0) {133 if ( initializer ) { 125 134 os << endl << string( indent + 2, ' ' ) << "with initializer "; 126 135 initializer->printOneLine( os ); … … 139 148 } 140 149 141 DeclarationNode *DeclarationNode::newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param, StatementNode *body, bool newStyle ) { 142 DeclarationNode *newnode = new DeclarationNode; 143 newnode->name = assign_strptr( name ); 144 150 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) { 151 DeclarationNode * newnode = new DeclarationNode; 152 newnode->name = name; 145 153 newnode->type = new TypeData( TypeData::Function ); 146 154 newnode->type->function.params = param; 147 155 newnode->type->function.newStyle = newStyle; 148 156 newnode->type->function.body = body; 149 typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID ); 157 // ignore unnamed routine declarations: void p( int (*)(int) ); 158 if ( newnode->name ) { 159 typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID ); 160 } // if 150 161 151 162 if ( body ) { … … 155 166 if ( ret ) { 156 167 newnode->type->base = ret->type; 157 ret->type = 0;168 ret->type = nullptr; 158 169 delete ret; 159 170 } // if … … 163 174 164 175 DeclarationNode * DeclarationNode::newQualifier( Qualifier q ) { 165 DeclarationNode * newnode = new DeclarationNode;176 DeclarationNode * newnode = new DeclarationNode; 166 177 newnode->type = new TypeData(); 167 178 newnode->type->qualifiers[ q ] = 1; … … 169 180 } // DeclarationNode::newQualifier 170 181 171 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) {172 DeclarationNode * newnode = new DeclarationNode;182 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) { 183 DeclarationNode * newnode = new DeclarationNode; 173 184 newnode->type = new TypeData( TypeData::Unknown ); 174 185 newnode->type->forall = forall; … … 177 188 178 189 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) { 179 DeclarationNode *newnode = new DeclarationNode; 180 //switch (sc) { 181 // case Inline: newnode->isInline = true; break; 182 // case Noreturn: newnode->isNoreturn = true; break; 183 // default: newnode->storageClass = sc; break; 184 //} 190 DeclarationNode * newnode = new DeclarationNode; 185 191 newnode->storageClass = sc; 186 192 return newnode; … … 188 194 189 195 DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) { 190 DeclarationNode * newnode = new DeclarationNode;196 DeclarationNode * newnode = new DeclarationNode; 191 197 newnode->type = new TypeData( TypeData::Basic ); 192 198 newnode->type->basictype = bt; … … 195 201 196 202 DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) { 197 DeclarationNode * newnode = new DeclarationNode;203 DeclarationNode * newnode = new DeclarationNode; 198 204 newnode->type = new TypeData( TypeData::Basic ); 199 205 newnode->type->complextype = ct; … … 202 208 203 209 DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) { 204 DeclarationNode * newnode = new DeclarationNode;210 DeclarationNode * newnode = new DeclarationNode; 205 211 newnode->type = new TypeData( TypeData::Basic ); 206 212 newnode->type->signedness = sn; … … 209 215 210 216 DeclarationNode * DeclarationNode::newLength( Length lnth ) { 211 DeclarationNode * newnode = new DeclarationNode;217 DeclarationNode * newnode = new DeclarationNode; 212 218 newnode->type = new TypeData( TypeData::Basic ); 213 219 newnode->type->length = lnth; … … 215 221 } // DeclarationNode::newLength 216 222 217 DeclarationNode * DeclarationNode::newFromTypedef( st d::string *name ) {218 DeclarationNode * newnode = new DeclarationNode;223 DeclarationNode * DeclarationNode::newFromTypedef( string * name ) { 224 DeclarationNode * newnode = new DeclarationNode; 219 225 newnode->type = new TypeData( TypeData::SymbolicInst ); 220 newnode->type->symbolic.name = assign_strptr( name );226 newnode->type->symbolic.name = name; 221 227 newnode->type->symbolic.isTypedef = true; 222 newnode->type->symbolic.params = 0;228 newnode->type->symbolic.params = nullptr; 223 229 return newnode; 224 230 } // DeclarationNode::newFromTypedef 225 231 226 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const st d::string *name, ExpressionNode *actuals, DeclarationNode *fields, bool body ) {227 DeclarationNode * newnode = new DeclarationNode;232 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 233 DeclarationNode * newnode = new DeclarationNode; 228 234 newnode->type = new TypeData( TypeData::Aggregate ); 229 235 newnode->type->aggregate.kind = kind; 230 newnode->type->aggregate.name = assign_strptr( name ); 231 if ( newnode->type->aggregate.name == "" ) { // anonymous aggregate ? 232 newnode->type->aggregate.name = anonymous.newName(); 236 if ( name ) { 237 newnode->type->aggregate.name = name; 238 } else { // anonymous aggregate ? 239 newnode->type->aggregate.name = new string( anonymous.newName() ); 233 240 } // if 234 241 newnode->type->aggregate.actuals = actuals; … … 238 245 } // DeclarationNode::newAggregate 239 246 240 DeclarationNode *DeclarationNode::newEnum( std::string *name, DeclarationNode *constants ) { 241 DeclarationNode *newnode = new DeclarationNode; 242 newnode->name = assign_strptr( name ); 247 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants ) { 248 DeclarationNode * newnode = new DeclarationNode; 243 249 newnode->type = new TypeData( TypeData::Enum ); 244 newnode->type->enumeration.name = newnode->name; 245 if ( newnode->type->enumeration.name == "" ) { // anonymous enumeration ? 246 newnode->type->enumeration.name = DeclarationNode::anonymous.newName(); 250 if ( name ) { 251 newnode->type->enumeration.name = name; 252 } else { // anonymous aggregate ? 253 newnode->type->enumeration.name = new string( anonymous.newName() ); 247 254 } // if 248 255 newnode->type->enumeration.constants = constants; … … 250 257 } // DeclarationNode::newEnum 251 258 252 DeclarationNode * DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) {253 DeclarationNode * newnode = new DeclarationNode;254 newnode->name = assign_strptr( name );259 DeclarationNode * DeclarationNode::newEnumConstant( string * name, ExpressionNode * constant ) { 260 DeclarationNode * newnode = new DeclarationNode; 261 newnode->name = name; 255 262 newnode->enumeratorValue.reset( constant ); 256 typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );263 typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID ); 257 264 return newnode; 258 265 } // DeclarationNode::newEnumConstant 259 266 260 DeclarationNode * DeclarationNode::newName( std::string *name ) {261 DeclarationNode * newnode = new DeclarationNode;262 newnode->name = assign_strptr( name );267 DeclarationNode * DeclarationNode::newName( string * name ) { 268 DeclarationNode * newnode = new DeclarationNode; 269 newnode->name = name; 263 270 return newnode; 264 271 } // DeclarationNode::newName 265 272 266 DeclarationNode * DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) {267 DeclarationNode * newnode = new DeclarationNode;273 DeclarationNode * DeclarationNode::newFromTypeGen( string * name, ExpressionNode * params ) { 274 DeclarationNode * newnode = new DeclarationNode; 268 275 newnode->type = new TypeData( TypeData::SymbolicInst ); 269 newnode->type->symbolic.name = assign_strptr( name );276 newnode->type->symbolic.name = name; 270 277 newnode->type->symbolic.isTypedef = false; 271 278 newnode->type->symbolic.actuals = params; … … 273 280 } // DeclarationNode::newFromTypeGen 274 281 275 DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) { 276 DeclarationNode *newnode = new DeclarationNode; 277 newnode->name = assign_strptr( name ); 278 newnode->type = new TypeData( TypeData::Variable ); 282 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, string * name ) { 283 DeclarationNode * newnode = new DeclarationNode; 284 newnode->type = nullptr; 279 285 newnode->variable.tyClass = tc; 280 newnode->variable.name = n ewnode->name;286 newnode->variable.name = name; 281 287 return newnode; 282 288 } // DeclarationNode::newTypeParam 283 289 284 DeclarationNode * DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) {285 DeclarationNode * newnode = new DeclarationNode;290 DeclarationNode * DeclarationNode::newTrait( const string * name, DeclarationNode * params, DeclarationNode * asserts ) { 291 DeclarationNode * newnode = new DeclarationNode; 286 292 newnode->type = new TypeData( TypeData::Aggregate ); 293 newnode->type->aggregate.name = name; 287 294 newnode->type->aggregate.kind = Trait; 288 295 newnode->type->aggregate.params = params; 289 296 newnode->type->aggregate.fields = asserts; 290 newnode->type->aggregate.name = assign_strptr( name );291 297 return newnode; 292 298 } // DeclarationNode::newTrait 293 299 294 DeclarationNode * DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) {295 DeclarationNode * newnode = new DeclarationNode;300 DeclarationNode * DeclarationNode::newTraitUse( const string * name, ExpressionNode * params ) { 301 DeclarationNode * newnode = new DeclarationNode; 296 302 newnode->type = new TypeData( TypeData::AggregateInst ); 297 303 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 298 304 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 299 newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name );305 newnode->type->aggInst.aggregate->aggregate.name = name; 300 306 newnode->type->aggInst.params = params; 301 307 return newnode; 302 308 } // DeclarationNode::newTraitUse 303 309 304 DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) { 305 DeclarationNode *newnode = new DeclarationNode; 306 newnode->name = assign_strptr( name ); 310 DeclarationNode * DeclarationNode::newTypeDecl( string * name, DeclarationNode * typeParams ) { 311 DeclarationNode * newnode = new DeclarationNode; 307 312 newnode->type = new TypeData( TypeData::Symbolic ); 308 313 newnode->type->symbolic.isTypedef = false; 309 314 newnode->type->symbolic.params = typeParams; 310 newnode->type->symbolic.name = n ewnode->name;315 newnode->type->symbolic.name = name; 311 316 return newnode; 312 317 } // DeclarationNode::newTypeDecl 313 318 314 DeclarationNode * DeclarationNode::newPointer( DeclarationNode *qualifiers ) {315 DeclarationNode * newnode = new DeclarationNode;319 DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers ) { 320 DeclarationNode * newnode = new DeclarationNode; 316 321 newnode->type = new TypeData( TypeData::Pointer ); 317 322 return newnode->addQualifiers( qualifiers ); 318 323 } // DeclarationNode::newPointer 319 324 320 DeclarationNode * DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) {321 DeclarationNode * newnode = new DeclarationNode;325 DeclarationNode * DeclarationNode::newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic ) { 326 DeclarationNode * newnode = new DeclarationNode; 322 327 newnode->type = new TypeData( TypeData::Array ); 323 328 newnode->type->array.dimension = size; 324 329 newnode->type->array.isStatic = isStatic; 325 if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) {330 if ( newnode->type->array.dimension == nullptr || newnode->type->array.dimension->isExpressionType<ConstantExpr * >() ) { 326 331 newnode->type->array.isVarLen = false; 327 332 } else { … … 331 336 } // DeclarationNode::newArray 332 337 333 DeclarationNode * DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {334 DeclarationNode * newnode = new DeclarationNode;338 DeclarationNode * DeclarationNode::newVarArray( DeclarationNode * qualifiers ) { 339 DeclarationNode * newnode = new DeclarationNode; 335 340 newnode->type = new TypeData( TypeData::Array ); 336 newnode->type->array.dimension = 0;341 newnode->type->array.dimension = nullptr; 337 342 newnode->type->array.isStatic = false; 338 343 newnode->type->array.isVarLen = true; … … 340 345 } 341 346 342 DeclarationNode * DeclarationNode::newBitfield( ExpressionNode *size ) {343 DeclarationNode * newnode = new DeclarationNode;347 DeclarationNode * DeclarationNode::newBitfield( ExpressionNode * size ) { 348 DeclarationNode * newnode = new DeclarationNode; 344 349 newnode->bitfieldWidth = size; 345 350 return newnode; 346 351 } 347 352 348 DeclarationNode * DeclarationNode::newTuple( DeclarationNode *members ) {349 DeclarationNode * newnode = new DeclarationNode;353 DeclarationNode * DeclarationNode::newTuple( DeclarationNode * members ) { 354 DeclarationNode * newnode = new DeclarationNode; 350 355 newnode->type = new TypeData( TypeData::Tuple ); 351 356 newnode->type->tuple = members; … … 353 358 } 354 359 355 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode *expr ) {356 DeclarationNode * newnode = new DeclarationNode;360 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) { 361 DeclarationNode * newnode = new DeclarationNode; 357 362 newnode->type = new TypeData( TypeData::Typeof ); 358 363 newnode->type->typeexpr = expr; … … 361 366 362 367 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) { 363 DeclarationNode * newnode = new DeclarationNode;368 DeclarationNode * newnode = new DeclarationNode; 364 369 newnode->type = new TypeData( TypeData::Builtin ); 365 370 newnode->builtin = bt; … … 367 372 } // DeclarationNode::newBuiltinType 368 373 369 DeclarationNode * DeclarationNode::newAttr( std::string *name, ExpressionNode *expr ) {370 DeclarationNode * newnode = new DeclarationNode;371 newnode->type = n ew TypeData( TypeData::Attr );372 newnode->attr.name = assign_strptr( name );374 DeclarationNode * DeclarationNode::newAttr( string * name, ExpressionNode * expr ) { 375 DeclarationNode * newnode = new DeclarationNode; 376 newnode->type = nullptr; 377 newnode->attr.name = name; 373 378 newnode->attr.expr = expr; 374 379 return newnode; 375 380 } 376 381 377 DeclarationNode * DeclarationNode::newAttr( std::string *name, DeclarationNode *type ) {378 DeclarationNode * newnode = new DeclarationNode;379 newnode->type = n ew TypeData( TypeData::Attr );380 newnode->attr.name = assign_strptr( name );382 DeclarationNode * DeclarationNode::newAttr( string * name, DeclarationNode * type ) { 383 DeclarationNode * newnode = new DeclarationNode; 384 newnode->type = nullptr; 385 newnode->attr.name = name; 381 386 newnode->attr.type = type; 382 387 return newnode; … … 389 394 } // appendError 390 395 391 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData *dst ) {396 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 392 397 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 393 398 … … 401 406 } // DeclarationNode::checkQualifiers 402 407 403 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) {408 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) { 404 409 if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) { 405 410 if ( storageClass == q->storageClass ) { // duplicate qualifier … … 413 418 } // DeclarationNode::copyStorageClasses 414 419 415 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode *q ) {420 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) { 416 421 isInline = isInline || q->isInline; 417 422 isNoreturn = isNoreturn || q->isNoreturn; … … 424 429 } // DeclarationNode::copyStorageClasses 425 430 426 static void addQualifiersToType( TypeData *&src, TypeData * dst ) {431 static void addQualifiersToType( TypeData *&src, TypeData * dst ) { 427 432 if ( src->forall && dst->kind == TypeData::Function ) { 428 433 if ( dst->forall ) { … … 431 436 dst->forall = src->forall; 432 437 } // if 433 src->forall = 0;438 src->forall = nullptr; 434 439 } // if 435 440 if ( dst->base ) { … … 437 442 } else if ( dst->kind == TypeData::Function ) { 438 443 dst->base = src; 439 src = 0;444 src = nullptr; 440 445 } else { 441 446 dst->qualifiers |= src->qualifiers; … … 443 448 } // addQualifiersToType 444 449 445 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode *q ) {446 if ( ! q ) return this;450 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) { 451 if ( ! q ) { delete q; return this; } 447 452 448 453 checkStorageClasses( q ); 449 454 copyStorageClasses( q ); 450 455 451 if ( ! q->type ) { delete q; return this; } 456 if ( ! q->type ) { 457 delete q; 458 return this; 459 } // if 452 460 453 461 if ( ! type ) { 454 // type = new TypeData; 455 type = q->type; 462 type = q->type; // reuse this structure 463 q->type = nullptr; 464 delete q; 456 465 return this; 457 466 } // if … … 467 476 type->aggregate.params = q->type->forall; 468 477 // change implicit typedef from TYPEDEFname to TYPEGENname 469 typedefTable.changeKind( type->aggregate.name, TypedefTable::TG );478 typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG ); 470 479 } else { 471 480 type->forall = q->type->forall; 472 481 } // if 473 482 } // if 474 q->type->forall = 0;483 q->type->forall = nullptr; 475 484 } // if 476 485 delete q; … … 485 494 dst->forall = src->forall; 486 495 } // if 487 src->forall = 0;496 src->forall = nullptr; 488 497 } // if 489 498 if ( dst->base ) { … … 494 503 src->qualifiers |= dst->qualifiers; 495 504 dst = src; 496 src = 0;505 src = nullptr; 497 506 break; 498 507 case TypeData::Basic: … … 504 513 dst->basictype = src->basictype; 505 514 } else if ( src->basictype != DeclarationNode::NoBasicType ) 506 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 ); 507 516 508 517 if ( dst->complextype == DeclarationNode::NoComplexType ) { 509 518 dst->complextype = src->complextype; 510 519 } else if ( src->complextype != DeclarationNode::NoComplexType ) 511 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 ); 512 521 513 522 if ( dst->signedness == DeclarationNode::NoSignedness ) { 514 523 dst->signedness = src->signedness; 515 524 } else if ( src->signedness != DeclarationNode::NoSignedness ) 516 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 ); 517 526 518 527 if ( dst->length == DeclarationNode::NoLength ) { … … 521 530 dst->length = DeclarationNode::LongLong; 522 531 } else if ( src->length != DeclarationNode::NoLength ) 523 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 ); 524 533 } // if 525 534 break; … … 534 543 } // if 535 544 dst->base->qualifiers |= src->qualifiers; 536 src = 0;545 src = nullptr; 537 546 break; 538 547 default: … … 542 551 dst->forall = src->forall; 543 552 } // if 544 src->forall = 0;553 src->forall = nullptr; 545 554 dst->base = src; 546 src = 0;555 src = nullptr; 547 556 } // switch 548 557 } // switch … … 550 559 } 551 560 552 DeclarationNode * DeclarationNode::addType( DeclarationNode *o ) {561 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) { 553 562 if ( o ) { 554 563 checkStorageClasses( o ); … … 566 575 type = o->type; 567 576 } // if 568 o->type = 0;577 o->type = nullptr; 569 578 } else { 570 579 addTypeToType( o->type, type ); … … 584 593 } 585 594 586 DeclarationNode * DeclarationNode::addTypedef() {587 TypeData * newtype = new TypeData( TypeData::Symbolic );588 newtype->symbolic.params = 0;595 DeclarationNode * DeclarationNode::addTypedef() { 596 TypeData * newtype = new TypeData( TypeData::Symbolic ); 597 newtype->symbolic.params = nullptr; 589 598 newtype->symbolic.isTypedef = true; 590 newtype->symbolic.name = name ;599 newtype->symbolic.name = name ? new string( *name ) : nullptr; 591 600 newtype->base = type; 592 601 type = newtype; … … 594 603 } 595 604 596 DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) { 605 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 606 if ( variable.name ) { 607 if ( variable.assertions ) { 608 variable.assertions->appendList( assertions ); 609 } else { 610 variable.assertions = assertions; 611 } // if 612 return this; 613 } // if 614 597 615 assert( type ); 598 616 switch ( type->kind ) { … … 604 622 } // if 605 623 break; 606 case TypeData::Variable:607 if ( variable.assertions ) {608 variable.assertions->appendList( assertions );609 } else {610 variable.assertions = assertions;611 } // if612 break;624 // case TypeData::Variable: 625 // if ( variable.assertions ) { 626 // variable.assertions->appendList( assertions ); 627 // } else { 628 // variable.assertions = assertions; 629 // } // if 630 // break; 613 631 default: 614 632 assert( false ); … … 618 636 } 619 637 620 DeclarationNode *DeclarationNode::addName( std::string *newname ) { 621 name = assign_strptr( newname ); 622 return this; 623 } 624 625 DeclarationNode *DeclarationNode::addBitfield( ExpressionNode *size ) { 638 DeclarationNode * DeclarationNode::addName( string * newname ) { 639 assert( ! name ); 640 name = newname; 641 return this; 642 } 643 644 DeclarationNode * DeclarationNode::addBitfield( ExpressionNode * size ) { 626 645 bitfieldWidth = size; 627 646 return this; 628 647 } 629 648 630 DeclarationNode * DeclarationNode::addVarArgs() {649 DeclarationNode * DeclarationNode::addVarArgs() { 631 650 assert( type ); 632 651 hasEllipsis = true; … … 634 653 } 635 654 636 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode *body ) {655 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) { 637 656 assert( type ); 638 657 assert( type->kind == TypeData::Function ); 639 assert( type->function.body == 0);658 assert( ! type->function.body ); 640 659 type->function.body = body; 641 660 type->function.hasBody = true; … … 643 662 } 644 663 645 DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode *list ) {664 DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode * list ) { 646 665 assert( type ); 647 666 assert( type->kind == TypeData::Function ); 648 assert( type->function.oldDeclList == 0);667 assert( ! type->function.oldDeclList ); 649 668 type->function.oldDeclList = list; 650 669 return this; 651 670 } 652 671 653 static void setBase( TypeData *&type, TypeData * newType ) {672 static void setBase( TypeData *&type, TypeData * newType ) { 654 673 if ( type ) { 655 TypeData * prevBase = type;656 TypeData * curBase = type->base;657 while ( curBase != 0) {674 TypeData * prevBase = type; 675 TypeData * curBase = type->base; 676 while ( curBase != nullptr ) { 658 677 prevBase = curBase; 659 678 curBase = curBase->base; … … 665 684 } 666 685 667 DeclarationNode * DeclarationNode::addPointer( DeclarationNode *p ) {686 DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) { 668 687 if ( p ) { 669 688 assert( p->type->kind == TypeData::Pointer ); 670 689 setBase( type, p->type ); 671 p->type = 0;690 p->type = nullptr; 672 691 delete p; 673 692 } // if … … 675 694 } 676 695 677 DeclarationNode * DeclarationNode::addArray( DeclarationNode *a ) {696 DeclarationNode * DeclarationNode::addArray( DeclarationNode * a ) { 678 697 if ( a ) { 679 698 assert( a->type->kind == TypeData::Array ); 680 699 setBase( type, a->type ); 681 a->type = 0;700 a->type = nullptr; 682 701 delete a; 683 702 } // if … … 685 704 } 686 705 687 DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode *p ) {706 DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode * p ) { 688 707 if ( p ) { 689 708 assert( p->type->kind == TypeData::Pointer ); … … 703 722 p->type->base = type; 704 723 } // switch 705 type = 0;724 type = nullptr; 706 725 } // if 707 726 delete this; … … 712 731 } 713 732 714 static TypeData * findLast( TypeData *a ) {733 static TypeData * findLast( TypeData * a ) { 715 734 assert( a ); 716 TypeData * cur = a;735 TypeData * cur = a; 717 736 while ( cur->base ) { 718 737 cur = cur->base; … … 721 740 } 722 741 723 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode *a ) {742 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 724 743 if ( a ) { 725 744 assert( a->type->kind == TypeData::Array ); 726 TypeData * lastArray = findLast( a->type );745 TypeData * lastArray = findLast( a->type ); 727 746 if ( type ) { 728 747 switch ( type->kind ) { … … 739 758 lastArray->base = type; 740 759 } // switch 741 type = 0;760 type = nullptr; 742 761 } // if 743 762 delete this; … … 748 767 } 749 768 750 DeclarationNode * DeclarationNode::addParamList( DeclarationNode *params ) {751 TypeData * ftype = new TypeData( TypeData::Function );769 DeclarationNode * DeclarationNode::addParamList( DeclarationNode * params ) { 770 TypeData * ftype = new TypeData( TypeData::Function ); 752 771 ftype->function.params = params; 753 772 setBase( type, ftype ); … … 755 774 } 756 775 757 static TypeData * addIdListToType( TypeData *type, DeclarationNode *ids ) {776 static TypeData * addIdListToType( TypeData * type, DeclarationNode * ids ) { 758 777 if ( type ) { 759 778 if ( type->kind != TypeData::Function ) { … … 764 783 return type; 765 784 } else { 766 TypeData * newtype = new TypeData( TypeData::Function );785 TypeData * newtype = new TypeData( TypeData::Function ); 767 786 newtype->function.idList = ids; 768 787 return newtype; 769 788 } // if 770 } 771 772 DeclarationNode * DeclarationNode::addIdList( DeclarationNode *ids ) {789 } // addIdListToType 790 791 DeclarationNode * DeclarationNode::addIdList( DeclarationNode * ids ) { 773 792 type = addIdListToType( type, ids ); 774 793 return this; 775 794 } 776 795 777 DeclarationNode *DeclarationNode::addInitializer( InitializerNode *init ) { 778 //assert 796 DeclarationNode * DeclarationNode::addInitializer( InitializerNode * init ) { 779 797 initializer = init; 780 798 return this; 781 799 } 782 800 783 DeclarationNode *DeclarationNode::cloneBaseType( string *newName ) { 784 DeclarationNode *newnode = new DeclarationNode; 785 TypeData *srcType = type; 786 while ( srcType->base ) { 787 srcType = srcType->base; 788 } // while 789 newnode->type = maybeClone( srcType ); 790 if ( newnode->type->kind == TypeData::AggregateInst ) { 791 // don't duplicate members 792 if ( newnode->type->aggInst.aggregate->kind == TypeData::Enum ) { 793 delete newnode->type->aggInst.aggregate->enumeration.constants; 794 newnode->type->aggInst.aggregate->enumeration.constants = 0; 795 } else { 796 assert( newnode->type->aggInst.aggregate->kind == TypeData::Aggregate ); 797 delete newnode->type->aggInst.aggregate->aggregate.fields; 798 newnode->type->aggInst.aggregate->aggregate.fields = 0; 799 } // if 800 } // if 801 newnode->type->forall = maybeClone( type->forall ); 802 assert( storageClass == NoStorageClass ); 803 newnode->copyStorageClasses( this ); 804 newnode->name = assign_strptr( newName ); 805 return newnode; 806 } 807 808 DeclarationNode *DeclarationNode::cloneBaseType( DeclarationNode *o ) { 809 if ( o ) { 810 o->copyStorageClasses( this ); 811 if ( type ) { 812 TypeData *srcType = type; 813 while ( srcType->base ) { 814 srcType = srcType->base; 815 } // while 816 TypeData *newType = srcType->clone(); 817 if ( newType->kind == TypeData::AggregateInst ) { 818 // don't duplicate members 819 if ( newType->aggInst.aggregate->kind == TypeData::Enum ) { 820 delete newType->aggInst.aggregate->enumeration.constants; 821 newType->aggInst.aggregate->enumeration.constants = 0; 822 } else { 823 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 824 delete newType->aggInst.aggregate->aggregate.fields; 825 newType->aggInst.aggregate->aggregate.fields = 0; 826 } // if 827 } // if 828 newType->forall = maybeClone( type->forall ); 829 if ( ! o->type ) { 830 o->type = newType; 831 } else { 832 addTypeToType( newType, o->type ); 833 delete newType; 834 } // if 835 } // if 836 } // if 837 return o; 838 } 839 840 DeclarationNode *DeclarationNode::cloneType( string *newName ) { 841 DeclarationNode *newnode = new DeclarationNode; 801 DeclarationNode * DeclarationNode::cloneType( string * newName ) { 802 DeclarationNode * newnode = new DeclarationNode; 842 803 newnode->type = maybeClone( type ); 843 804 assert( storageClass == NoStorageClass ); 844 805 newnode->copyStorageClasses( this ); 845 newnode->name = assign_strptr( newName ); 846 return newnode; 847 } 848 849 DeclarationNode *DeclarationNode::cloneType( DeclarationNode *o ) { 850 if ( o ) { 851 assert( storageClass == NoStorageClass ); 852 o->copyStorageClasses( this ); 853 if ( type ) { 854 TypeData *newType = type->clone(); 855 if ( ! o->type ) { 856 o->type = newType; 806 assert( newName ); 807 newnode->name = newName; 808 return newnode; 809 } 810 811 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) { 812 if ( ! o ) return nullptr; 813 814 o->copyStorageClasses( this ); 815 if ( type ) { 816 TypeData * srcType = type; 817 818 while ( srcType->base ) { 819 srcType = srcType->base; 820 } // while 821 822 TypeData * newType = srcType->clone(); 823 if ( newType->kind == TypeData::AggregateInst ) { 824 // don't duplicate members 825 if ( newType->aggInst.aggregate->kind == TypeData::Enum ) { 826 delete newType->aggInst.aggregate->enumeration.constants; 827 newType->aggInst.aggregate->enumeration.constants = nullptr; 857 828 } else { 858 addTypeToType( newType, o->type ); 859 delete newType; 829 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 830 delete newType->aggInst.aggregate->aggregate.fields; 831 newType->aggInst.aggregate->aggregate.fields = nullptr; 860 832 } // if 861 833 } // if 862 } // if 863 delete o; 834 835 newType->forall = maybeClone( type->forall ); 836 if ( ! o->type ) { 837 o->type = newType; 838 } else { 839 addTypeToType( newType, o->type ); 840 delete newType; 841 } // if 842 } // if 864 843 return o; 865 844 } 866 845 867 DeclarationNode * DeclarationNode::extractAggregate() const {846 DeclarationNode * DeclarationNode::extractAggregate() const { 868 847 if ( type ) { 869 TypeData * ret = typeextractAggregate( type );848 TypeData * ret = typeextractAggregate( type ); 870 849 if ( ret ) { 871 DeclarationNode * newnode = new DeclarationNode;850 DeclarationNode * newnode = new DeclarationNode; 872 851 newnode->type = ret; 873 852 return newnode; 874 853 } // if 875 854 } // if 876 return 0;877 } 878 879 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) {855 return nullptr; 856 } 857 858 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) { 880 859 SemanticError errors; 881 860 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); 882 const DeclarationNode *cur = firstNode; 861 const DeclarationNode * cur = firstNode; 862 883 863 while ( cur ) { 884 864 try { 885 if ( DeclarationNode * extr = cur->extractAggregate() ) {865 if ( DeclarationNode * extr = cur->extractAggregate() ) { 886 866 // handle the case where a structure declaration is contained within an object or type declaration 887 Declaration * decl = extr->build();867 Declaration * decl = extr->build(); 888 868 if ( decl ) { 889 * out++ = decl;869 * out++ = decl; 890 870 } // if 891 871 delete extr; 892 872 } // if 893 Declaration *decl = cur->build(); 873 874 Declaration * decl = cur->build(); 894 875 if ( decl ) { 895 * out++ = decl;876 * out++ = decl; 896 877 } // if 897 878 } catch( SemanticError &e ) { … … 900 881 cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); 901 882 } // while 883 902 884 if ( ! errors.isEmpty() ) { 903 885 throw errors; 904 886 } // if 905 } 906 907 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) {887 } // buildList 888 889 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) { 908 890 SemanticError errors; 909 891 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); 910 const DeclarationNode * cur = firstNode;892 const DeclarationNode * cur = firstNode; 911 893 while ( cur ) { 912 894 try { 913 Declaration * decl = cur->build();895 Declaration * decl = cur->build(); 914 896 if ( decl ) { 915 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {916 * out++ = dwt;917 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {918 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );919 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, 0, inst, 0);897 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) { 898 * out++ = dwt; 899 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 900 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 901 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 920 902 delete agg; 921 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {922 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );923 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, 0, inst, 0);903 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 904 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 905 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 924 906 } // if 925 907 } // if … … 932 914 throw errors; 933 915 } // if 934 } 935 936 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) {916 } // buildList 917 918 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) { 937 919 SemanticError errors; 938 920 std::back_insert_iterator< std::list< Type * > > out( outputList ); 939 const DeclarationNode *cur = firstNode; 921 const DeclarationNode * cur = firstNode; 922 940 923 while ( cur ) { 941 924 try { 942 * out++ = cur->buildType();925 * out++ = cur->buildType(); 943 926 } catch( SemanticError &e ) { 944 927 errors.append( e ); … … 946 929 cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); 947 930 } // while 931 948 932 if ( ! errors.isEmpty() ) { 949 933 throw errors; 950 934 } // if 951 } 952 953 Declaration * DeclarationNode::build() const {935 } // buildTypeList 936 937 Declaration * DeclarationNode::build() const { 954 938 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this ); 939 940 if ( variable.name ) { 941 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 942 TypeDecl * ret = new TypeDecl( *variable.name, DeclarationNode::NoStorageClass, nullptr, kindMap[ variable.tyClass ] ); 943 buildList( variable.assertions, ret->get_assertions() ); 944 return ret; 945 } // if 946 955 947 if ( type ) { 956 if ( type->kind == TypeData::Variable ) { 957 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 958 TypeDecl * ret = new TypeDecl( variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ variable.tyClass ] ); 959 buildList( variable.assertions, ret->get_assertions() ); 960 return ret; 948 return buildDecl( type, name ? *name : string( "" ), storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 949 } // if 950 951 if ( ! isInline && ! isNoreturn ) { 952 assertf( name, "ObjectDecl are assumed to have names\n" ); 953 return (new ObjectDecl( *name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_extension( extension ); 954 } // if 955 956 throw SemanticError( "invalid function specifier ", this ); 957 } 958 959 Type * DeclarationNode::buildType() const { 960 assert( type ); 961 962 if ( attr.name ) { 963 AttrType * ret; 964 if ( attr.expr ) { 965 ret = new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() ); 961 966 } else { 962 return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 963 } // if 964 } // if 965 if ( ! isInline && ! isNoreturn ) { 966 return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension ); 967 } // if 968 throw SemanticError( "invalid function specifier ", this ); 969 } 970 971 Type *DeclarationNode::buildType() const { 972 assert( type ); 967 assert( attr.type ); 968 ret = new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() ); 969 } // if 970 return ret; 971 } // if 973 972 974 973 switch ( type->kind ) { 975 974 case TypeData::Enum: 976 return new EnumInstType( buildQualifiers( type ), type->enumeration.name );975 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 977 976 case TypeData::Aggregate: { 978 ReferenceToType * ret;977 ReferenceToType * ret; 979 978 switch ( type->aggregate.kind ) { 980 979 case DeclarationNode::Struct: 981 ret = new StructInstType( buildQualifiers( type ), type->aggregate.name );980 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 982 981 break; 983 982 case DeclarationNode::Union: 984 ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name );983 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 985 984 break; 986 985 case DeclarationNode::Trait: 987 ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name );986 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 988 987 break; 989 988 default: … … 994 993 } 995 994 case TypeData::Symbolic: { 996 TypeInstType * ret = new TypeInstType( buildQualifiers( type ),type->symbolic.name, false );995 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false ); 997 996 buildList( type->symbolic.actuals, ret->get_parameters() ); 998 return ret;999 }1000 case TypeData::Attr: {1001 assert( type->kind == TypeData::Attr );1002 // assert( type->attr );1003 AttrType * ret;1004 if ( attr.expr ) {1005 ret = new AttrType( buildQualifiers( type ), attr.name, attr.expr->build() );1006 } else {1007 assert( attr.type );1008 ret = new AttrType( buildQualifiers( type ), attr.name, attr.type->buildType() );1009 } // if1010 997 return ret; 1011 998 }
Note: See TracChangeset
for help on using the changeset viewer.