| 401 | } |
| 402 | |
| 403 | ASTPointer<ContractDefinition> Parser::parseContractDefinition() |
| 404 | { |
| 405 | RecursionGuard recursionGuard(*this); |
| 406 | ASTNodeFactory nodeFactory(*this); |
| 407 | ASTPointer<ASTString> name = nullptr; |
| 408 | SourceLocation nameLocation{}; |
| 409 | ASTPointer<StructuredDocumentation> documentation; |
| 410 | std::vector<ASTPointer<InheritanceSpecifier>> baseContracts; |
| 411 | std::vector<ASTPointer<ASTNode>> subNodes; |
| 412 | std::pair<ContractKind, bool> contractKind{}; |
| 413 | ASTPointer<StorageLayoutSpecifier> storageLayoutSpecifier; |
| 414 | documentation = parseStructuredDocumentation(); |
| 415 | contractKind = parseContractKind(); |
| 416 | std::tie(name, nameLocation) = expectIdentifierWithLocation(); |
| 417 | while (true) |
| 418 | { |
| 419 | if (m_scanner->currentToken() == Token::Is) |
| 420 | { |
| 421 | if (baseContracts.size() != 0) |
| 422 | m_errorReporter.parserError( |
| 423 | 6668_error, |
| 424 | m_scanner->currentLocation(), |
| 425 | SecondarySourceLocation().append("Previous list:", baseContracts[0]->location()), |
| 426 | "More than one inheritance list." |
| 427 | ); |
| 428 | do |
| 429 | { |
| 430 | advance(); |
| 431 | baseContracts.push_back(parseInheritanceSpecifier()); |
| 432 | } |
| 433 | while (m_scanner->currentToken() == Token::Comma); |
| 434 | } |
| 435 | else if ( |
| 436 | m_scanner->currentToken() == Token::Identifier && |
| 437 | m_scanner->currentLiteral() == "layout" && |
| 438 | contractKind.first == ContractKind::Contract |
| 439 | ) |
| 440 | { |
| 441 | if (storageLayoutSpecifier) |
| 442 | m_errorReporter.parserError( |
| 443 | 8714_error, |
| 444 | m_scanner->currentLocation(), |
| 445 | SecondarySourceLocation().append("Previous definition:", storageLayoutSpecifier->location()), |
| 446 | "More than one storage layout definition." |
| 447 | ); |
| 448 | |
| 449 | storageLayoutSpecifier = parseStorageLayoutSpecifier(); |
| 450 | } |
| 451 | else |
| 452 | break; |
| 453 | } |
| 454 | |
| 455 | if (storageLayoutSpecifier && baseContracts.size() > 0) |
| 456 | { |
| 457 | solAssert(!storageLayoutSpecifier->location().intersects(baseContracts[0]->location())); |
| 458 | solAssert(!baseContracts[0]->location().intersects(storageLayoutSpecifier->location())); |
| 459 | } |
| 460 |
nothing calls this directly
no test coverage detected