Changeset 7756647 for src/Parser/DeclarationNode.cc
- Timestamp:
- Oct 13, 2016, 2:45:17 PM (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:
- 848ce71
- Parents:
- ac9ca96 (diff), d58a39a0 (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
-
src/Parser/DeclarationNode.cc (modified) (62 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rac9ca96 r7756647 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:28 201613 // Update Count : 50212 // Last Modified On : Mon Oct 3 18:03:08 2016 13 // Update Count : 651 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 variable.tyClass = DeclarationNode::Otype; 57 58 // variable.name = nullptr; 59 variable.tyClass = NoTypeClass; 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 106 115 if ( linkage != LinkageSpec::Cforall ) { 107 os << LinkageSpec:: toString( linkage ) << " ";116 os << LinkageSpec::linkageName( linkage ) << " "; 108 117 } // if 109 118 … … 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; 285 assert( ! newnode->name ); 286 // newnode->variable.name = name; 287 newnode->name = name; 279 288 newnode->variable.tyClass = tc; 280 newnode->variable. name = newnode->name;289 newnode->variable.assertions = nullptr; 281 290 return newnode; 282 291 } // DeclarationNode::newTypeParam 283 292 284 DeclarationNode * DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) {285 DeclarationNode * newnode = new DeclarationNode;293 DeclarationNode * DeclarationNode::newTrait( const string * name, DeclarationNode * params, DeclarationNode * asserts ) { 294 DeclarationNode * newnode = new DeclarationNode; 286 295 newnode->type = new TypeData( TypeData::Aggregate ); 296 newnode->type->aggregate.name = name; 287 297 newnode->type->aggregate.kind = Trait; 288 298 newnode->type->aggregate.params = params; 289 299 newnode->type->aggregate.fields = asserts; 290 newnode->type->aggregate.name = assign_strptr( name );291 300 return newnode; 292 301 } // DeclarationNode::newTrait 293 302 294 DeclarationNode * DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) {295 DeclarationNode * newnode = new DeclarationNode;303 DeclarationNode * DeclarationNode::newTraitUse( const string * name, ExpressionNode * params ) { 304 DeclarationNode * newnode = new DeclarationNode; 296 305 newnode->type = new TypeData( TypeData::AggregateInst ); 297 306 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 298 307 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 299 newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name );308 newnode->type->aggInst.aggregate->aggregate.name = name; 300 309 newnode->type->aggInst.params = params; 301 310 return newnode; 302 311 } // DeclarationNode::newTraitUse 303 312 304 DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) { 305 DeclarationNode *newnode = new DeclarationNode; 306 newnode->name = assign_strptr( name ); 313 DeclarationNode * DeclarationNode::newTypeDecl( string * name, DeclarationNode * typeParams ) { 314 DeclarationNode * newnode = new DeclarationNode; 307 315 newnode->type = new TypeData( TypeData::Symbolic ); 308 316 newnode->type->symbolic.isTypedef = false; 309 317 newnode->type->symbolic.params = typeParams; 310 newnode->type->symbolic.name = n ewnode->name;318 newnode->type->symbolic.name = name; 311 319 return newnode; 312 320 } // DeclarationNode::newTypeDecl 313 321 314 DeclarationNode * DeclarationNode::newPointer( DeclarationNode *qualifiers ) {315 DeclarationNode * newnode = new DeclarationNode;322 DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers ) { 323 DeclarationNode * newnode = new DeclarationNode; 316 324 newnode->type = new TypeData( TypeData::Pointer ); 317 325 return newnode->addQualifiers( qualifiers ); 318 326 } // DeclarationNode::newPointer 319 327 320 DeclarationNode * DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) {321 DeclarationNode * newnode = new DeclarationNode;328 DeclarationNode * DeclarationNode::newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic ) { 329 DeclarationNode * newnode = new DeclarationNode; 322 330 newnode->type = new TypeData( TypeData::Array ); 323 331 newnode->type->array.dimension = size; 324 332 newnode->type->array.isStatic = isStatic; 325 if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) {333 if ( newnode->type->array.dimension == nullptr || newnode->type->array.dimension->isExpressionType<ConstantExpr * >() ) { 326 334 newnode->type->array.isVarLen = false; 327 335 } else { … … 331 339 } // DeclarationNode::newArray 332 340 333 DeclarationNode * DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {334 DeclarationNode * newnode = new DeclarationNode;341 DeclarationNode * DeclarationNode::newVarArray( DeclarationNode * qualifiers ) { 342 DeclarationNode * newnode = new DeclarationNode; 335 343 newnode->type = new TypeData( TypeData::Array ); 336 newnode->type->array.dimension = 0;344 newnode->type->array.dimension = nullptr; 337 345 newnode->type->array.isStatic = false; 338 346 newnode->type->array.isVarLen = true; … … 340 348 } 341 349 342 DeclarationNode * DeclarationNode::newBitfield( ExpressionNode *size ) {343 DeclarationNode * newnode = new DeclarationNode;350 DeclarationNode * DeclarationNode::newBitfield( ExpressionNode * size ) { 351 DeclarationNode * newnode = new DeclarationNode; 344 352 newnode->bitfieldWidth = size; 345 353 return newnode; 346 354 } 347 355 348 DeclarationNode * DeclarationNode::newTuple( DeclarationNode *members ) {349 DeclarationNode * newnode = new DeclarationNode;356 DeclarationNode * DeclarationNode::newTuple( DeclarationNode * members ) { 357 DeclarationNode * newnode = new DeclarationNode; 350 358 newnode->type = new TypeData( TypeData::Tuple ); 351 359 newnode->type->tuple = members; … … 353 361 } 354 362 355 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode *expr ) {356 DeclarationNode * newnode = new DeclarationNode;363 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) { 364 DeclarationNode * newnode = new DeclarationNode; 357 365 newnode->type = new TypeData( TypeData::Typeof ); 358 366 newnode->type->typeexpr = expr; … … 361 369 362 370 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) { 363 DeclarationNode * newnode = new DeclarationNode;371 DeclarationNode * newnode = new DeclarationNode; 364 372 newnode->type = new TypeData( TypeData::Builtin ); 365 373 newnode->builtin = bt; … … 367 375 } // DeclarationNode::newBuiltinType 368 376 369 DeclarationNode *DeclarationNode::newAttr( std::string *name, ExpressionNode *expr ) { 370 DeclarationNode *newnode = new DeclarationNode; 371 newnode->type = new TypeData( TypeData::Attr ); 372 newnode->attr.name = assign_strptr( name ); 377 DeclarationNode * DeclarationNode::newAttr( string * name, ExpressionNode * expr ) { 378 DeclarationNode * newnode = new DeclarationNode; 379 newnode->type = nullptr; 380 // newnode->attr.name = name; 381 newnode->name = name; 373 382 newnode->attr.expr = expr; 374 383 return newnode; 375 384 } 376 385 377 DeclarationNode *DeclarationNode::newAttr( std::string *name, DeclarationNode *type ) { 378 DeclarationNode *newnode = new DeclarationNode; 379 newnode->type = new TypeData( TypeData::Attr ); 380 newnode->attr.name = assign_strptr( name ); 386 DeclarationNode * DeclarationNode::newAttr( string * name, DeclarationNode * type ) { 387 DeclarationNode * newnode = new DeclarationNode; 388 newnode->type = nullptr; 389 // newnode->attr.name = name; 390 newnode->name = name; 381 391 newnode->attr.type = type; 382 392 return newnode; … … 389 399 } // appendError 390 400 391 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData *dst ) {401 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 392 402 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 393 403 … … 401 411 } // DeclarationNode::checkQualifiers 402 412 403 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) {413 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) { 404 414 if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) { 405 415 if ( storageClass == q->storageClass ) { // duplicate qualifier … … 413 423 } // DeclarationNode::copyStorageClasses 414 424 415 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode *q ) {425 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) { 416 426 isInline = isInline || q->isInline; 417 427 isNoreturn = isNoreturn || q->isNoreturn; … … 424 434 } // DeclarationNode::copyStorageClasses 425 435 426 static void addQualifiersToType( TypeData *&src, TypeData * dst ) {436 static void addQualifiersToType( TypeData *&src, TypeData * dst ) { 427 437 if ( src->forall && dst->kind == TypeData::Function ) { 428 438 if ( dst->forall ) { … … 431 441 dst->forall = src->forall; 432 442 } // if 433 src->forall = 0;443 src->forall = nullptr; 434 444 } // if 435 445 if ( dst->base ) { … … 437 447 } else if ( dst->kind == TypeData::Function ) { 438 448 dst->base = src; 439 src = 0;449 src = nullptr; 440 450 } else { 441 451 dst->qualifiers |= src->qualifiers; … … 443 453 } // addQualifiersToType 444 454 445 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode *q ) {446 if ( ! q ) return this;455 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) { 456 if ( ! q ) { delete q; return this; } 447 457 448 458 checkStorageClasses( q ); 449 459 copyStorageClasses( q ); 450 460 451 if ( ! q->type ) { delete q; return this; } 461 if ( ! q->type ) { 462 delete q; 463 return this; 464 } // if 452 465 453 466 if ( ! type ) { 454 // type = new TypeData; 455 type = q->type; 467 type = q->type; // reuse this structure 468 q->type = nullptr; 469 delete q; 456 470 return this; 457 471 } // if … … 467 481 type->aggregate.params = q->type->forall; 468 482 // change implicit typedef from TYPEDEFname to TYPEGENname 469 typedefTable.changeKind( type->aggregate.name, TypedefTable::TG );483 typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG ); 470 484 } else { 471 485 type->forall = q->type->forall; 472 486 } // if 473 487 } // if 474 q->type->forall = 0;488 q->type->forall = nullptr; 475 489 } // if 476 490 delete q; … … 485 499 dst->forall = src->forall; 486 500 } // if 487 src->forall = 0;501 src->forall = nullptr; 488 502 } // if 489 503 if ( dst->base ) { … … 494 508 src->qualifiers |= dst->qualifiers; 495 509 dst = src; 496 src = 0;510 src = nullptr; 497 511 break; 498 512 case TypeData::Basic: … … 504 518 dst->basictype = src->basictype; 505 519 } else if ( src->basictype != DeclarationNode::NoBasicType ) 506 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src );520 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src ); 507 521 508 522 if ( dst->complextype == DeclarationNode::NoComplexType ) { 509 523 dst->complextype = src->complextype; 510 524 } else if ( src->complextype != DeclarationNode::NoComplexType ) 511 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src );525 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src ); 512 526 513 527 if ( dst->signedness == DeclarationNode::NoSignedness ) { 514 528 dst->signedness = src->signedness; 515 529 } else if ( src->signedness != DeclarationNode::NoSignedness ) 516 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src );530 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src ); 517 531 518 532 if ( dst->length == DeclarationNode::NoLength ) { … … 521 535 dst->length = DeclarationNode::LongLong; 522 536 } else if ( src->length != DeclarationNode::NoLength ) 523 throw SemanticError( st d::string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src );537 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src ); 524 538 } // if 525 539 break; … … 534 548 } // if 535 549 dst->base->qualifiers |= src->qualifiers; 536 src = 0;550 src = nullptr; 537 551 break; 538 552 default: … … 542 556 dst->forall = src->forall; 543 557 } // if 544 src->forall = 0;558 src->forall = nullptr; 545 559 dst->base = src; 546 src = 0;560 src = nullptr; 547 561 } // switch 548 562 } // switch … … 550 564 } 551 565 552 DeclarationNode * DeclarationNode::addType( DeclarationNode *o ) {566 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) { 553 567 if ( o ) { 554 568 checkStorageClasses( o ); … … 566 580 type = o->type; 567 581 } // if 568 o->type = 0;582 o->type = nullptr; 569 583 } else { 570 584 addTypeToType( o->type, type ); … … 584 598 } 585 599 586 DeclarationNode * DeclarationNode::addTypedef() {587 TypeData * newtype = new TypeData( TypeData::Symbolic );588 newtype->symbolic.params = 0;600 DeclarationNode * DeclarationNode::addTypedef() { 601 TypeData * newtype = new TypeData( TypeData::Symbolic ); 602 newtype->symbolic.params = nullptr; 589 603 newtype->symbolic.isTypedef = true; 590 newtype->symbolic.name = name ;604 newtype->symbolic.name = name ? new string( *name ) : nullptr; 591 605 newtype->base = type; 592 606 type = newtype; … … 594 608 } 595 609 596 DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) { 610 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 611 if ( variable.tyClass != NoTypeClass ) { 612 if ( variable.assertions ) { 613 variable.assertions->appendList( assertions ); 614 } else { 615 variable.assertions = assertions; 616 } // if 617 return this; 618 } // if 619 597 620 assert( type ); 598 621 switch ( type->kind ) { … … 604 627 } // if 605 628 break; 606 case TypeData::Variable:607 if ( variable.assertions ) {608 variable.assertions->appendList( assertions );609 } else {610 variable.assertions = assertions;611 } // if612 break;613 629 default: 614 630 assert( false ); … … 618 634 } 619 635 620 DeclarationNode *DeclarationNode::addName( std::string *newname ) { 621 name = assign_strptr( newname ); 622 return this; 623 } 624 625 DeclarationNode *DeclarationNode::addBitfield( ExpressionNode *size ) { 636 DeclarationNode * DeclarationNode::addName( string * newname ) { 637 assert( ! name ); 638 name = newname; 639 return this; 640 } 641 642 DeclarationNode * DeclarationNode::addBitfield( ExpressionNode * size ) { 626 643 bitfieldWidth = size; 627 644 return this; 628 645 } 629 646 630 DeclarationNode * DeclarationNode::addVarArgs() {647 DeclarationNode * DeclarationNode::addVarArgs() { 631 648 assert( type ); 632 649 hasEllipsis = true; … … 634 651 } 635 652 636 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode *body ) {653 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) { 637 654 assert( type ); 638 655 assert( type->kind == TypeData::Function ); 639 assert( type->function.body == 0);656 assert( ! type->function.body ); 640 657 type->function.body = body; 641 658 type->function.hasBody = true; … … 643 660 } 644 661 645 DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode *list ) {662 DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode * list ) { 646 663 assert( type ); 647 664 assert( type->kind == TypeData::Function ); 648 assert( type->function.oldDeclList == 0);665 assert( ! type->function.oldDeclList ); 649 666 type->function.oldDeclList = list; 650 667 return this; 651 668 } 652 669 653 static void setBase( TypeData *&type, TypeData * newType ) {670 static void setBase( TypeData *&type, TypeData * newType ) { 654 671 if ( type ) { 655 TypeData * prevBase = type;656 TypeData * curBase = type->base;657 while ( curBase != 0) {672 TypeData * prevBase = type; 673 TypeData * curBase = type->base; 674 while ( curBase != nullptr ) { 658 675 prevBase = curBase; 659 676 curBase = curBase->base; … … 665 682 } 666 683 667 DeclarationNode * DeclarationNode::addPointer( DeclarationNode *p ) {684 DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) { 668 685 if ( p ) { 669 686 assert( p->type->kind == TypeData::Pointer ); 670 687 setBase( type, p->type ); 671 p->type = 0;688 p->type = nullptr; 672 689 delete p; 673 690 } // if … … 675 692 } 676 693 677 DeclarationNode * DeclarationNode::addArray( DeclarationNode *a ) {694 DeclarationNode * DeclarationNode::addArray( DeclarationNode * a ) { 678 695 if ( a ) { 679 696 assert( a->type->kind == TypeData::Array ); 680 697 setBase( type, a->type ); 681 a->type = 0;698 a->type = nullptr; 682 699 delete a; 683 700 } // if … … 685 702 } 686 703 687 DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode *p ) {704 DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode * p ) { 688 705 if ( p ) { 689 706 assert( p->type->kind == TypeData::Pointer ); … … 703 720 p->type->base = type; 704 721 } // switch 705 type = 0;722 type = nullptr; 706 723 } // if 707 724 delete this; … … 712 729 } 713 730 714 static TypeData * findLast( TypeData *a ) {731 static TypeData * findLast( TypeData * a ) { 715 732 assert( a ); 716 TypeData * cur = a;733 TypeData * cur = a; 717 734 while ( cur->base ) { 718 735 cur = cur->base; … … 721 738 } 722 739 723 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode *a ) {740 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 724 741 if ( a ) { 725 742 assert( a->type->kind == TypeData::Array ); 726 TypeData * lastArray = findLast( a->type );743 TypeData * lastArray = findLast( a->type ); 727 744 if ( type ) { 728 745 switch ( type->kind ) { … … 739 756 lastArray->base = type; 740 757 } // switch 741 type = 0;758 type = nullptr; 742 759 } // if 743 760 delete this; … … 748 765 } 749 766 750 DeclarationNode * DeclarationNode::addParamList( DeclarationNode *params ) {751 TypeData * ftype = new TypeData( TypeData::Function );767 DeclarationNode * DeclarationNode::addParamList( DeclarationNode * params ) { 768 TypeData * ftype = new TypeData( TypeData::Function ); 752 769 ftype->function.params = params; 753 770 setBase( type, ftype ); … … 755 772 } 756 773 757 static TypeData * addIdListToType( TypeData *type, DeclarationNode *ids ) {774 static TypeData * addIdListToType( TypeData * type, DeclarationNode * ids ) { 758 775 if ( type ) { 759 776 if ( type->kind != TypeData::Function ) { … … 764 781 return type; 765 782 } else { 766 TypeData * newtype = new TypeData( TypeData::Function );783 TypeData * newtype = new TypeData( TypeData::Function ); 767 784 newtype->function.idList = ids; 768 785 return newtype; 769 786 } // if 770 } 771 772 DeclarationNode * DeclarationNode::addIdList( DeclarationNode *ids ) {787 } // addIdListToType 788 789 DeclarationNode * DeclarationNode::addIdList( DeclarationNode * ids ) { 773 790 type = addIdListToType( type, ids ); 774 791 return this; 775 792 } 776 793 777 DeclarationNode *DeclarationNode::addInitializer( InitializerNode *init ) { 778 //assert 794 DeclarationNode * DeclarationNode::addInitializer( InitializerNode * init ) { 779 795 initializer = init; 780 796 return this; 781 797 } 782 798 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; 799 DeclarationNode * DeclarationNode::cloneType( string * newName ) { 800 DeclarationNode * newnode = new DeclarationNode; 842 801 newnode->type = maybeClone( type ); 843 802 assert( storageClass == NoStorageClass ); 844 803 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; 804 assert( newName ); 805 newnode->name = newName; 806 return newnode; 807 } 808 809 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) { 810 if ( ! o ) return nullptr; 811 812 o->copyStorageClasses( this ); 813 if ( type ) { 814 TypeData * srcType = type; 815 816 while ( srcType->base ) { 817 srcType = srcType->base; 818 } // while 819 820 TypeData * newType = srcType->clone(); 821 if ( newType->kind == TypeData::AggregateInst ) { 822 // don't duplicate members 823 if ( newType->aggInst.aggregate->kind == TypeData::Enum ) { 824 delete newType->aggInst.aggregate->enumeration.constants; 825 newType->aggInst.aggregate->enumeration.constants = nullptr; 857 826 } else { 858 addTypeToType( newType, o->type ); 859 delete newType; 827 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 828 delete newType->aggInst.aggregate->aggregate.fields; 829 newType->aggInst.aggregate->aggregate.fields = nullptr; 860 830 } // if 861 831 } // if 862 } // if 863 delete o; 832 833 newType->forall = maybeClone( type->forall ); 834 if ( ! o->type ) { 835 o->type = newType; 836 } else { 837 addTypeToType( newType, o->type ); 838 delete newType; 839 } // if 840 } // if 864 841 return o; 865 842 } 866 843 867 DeclarationNode * DeclarationNode::extractAggregate() const {844 DeclarationNode * DeclarationNode::extractAggregate() const { 868 845 if ( type ) { 869 TypeData * ret = typeextractAggregate( type );846 TypeData * ret = typeextractAggregate( type ); 870 847 if ( ret ) { 871 DeclarationNode * newnode = new DeclarationNode;848 DeclarationNode * newnode = new DeclarationNode; 872 849 newnode->type = ret; 873 850 return newnode; 874 851 } // if 875 852 } // if 876 return 0;877 } 878 879 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) {853 return nullptr; 854 } 855 856 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) { 880 857 SemanticError errors; 881 858 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); 882 const DeclarationNode *cur = firstNode; 859 const DeclarationNode * cur = firstNode; 860 883 861 while ( cur ) { 884 862 try { 885 if ( DeclarationNode * extr = cur->extractAggregate() ) {863 if ( DeclarationNode * extr = cur->extractAggregate() ) { 886 864 // handle the case where a structure declaration is contained within an object or type declaration 887 Declaration * decl = extr->build();865 Declaration * decl = extr->build(); 888 866 if ( decl ) { 889 * out++ = decl;867 * out++ = decl; 890 868 } // if 891 869 delete extr; 892 870 } // if 893 Declaration *decl = cur->build(); 871 872 Declaration * decl = cur->build(); 894 873 if ( decl ) { 895 * out++ = decl;874 * out++ = decl; 896 875 } // if 897 876 } catch( SemanticError &e ) { … … 900 879 cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); 901 880 } // while 881 902 882 if ( ! errors.isEmpty() ) { 903 883 throw errors; 904 884 } // if 905 } 906 907 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) {885 } // buildList 886 887 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) { 908 888 SemanticError errors; 909 889 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); 910 const DeclarationNode * cur = firstNode;890 const DeclarationNode * cur = firstNode; 911 891 while ( cur ) { 912 892 try { 913 Declaration * decl = cur->build();893 Declaration * decl = cur->build(); 914 894 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);895 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) { 896 * out++ = dwt; 897 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 898 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 899 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 920 900 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);901 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 902 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 903 * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 924 904 } // if 925 905 } // if … … 932 912 throw errors; 933 913 } // if 934 } 935 936 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) {914 } // buildList 915 916 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) { 937 917 SemanticError errors; 938 918 std::back_insert_iterator< std::list< Type * > > out( outputList ); 939 const DeclarationNode *cur = firstNode; 919 const DeclarationNode * cur = firstNode; 920 940 921 while ( cur ) { 941 922 try { 942 * out++ = cur->buildType();923 * out++ = cur->buildType(); 943 924 } catch( SemanticError &e ) { 944 925 errors.append( e ); … … 946 927 cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); 947 928 } // while 929 948 930 if ( ! errors.isEmpty() ) { 949 931 throw errors; 950 932 } // if 951 } 952 953 Declaration * DeclarationNode::build() const {933 } // buildTypeList 934 935 Declaration * DeclarationNode::build() const { 954 936 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this ); 937 938 // if ( variable.name ) { 939 if ( variable.tyClass != NoTypeClass ) { 940 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 941 // TypeDecl * ret = new TypeDecl( *variable.name, DeclarationNode::NoStorageClass, nullptr, kindMap[ variable.tyClass ] ); 942 TypeDecl * ret = new TypeDecl( *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; 961 } else { 962 return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 963 } // if 964 } // if 948 return buildDecl( type, name ? *name : string( "" ), storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 949 } // if 950 965 951 if ( ! isInline && ! isNoreturn ) { 966 return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension ); 967 } // if 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 968 956 throw SemanticError( "invalid function specifier ", this ); 969 957 } 970 958 971 Type * DeclarationNode::buildType() const {959 Type * DeclarationNode::buildType() const { 972 960 assert( type ); 961 962 if ( attr.expr ) { 963 // return new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() ); 964 return new AttrType( buildQualifiers( type ), *name, attr.expr->build() ); 965 } else if ( attr.type ) { 966 // return new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() ); 967 return new AttrType( buildQualifiers( type ), *name, attr.type->buildType() ); 968 } // if 973 969 974 970 switch ( type->kind ) { 975 971 case TypeData::Enum: 976 return new EnumInstType( buildQualifiers( type ), type->enumeration.name );972 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 977 973 case TypeData::Aggregate: { 978 ReferenceToType * ret;974 ReferenceToType * ret; 979 975 switch ( type->aggregate.kind ) { 980 976 case DeclarationNode::Struct: 981 ret = new StructInstType( buildQualifiers( type ), type->aggregate.name );977 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 982 978 break; 983 979 case DeclarationNode::Union: 984 ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name );980 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 985 981 break; 986 982 case DeclarationNode::Trait: 987 ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name );983 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 988 984 break; 989 985 default: … … 994 990 } 995 991 case TypeData::Symbolic: { 996 TypeInstType * ret = new TypeInstType( buildQualifiers( type ),type->symbolic.name, false );992 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false ); 997 993 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 994 return ret; 1011 995 }
Note:
See TracChangeset
for help on using the changeset viewer.