Changes in src/Parser/TypeData.cc [4cc4286:4040425]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
r4cc4286 r4040425 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeData.cc -- 7 // TypeData.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Jan 14 10:43:42201613 // Update Count : 3611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:26:45 2016 13 // Update Count : 49 14 14 // 15 15 … … 23 23 #include "SynTree/Expression.h" 24 24 #include "SynTree/Statement.h" 25 #include "SynTree/Initializer.h" 25 26 26 27 TypeData::TypeData( Kind k ) : kind( k ), base( 0 ), forall( 0 ) { … … 84 85 typeexpr->expr = 0; 85 86 break; 87 case Builtin: 88 builtin = new Builtin_t; 89 break; 86 90 case Attr: 87 91 attr = new Attr_t; … … 149 153 delete typeexpr->expr; 150 154 delete typeexpr; 155 break; 156 case Builtin: 157 delete builtin; 151 158 break; 152 159 case Attr: … … 221 228 newtype->typeexpr->expr = maybeClone( typeexpr->expr ); 222 229 break; 230 case Builtin: 231 newtype->builtin->type = builtin->type; 232 break; 223 233 case Attr: 224 234 newtype->attr->expr = maybeClone( attr->expr ); … … 397 407 } // if 398 408 break; 409 case Builtin: 410 os << "gcc builtin type"; 411 break; 399 412 default: 400 413 os << "internal error: TypeData::print " << kind << endl; … … 436 449 for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 437 450 if ( (*i)->get_kind() == TypeDecl::Any ) { 438 // add assertion parameters to `type' tyvars in reverse order439 // add dtor: void ^?{}(T *)440 FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false );441 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );442 (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) );443 444 // add copy ctor: void ?{}(T *, T)445 FunctionType *copyCtorType = new FunctionType( Type::Qualifiers(), false );446 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );447 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );448 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, 0, false, false ) );449 450 // add default ctor: void ?{}(T *)451 FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false );452 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );453 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) );454 455 // add assignment operator: T * ?=?(T *, T)456 451 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 457 452 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); … … 524 519 case Typeof: 525 520 return buildTypeof(); 521 case Builtin: 522 return new VarArgsType( buildQualifiers() ); 526 523 case Attr: 527 524 return buildAttr(); … … 823 820 buildForall( aggregate->params, at->get_parameters() ); 824 821 break; 825 case DeclarationNode:: Context:826 at = new ContextDecl( aggregate->name );822 case DeclarationNode::Trait: 823 at = new TraitDecl( aggregate->name ); 827 824 buildList( aggregate->params, at->get_parameters() ); 828 825 break; … … 863 860 ret = new UnionInstType( buildQualifiers(), aggInst->aggregate->aggregate->name ); 864 861 break; 865 case DeclarationNode:: Context:866 ret = new ContextInstType( buildQualifiers(), aggInst->aggregate->aggregate->name );862 case DeclarationNode::Trait: 863 ret = new TraitInstType( buildQualifiers(), aggInst->aggregate->aggregate->name ); 867 864 break; 868 865 default: … … 901 898 EnumDecl *ret = new EnumDecl( enumeration->name ); 902 899 buildList( enumeration->constants, ret->get_members() ); 900 std::list< Declaration * >::iterator members = ret->get_members().begin(); 901 for ( const DeclarationNode *cur = enumeration->constants; cur != NULL; cur = dynamic_cast<DeclarationNode *>( cur->get_link() ), ++members ) { 902 if ( cur->get_enumeratorValue() != NULL ) { 903 ObjectDecl *member = dynamic_cast<ObjectDecl *>(*members); 904 member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ) ) ); 905 } // if 906 } // for 903 907 return ret; 904 908 }
Note: See TracChangeset
for help on using the changeset viewer.