Changeset 2f42718 for src/Parser
- Timestamp:
- Feb 22, 2019, 10:43:29 AM (7 years ago)
- Branches:
- no_list
- Parents:
- 43e0949
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r43e0949 r2f42718 1065 1065 } // buildList 1066 1066 1067 void buildTypeList( const DeclarationNode * firstNode, std:: list< Type * > & outputList ) {1067 void buildTypeList( const DeclarationNode * firstNode, std::vector< Type * > & outputList ) { 1068 1068 SemanticErrorException errors; 1069 std::back_insert_iterator< std:: list< Type * > > out( outputList );1069 std::back_insert_iterator< std::vector< Type * > > out( outputList ); 1070 1070 const DeclarationNode * cur = firstNode; 1071 1071 … … 1097 1097 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1098 1098 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); 1099 buildList( variable.assertions, ret-> get_assertions());1099 buildList( variable.assertions, ret->assertions ); 1100 1100 return ret; 1101 1101 } // if -
src/Parser/ParseNode.h
r43e0949 r2f42718 467 467 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ); 468 468 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ); 469 void buildTypeList( const DeclarationNode * firstNode, std:: list< Type * > & outputList );469 void buildTypeList( const DeclarationNode * firstNode, std::vector< Type * > & outputList ); 470 470 471 471 template< typename SynTreeType, typename NodeType > -
src/Parser/TypeData.cc
r43e0949 r2f42718 493 493 // add dtor: void ^?{}(T *) 494 494 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 495 dtorType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );496 td-> get_assertions().push_front(new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );495 dtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 496 td->assertions.insert( td->assertions.begin(), new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) ); 497 497 498 498 // add copy ctor: void ?{}(T *, T) 499 499 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 500 copyCtorType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );501 copyCtorType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );502 td-> get_assertions().push_front(new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );500 copyCtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 501 copyCtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 502 td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) ); 503 503 504 504 // add default ctor: void ?{}(T *) 505 505 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 506 ctorType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );507 td-> get_assertions().push_front(new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );506 ctorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 507 td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) ); 508 508 509 509 // add assignment operator: T * ?=?(T *, T) 510 510 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 511 assignType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );512 assignType-> get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );513 assignType-> get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );514 td-> get_assertions().push_front(new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );511 assignType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 512 assignType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 513 assignType->returnVals.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 514 td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) ); 515 515 } // if 516 516 } // for … … 897 897 } // if 898 898 buildList( td->symbolic.params, ret->get_parameters() ); 899 buildList( td->symbolic.assertions, ret-> get_assertions());899 buildList( td->symbolic.assertions, ret->assertions ); 900 900 ret->base->attributes.insert( ret->base->attributes.end(), attributes.begin(), attributes.end() ); 901 901 return ret; … … 930 930 TupleType * buildTuple( const TypeData * td ) { 931 931 assert( td->kind == TypeData::Tuple ); 932 std:: list< Type * > types;932 std::vector< Type * > types; 933 933 buildTypeList( td->tuple, types ); 934 934 TupleType * ret = new TupleType( buildQualifiers( td ), types ); … … 983 983 break; 984 984 default: 985 ft-> get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );985 ft->returnVals.push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 986 986 } // switch 987 987 } else { 988 ft-> get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );988 ft->returnVals.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 989 989 } // if 990 990 return ft;
Note:
See TracChangeset
for help on using the changeset viewer.