Changeset 8f6f47d7
- Timestamp:
- Aug 29, 2016, 5:39:26 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
- 28307be
- Parents:
- b542bfb
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rb542bfb r8f6f47d7 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 22:12:44201613 // Update Count : 27812 // Last Modified On : Mon Aug 29 15:55:12 2016 13 // Update Count : 311 14 14 // 15 15 … … 129 129 130 130 newnode->type = new TypeData( TypeData::Function ); 131 newnode->type->function ->params = param;132 newnode->type->function ->newStyle = newStyle;133 newnode->type->function ->body = body;131 newnode->type->function.params = param; 132 newnode->type->function.newStyle = newStyle; 133 newnode->type->function.body = body; 134 134 typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID ); 135 135 136 136 if ( body ) { 137 newnode->type->function ->hasBody = true;137 newnode->type->function.hasBody = true; 138 138 } // if 139 139 … … 175 175 DeclarationNode *newnode = new DeclarationNode; 176 176 newnode->type = new TypeData( TypeData::Basic ); 177 newnode->type->basic ->typeSpec.push_back( bt );177 newnode->type->basic.typeSpec.push_back( bt ); 178 178 return newnode; 179 179 } // DeclarationNode::newBasicType … … 182 182 DeclarationNode *newnode = new DeclarationNode; 183 183 newnode->type = new TypeData( TypeData::Basic ); 184 newnode->type->basic ->modifiers.push_back( mod );184 newnode->type->basic.modifiers.push_back( mod ); 185 185 return newnode; 186 186 } // DeclarationNode::newModifier 187 187 188 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {189 DeclarationNode *newnode = new DeclarationNode;190 newnode->type = new TypeData( TypeData::Builtin );191 newnode->type->builtin->type = bt;192 return newnode;193 } // DeclarationNode::newBuiltinType194 195 188 DeclarationNode * DeclarationNode::newFromTypedef( std::string *name ) { 196 189 DeclarationNode *newnode = new DeclarationNode; 197 190 newnode->type = new TypeData( TypeData::SymbolicInst ); 198 newnode->type->symbolic ->name = assign_strptr( name );199 newnode->type->symbolic ->isTypedef = true;200 newnode->type->symbolic ->params = 0;191 newnode->type->symbolic.name = assign_strptr( name ); 192 newnode->type->symbolic.isTypedef = true; 193 newnode->type->symbolic.params = 0; 201 194 return newnode; 202 195 } // DeclarationNode::newFromTypedef … … 205 198 DeclarationNode *newnode = new DeclarationNode; 206 199 newnode->type = new TypeData( TypeData::Aggregate ); 207 newnode->type->aggregate ->kind = kind;208 newnode->type->aggregate ->name = assign_strptr( name );209 if ( newnode->type->aggregate ->name == "" ) { // anonymous aggregate ?210 newnode->type->aggregate ->name = anonymous.newName();211 } // if 212 newnode->type->aggregate ->actuals = actuals;213 newnode->type->aggregate ->fields = fields;214 newnode->type->aggregate ->body = body;200 newnode->type->aggregate.kind = kind; 201 newnode->type->aggregate.name = assign_strptr( name ); 202 if ( newnode->type->aggregate.name == "" ) { // anonymous aggregate ? 203 newnode->type->aggregate.name = anonymous.newName(); 204 } // if 205 newnode->type->aggregate.actuals = actuals; 206 newnode->type->aggregate.fields = fields; 207 newnode->type->aggregate.body = body; 215 208 return newnode; 216 209 } // DeclarationNode::newAggregate … … 220 213 newnode->name = assign_strptr( name ); 221 214 newnode->type = new TypeData( TypeData::Enum ); 222 newnode->type->enumeration ->name = newnode->name;223 if ( newnode->type->enumeration ->name == "" ) { // anonymous enumeration ?224 newnode->type->enumeration ->name = DeclarationNode::anonymous.newName();225 } // if 226 newnode->type->enumeration ->constants = constants;215 newnode->type->enumeration.name = newnode->name; 216 if ( newnode->type->enumeration.name == "" ) { // anonymous enumeration ? 217 newnode->type->enumeration.name = DeclarationNode::anonymous.newName(); 218 } // if 219 newnode->type->enumeration.constants = constants; 227 220 return newnode; 228 221 } // DeclarationNode::newEnum … … 245 238 DeclarationNode *newnode = new DeclarationNode; 246 239 newnode->type = new TypeData( TypeData::SymbolicInst ); 247 newnode->type->symbolic ->name = assign_strptr( name );248 newnode->type->symbolic ->isTypedef = false;249 newnode->type->symbolic ->actuals = params;240 newnode->type->symbolic.name = assign_strptr( name ); 241 newnode->type->symbolic.isTypedef = false; 242 newnode->type->symbolic.actuals = params; 250 243 return newnode; 251 244 } // DeclarationNode::newFromTypeGen … … 255 248 newnode->name = assign_strptr( name ); 256 249 newnode->type = new TypeData( TypeData::Variable ); 257 newnode->type->variable ->tyClass = tc;258 newnode->type->variable ->name = newnode->name;250 newnode->type->variable.tyClass = tc; 251 newnode->type->variable.name = newnode->name; 259 252 return newnode; 260 253 } // DeclarationNode::newTypeParam … … 263 256 DeclarationNode *newnode = new DeclarationNode; 264 257 newnode->type = new TypeData( TypeData::Aggregate ); 265 newnode->type->aggregate ->kind = Trait;266 newnode->type->aggregate ->params = params;267 newnode->type->aggregate ->fields = asserts;268 newnode->type->aggregate ->name = assign_strptr( name );258 newnode->type->aggregate.kind = Trait; 259 newnode->type->aggregate.params = params; 260 newnode->type->aggregate.fields = asserts; 261 newnode->type->aggregate.name = assign_strptr( name ); 269 262 return newnode; 270 263 } // DeclarationNode::newTrait … … 273 266 DeclarationNode *newnode = new DeclarationNode; 274 267 newnode->type = new TypeData( TypeData::AggregateInst ); 275 newnode->type->aggInst ->aggregate = new TypeData( TypeData::Aggregate );276 newnode->type->aggInst ->aggregate->aggregate->kind = Trait;277 newnode->type->aggInst ->aggregate->aggregate->name = assign_strptr( name );278 newnode->type->aggInst ->params = params;268 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 269 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 270 newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name ); 271 newnode->type->aggInst.params = params; 279 272 return newnode; 280 273 } // DeclarationNode::newTraitUse … … 284 277 newnode->name = assign_strptr( name ); 285 278 newnode->type = new TypeData( TypeData::Symbolic ); 286 newnode->type->symbolic ->isTypedef = false;287 newnode->type->symbolic ->params = typeParams;288 newnode->type->symbolic ->name = newnode->name;279 newnode->type->symbolic.isTypedef = false; 280 newnode->type->symbolic.params = typeParams; 281 newnode->type->symbolic.name = newnode->name; 289 282 return newnode; 290 283 } // DeclarationNode::newTypeDecl … … 299 292 DeclarationNode *newnode = new DeclarationNode; 300 293 newnode->type = new TypeData( TypeData::Array ); 301 newnode->type->array ->dimension = size;302 newnode->type->array ->isStatic = isStatic;303 if ( newnode->type->array ->dimension == 0 || newnode->type->array->dimension->isExpressionType<ConstantExpr *>() ) {304 newnode->type->array ->isVarLen = false;294 newnode->type->array.dimension = size; 295 newnode->type->array.isStatic = isStatic; 296 if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) { 297 newnode->type->array.isVarLen = false; 305 298 } else { 306 newnode->type->array ->isVarLen = true;299 newnode->type->array.isVarLen = true; 307 300 } // if 308 301 return newnode->addQualifiers( qualifiers ); … … 312 305 DeclarationNode *newnode = new DeclarationNode; 313 306 newnode->type = new TypeData( TypeData::Array ); 314 newnode->type->array ->dimension = 0;315 newnode->type->array ->isStatic = false;316 newnode->type->array ->isVarLen = true;307 newnode->type->array.dimension = 0; 308 newnode->type->array.isStatic = false; 309 newnode->type->array.isVarLen = true; 317 310 return newnode->addQualifiers( qualifiers ); 318 311 } … … 327 320 DeclarationNode *newnode = new DeclarationNode; 328 321 newnode->type = new TypeData( TypeData::Tuple ); 329 newnode->type->tuple ->members= members;322 newnode->type->tuple = members; 330 323 return newnode; 331 324 } … … 334 327 DeclarationNode *newnode = new DeclarationNode; 335 328 newnode->type = new TypeData( TypeData::Typeof ); 336 newnode->type->typeexpr->expr = expr; 337 return newnode; 338 } 329 newnode->type->typeexpr = expr; 330 return newnode; 331 } 332 333 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) { 334 DeclarationNode *newnode = new DeclarationNode; 335 newnode->type = new TypeData( TypeData::Builtin ); 336 newnode->builtin = bt; 337 return newnode; 338 } // DeclarationNode::newBuiltinType 339 339 340 340 DeclarationNode *DeclarationNode::newAttr( std::string *name, ExpressionNode *expr ) { 341 341 DeclarationNode *newnode = new DeclarationNode; 342 342 newnode->type = new TypeData( TypeData::Attr ); 343 newnode->type->attr ->name = assign_strptr( name );344 newnode->type->attr ->expr = expr;343 newnode->type->attr.name = assign_strptr( name ); 344 newnode->type->attr.expr = expr; 345 345 return newnode; 346 346 } … … 349 349 DeclarationNode *newnode = new DeclarationNode; 350 350 newnode->type = new TypeData( TypeData::Attr ); 351 newnode->type->attr ->name = assign_strptr( name );352 newnode->type->attr ->type = type;351 newnode->type->attr.name = assign_strptr( name ); 352 newnode->type->attr.type = type; 353 353 return newnode; 354 354 } … … 407 407 } else { 408 408 if ( type->kind == TypeData::Aggregate ) { 409 type->aggregate ->params = q->type->forall;409 type->aggregate.params = q->type->forall; 410 410 // change implicit typedef from TYPEDEFname to TYPEGENname 411 typedefTable.changeKind( type->aggregate ->name, TypedefTable::TG );411 typedefTable.changeKind( type->aggregate.name, TypedefTable::TG ); 412 412 } else { 413 413 type->forall = q->type->forall; … … 457 457 if ( src->kind != TypeData::Unknown ) { 458 458 assert( src->kind == TypeData::Basic ); 459 dst->basic ->modifiers.splice( dst->basic->modifiers.end(), src->basic->modifiers );460 dst->basic ->typeSpec.splice( dst->basic->typeSpec.end(), src->basic->typeSpec );459 dst->basic.modifiers.splice( dst->basic.modifiers.end(), src->basic.modifiers ); 460 dst->basic.typeSpec.splice( dst->basic.typeSpec.end(), src->basic.typeSpec ); 461 461 } // if 462 462 break; … … 466 466 case TypeData::Enum: 467 467 dst->base = new TypeData( TypeData::AggregateInst ); 468 dst->base->aggInst ->aggregate = src;468 dst->base->aggInst.aggregate = src; 469 469 if ( src->kind == TypeData::Aggregate ) { 470 dst->base->aggInst ->params = maybeClone( src->aggregate->actuals );470 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 471 471 } // if 472 472 dst->base->qualifiers |= src->qualifiers; … … 495 495 if ( o->type->kind == TypeData::Aggregate || o->type->kind == TypeData::Enum ) { 496 496 type = new TypeData( TypeData::AggregateInst ); 497 type->aggInst ->aggregate = o->type;497 type->aggInst.aggregate = o->type; 498 498 if ( o->type->kind == TypeData::Aggregate ) { 499 type->aggInst ->params = maybeClone( o->type->aggregate->actuals );499 type->aggInst.params = maybeClone( o->type->aggregate.actuals ); 500 500 } // if 501 501 type->qualifiers |= o->type->qualifiers; … … 523 523 DeclarationNode *DeclarationNode::addTypedef() { 524 524 TypeData *newtype = new TypeData( TypeData::Symbolic ); 525 newtype->symbolic ->params = 0;526 newtype->symbolic ->isTypedef = true;527 newtype->symbolic ->name = name;525 newtype->symbolic.params = 0; 526 newtype->symbolic.isTypedef = true; 527 newtype->symbolic.name = name; 528 528 newtype->base = type; 529 529 type = newtype; … … 535 535 switch ( type->kind ) { 536 536 case TypeData::Symbolic: 537 if ( type->symbolic ->assertions ) {538 type->symbolic ->assertions->appendList( assertions );537 if ( type->symbolic.assertions ) { 538 type->symbolic.assertions->appendList( assertions ); 539 539 } else { 540 type->symbolic ->assertions = assertions;540 type->symbolic.assertions = assertions; 541 541 } // if 542 542 break; 543 543 case TypeData::Variable: 544 if ( type->variable ->assertions ) {545 type->variable ->assertions->appendList( assertions );544 if ( type->variable.assertions ) { 545 type->variable.assertions->appendList( assertions ); 546 546 } else { 547 type->variable ->assertions = assertions;547 type->variable.assertions = assertions; 548 548 } // if 549 549 break; … … 574 574 assert( type ); 575 575 assert( type->kind == TypeData::Function ); 576 assert( type->function ->body == 0 );577 type->function ->body = body;578 type->function ->hasBody = true;576 assert( type->function.body == 0 ); 577 type->function.body = body; 578 type->function.hasBody = true; 579 579 return this; 580 580 } … … 583 583 assert( type ); 584 584 assert( type->kind == TypeData::Function ); 585 assert( type->function ->oldDeclList == 0 );586 type->function ->oldDeclList = list;585 assert( type->function.oldDeclList == 0 ); 586 type->function.oldDeclList = list; 587 587 return this; 588 588 } … … 630 630 case TypeData::Enum: 631 631 p->type->base = new TypeData( TypeData::AggregateInst ); 632 p->type->base->aggInst ->aggregate = type;632 p->type->base->aggInst.aggregate = type; 633 633 if ( type->kind == TypeData::Aggregate ) { 634 p->type->base->aggInst ->params = maybeClone( type->aggregate->actuals );634 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 635 635 } // if 636 636 p->type->base->qualifiers |= type->qualifiers; … … 667 667 case TypeData::Enum: 668 668 lastArray->base = new TypeData( TypeData::AggregateInst ); 669 lastArray->base->aggInst ->aggregate = type;669 lastArray->base->aggInst.aggregate = type; 670 670 if ( type->kind == TypeData::Aggregate ) { 671 lastArray->base->aggInst ->params = maybeClone( type->aggregate->actuals );671 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 672 672 } // if 673 673 lastArray->base->qualifiers |= type->qualifiers; … … 687 687 DeclarationNode *DeclarationNode::addParamList( DeclarationNode *params ) { 688 688 TypeData *ftype = new TypeData( TypeData::Function ); 689 ftype->function ->params = params;689 ftype->function.params = params; 690 690 setBase( type, ftype ); 691 691 return this; … … 697 697 type->base = addIdListToType( type->base, ids ); 698 698 } else { 699 type->function ->idList = ids;699 type->function.idList = ids; 700 700 } // if 701 701 return type; 702 702 } else { 703 703 TypeData *newtype = new TypeData( TypeData::Function ); 704 newtype->function ->idList = ids;704 newtype->function.idList = ids; 705 705 return newtype; 706 706 } // if … … 727 727 if ( newnode->type->kind == TypeData::AggregateInst ) { 728 728 // don't duplicate members 729 if ( newnode->type->aggInst ->aggregate->kind == TypeData::Enum ) {730 delete newnode->type->aggInst ->aggregate->enumeration->constants;731 newnode->type->aggInst ->aggregate->enumeration->constants = 0;729 if ( newnode->type->aggInst.aggregate->kind == TypeData::Enum ) { 730 delete newnode->type->aggInst.aggregate->enumeration.constants; 731 newnode->type->aggInst.aggregate->enumeration.constants = 0; 732 732 } else { 733 assert( newnode->type->aggInst ->aggregate->kind == TypeData::Aggregate );734 delete newnode->type->aggInst ->aggregate->aggregate->fields;735 newnode->type->aggInst ->aggregate->aggregate->fields = 0;733 assert( newnode->type->aggInst.aggregate->kind == TypeData::Aggregate ); 734 delete newnode->type->aggInst.aggregate->aggregate.fields; 735 newnode->type->aggInst.aggregate->aggregate.fields = 0; 736 736 } // if 737 737 } // if … … 753 753 if ( newType->kind == TypeData::AggregateInst ) { 754 754 // don't duplicate members 755 if ( newType->aggInst ->aggregate->kind == TypeData::Enum ) {756 delete newType->aggInst ->aggregate->enumeration->constants;757 newType->aggInst ->aggregate->enumeration->constants = 0;755 if ( newType->aggInst.aggregate->kind == TypeData::Enum ) { 756 delete newType->aggInst.aggregate->enumeration.constants; 757 newType->aggInst.aggregate->enumeration.constants = 0; 758 758 } else { 759 assert( newType->aggInst ->aggregate->kind == TypeData::Aggregate );760 delete newType->aggInst ->aggregate->aggregate->fields;761 newType->aggInst ->aggregate->aggregate->fields = 0;759 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 760 delete newType->aggInst.aggregate->aggregate.fields; 761 newType->aggInst.aggregate->aggregate.fields = 0; 762 762 } // if 763 763 } // if … … 909 909 switch ( type->kind ) { 910 910 case TypeData::Enum: 911 return new EnumInstType( buildQualifiers( type ), type->enumeration ->name );911 return new EnumInstType( buildQualifiers( type ), type->enumeration.name ); 912 912 case TypeData::Aggregate: { 913 913 ReferenceToType *ret; 914 switch ( type->aggregate ->kind ) {914 switch ( type->aggregate.kind ) { 915 915 case DeclarationNode::Struct: 916 ret = new StructInstType( buildQualifiers( type ), type->aggregate ->name );916 ret = new StructInstType( buildQualifiers( type ), type->aggregate.name ); 917 917 break; 918 918 case DeclarationNode::Union: 919 ret = new UnionInstType( buildQualifiers( type ), type->aggregate ->name );919 ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name ); 920 920 break; 921 921 case DeclarationNode::Trait: 922 ret = new TraitInstType( buildQualifiers( type ), type->aggregate ->name );922 ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name ); 923 923 break; 924 924 default: 925 925 assert( false ); 926 926 } // switch 927 buildList( type->aggregate ->actuals, ret->get_parameters() );927 buildList( type->aggregate.actuals, ret->get_parameters() ); 928 928 return ret; 929 929 } 930 930 case TypeData::Symbolic: { 931 TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic ->name, false );932 buildList( type->symbolic ->actuals, ret->get_parameters() );931 TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic.name, false ); 932 buildList( type->symbolic.actuals, ret->get_parameters() ); 933 933 return ret; 934 934 } -
src/Parser/ParseNode.h
rb542bfb r8f6f47d7 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 21:14:51 201613 // Update Count : 57 512 // Last Modified On : Mon Aug 29 10:19:01 2016 13 // Update Count : 579 14 14 // 15 15 … … 290 290 // bool buildFuncSpecifier( StorageClass key ) const; 291 291 292 BuiltinType builtin; 293 292 294 TypeData *type; 293 295 std::string name; -
src/Parser/TypeData.cc
rb542bfb r8f6f47d7 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 18:28:58201613 // Update Count : 2 2312 // Last Modified On : Mon Aug 29 15:54:55 2016 13 // Update Count : 266 14 14 // 15 15 … … 33 33 break; 34 34 case Basic: 35 basic = new Basic_t;35 // basic = new Basic_t; 36 36 break; 37 37 case Array: 38 array = new Array_t;39 array ->dimension = 0;40 array ->isVarLen = false;41 array ->isStatic = false;38 // array = new Array_t; 39 array.dimension = 0; 40 array.isVarLen = false; 41 array.isStatic = false; 42 42 break; 43 43 case Function: 44 function = new Function_t;45 function ->params = 0;46 function ->idList = 0;47 function ->oldDeclList = 0;48 function ->body = 0;49 function ->hasBody = false;50 function ->newStyle = false;44 // function = new Function_t; 45 function.params = 0; 46 function.idList = 0; 47 function.oldDeclList = 0; 48 function.body = 0; 49 function.hasBody = false; 50 function.newStyle = false; 51 51 break; 52 52 case Aggregate: 53 aggregate = new Aggregate_t;54 aggregate ->params = 0;55 aggregate ->actuals = 0;56 aggregate ->fields = 0;53 // aggregate = new Aggregate_t; 54 aggregate.params = 0; 55 aggregate.actuals = 0; 56 aggregate.fields = 0; 57 57 break; 58 58 case AggregateInst: 59 aggInst = new AggInst_t;60 aggInst ->aggregate = 0;61 aggInst ->params = 0;59 // aggInst = new AggInst_t; 60 aggInst.aggregate = 0; 61 aggInst.params = 0; 62 62 break; 63 63 case Enum: 64 enumeration = new Enumeration_t;65 enumeration ->constants = 0;64 // enumeration = new Enumeration_t; 65 enumeration.constants = 0; 66 66 break; 67 67 case Symbolic: 68 68 case SymbolicInst: 69 symbolic = new Symbolic_t;70 symbolic ->params = 0;71 symbolic ->actuals = 0;72 symbolic ->assertions = 0;69 // symbolic = new Symbolic_t; 70 symbolic.params = 0; 71 symbolic.actuals = 0; 72 symbolic.assertions = 0; 73 73 break; 74 74 case Variable: 75 variable = new Variable_t;76 variable ->tyClass = DeclarationNode::Type;77 variable ->assertions = 0;75 // variable = new Variable_t; 76 variable.tyClass = DeclarationNode::Type; 77 variable.assertions = 0; 78 78 break; 79 79 case Tuple: 80 tuple = new Tuple_t;81 tuple ->members = 0;80 // tuple = new Tuple_t; 81 tuple = nullptr; 82 82 break; 83 83 case Typeof: 84 typeexpr = new Typeof_t;85 typeexpr ->expr = 0;84 // typeexpr = new Typeof_t; 85 typeexpr = nullptr; 86 86 break; 87 87 case Builtin: 88 builtin = new Builtin_t;88 // builtin = new Builtin_t; 89 89 break; 90 90 case Attr: 91 attr = new Attr_t;92 attr ->expr = 0;93 attr ->type = 0;91 // attr = new Attr_t; 92 attr.expr = nullptr; 93 attr.type = nullptr; 94 94 break; 95 95 } // switch … … 107 107 break; 108 108 case Basic: 109 delete basic;109 // delete basic; 110 110 break; 111 111 case Array: 112 delete array ->dimension;113 delete array;112 delete array.dimension; 113 // delete array; 114 114 break; 115 115 case Function: 116 delete function ->params;117 delete function ->idList;118 delete function ->oldDeclList;119 delete function ->body;120 delete function;116 delete function.params; 117 delete function.idList; 118 delete function.oldDeclList; 119 delete function.body; 120 // delete function; 121 121 break; 122 122 case Aggregate: 123 delete aggregate ->params;124 delete aggregate ->actuals;125 delete aggregate ->fields;126 delete aggregate;123 delete aggregate.params; 124 delete aggregate.actuals; 125 delete aggregate.fields; 126 // delete aggregate; 127 127 break; 128 128 case AggregateInst: 129 delete aggInst ->aggregate;130 delete aggInst ->params;131 delete aggInst;129 delete aggInst.aggregate; 130 delete aggInst.params; 131 // delete aggInst; 132 132 break; 133 133 case Enum: 134 delete enumeration ->constants;135 delete enumeration;134 delete enumeration.constants; 135 // delete enumeration; 136 136 break; 137 137 case Symbolic: 138 138 case SymbolicInst: 139 delete symbolic ->params;140 delete symbolic ->actuals;141 delete symbolic ->assertions;142 delete symbolic;139 delete symbolic.params; 140 delete symbolic.actuals; 141 delete symbolic.assertions; 142 // delete symbolic; 143 143 break; 144 144 case Variable: 145 delete variable ->assertions;146 delete variable;145 delete variable.assertions; 146 // delete variable; 147 147 break; 148 148 case Tuple: 149 delete tuple->members;149 // delete tuple->members; 150 150 delete tuple; 151 151 break; 152 152 case Typeof: 153 delete typeexpr->expr;153 // delete typeexpr->expr; 154 154 delete typeexpr; 155 155 break; 156 156 case Builtin: 157 delete builtin;157 // delete builtin; 158 158 break; 159 159 case Attr: 160 delete attr ->expr;161 delete attr ->type;162 delete attr;160 delete attr.expr; 161 delete attr.type; 162 // delete attr; 163 163 break; 164 164 } // switch … … 178 178 break; 179 179 case Basic: 180 newtype->basic ->typeSpec = basic->typeSpec;181 newtype->basic ->modifiers = basic->modifiers;180 newtype->basic.typeSpec = basic.typeSpec; 181 newtype->basic.modifiers = basic.modifiers; 182 182 break; 183 183 case Array: 184 newtype->array ->dimension = maybeClone( array->dimension );185 newtype->array ->isVarLen = array->isVarLen;186 newtype->array ->isStatic = array->isStatic;184 newtype->array.dimension = maybeClone( array.dimension ); 185 newtype->array.isVarLen = array.isVarLen; 186 newtype->array.isStatic = array.isStatic; 187 187 break; 188 188 case Function: 189 newtype->function ->params = maybeClone( function->params );190 newtype->function ->idList = maybeClone( function->idList );191 newtype->function ->oldDeclList = maybeClone( function->oldDeclList );192 newtype->function ->body = maybeClone( function->body );193 newtype->function ->hasBody = function->hasBody;194 newtype->function ->newStyle = function->newStyle;189 newtype->function.params = maybeClone( function.params ); 190 newtype->function.idList = maybeClone( function.idList ); 191 newtype->function.oldDeclList = maybeClone( function.oldDeclList ); 192 newtype->function.body = maybeClone( function.body ); 193 newtype->function.hasBody = function.hasBody; 194 newtype->function.newStyle = function.newStyle; 195 195 break; 196 196 case Aggregate: 197 newtype->aggregate ->params = maybeClone( aggregate->params );198 newtype->aggregate ->actuals = maybeClone( aggregate->actuals );199 newtype->aggregate ->fields = maybeClone( aggregate->fields );200 newtype->aggregate ->name = aggregate->name;201 newtype->aggregate ->kind = aggregate->kind;202 newtype->aggregate ->body = aggregate->body;197 newtype->aggregate.params = maybeClone( aggregate.params ); 198 newtype->aggregate.actuals = maybeClone( aggregate.actuals ); 199 newtype->aggregate.fields = maybeClone( aggregate.fields ); 200 newtype->aggregate.name = aggregate.name; 201 newtype->aggregate.kind = aggregate.kind; 202 newtype->aggregate.body = aggregate.body; 203 203 break; 204 204 case AggregateInst: 205 newtype->aggInst ->aggregate = maybeClone( aggInst->aggregate );206 newtype->aggInst ->params = maybeClone( aggInst->params );205 newtype->aggInst.aggregate = maybeClone( aggInst.aggregate ); 206 newtype->aggInst.params = maybeClone( aggInst.params ); 207 207 break; 208 208 case Enum: 209 newtype->enumeration ->name = enumeration->name;210 newtype->enumeration ->constants = maybeClone( enumeration->constants );209 newtype->enumeration.name = enumeration.name; 210 newtype->enumeration.constants = maybeClone( enumeration.constants ); 211 211 break; 212 212 case Symbolic: 213 213 case SymbolicInst: 214 newtype->symbolic ->params = maybeClone( symbolic->params );215 newtype->symbolic ->actuals = maybeClone( symbolic->actuals );216 newtype->symbolic ->assertions = maybeClone( symbolic->assertions );217 newtype->symbolic ->isTypedef = symbolic->isTypedef;218 newtype->symbolic ->name = symbolic->name;214 newtype->symbolic.params = maybeClone( symbolic.params ); 215 newtype->symbolic.actuals = maybeClone( symbolic.actuals ); 216 newtype->symbolic.assertions = maybeClone( symbolic.assertions ); 217 newtype->symbolic.isTypedef = symbolic.isTypedef; 218 newtype->symbolic.name = symbolic.name; 219 219 break; 220 220 case Variable: 221 newtype->variable ->assertions = maybeClone( variable->assertions );222 newtype->variable ->name = variable->name;223 newtype->variable ->tyClass = variable->tyClass;221 newtype->variable.assertions = maybeClone( variable.assertions ); 222 newtype->variable.name = variable.name; 223 newtype->variable.tyClass = variable.tyClass; 224 224 break; 225 225 case Tuple: 226 newtype->tuple ->members = maybeClone( tuple->members);226 newtype->tuple = maybeClone( tuple ); 227 227 break; 228 228 case Typeof: 229 newtype->typeexpr ->expr = maybeClone( typeexpr->expr );229 newtype->typeexpr = maybeClone( typeexpr ); 230 230 break; 231 231 case Builtin: 232 newtype->builtin->type = builtin->type;232 // newtype->builtin = builtin; 233 233 break; 234 234 case Attr: 235 newtype->attr ->expr = maybeClone( attr->expr );236 newtype->attr ->type = maybeClone( attr->type );235 newtype->attr.expr = maybeClone( attr.expr ); 236 newtype->attr.type = maybeClone( attr.type ); 237 237 break; 238 238 } // switch … … 268 268 break; 269 269 case Basic: 270 printEnums( basic ->modifiers.begin(), basic->modifiers.end(), DeclarationNode::modifierName, os );271 printEnums( basic ->typeSpec.begin(), basic->typeSpec.end(), DeclarationNode::basicTypeName, os );270 printEnums( basic.modifiers.begin(), basic.modifiers.end(), DeclarationNode::modifierName, os ); 271 printEnums( basic.typeSpec.begin(), basic.typeSpec.end(), DeclarationNode::basicTypeName, os ); 272 272 break; 273 273 case Array: 274 if ( array ->isStatic ) {274 if ( array.isStatic ) { 275 275 os << "static "; 276 276 } // if 277 if ( array ->dimension ) {277 if ( array.dimension ) { 278 278 os << "array of "; 279 array ->dimension->printOneLine( os, indent );280 } else if ( array ->isVarLen ) {279 array.dimension->printOneLine( os, indent ); 280 } else if ( array.isVarLen ) { 281 281 os << "variable-length array of "; 282 282 } else { … … 289 289 case Function: 290 290 os << "function" << endl; 291 if ( function ->params ) {291 if ( function.params ) { 292 292 os << string( indent + 2, ' ' ) << "with parameters " << endl; 293 function ->params->printList( os, indent + 4 );293 function.params->printList( os, indent + 4 ); 294 294 } else { 295 295 os << string( indent + 2, ' ' ) << "with no parameters " << endl; 296 296 } // if 297 if ( function ->idList ) {297 if ( function.idList ) { 298 298 os << string( indent + 2, ' ' ) << "with old-style identifier list " << endl; 299 function ->idList->printList( os, indent + 4 );300 } // if 301 if ( function ->oldDeclList ) {299 function.idList->printList( os, indent + 4 ); 300 } // if 301 if ( function.oldDeclList ) { 302 302 os << string( indent + 2, ' ' ) << "with old-style declaration list " << endl; 303 function ->oldDeclList->printList( os, indent + 4 );303 function.oldDeclList->printList( os, indent + 4 ); 304 304 } // if 305 305 os << string( indent + 2, ' ' ) << "returning "; … … 310 310 } // if 311 311 os << endl; 312 if ( function ->hasBody ) {312 if ( function.hasBody ) { 313 313 os << string( indent + 2, ' ' ) << "with body " << endl; 314 314 } // if 315 if ( function ->body ) {316 function ->body->printList( os, indent + 2 );315 if ( function.body ) { 316 function.body->printList( os, indent + 2 ); 317 317 } // if 318 318 break; 319 319 case Aggregate: 320 os << DeclarationNode::aggregateName[ aggregate ->kind ] << ' ' << aggregate->name << endl;321 if ( aggregate ->params ) {320 os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << aggregate.name << endl; 321 if ( aggregate.params ) { 322 322 os << string( indent + 2, ' ' ) << "with type parameters " << endl; 323 aggregate ->params->printList( os, indent + 4 );324 } // if 325 if ( aggregate ->actuals ) {323 aggregate.params->printList( os, indent + 4 ); 324 } // if 325 if ( aggregate.actuals ) { 326 326 os << string( indent + 2, ' ' ) << "instantiated with actual parameters " << endl; 327 aggregate ->actuals->printList( os, indent + 4 );328 } // if 329 if ( aggregate ->fields ) {327 aggregate.actuals->printList( os, indent + 4 ); 328 } // if 329 if ( aggregate.fields ) { 330 330 os << string( indent + 2, ' ' ) << "with members " << endl; 331 aggregate ->fields->printList( os, indent + 4 );332 } // if 333 if ( aggregate ->body ) {331 aggregate.fields->printList( os, indent + 4 ); 332 } // if 333 if ( aggregate.body ) { 334 334 os << string( indent + 2, ' ' ) << " with body " << endl; 335 335 } // if 336 336 break; 337 337 case AggregateInst: 338 if ( aggInst ->aggregate ) {338 if ( aggInst.aggregate ) { 339 339 os << "instance of " ; 340 aggInst ->aggregate->print( os, indent );340 aggInst.aggregate->print( os, indent ); 341 341 } else { 342 342 os << "instance of an unspecified aggregate "; 343 343 } // if 344 if ( aggInst ->params ) {344 if ( aggInst.params ) { 345 345 os << string( indent + 2, ' ' ) << "with parameters " << endl; 346 aggInst ->params->printList( os, indent + 2 );346 aggInst.params->printList( os, indent + 2 ); 347 347 } // if 348 348 break; 349 349 case Enum: 350 350 os << "enumeration "; 351 if ( enumeration ->constants ) {351 if ( enumeration.constants ) { 352 352 os << "with constants" << endl; 353 enumeration ->constants->printList( os, indent + 2 );353 enumeration.constants->printList( os, indent + 2 ); 354 354 } // if 355 355 break; 356 356 case SymbolicInst: 357 os << "instance of type " << symbolic ->name;358 if ( symbolic ->actuals ) {357 os << "instance of type " << symbolic.name; 358 if ( symbolic.actuals ) { 359 359 os << " with parameters" << endl; 360 symbolic ->actuals->printList( os, indent + 2 );360 symbolic.actuals->printList( os, indent + 2 ); 361 361 } // if 362 362 break; 363 363 case Symbolic: 364 if ( symbolic ->isTypedef ) {364 if ( symbolic.isTypedef ) { 365 365 os << "typedef definition "; 366 366 } else { 367 367 os << "type definition "; 368 368 } // if 369 if ( symbolic ->params ) {369 if ( symbolic.params ) { 370 370 os << endl << string( indent + 2, ' ' ) << "with parameters" << endl; 371 symbolic ->params->printList( os, indent + 2 );372 } // if 373 if ( symbolic ->assertions ) {371 symbolic.params->printList( os, indent + 2 ); 372 } // if 373 if ( symbolic.assertions ) { 374 374 os << endl << string( indent + 2, ' ' ) << "with assertions" << endl; 375 symbolic ->assertions->printList( os, indent + 4 );375 symbolic.assertions->printList( os, indent + 4 ); 376 376 os << string( indent + 2, ' ' ); 377 377 } // if … … 382 382 break; 383 383 case Variable: 384 os << DeclarationNode::typeClassName[ variable ->tyClass ] << " variable ";385 if ( variable ->assertions ) {384 os << DeclarationNode::typeClassName[ variable.tyClass ] << " variable "; 385 if ( variable.assertions ) { 386 386 os << endl << string( indent + 2, ' ' ) << "with assertions" << endl; 387 variable ->assertions->printList( os, indent + 4 );387 variable.assertions->printList( os, indent + 4 ); 388 388 os << string( indent + 2, ' ' ); 389 389 } // if … … 391 391 case Tuple: 392 392 os << "tuple "; 393 if ( tuple ->members) {393 if ( tuple ) { 394 394 os << "with members " << endl; 395 tuple-> members->printList( os, indent + 2 );395 tuple->printList( os, indent + 2 ); 396 396 } // if 397 397 break; 398 398 case Typeof: 399 399 os << "type-of expression "; 400 if ( typeexpr ->expr) {401 typeexpr-> expr->print( os, indent + 2 );400 if ( typeexpr ) { 401 typeexpr->print( os, indent + 2 ); 402 402 } // if 403 403 break; 404 404 case Attr: 405 os << "attribute type decl " << attr ->name << " applied to ";406 if ( attr ->expr ) {407 attr ->expr->print( os, indent + 2 );408 } // if 409 if ( attr ->type ) {410 attr ->type->print( os, indent + 2 );405 os << "attribute type decl " << attr.name << " applied to "; 406 if ( attr.expr ) { 407 attr.expr->print( os, indent + 2 ); 408 } // if 409 if ( attr.type ) { 410 attr.type->print( os, indent + 2 ); 411 411 } // if 412 412 break; … … 494 494 switch ( td->kind ) { 495 495 case TypeData::Aggregate: 496 if ( ! toplevel && td->aggregate ->fields ) {496 if ( ! toplevel && td->aggregate.fields ) { 497 497 ret = td->clone(); 498 498 } // if 499 499 break; 500 500 case TypeData::Enum: 501 if ( ! toplevel && td->enumeration ->constants ) {501 if ( ! toplevel && td->enumeration.constants ) { 502 502 ret = td->clone(); 503 503 } // if 504 504 break; 505 505 case TypeData::AggregateInst: 506 if ( td->aggInst ->aggregate ) {507 ret = typeextractAggregate( td->aggInst ->aggregate, false );506 if ( td->aggInst.aggregate ) { 507 ret = typeextractAggregate( td->aggInst.aggregate, false ); 508 508 } // if 509 509 break; … … 535 535 BasicType::Kind ret; 536 536 537 for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic ->typeSpec.begin(); i != td->basic->typeSpec.end(); ++i ) {537 for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic.typeSpec.begin(); i != td->basic.typeSpec.end(); ++i ) { 538 538 if ( ! init ) { 539 539 init = true; 540 540 if ( *i == DeclarationNode::Void ) { 541 if ( td->basic ->typeSpec.size() != 1 || ! td->basic->modifiers.empty() ) {541 if ( td->basic.typeSpec.size() != 1 || ! td->basic.modifiers.empty() ) { 542 542 throw SemanticError( "invalid type specifier \"void\" in type: ", td ); 543 543 } else { … … 611 611 } // for 612 612 613 for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic ->modifiers.begin(); i != td->basic->modifiers.end(); ++i ) {613 for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic.modifiers.begin(); i != td->basic.modifiers.end(); ++i ) { 614 614 switch ( *i ) { 615 615 case DeclarationNode::Long: … … 746 746 ArrayType * at; 747 747 if ( td->base ) { 748 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild< Expression >( td->array ->dimension ),749 td->array ->isVarLen, td->array->isStatic );748 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild< Expression >( td->array.dimension ), 749 td->array.isVarLen, td->array.isStatic ); 750 750 } else { 751 751 at = new ArrayType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 752 maybeBuild< Expression >( td->array ->dimension ), td->array->isVarLen, td->array->isStatic );752 maybeBuild< Expression >( td->array.dimension ), td->array.isVarLen, td->array.isStatic ); 753 753 } // if 754 754 buildForall( td->forall, at->get_forall() ); … … 759 759 assert( td->kind == TypeData::Aggregate ); 760 760 AggregateDecl * at; 761 switch ( td->aggregate ->kind ) {761 switch ( td->aggregate.kind ) { 762 762 case DeclarationNode::Struct: 763 at = new StructDecl( td->aggregate ->name );764 buildForall( td->aggregate ->params, at->get_parameters() );763 at = new StructDecl( td->aggregate.name ); 764 buildForall( td->aggregate.params, at->get_parameters() ); 765 765 break; 766 766 case DeclarationNode::Union: 767 at = new UnionDecl( td->aggregate ->name );768 buildForall( td->aggregate ->params, at->get_parameters() );767 at = new UnionDecl( td->aggregate.name ); 768 buildForall( td->aggregate.params, at->get_parameters() ); 769 769 break; 770 770 case DeclarationNode::Trait: 771 at = new TraitDecl( td->aggregate ->name );772 buildList( td->aggregate ->params, at->get_parameters() );771 at = new TraitDecl( td->aggregate.name ); 772 buildList( td->aggregate.params, at->get_parameters() ); 773 773 break; 774 774 default: … … 776 776 } // switch 777 777 778 buildList( td->aggregate ->fields, at->get_members() );779 at->set_body( td->aggregate ->body );778 buildList( td->aggregate.fields, at->get_members() ); 779 at->set_body( td->aggregate.body ); 780 780 781 781 return at; … … 786 786 787 787 ReferenceToType * ret; 788 if ( td->aggInst ->aggregate->kind == TypeData::Enum ) {789 ret = new EnumInstType( buildQualifiers( td ), td->aggInst ->aggregate->enumeration->name );788 if ( td->aggInst.aggregate->kind == TypeData::Enum ) { 789 ret = new EnumInstType( buildQualifiers( td ), td->aggInst.aggregate->enumeration.name ); 790 790 } else { 791 assert( td->aggInst ->aggregate->kind == TypeData::Aggregate );792 switch ( td->aggInst ->aggregate->aggregate->kind ) {791 assert( td->aggInst.aggregate->kind == TypeData::Aggregate ); 792 switch ( td->aggInst.aggregate->aggregate.kind ) { 793 793 case DeclarationNode::Struct: 794 ret = new StructInstType( buildQualifiers( td ), td->aggInst ->aggregate->aggregate->name );794 ret = new StructInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name ); 795 795 break; 796 796 case DeclarationNode::Union: 797 ret = new UnionInstType( buildQualifiers( td ), td->aggInst ->aggregate->aggregate->name );797 ret = new UnionInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name ); 798 798 break; 799 799 case DeclarationNode::Trait: 800 ret = new TraitInstType( buildQualifiers( td ), td->aggInst ->aggregate->aggregate->name );800 ret = new TraitInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name ); 801 801 break; 802 802 default: … … 804 804 } // switch 805 805 } // if 806 buildList( td->aggInst ->params, ret->get_parameters() );806 buildList( td->aggInst.params, ret->get_parameters() ); 807 807 buildForall( td->forall, ret->get_forall() ); 808 808 return ret; … … 813 813 NamedTypeDecl * ret; 814 814 assert( td->base ); 815 if ( td->symbolic ->isTypedef ) {815 if ( td->symbolic.isTypedef ) { 816 816 ret = new TypedefDecl( name, sc, typebuild( td->base ) ); 817 817 } else { 818 818 ret = new TypeDecl( name, sc, typebuild( td->base ), TypeDecl::Any ); 819 819 } // if 820 buildList( td->symbolic ->params, ret->get_parameters() );821 buildList( td->symbolic ->assertions, ret->get_assertions() );820 buildList( td->symbolic.params, ret->get_parameters() ); 821 buildList( td->symbolic.assertions, ret->get_assertions() ); 822 822 return ret; 823 823 } // buildSymbolic … … 827 827 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 828 828 829 TypeDecl * ret = new TypeDecl( td->variable ->name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable->tyClass ] );830 buildList( td->variable ->assertions, ret->get_assertions() );829 TypeDecl * ret = new TypeDecl( td->variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable.tyClass ] ); 830 buildList( td->variable.assertions, ret->get_assertions() ); 831 831 return ret; 832 832 } // buildSymbolic … … 834 834 EnumDecl * buildEnum( const TypeData * td ) { 835 835 assert( td->kind == TypeData::Enum ); 836 EnumDecl * ret = new EnumDecl( td->enumeration ->name );837 buildList( td->enumeration ->constants, ret->get_members() );836 EnumDecl * ret = new EnumDecl( td->enumeration.name ); 837 buildList( td->enumeration.constants, ret->get_members() ); 838 838 std::list< Declaration * >::iterator members = ret->get_members().begin(); 839 for ( const DeclarationNode * cur = td->enumeration ->constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {839 for ( const DeclarationNode * cur = td->enumeration. constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 840 840 if ( cur->has_enumeratorValue() ) { 841 841 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); … … 848 848 TypeInstType * buildSymbolicInst( const TypeData * td ) { 849 849 assert( td->kind == TypeData::SymbolicInst ); 850 TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic ->name, false );851 buildList( td->symbolic ->actuals, ret->get_parameters() );850 TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic.name, false ); 851 buildList( td->symbolic.actuals, ret->get_parameters() ); 852 852 buildForall( td->forall, ret->get_forall() ); 853 853 return ret; … … 857 857 assert( td->kind == TypeData::Tuple ); 858 858 TupleType * ret = new TupleType( buildQualifiers( td ) ); 859 buildTypeList( td->tuple ->members, ret->get_types() );859 buildTypeList( td->tuple, ret->get_types() ); 860 860 buildForall( td->forall, ret->get_forall() ); 861 861 return ret; … … 865 865 assert( td->kind == TypeData::Typeof ); 866 866 assert( td->typeexpr ); 867 assert( td->typeexpr->expr );868 return new TypeofType( buildQualifiers( td ), td->typeexpr-> expr->build() );867 // assert( td->typeexpr->expr ); 868 return new TypeofType( buildQualifiers( td ), td->typeexpr->build() ); 869 869 } // buildTypeof 870 870 871 871 AttrType * buildAttr( const TypeData * td ) { 872 872 assert( td->kind == TypeData::Attr ); 873 assert( td->attr );873 // assert( td->attr ); 874 874 AttrType * ret; 875 if ( td->attr ->expr ) {876 ret = new AttrType( buildQualifiers( td ), td->attr ->name, td->attr->expr->build() );875 if ( td->attr.expr ) { 876 ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.expr->build() ); 877 877 } else { 878 assert( td->attr ->type );879 ret = new AttrType( buildQualifiers( td ), td->attr ->name, td->attr->type->buildType() );878 assert( td->attr.type ); 879 ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.type->buildType() ); 880 880 } // if 881 881 return ret; … … 885 885 if ( td->kind == TypeData::Function ) { 886 886 FunctionDecl * decl; 887 if ( td->function ->hasBody ) {888 if ( td->function ->body ) {889 Statement * stmt = td->function ->body->build();887 if ( td->function.hasBody ) { 888 if ( td->function.body ) { 889 Statement * stmt = td->function.body->build(); 890 890 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 891 891 assert( body ); … … 898 898 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), 0, isInline, isNoreturn ); 899 899 } // if 900 for ( DeclarationNode * cur = td->function ->idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {900 for ( DeclarationNode * cur = td->function.idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) { 901 901 if ( cur->get_name() != "" ) { 902 902 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() ); 903 903 } // if 904 904 } // for 905 buildList( td->function ->oldDeclList, decl->get_oldDecls() );905 buildList( td->function.oldDeclList, decl->get_oldDecls() ); 906 906 return decl; 907 907 } else if ( td->kind == TypeData::Aggregate ) { … … 921 921 FunctionType * buildFunction( const TypeData * td ) { 922 922 assert( td->kind == TypeData::Function ); 923 bool hasEllipsis = td->function ->params ? td->function->params->get_hasEllipsis() : true;924 if ( ! td->function ->params ) hasEllipsis = ! td->function->newStyle;923 bool hasEllipsis = td->function.params ? td->function.params->get_hasEllipsis() : true; 924 if ( ! td->function.params ) hasEllipsis = ! td->function.newStyle; 925 925 FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis ); 926 buildList( td->function ->params, ft->get_parameters() );926 buildList( td->function.params, ft->get_parameters() ); 927 927 buildForall( td->forall, ft->get_forall() ); 928 928 if ( td->base ) { 929 929 switch ( td->base->kind ) { 930 930 case TypeData::Tuple: 931 buildList( td->base->tuple ->members, ft->get_returnVals() );931 buildList( td->base->tuple, ft->get_returnVals() ); 932 932 break; 933 933 default: -
src/Parser/TypeData.h
rb542bfb r8f6f47d7 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 22:39:00 201613 // Update Count : 8512 // Last Modified On : Mon Aug 29 15:54:00 2016 13 // Update Count : 106 14 14 // 15 15 … … 79 79 }; 80 80 81 struct Tuple_t {82 DeclarationNode * members;83 };81 // struct Tuple_t { 82 // DeclarationNode * members; 83 // }; 84 84 85 struct Typeof_t {86 ExpressionNode * expr;87 };85 // struct Typeof_t { 86 // ExpressionNode * expr; 87 // }; 88 88 89 struct Builtin_t {90 DeclarationNode::BuiltinType type;91 };89 // struct Builtin_t { 90 // DeclarationNode::BuiltinType type; 91 // }; 92 92 93 93 struct Attr_t { … … 102 102 DeclarationNode * forall; 103 103 104 union { 105 Basic_t * basic; 106 Aggregate_t * aggregate; 107 AggInst_t * aggInst; 108 Array_t * array; 109 Enumeration_t * enumeration; 110 Function_t * function; 111 Symbolic_t * symbolic; 112 Variable_t * variable; 113 Tuple_t * tuple; 114 Typeof_t * typeexpr; 115 Attr_t * attr; 116 Builtin_t * builtin; 117 }; 104 Basic_t basic; 105 Aggregate_t aggregate; 106 AggInst_t aggInst; 107 Array_t array; 108 Enumeration_t enumeration; 109 Function_t function; 110 Symbolic_t symbolic; 111 Variable_t variable; 112 DeclarationNode * tuple; 113 ExpressionNode * typeexpr; 114 Attr_t attr; 115 // DeclarationNode::BuiltinType builtin; 118 116 119 117 TypeData( Kind k = Unknown );
Note: See TracChangeset
for help on using the changeset viewer.